[1270] | 1 | include "joint/Joint.ma". |
---|
[754] | 2 | |
---|
[2286] | 3 | inductive rtl_seq : Type[0] ≝ |
---|
| 4 | | rtl_stack_address: register → register → rtl_seq. |
---|
| 5 | |
---|
[2681] | 6 | definition RTL_uns ≝ mk_unserialized_params |
---|
[2286] | 7 | (* acc_a_reg ≝ *) register |
---|
| 8 | (* acc_b_reg ≝ *) register |
---|
| 9 | (* acc_a_arg ≝ *) psd_argument |
---|
| 10 | (* acc_b_arg ≝ *) psd_argument |
---|
| 11 | (* dpl_reg ≝ *) register |
---|
| 12 | (* dph_reg ≝ *) register |
---|
| 13 | (* dpl_arg ≝ *) psd_argument |
---|
| 14 | (* dph_arg ≝ *) psd_argument |
---|
| 15 | (* snd_arg ≝ *) psd_argument |
---|
| 16 | (* pair_move ≝ *) (register × psd_argument) |
---|
| 17 | (* call_args ≝ *) (list psd_argument) |
---|
| 18 | (* call_dest ≝ *) (list register) |
---|
| 19 | (* ext_seq ≝ *) rtl_seq |
---|
[2640] | 20 | (* ext_seq_labels ≝ *) (λ_.[]) |
---|
[2681] | 21 | (* has_tailcalls ≝ *) false |
---|
[2640] | 22 | (* paramsT ≝ *) (list register). |
---|
[754] | 23 | |
---|
[2783] | 24 | definition RTL_functs ≝ mk_get_pseudo_reg_functs RTL_uns |
---|
| 25 | (* acc_a_regs *) (λr.[r]) |
---|
| 26 | (* acc_b_regs *) (λr.[r]) |
---|
| 27 | (* acc_a_args *) (λa. match a with [Reg r ⇒ [r] |Imm _ ⇒ [ ]]) |
---|
| 28 | (* acc_b_args *) (λa. match a with [Reg r ⇒ [r] |Imm _ ⇒ [ ]]) |
---|
| 29 | (* dpl_regs *) (λr.[r]) |
---|
| 30 | (* dph_regs *) (λr.[r]) |
---|
| 31 | (* dpl_args *) (λa. match a with [Reg r ⇒ [r] |Imm _ ⇒ [ ]]) |
---|
| 32 | (* dph_args *) (λa. match a with [Reg r ⇒ [r] |Imm _ ⇒ [ ]]) |
---|
| 33 | (* snd_args *) (λa. match a with [Reg r ⇒ [r] |Imm _ ⇒ [ ]]) |
---|
| 34 | (* pair_move_regs *) (λx.[\fst x] @ (match \snd x with [Reg r ⇒ [r] |Imm _ ⇒ [ ]])) |
---|
| 35 | (* f_call_args *) (λl.foldl ?? (λl1.λa.l1@(match a with [Reg r ⇒ [r] |Imm _ ⇒ [ ]])) [ ] l) |
---|
| 36 | (* f_call_dest *) (λx.x) |
---|
| 37 | (* ext_seq_regs *) (λext.match ext with [rtl_stack_address r1 r2 ⇒ [r1;r2]]) |
---|
| 38 | (* params_regs *) (λx.x). |
---|
| 39 | |
---|
| 40 | definition RTL ≝ mk_graph_params (mk_uns_params RTL_uns RTL_functs). |
---|
[2286] | 41 | definition rtl_program ≝ joint_program RTL. |
---|
[2946] | 42 | unification hint 0 ≔ ⊢ rtl_program ≡ joint_program RTL. |
---|
[1270] | 43 | |
---|
[2286] | 44 | interpretation "move" 'mov r a = (MOVE RTL ? (mk_Prod ? psd_argument r a)). |
---|
[1275] | 45 | |
---|
[2286] | 46 | (* aid unification *) |
---|
| 47 | include "hints_declaration.ma". |
---|
| 48 | unification hint 0 ≔ |
---|
| 49 | (*---------------*) ⊢ |
---|
| 50 | acc_a_reg RTL ≡ register. |
---|
| 51 | unification hint 0 ≔ |
---|
| 52 | (*---------------*) ⊢ |
---|
| 53 | acc_b_reg RTL ≡ register. |
---|
| 54 | unification hint 0 ≔ |
---|
| 55 | (*---------------*) ⊢ |
---|
| 56 | acc_a_arg RTL ≡ psd_argument. |
---|
| 57 | unification hint 0 ≔ |
---|
| 58 | (*---------------*) ⊢ |
---|
| 59 | acc_b_arg RTL ≡ psd_argument. |
---|
| 60 | unification hint 0 ≔ |
---|
| 61 | (*---------------*) ⊢ |
---|
| 62 | dpl_reg RTL ≡ register. |
---|
| 63 | unification hint 0 ≔ |
---|
| 64 | (*---------------*) ⊢ |
---|
| 65 | dph_reg RTL ≡ register. |
---|
| 66 | unification hint 0 ≔ |
---|
| 67 | (*---------------*) ⊢ |
---|
| 68 | dpl_arg RTL ≡ psd_argument. |
---|
| 69 | unification hint 0 ≔ |
---|
| 70 | (*---------------*) ⊢ |
---|
| 71 | dph_arg RTL ≡ psd_argument. |
---|
| 72 | unification hint 0 ≔ |
---|
| 73 | (*---------------*) ⊢ |
---|
| 74 | snd_arg RTL ≡ psd_argument. |
---|
| 75 | unification hint 0 ≔ |
---|
| 76 | (*---------------*) ⊢ |
---|
| 77 | pair_move RTL ≡ register × psd_argument. |
---|
| 78 | unification hint 0 ≔ |
---|
| 79 | (*---------------*) ⊢ |
---|
| 80 | call_args RTL ≡ list psd_argument. |
---|
| 81 | unification hint 0 ≔ |
---|
| 82 | (*---------------*) ⊢ |
---|
| 83 | call_dest RTL ≡ list register. |
---|
[1275] | 84 | |
---|
[2286] | 85 | unification hint 0 ≔ |
---|
| 86 | (*---------------*) ⊢ |
---|
| 87 | ext_seq RTL ≡ rtl_seq. |
---|
[1275] | 88 | |
---|
[2286] | 89 | coercion reg_to_rtl_snd_argument : ∀r : register.snd_arg RTL ≝ psd_argument_from_reg |
---|
| 90 | on _r : register to snd_arg RTL. |
---|
| 91 | coercion byte_to_rtl_snd_argument : ∀b : Byte.snd_arg RTL ≝ psd_argument_from_byte |
---|
| 92 | on _b : Byte to snd_arg RTL. |
---|
[2946] | 93 | |
---|
| 94 | (* parameters for main need to be passed to the premain *) |
---|
| 95 | definition RTL_premain : ∀p : rtl_program.joint_closed_internal_function RTL (prog_var_names ?? p) ≝ |
---|
| 96 | λp. |
---|
| 97 | let l1 : label ≝ an_identifier … one in |
---|
| 98 | let l2 : label ≝ an_identifier … (p0 one) in |
---|
| 99 | let l3 : label ≝ an_identifier … (p1 one) in |
---|
| 100 | let rs : list register ≝ |
---|
| 101 | [ an_identifier … one ; |
---|
| 102 | an_identifier … (p0 one) ; |
---|
| 103 | an_identifier … (p1 one) ; |
---|
| 104 | an_identifier … (p0 (p0 one)) ] in |
---|
| 105 | let res ≝ |
---|
| 106 | mk_joint_internal_function RTL (prog_var_names … p) |
---|
| 107 | (mk_universe … (p0 (p0 one))) |
---|
| 108 | (mk_universe … (p1 (p0 one))) |
---|
| 109 | [ ] rs 0 0 (empty_map …) l1 in |
---|
| 110 | (* todo: args for main? *) |
---|
| 111 | let res ≝ add_graph … l1 |
---|
| 112 | (sequential … (COST_LABEL … (init_cost_label … p)) l2) |
---|
| 113 | res in |
---|
| 114 | let res ≝ add_graph … l2 |
---|
[2955] | 115 | (sequential … (CALL RTL ? (inl … (prog_main … p)) [ ] [ ]) l3) |
---|
[2946] | 116 | res in |
---|
| 117 | let res ≝ add_graph … l3 |
---|
| 118 | (GOTO ? l3) |
---|
| 119 | res in |
---|
| 120 | res. |
---|
| 121 | % |
---|
| 122 | [ ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%?→?); #EQ destruct |
---|
| 123 | % |
---|
| 124 | [1,3,5: %{I} % whd in ⊢ (??%(??%)→?); #EQ destruct |
---|
| 125 | |2: % |
---|
| 126 | |4,6: % whd in ⊢ (??%%→?); #EQ destruct |
---|
| 127 | ] |
---|
| 128 | | ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%?→?); #EQ destruct % try @I %{I I} |
---|
| 129 | | ** [2,3: * [2,3,5,6: #p ]] * whd whd in ⊢ (?%%); // |
---|
[2955] | 130 | | ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%%→?); #EQ destruct @I |
---|
[2946] | 131 | | %{l2} %{(init_cost_label … p)} % |
---|
| 132 | ] |
---|
| 133 | qed. |
---|