1 | |
---|
2 | (* NB: this was produced via compcert, acc and some hand mangling because acc |
---|
3 | doesn't yet implement switch correctly in the clight → cminor phase. *) |
---|
4 | |
---|
5 | include "Cminor/semantics.ma". |
---|
6 | include "common/Animation.ma". |
---|
7 | |
---|
8 | definition id_get := ident_of_nat 99. |
---|
9 | definition f_get := External internal_function (mk_external_function id_get (mk_signature [] (Some ? (ASTint I32 Signed)))). |
---|
10 | |
---|
11 | |
---|
12 | definition id_main := ident_of_nat 0. |
---|
13 | definition id_main_i := ident_of_nat 1. |
---|
14 | definition id_main_x1 := ident_of_nat 2. |
---|
15 | definition f_main := Internal ? (mk_internal_function |
---|
16 | (mk_signature [] (Some ? (ASTint I32 Signed))) |
---|
17 | [] |
---|
18 | [id_main_i; id_main_x1] |
---|
19 | [] |
---|
20 | 0 ( |
---|
21 | St_seq ( |
---|
22 | St_assign id_main_i (Op1 Ocast8unsigned (Cst (Ointconst (repr 0)))) |
---|
23 | ) ( |
---|
24 | St_seq ( |
---|
25 | St_call (Some ? id_main_x1) (Cst (Oaddrsymbol id_get zero)) [] |
---|
26 | ) ( |
---|
27 | St_seq ( |
---|
28 | St_block ( |
---|
29 | St_seq ( |
---|
30 | St_block ( |
---|
31 | St_seq ( |
---|
32 | St_block ( |
---|
33 | St_seq ( |
---|
34 | St_block ( |
---|
35 | St_seq ( |
---|
36 | St_block ( |
---|
37 | St_seq ( |
---|
38 | St_block ( |
---|
39 | St_seq ( |
---|
40 | St_switch (Id id_main_x1) [ |
---|
41 | (pair ?? (repr 1) 0); |
---|
42 | (pair ?? (repr 3) 1); |
---|
43 | (pair ?? (repr 5) 2); |
---|
44 | (pair ?? (repr 7) 3)] 4 |
---|
45 | ) ( |
---|
46 | St_skip ) |
---|
47 | ) |
---|
48 | ) ( |
---|
49 | St_seq ( |
---|
50 | St_exit 4 |
---|
51 | ) ( |
---|
52 | St_skip ) |
---|
53 | ) |
---|
54 | ) |
---|
55 | ) ( |
---|
56 | St_seq ( |
---|
57 | St_assign id_main_i (Op1 Ocast8unsigned (Op2 Oadd (Id id_main_i) (Cst (Ointconst (repr 1))))) |
---|
58 | ) ( |
---|
59 | St_seq ( |
---|
60 | St_exit 3 |
---|
61 | ) ( |
---|
62 | St_skip ) |
---|
63 | ) |
---|
64 | ) |
---|
65 | ) |
---|
66 | ) ( |
---|
67 | St_seq ( |
---|
68 | St_assign id_main_i (Op1 Ocast8unsigned (Op2 Oadd (Id id_main_i) (Cst (Ointconst (repr 2))))) |
---|
69 | ) ( |
---|
70 | St_skip ) |
---|
71 | ) |
---|
72 | ) |
---|
73 | ) ( |
---|
74 | St_seq ( |
---|
75 | St_assign id_main_i (Op1 Ocast8unsigned (Op2 Oadd (Id id_main_i) (Cst (Ointconst (repr 3))))) |
---|
76 | ) ( |
---|
77 | St_seq ( |
---|
78 | St_exit 1 |
---|
79 | ) ( |
---|
80 | St_skip ) |
---|
81 | ) |
---|
82 | ) |
---|
83 | ) |
---|
84 | ) ( |
---|
85 | St_seq ( |
---|
86 | St_assign id_main_i (Op1 Ocast8unsigned (Op2 Oadd (Id id_main_i) (Cst (Ointconst (repr 16))))) |
---|
87 | ) ( |
---|
88 | St_skip ) |
---|
89 | ) |
---|
90 | ) |
---|
91 | ) ( |
---|
92 | St_seq ( |
---|
93 | St_return (Some ? (Id id_main_i)) |
---|
94 | ) ( |
---|
95 | St_skip ) |
---|
96 | ) |
---|
97 | ) |
---|
98 | ) |
---|
99 | |
---|
100 | )). |
---|
101 | |
---|
102 | |
---|
103 | |
---|
104 | definition myprog : Cminor_program := |
---|
105 | mk_program ?? [ |
---|
106 | (pair ?? id_main f_main); |
---|
107 | (pair ?? id_get f_get) |
---|
108 | ] id_main |
---|
109 | [] |
---|
110 | . |
---|
111 | |
---|
112 | |
---|
113 | example exec0: finishes_with (repr 16) ? (exec_up_to Cminor_fullexec myprog 100 [EVint (repr 0)]). |
---|
114 | normalize (* you can examine the result here *) |
---|
115 | @refl qed. |
---|
116 | |
---|
117 | example exec1: finishes_with (repr 0) ? (exec_up_to Cminor_fullexec myprog 100 [EVint (repr 1)]). |
---|
118 | normalize (* you can examine the result here *) |
---|
119 | @refl qed. |
---|
120 | |
---|
121 | example exec3: finishes_with (repr 1) ? (exec_up_to Cminor_fullexec myprog 100 [EVint (repr 3)]). |
---|
122 | normalize (* you can examine the result here *) |
---|
123 | @refl qed. |
---|
124 | |
---|
125 | example exec5: finishes_with (repr 5) ? (exec_up_to Cminor_fullexec myprog 100 [EVint (repr 5)]). |
---|
126 | normalize (* you can examine the result here *) |
---|
127 | @refl qed. |
---|
128 | |
---|
129 | example exec7: finishes_with (repr 3) ? (exec_up_to Cminor_fullexec myprog 100 [EVint (repr 7)]). |
---|
130 | normalize (* you can examine the result here *) |
---|
131 | @refl qed. |
---|
132 | |
---|
133 | include "Cminor/toRTLabs.ma". |
---|
134 | include "RTLabs/semantics.ma". |
---|
135 | |
---|
136 | example execRTL0: finishes_with (repr 16) ? (do myprog' ← cminor_init_to_rtlabs myprog; exec_up_to RTLabs_fullexec myprog' 1000 [EVint (repr 0)]). |
---|
137 | normalize (* you can examine the result here *) |
---|
138 | @refl |
---|
139 | qed. |
---|
140 | |
---|
141 | example execRTL1: finishes_with (repr 0) ? (do myprog' ← cminor_init_to_rtlabs myprog; exec_up_to RTLabs_fullexec myprog' 1000 [EVint (repr 1)]). |
---|
142 | normalize (* you can examine the result here *) |
---|
143 | @refl |
---|
144 | qed. |
---|
145 | |
---|
146 | example execRTL3: finishes_with (repr 1) ? (do myprog' ← cminor_init_to_rtlabs myprog; exec_up_to RTLabs_fullexec myprog' 1000 [EVint (repr 3)]). |
---|
147 | normalize (* you can examine the result here *) |
---|
148 | @refl |
---|
149 | qed. |
---|
150 | |
---|
151 | example execRTL5: finishes_with (repr 5) ? (do myprog' ← cminor_init_to_rtlabs myprog; exec_up_to RTLabs_fullexec myprog' 1000 [EVint (repr 5)]). |
---|
152 | normalize (* you can examine the result here *) |
---|
153 | @refl |
---|
154 | qed. |
---|
155 | |
---|
156 | example execRTL7: finishes_with (repr 3) ? (do myprog' ← cminor_init_to_rtlabs myprog; exec_up_to RTLabs_fullexec myprog' 1000 [EVint (repr 7)]). |
---|
157 | normalize (* you can examine the result here *) |
---|
158 | @refl |
---|
159 | qed. |
---|