source: src/ERTLptr/ERTLToERTLptr.ma @ 3362

Last change on this file since 3362 was 3018, checked in by sacerdot, 7 years ago

1) some files repaired
2) all stuff related to the aborted pass ERTLptr (now merged with

ERTLToLTL) moved into the ERTLptr directory (no longer used/linked)

File size: 4.9 KB
Line 
1(**************************************************************************)
2(*       ___                                                              *)
3(*      ||M||                                                             *)
4(*      ||A||       A project by Andrea Asperti                           *)
5(*      ||T||                                                             *)
6(*      ||I||       Developers:                                           *)
7(*      ||T||         The HELM team.                                      *)
8(*      ||A||         http://helm.cs.unibo.it                             *)
9(*      \   /                                                             *)
10(*       \ /        This file is distributed under the terms of the       *)
11(*        v         GNU General Public License Version 2                  *)
12(*                                                                        *)
13(**************************************************************************)
14
15include "ERTL/ERTL.ma".
16include "ERTLptr/ERTLptr.ma".
17include "joint/TranslateUtils.ma".
18 
19definition seq_embed :
20∀globals.(joint_seq ERTL globals) → (joint_seq ERTLptr globals) ≝
21λglobals,s.
22match s with
23[COMMENT s ⇒ COMMENT ERTLptr … s
24|MOVE a  ⇒ MOVE ERTLptr … a
25|POP a ⇒ POP ERTLptr … a
26|PUSH a ⇒ PUSH ERTLptr … a
27|ADDRESS i H reg1 reg2 ⇒ ADDRESS ERTLptr … i H reg1 reg2
28|OPACCS op reg1 reg2 reg3 reg4 ⇒ OPACCS ERTLptr … op reg1 reg2 reg3 reg4
29|OP1 op reg1 reg2 ⇒ OP1 ERTLptr … op reg1 reg2
30|OP2 op reg1 reg2 arg ⇒ OP2 ERTLptr … op reg1 reg2 arg
31|CLEAR_CARRY ⇒ CLEAR_CARRY ERTLptr ?
32|SET_CARRY ⇒ SET_CARRY ERTLptr ?
33|LOAD reg1 reg2 reg3 ⇒ LOAD ERTLptr … reg1 reg2 reg3
34|STORE arg1 arg2 reg ⇒ STORE ERTLptr … arg1 arg2 reg
35|extension_seq s ⇒ extension_seq ERTLptr … (ertlptr_ertl s)
36].
37
38definition translate_step:
39 ∀globals.
40 label
41  →joint_step ERTL globals
42   →bind_step_block ERTLptr globals ≝
43 λglobals.λl.λs.
44match s return λ_.bind_step_block ERTLptr globals with
45[ CALL called args dest ⇒
46    match called return λ_.bind_step_block ERTLptr globals with
47    [inl id ⇒ bret … 〈[ ], λ_.CALL ERTLptr ? (inl … id) args dest, [ ]〉
48    |inr dest1 ⇒ νreg in bret ? (step_block ERTLptr globals)
49      〈[λl.(LOW_ADDRESS reg l : joint_seq ??);
50        λ_.PUSH ERTLptr … (Reg … reg);
51        λl.HIGH_ADDRESS reg l;
52        λ_.PUSH ERTLptr … (Reg … reg)],
53        λ_.CALL ERTLptr ? (inr … dest1) args dest, [ ]〉
54    ]
55|COST_LABEL c ⇒ bret … 〈[ ], λ_.COST_LABEL ERTLptr … c, [ ]〉
56| COND reg l ⇒ bret … 〈[ ], λ_.COND ERTLptr ? reg l, [ ]〉
57| step_seq x ⇒ bret … [seq_embed … x]
58].
59
60definition fin_step_embed: joint_fin_step ERTL → joint_fin_step ERTLptr ≝
61λs.
62match s with
63[GOTO l ⇒ GOTO ERTLptr … l
64|RETURN  ⇒ RETURN ERTLptr
65|TAILCALL H arg arg' ⇒ TAILCALL ERTLptr … H arg arg'
66].
67
68definition translate_fin_step:
69 ∀globals.
70 label
71  →joint_fin_step ERTL
72   →bind_fin_block ERTLptr globals ≝
73 λglobals.λl.λs.bret … 〈[ ], fin_step_embed … s〉.
74
75definition translate_data :
76  ∀globals.joint_closed_internal_function ERTL globals →
77  bind_new register (b_graph_translate_data ERTL ERTLptr globals) ≝
78λglobals,def.bret …
79   (mk_b_graph_translate_data …
80    (* init_ret ≝ *) (joint_if_result … def)
81    (* init_params ≝ *) (joint_if_params … def)
82    (* init_stack_size ≝ *) (joint_if_stacksize … def)
83    (* added_prologue ≝ *) [ ]
84    (* new_regs ≝ *) [ ]
85    (* f_step ≝ *) (translate_step globals)
86    (* f_fin ≝ *) (translate_fin_step globals)
87    ????).
88@hide_prf
89[ #l * [ #c' | * #f #args #dest | #a #ltrue | #s ] #c whd
90  [3: #r1 ] #l' #EQ destruct try %
91  cases s in EQ; whd in match ensure_step_block; normalize nodelta
92  try #a try #b try #c try #d try #e try #f destruct
93| #l #c %
94]
95#l *
96[ #l' whd %{I} %{I} %{I} %2 % %
97| whd %{I} %{I I}
98| #abs #called #args whd %{I} %{I I}
99| #c #l' whd %{I} %{I} %{I} %
100| * #called #args #dest whd in match translate_step; normalize nodelta whd
101  [ #l' %{I} %{I} %{I} %
102  | #r #l' whd %{I} %
103    [2: whd %{I} whd in match step_forall_registers; normalize nodelta
104        whd in match step_registers; whd in match get_used_registers_from_step;
105        normalize nodelta normalize cases(\fst called) [#r1 | #b1]
106        normalize nodelta cases(\snd called) [1,3: #r2 |*: #b2 ]
107        normalize nodelta /2 by All_mp, I/ % // [1,3,4: %2 % %]
108        % [%2 %2 % %] %
109    | %  [2: % [2: % [2: %{I} ]]] % try @I %{I} %1 %
110    ]
111  ]
112| #a #l_true whd #l %{I} %{I} % %{I} [ %2 ] %1 %
113| #s whd #l %{I} %{I} whd %
114  [ @(All_mp … (In ? (step_labels … s))) [ #l' #H %2{H} ] cases s -s // ]
115  cut (∀X,l1,l2.l1 = l2 → All X (In X l1) l2)
116  [ #X #l1 #l2 #EQ destruct elim l2 [ % ] #hd #tl #IH % [ %1 % ] @(All_mp … IH) #x #H %2{H} ]
117  #aux @aux cases s //
118]
119qed.
120
121
122definition ertl_to_ertlptr: ertl_program → ertlptr_program ≝
123  b_graph_transform_program ERTL ERTLptr translate_data.
124%
125qed.
Note: See TracBrowser for help on using the repository browser.