1 | include "joint/Joint_paolo.ma". |
---|
2 | |
---|
3 | inductive rtl_argument : Type[0] ≝ |
---|
4 | | Reg : register → rtl_argument |
---|
5 | | Imm : Byte → rtl_argument. |
---|
6 | |
---|
7 | coercion reg_to_rtl_argument : ∀r : register.rtl_argument ≝ Reg |
---|
8 | on _r : register to rtl_argument. |
---|
9 | |
---|
10 | coercion byte_to_rtl_argument : ∀b : Byte.rtl_argument ≝ Imm |
---|
11 | on _b : Byte to rtl_argument. |
---|
12 | |
---|
13 | definition imm_nat : nat → rtl_argument ≝ λn.Imm (nat_to_bv ? n). |
---|
14 | |
---|
15 | coercion nat_to_rtl_argument : ∀n : nat.rtl_argument ≝ imm_nat |
---|
16 | on _n : nat to rtl_argument. |
---|
17 | |
---|
18 | inductive rtl_step_extension: Type[0] ≝ |
---|
19 | | rtl_st_ext_stack_address: register → register → rtl_step_extension |
---|
20 | | rtl_st_ext_call_ptr: register → register → list rtl_argument → list register → rtl_step_extension. |
---|
21 | |
---|
22 | inductive rtl_statement_extension : Type[0] ≝ |
---|
23 | | rtl_st_ext_tailcall_id: ident → list rtl_argument → rtl_statement_extension |
---|
24 | | rtl_st_ext_tailcall_ptr: register → register → list rtl_argument → rtl_statement_extension. |
---|
25 | |
---|
26 | definition rtl_uns_params ≝ mk_unserialized_params |
---|
27 | (mk_step_params |
---|
28 | (* acc_a_reg ≝ *) register |
---|
29 | (* acc_b_reg ≝ *) register |
---|
30 | (* acc_a_arg ≝ *) rtl_argument |
---|
31 | (* acc_b_arg ≝ *) rtl_argument |
---|
32 | (* dpl_reg ≝ *) register |
---|
33 | (* dph_reg ≝ *) register |
---|
34 | (* dpl_arg ≝ *) rtl_argument |
---|
35 | (* dph_arg ≝ *) rtl_argument |
---|
36 | (* snd_arg ≝ *) rtl_argument |
---|
37 | (* pair_move ≝ *) (register × rtl_argument) |
---|
38 | (* call_args ≝ *) (list rtl_argument) |
---|
39 | (* call_dest ≝ *) (list register) |
---|
40 | (* ext_step ≝ *) rtl_step_extension |
---|
41 | (* ext_step_labels ≝ *) (λes.[ ]) |
---|
42 | (* ext_fin_stmt ≝ *) rtl_statement_extension |
---|
43 | (* ext_fin_stmt_labels ≝ *) (λes.[ ])) |
---|
44 | (mk_local_params |
---|
45 | (mk_funct_params |
---|
46 | (* resultT ≝ *) (list register) |
---|
47 | (* paramsT ≝ *) (list register)) |
---|
48 | (* localsT ≝ *) (list register)). |
---|
49 | |
---|
50 | definition rtl_params ≝ mk_graph_params rtl_uns_params. |
---|
51 | definition lin_rtl_params ≝ mk_lin_params rtl_uns_params. |
---|
52 | definition rtl_internal_function ≝ |
---|
53 | λglobals. joint_internal_function globals rtl_params. |
---|
54 | definition rtl_program ≝ joint_program rtl_params. |
---|
55 | definition rtl_step ≝ joint_step rtl_params. |
---|
56 | definition rtl_statement ≝ joint_statement rtl_params. |
---|
57 | |
---|
58 | |
---|
59 | interpretation "move" 'mov r a = (MOVE ? ? (mk_Prod ? rtl_argument r a)). |
---|
60 | |
---|
61 | (* aid unification *) |
---|
62 | include "hints_declaration.ma". |
---|
63 | unification hint 0 ≔ |
---|
64 | (*---------------*) ⊢ |
---|
65 | acc_a_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register. |
---|
66 | unification hint 0 ≔ |
---|
67 | (*---------------*) ⊢ |
---|
68 | acc_b_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register. |
---|
69 | unification hint 0 ≔ |
---|
70 | (*---------------*) ⊢ |
---|
71 | acc_a_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument. |
---|
72 | unification hint 0 ≔ |
---|
73 | (*---------------*) ⊢ |
---|
74 | acc_b_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument. |
---|
75 | unification hint 0 ≔ |
---|
76 | (*---------------*) ⊢ |
---|
77 | dpl_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register. |
---|
78 | unification hint 0 ≔ |
---|
79 | (*---------------*) ⊢ |
---|
80 | dph_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register. |
---|
81 | unification hint 0 ≔ |
---|
82 | (*---------------*) ⊢ |
---|
83 | dpl_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument. |
---|
84 | unification hint 0 ≔ |
---|
85 | (*---------------*) ⊢ |
---|
86 | dph_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument. |
---|
87 | unification hint 0 ≔ |
---|
88 | (*---------------*) ⊢ |
---|
89 | snd_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument. |
---|
90 | unification hint 0 ≔ |
---|
91 | (*---------------*) ⊢ |
---|
92 | pair_move (u_inst_pars (g_u_pars rtl_params)) ≡ register × rtl_argument. |
---|
93 | unification hint 0 ≔ |
---|
94 | (*---------------*) ⊢ |
---|
95 | call_args (u_inst_pars (g_u_pars rtl_params)) ≡ list rtl_argument. |
---|
96 | unification hint 0 ≔ |
---|
97 | (*---------------*) ⊢ |
---|
98 | call_dest (u_inst_pars (g_u_pars rtl_params)) ≡ list register. |
---|
99 | |
---|
100 | unification hint 0 ≔ |
---|
101 | (*---------------*) ⊢ |
---|
102 | ext_step (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_step_extension. |
---|
103 | unification hint 0 ≔ globals |
---|
104 | (*---------------*) ⊢ |
---|
105 | joint_step (u_inst_pars (g_u_pars rtl_params)) globals ≡ rtl_step globals. |
---|
106 | |
---|
107 | unification hint 0 ≔ |
---|
108 | (*---------------*) ⊢ |
---|
109 | ext_fin_stmt (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_statement_extension. |
---|
110 | unification hint 0 ≔ globals |
---|
111 | (*---------------*) ⊢ |
---|
112 | joint_statement (stmt_pars (graph_params_to_params rtl_params)) globals ≡ rtl_statement globals. |
---|
113 | |
---|
114 | (************ Same without tail calls ****************) |
---|
115 | |
---|
116 | inductive rtlntc_statement_extension: Type[0] ≝ |
---|
117 | | rtlntc_st_ext_stack_address: register → register → rtlntc_statement_extension |
---|
118 | | rtlntc_st_ext_call_ptr: register → register → list register → list register → rtlntc_statement_extension. |
---|
119 | |
---|
120 | definition rtlntc_params ≝ mk_graph_params (mk_unserialized_params |
---|
121 | (mk_step_params |
---|
122 | (* acc_a_reg ≝ *) register |
---|
123 | (* acc_b_reg ≝ *) register |
---|
124 | (* acc_a_arg ≝ *) rtl_argument |
---|
125 | (* acc_b_arg ≝ *) rtl_argument |
---|
126 | (* dpl_reg ≝ *) register |
---|
127 | (* dph_reg ≝ *) register |
---|
128 | (* dpl_arg ≝ *) rtl_argument |
---|
129 | (* dph_arg ≝ *) rtl_argument |
---|
130 | (* snd_arg ≝ *) rtl_argument |
---|
131 | (* pair_move ≝ *) (register × rtl_argument) |
---|
132 | (* call_args ≝ *) (list rtl_argument) |
---|
133 | (* call_dest ≝ *) (list register) |
---|
134 | (* extend_statements ≝ *) rtlntc_statement_extension |
---|
135 | (* ext_forall_labels ≝ *) (λes.[ ]) |
---|
136 | void (λes.[ ])) |
---|
137 | (mk_local_params |
---|
138 | (mk_funct_params |
---|
139 | (* resultT ≝ *) (list register) |
---|
140 | (* paramsT ≝ *) (list register)) |
---|
141 | (* localsT ≝ *) (list register))). |
---|
142 | |
---|
143 | definition rtlntc_statement ≝ joint_statement (rtlntc_params : params). |
---|
144 | |
---|
145 | definition rtlntc_internal_function ≝ |
---|
146 | λglobals. joint_internal_function … globals rtlntc_params. |
---|
147 | |
---|
148 | definition rtlntc_program ≝ joint_program rtlntc_params. |
---|