1 | include "joint/Joint.ma". |
---|
2 | |
---|
3 | inductive rtl_seq : Type[0] ≝ |
---|
4 | | rtl_stack_address: register → register → rtl_seq. |
---|
5 | |
---|
6 | definition RTL_uns ≝ mk_unserialized_params |
---|
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 |
---|
20 | (* ext_seq_labels ≝ *) (λ_.[]) |
---|
21 | (* has_tailcalls ≝ *) false |
---|
22 | (* paramsT ≝ *) (list register). |
---|
23 | |
---|
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). |
---|
41 | definition rtl_program ≝ joint_program RTL. |
---|
42 | unification hint 0 ≔ ⊢ rtl_program ≡ joint_program RTL. |
---|
43 | |
---|
44 | interpretation "move" 'mov r a = (MOVE RTL ? (mk_Prod ? psd_argument r a)). |
---|
45 | |
---|
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. |
---|
84 | |
---|
85 | unification hint 0 ≔ |
---|
86 | (*---------------*) ⊢ |
---|
87 | ext_seq RTL ≡ rtl_seq. |
---|
88 | |
---|
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. |
---|
93 | |
---|
94 | (* parameters for main need to be passed to the premain *) |
---|
95 | definition RTL_premain : ∀p : rtl_program. |
---|
96 | joint_closed_internal_function RTL (prog_names … p) ≝ |
---|
97 | λp. |
---|
98 | let l1 : label ≝ an_identifier … one in |
---|
99 | let l2 : label ≝ an_identifier … (p0 one) in |
---|
100 | let l3 : label ≝ an_identifier … (p1 one) in |
---|
101 | let rs : list register ≝ |
---|
102 | [ an_identifier … one ; |
---|
103 | an_identifier … (p0 one) ; |
---|
104 | an_identifier … (p1 one) ; |
---|
105 | an_identifier … (p0 (p0 one)) ] in |
---|
106 | let res ≝ |
---|
107 | mk_joint_internal_function RTL (prog_names … p) |
---|
108 | (mk_universe … (p0 (p0 one))) |
---|
109 | (mk_universe … (p1 (p0 one))) |
---|
110 | [ ] rs 0 0 (empty_map …) l1 in |
---|
111 | (* todo: args for main? *) |
---|
112 | let res ≝ add_graph … l1 |
---|
113 | (sequential … (COST_LABEL … (init_cost_label … p)) l2) |
---|
114 | res in |
---|
115 | let res ≝ add_graph … l2 |
---|
116 | (sequential … (CALL RTL ? (inl … (prog_main … p)) [ ] rs) l3) |
---|
117 | res in |
---|
118 | let res ≝ add_graph … l3 |
---|
119 | (GOTO ? l3) |
---|
120 | res in |
---|
121 | res. |
---|
122 | % |
---|
123 | [ ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%?→?); #EQ destruct |
---|
124 | % |
---|
125 | [1,3,5: %{I} % whd in ⊢ (??%(??%)→?); #EQ destruct |
---|
126 | |2: % |
---|
127 | |4,6: % whd in ⊢ (??%%→?); #EQ destruct |
---|
128 | ] |
---|
129 | | ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%?→?); #EQ destruct % try @I %{I I} |
---|
130 | | ** [2,3: * [2,3,5,6: #p ]] * whd whd in ⊢ (?%%); // |
---|
131 | | ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%%→?); #EQ destruct try @I |
---|
132 | try % try % try % try % try % whd /2 by double_lt3/ |
---|
133 | | %{l2} %{(init_cost_label … p)} % |
---|
134 | ] |
---|
135 | qed. |
---|