source: src/RTL/RTL_paolo.ma @ 1640

Last change on this file since 1640 was 1640, checked in by tranquil, 8 years ago
  • finished fork of semantics.ma
  • unification of Errors under the monad notations brings problems in type checking when res and IO are used together. Needs a lot of annotations, and may break the pre-fork material
File size: 5.0 KB
Line 
1include "joint/Joint_paolo.ma".
2
3inductive rtl_argument : Type[0] ≝
4  | Reg : register → rtl_argument
5  | Imm : Byte → rtl_argument.
6 
7coercion reg_to_rtl_argument : ∀r : register.rtl_argument ≝ Reg
8  on _r : register to rtl_argument.
9
10coercion byte_to_rtl_argument : ∀b : Byte.rtl_argument ≝ Imm
11  on _b : Byte to rtl_argument.
12
13definition imm_nat : nat → rtl_argument ≝ λn.Imm (nat_to_bv ? n).
14 
15coercion nat_to_rtl_argument : ∀n : nat.rtl_argument ≝ imm_nat
16  on _n : nat to rtl_argument.
17
18(*CSC: XXX PROBLEM HERE. Tailcalls are not instructions, but statements since they
19  are not sequential. Thus there is a dummy label at the moment in the code.
20  To be fixed once we understand exactly what to do with tail calls. *)
21inductive rtl_statement_extension: Type[0] ≝
22  | rtl_st_ext_stack_address: register → register → rtl_statement_extension
23  | rtl_st_ext_call_ptr: register → register → list rtl_argument → list register → rtl_statement_extension
24  | rtl_st_ext_tailcall_id: ident → list rtl_argument → rtl_statement_extension
25  | rtl_st_ext_tailcall_ptr: register → register → list rtl_argument → rtl_statement_extension.
26
27definition rtl_params ≝ mk_graph_params (mk_unserialized_params
28  (mk_inst_params
29    (* acc_a_reg ≝ *) register
30    (* acc_b_reg ≝ *) register
31    (* acc_a_arg ≝ *) rtl_argument
32    (* acc_b_arg ≝ *) rtl_argument
33    (* dpl_reg   ≝ *) register
34    (* dph_reg   ≝ *) register
35    (* dpl_arg   ≝ *) rtl_argument
36    (* dph_arg   ≝ *) rtl_argument
37    (* snd_arg   ≝ *) rtl_argument
38    (* pair_move ≝ *) (register × rtl_argument)
39    (* call_args ≝ *) (list rtl_argument)
40    (* call_dest ≝ *) (list register)
41    (* extend_statements ≝ *) rtl_statement_extension
42    (* ext_forall_labels ≝ *) (λP.λes.True))
43  (mk_local_params
44    (mk_funct_params
45      (* resultT ≝ *) (list register)
46      (* paramsT ≝ *) (list register))
47      (* localsT ≝ *) (list register))).
48
49interpretation "move" 'mov r a = (MOVE ? ? (mk_Prod ?? r a)).
50
51(* aid unification *)
52include "hints_declaration.ma".
53unification hint 0 ≔
54(*---------------*) ⊢
55acc_a_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register.
56unification hint 0 ≔
57(*---------------*) ⊢
58acc_b_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register.
59unification hint 0 ≔
60(*---------------*) ⊢
61acc_a_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument.
62unification hint 0 ≔
63(*---------------*) ⊢
64acc_b_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument.
65unification hint 0 ≔
66(*---------------*) ⊢
67dpl_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register.
68unification hint 0 ≔
69(*---------------*) ⊢
70dph_reg (u_inst_pars (g_u_pars rtl_params)) ≡ register.
71unification hint 0 ≔
72(*---------------*) ⊢
73dpl_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument.
74unification hint 0 ≔
75(*---------------*) ⊢
76dph_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument.
77unification hint 0 ≔
78(*---------------*) ⊢
79snd_arg (u_inst_pars (g_u_pars rtl_params)) ≡ rtl_argument.
80unification hint 0 ≔
81(*---------------*) ⊢
82pair_move (u_inst_pars (g_u_pars rtl_params)) ≡ register × rtl_argument.
83unification hint 0 ≔
84(*---------------*) ⊢
85call_args (u_inst_pars (g_u_pars rtl_params)) ≡ list rtl_argument.
86unification hint 0 ≔
87(*---------------*) ⊢
88call_dest (u_inst_pars (g_u_pars rtl_params)) ≡ list register.
89
90
91definition rtl_instruction ≝ joint_instruction rtl_params.
92(* Paolo: can't understand why coercions do not compose implicitly here *)
93definition rtl_statement ≝ joint_statement (rtl_params : params).
94
95definition rtl_internal_function ≝
96  λglobals. joint_internal_function globals rtl_params.
97
98definition rtl_program ≝ joint_program rtl_params.
99
100(************ Same without tail calls ****************)
101
102inductive rtlntc_statement_extension: Type[0] ≝
103  | rtlntc_st_ext_stack_address: register → register → rtlntc_statement_extension
104  | rtlntc_st_ext_call_ptr: register → register → list register → list register → rtlntc_statement_extension.
105
106definition rtlntc_params ≝ mk_graph_params (mk_unserialized_params
107  (mk_inst_params
108    (* acc_a_reg ≝ *) register
109    (* acc_b_reg ≝ *) register
110    (* acc_a_arg ≝ *) rtl_argument
111    (* acc_b_arg ≝ *) rtl_argument
112    (* dpl_reg   ≝ *) register
113    (* dph_reg   ≝ *) register
114    (* dpl_arg   ≝ *) rtl_argument
115    (* dph_arg   ≝ *) rtl_argument
116    (* snd_arg   ≝ *) rtl_argument
117    (* pair_move ≝ *) (register × rtl_argument)
118    (* call_args ≝ *) (list rtl_argument)
119    (* call_dest ≝ *) (list register)
120    (* extend_statements ≝ *) rtlntc_statement_extension
121    (* ext_forall_labels ≝ *) (λP.λes.True))
122  (mk_local_params
123    (mk_funct_params
124      (* resultT ≝ *) (list register)
125      (* paramsT ≝ *) (list register))
126      (* localsT ≝ *) (list register))).
127
128definition rtlntc_statement ≝ joint_statement (rtlntc_params : params).
129
130definition rtlntc_internal_function ≝
131  λglobals. joint_internal_function … globals rtlntc_params.
132
133definition rtlntc_program ≝ joint_program rtlntc_params.
Note: See TracBrowser for help on using the repository browser.