1 | include "ERTL/ERTL.ma". |
---|
2 | |
---|
3 | inductive ertlptr_seq : Type[0] ≝ |
---|
4 | | ertlptr_ertl: ertl_seq → ertlptr_seq |
---|
5 | | LOW_ADDRESS : register → label → ertlptr_seq |
---|
6 | | HIGH_ADDRESS : register → label → ertlptr_seq. |
---|
7 | |
---|
8 | definition ERTLptr_uns ≝ mk_unserialized_params |
---|
9 | (* acc_a_reg ≝ *) register |
---|
10 | (* acc_b_reg ≝ *) register |
---|
11 | (* acc_a_arg ≝ *) psd_argument |
---|
12 | (* acc_b_arg ≝ *) psd_argument |
---|
13 | (* dpl_reg ≝ *) register |
---|
14 | (* dph_reg ≝ *) register |
---|
15 | (* dpl_arg ≝ *) psd_argument |
---|
16 | (* dph_arg ≝ *) psd_argument |
---|
17 | (* snd_arg ≝ *) psd_argument |
---|
18 | (* pair_move ≝ *) (move_dst × move_src) |
---|
19 | (* call_args ≝ *) ℕ |
---|
20 | (* call_dest ≝ *) unit |
---|
21 | (* ext_seq ≝ *) ertlptr_seq |
---|
22 | (* ext_seq_labels ≝ *) |
---|
23 | (λs.match s with [ LOW_ADDRESS _ l ⇒ [l] | HIGH_ADDRESS _ l ⇒ [l] | _ ⇒ [ ]]) |
---|
24 | (* has_tailcall ≝ *) false |
---|
25 | (* paramsT ≝ *) ℕ. |
---|
26 | |
---|
27 | definition ERTLptr_functs ≝ mk_get_pseudo_reg_functs ERTLptr_uns |
---|
28 | (* acc_a_regs *) (λr.[r]) |
---|
29 | (* acc_b_regs *) (λr.[r]) |
---|
30 | (* acc_a_args *) (λarg.match arg with [ Imm _ ⇒ [ ] | Reg r ⇒ [r]]) |
---|
31 | (* acc_b_args *) (λarg.match arg with [ Imm _ ⇒ [ ] | Reg r ⇒ [r]]) |
---|
32 | (* dpl_regs *) (λr.[r]) |
---|
33 | (* dph_regs *) (λr.[r]) |
---|
34 | (* dpl_args *) (λarg.match arg with [ Imm _ ⇒ [ ] | Reg r ⇒ [r]]) |
---|
35 | (* dph_args *) (λarg.match arg with [ Imm _ ⇒ [ ] | Reg r ⇒ [r]]) |
---|
36 | (* snd_args *) (λarg.match arg with [ Imm _ ⇒ [ ] | Reg r ⇒ [r]]) |
---|
37 | (* pair_move_regs *) (λx.(regs_from_move_dst (\fst x)) @ (regs_from_move_src (\snd x))) |
---|
38 | (* f_call_args *) (λ_.[ ]) |
---|
39 | (* f_call_dest *) (λ_.[ ]) |
---|
40 | (* ext_seq_regs *) |
---|
41 | (λs.match s with [ LOW_ADDRESS r _ ⇒ [r] |
---|
42 | | HIGH_ADDRESS r _ ⇒ [r] |
---|
43 | | ertlptr_ertl s' ⇒ ertl_ext_seq_regs s' |
---|
44 | ]) |
---|
45 | (* params_regs *) (λ_.[ ]). |
---|
46 | |
---|
47 | definition ERTLptr ≝ mk_graph_params (mk_uns_params ERTLptr_uns ERTLptr_functs). |
---|
48 | definition ertlptr_program ≝ joint_program ERTLptr. |
---|
49 | unification hint 0 ≔ ⊢ ertlptr_program ≡ joint_program ERTLptr. |
---|
50 | |
---|
51 | definition ertlptr_seq_joint ≝ extension_seq ERTLptr. |
---|
52 | coercion ertlptr_seq_to_joint_seq : ∀globals.∀s : ertlptr_seq.joint_seq ERTLptr globals ≝ ertlptr_seq_joint |
---|
53 | on _s : ertlptr_seq to joint_seq ERTLptr ?. |
---|
54 | |
---|
55 | definition ERTLptr_premain : ∀p : ertlptr_program.joint_closed_internal_function ERTLptr (prog_var_names ?? p) ≝ |
---|
56 | λp. |
---|
57 | let l1 : label ≝ an_identifier … one in |
---|
58 | let l2 : label ≝ an_identifier … (p0 one) in |
---|
59 | let l3 : label ≝ an_identifier … (p1 one) in |
---|
60 | let res ≝ |
---|
61 | mk_joint_internal_function ERTLptr (prog_var_names … p) |
---|
62 | (mk_universe … (p0 (p0 one))) |
---|
63 | (mk_universe … one) |
---|
64 | it 4 0 0 (empty_map …) l1 in |
---|
65 | (* todo: args for main? *) |
---|
66 | let res ≝ add_graph … l1 |
---|
67 | (sequential … (COST_LABEL … (init_cost_label … p)) l2) |
---|
68 | res in |
---|
69 | let res ≝ add_graph … l2 |
---|
70 | (sequential … (CALL ERTLptr ? (inl … (prog_main … p)) 4 it) l3) |
---|
71 | res in |
---|
72 | let res ≝ add_graph … l3 |
---|
73 | (GOTO ? l3) |
---|
74 | res in |
---|
75 | res. |
---|
76 | % |
---|
77 | [ ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%?→?); #EQ destruct |
---|
78 | % |
---|
79 | [1,3,5: %{I} % whd in ⊢ (??%(??%)→?); #EQ destruct |
---|
80 | |2: % |
---|
81 | |4,6: % whd in ⊢ (??%%→?); #EQ destruct |
---|
82 | ] |
---|
83 | | ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%?→?); #EQ destruct % try @I %{I I} |
---|
84 | | ** [2,3: * [2,3,5,6: #p ]] * whd whd in ⊢ (?%%); // |
---|
85 | | ** [2,3: * [2,3,5,6: #p ]] #s whd in ⊢ (??%%→?); #EQ destruct @I |
---|
86 | | %{l2} %{(init_cost_label … p)} % |
---|
87 | ] |
---|
88 | qed. |
---|