source: src/ERTLptr/ERTLptr.ma @ 2946

Last change on this file since 2946 was 2946, checked in by tranquil, 7 years ago

main novelties:

  • there is an in-built stack_usage nat in joint states, at the base of the new division of RTL's semantics (with separate stacks, with separate stacks but with an artificial overflow error, with a unique stack)
  • a premain is added semantically to the global env, so initial cost label and main call and return are observed
  • proper initialization is now in LINToASM (to be sure, endianess should be checked ;-)

The update breaks proofs of back end atm. compiler.ma should be okay, but I have not had time to complete its compilation.

File size: 3.3 KB
Line 
1include "ERTL/ERTL.ma".
2
3inductive 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
8definition 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   
27definition 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
47definition ERTLptr ≝ mk_graph_params (mk_uns_params ERTLptr_uns ERTLptr_functs).
48definition ertlptr_program ≝ joint_program ERTLptr.
49unification hint 0 ≔ ⊢ ertlptr_program ≡ joint_program ERTLptr.
50 
51definition ertlptr_seq_joint ≝ extension_seq ERTLptr.
52coercion 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 
55definition ERTLptr_premain : ∀p : ertlptr_program.joint_closed_internal_function ERTLptr (prog_var_names ?? p) ≝
56λp.
57let l1 : label ≝ an_identifier … one in
58let l2 : label ≝ an_identifier … (p0 one) in
59let l3 : label ≝ an_identifier … (p1 one) in
60let 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? *)
66let res ≝ add_graph … l1
67  (sequential … (COST_LABEL … (init_cost_label … p)) l2)
68  res in
69let res ≝ add_graph … l2
70  (sequential … (CALL ERTLptr ? (inl … (prog_main … p)) 4 it) l3)
71  res in
72let res ≝ add_graph … l3
73  (GOTO ? l3)
74  res in
75res.
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]
88qed.
Note: See TracBrowser for help on using the repository browser.