25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: generate_arm_loadstore.c,v 1.7 2006/12/30 13:30:56 debug Exp $ |
* $Id: generate_arm_loadstore.c,v 1.9 2007/06/04 06:59:01 debug Exp $ |
29 |
*/ |
*/ |
30 |
|
|
31 |
#include <stdio.h> |
#include <stdio.h> |
32 |
|
#include <stdlib.h> |
33 |
|
|
34 |
|
|
35 |
char *cond[16] = { |
char *cond[16] = { |
36 |
"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", |
"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", |
38 |
|
|
39 |
int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
40 |
{ |
{ |
41 |
int l, b, w, h, s, u, p, reg, c, n; |
int l, b, w=0, h, s, u=0, p=0, reg, c, n; |
42 |
|
int only_array = 0; |
43 |
|
|
44 |
|
if (argc == 1) { |
45 |
|
only_array = 1; |
46 |
|
} else { |
47 |
|
if (argc != 4) { |
48 |
|
fprintf(stderr, "puw missing?\n"); |
49 |
|
exit(1); |
50 |
|
} |
51 |
|
p = atoi(argv[1]); |
52 |
|
u = atoi(argv[2]); |
53 |
|
w = atoi(argv[3]); |
54 |
|
} |
55 |
|
|
56 |
printf("\n/* AUTOMATICALLY GENERATED! Do not edit. */\n\n"); |
printf("\n/* AUTOMATICALLY GENERATED! Do not edit. */\n\n"); |
57 |
printf("#include <stdio.h>\n#include <stdlib.h>\n" |
printf("#include <stdio.h>\n#include <stdlib.h>\n" |
68 |
"struct arm_instr_call *);\n"); |
"struct arm_instr_call *);\n"); |
69 |
printf("extern void arm_pc_to_pointers(struct cpu *);\n"); |
printf("extern void arm_pc_to_pointers(struct cpu *);\n"); |
70 |
|
|
71 |
|
if (!only_array) |
72 |
for (reg=0; reg<=1; reg++) |
for (reg=0; reg<=1; reg++) |
|
for (p=0; p<=1; p++) |
|
|
for (u=0; u<=1; u++) |
|
73 |
for (b=0; b<=1; b++) |
for (b=0; b<=1; b++) |
|
for (w=0; w<=1; w++) |
|
74 |
for (l=0; l<=1; l++) { |
for (l=0; l<=1; l++) { |
75 |
printf("#define A__NAME__general arm_instr_%s_" |
printf("#define A__NAME__general arm_instr_%s_" |
76 |
"%s_%s_%s_%s_%s__general\n", |
"%s_%s_%s_%s_%s__general\n", |
122 |
printf("#undef A__NAME\n"); |
printf("#undef A__NAME\n"); |
123 |
} |
} |
124 |
|
|
125 |
printf("\n\tvoid (*arm_load_store_instr[1024])(struct cpu *,\n" |
if (only_array) { |
126 |
"\t\tstruct arm_instr_call *) = {\n"); |
for (reg=0; reg<=1; reg++) |
127 |
n = 0; |
for (p=0; p<=1; p++) |
128 |
for (reg=0; reg<=1; reg++) |
for (u=0; u<=1; u++) |
129 |
for (p=0; p<=1; p++) |
for (b=0; b<=1; b++) |
130 |
for (u=0; u<=1; u++) |
for (w=0; w<=1; w++) |
131 |
for (b=0; b<=1; b++) |
for (l=0; l<=1; l++) |
132 |
for (w=0; w<=1; w++) |
for (c=0; c<16; c++) { |
133 |
for (l=0; l<=1; l++) |
if (c == 15) |
134 |
for (c=0; c<16; c++) { |
continue; |
135 |
if (c == 15) |
|
136 |
printf("\tarm_instr_nop"); |
printf("void arm_instr_%s_%s_%s" |
137 |
else |
"_%s_%s_%s%s%s(struct cpu *, struct " |
138 |
printf("\tarm_instr_%s_%s_%s_%s_%s_%s%s%s", |
"arm_instr_call *);", |
139 |
l? "load" : "store", |
l? "load" : "store", |
140 |
w? "w1" : "w0", |
w? "w1" : "w0", |
141 |
b? "byte" : "word", |
b? "byte" : "word", |
143 |
p? "p1" : "p0", |
p? "p1" : "p0", |
144 |
reg? "reg" : "imm", |
reg? "reg" : "imm", |
145 |
c!=14? "__" : "", cond[c]); |
c!=14? "__" : "", cond[c]); |
146 |
n++; |
printf("void arm_instr_%s_%s_%s_%s_%s_%s_pc%s%s" |
147 |
if (n!=2*2*2*2*2*2*16) |
"(struct cpu *, struct " |
148 |
printf(","); |
"arm_instr_call *);\n", |
|
printf("\n"); |
|
|
} |
|
|
|
|
|
printf("};\n\n"); |
|
|
|
|
|
/* Load/store with the pc register: */ |
|
|
printf("\n\tvoid (*arm_load_store_instr_pc[1024])(struct cpu *,\n" |
|
|
"\t\tstruct arm_instr_call *) = {\n"); |
|
|
n = 0; |
|
|
for (reg=0; reg<=1; reg++) |
|
|
for (p=0; p<=1; p++) |
|
|
for (u=0; u<=1; u++) |
|
|
for (b=0; b<=1; b++) |
|
|
for (w=0; w<=1; w++) |
|
|
for (l=0; l<=1; l++) |
|
|
for (c=0; c<16; c++) { |
|
|
if (c == 15) |
|
|
printf("\tarm_instr_nop"); |
|
|
else |
|
|
printf("\tarm_instr_%s_%s_%s_%s_%s_%s_pc%s%s", |
|
149 |
l? "load" : "store", |
l? "load" : "store", |
150 |
w? "w1" : "w0", |
w? "w1" : "w0", |
151 |
b? "byte" : "word", |
b? "byte" : "word", |
153 |
p? "p1" : "p0", |
p? "p1" : "p0", |
154 |
reg? "reg" : "imm", |
reg? "reg" : "imm", |
155 |
c!=14? "__" : "", cond[c]); |
c!=14? "__" : "", cond[c]); |
156 |
n++; |
} |
|
if (n!=2*2*2*2*2*2*16) |
|
|
printf(","); |
|
|
printf("\n"); |
|
|
} |
|
157 |
|
|
158 |
printf("};\n\n"); |
printf("\n\tvoid (*arm_load_store_instr[1024])(struct cpu *,\n" |
159 |
|
"\t\tstruct arm_instr_call *) = {\n"); |
160 |
|
n = 0; |
161 |
|
for (reg=0; reg<=1; reg++) |
162 |
|
for (p=0; p<=1; p++) |
163 |
|
for (u=0; u<=1; u++) |
164 |
|
for (b=0; b<=1; b++) |
165 |
|
for (w=0; w<=1; w++) |
166 |
|
for (l=0; l<=1; l++) |
167 |
|
for (c=0; c<16; c++) { |
168 |
|
if (c == 15) |
169 |
|
printf("\tarm_instr_nop"); |
170 |
|
else |
171 |
|
printf("\tarm_instr_%s_%s_%s" |
172 |
|
"_%s_%s_%s%s%s", |
173 |
|
l? "load" : "store", |
174 |
|
w? "w1" : "w0", |
175 |
|
b? "byte" : "word", |
176 |
|
u? "u1" : "u0", |
177 |
|
p? "p1" : "p0", |
178 |
|
reg? "reg" : "imm", |
179 |
|
c!=14? "__" : "", cond[c]); |
180 |
|
n++; |
181 |
|
if (n!=2*2*2*2*2*2*16) |
182 |
|
printf(","); |
183 |
|
printf("\n"); |
184 |
|
} |
185 |
|
|
186 |
|
printf("};\n\n"); |
187 |
|
|
188 |
|
/* Load/store with the pc register: */ |
189 |
|
printf("\n\tvoid (*arm_load_store_instr_pc[1024])" |
190 |
|
"(struct cpu *,\n\t\tstruct arm_instr_call *) = {\n"); |
191 |
|
n = 0; |
192 |
|
for (reg=0; reg<=1; reg++) |
193 |
|
for (p=0; p<=1; p++) |
194 |
|
for (u=0; u<=1; u++) |
195 |
|
for (b=0; b<=1; b++) |
196 |
|
for (w=0; w<=1; w++) |
197 |
|
for (l=0; l<=1; l++) |
198 |
|
for (c=0; c<16; c++) { |
199 |
|
if (c == 15) |
200 |
|
printf("\tarm_instr_nop"); |
201 |
|
else |
202 |
|
printf("\tarm_instr_%s_%s_%s_" |
203 |
|
"%s_%s_%s_pc%s%s", |
204 |
|
l? "load" : "store", |
205 |
|
w? "w1" : "w0", |
206 |
|
b? "byte" : "word", |
207 |
|
u? "u1" : "u0", |
208 |
|
p? "p1" : "p0", |
209 |
|
reg? "reg" : "imm", |
210 |
|
c!=14? "__" : "", cond[c]); |
211 |
|
n++; |
212 |
|
if (n!=2*2*2*2*2*2*16) |
213 |
|
printf(","); |
214 |
|
printf("\n"); |
215 |
|
} |
216 |
|
|
217 |
|
printf("};\n\n"); |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
/* "Addressing mode 3": */ |
/* "Addressing mode 3": */ |
222 |
|
|
223 |
|
if (!only_array) |
224 |
for (reg=0; reg<=1; reg++) |
for (reg=0; reg<=1; reg++) |
|
for (p=0; p<=1; p++) |
|
|
for (u=0; u<=1; u++) |
|
225 |
for (h=0; h<=1; h++) |
for (h=0; h<=1; h++) |
|
for (w=0; w<=1; w++) |
|
226 |
for (s=0; s<=1; s++) |
for (s=0; s<=1; s++) |
227 |
for (l=0; l<=1; l++) { |
for (l=0; l<=1; l++) { |
228 |
if (s==0 && h==0) |
if (s==0 && h==0) |
289 |
printf("#undef A__NAME\n"); |
printf("#undef A__NAME\n"); |
290 |
} |
} |
291 |
|
|
292 |
printf("\n\tvoid (*arm_load_store_instr_3[2048])(struct cpu *,\n" |
if (only_array) { |
293 |
"\t\tstruct arm_instr_call *) = {\n"); |
for (reg=0; reg<=1; reg++) |
294 |
n = 0; |
for (p=0; p<=1; p++) |
295 |
for (reg=0; reg<=1; reg++) |
for (u=0; u<=1; u++) |
296 |
for (p=0; p<=1; p++) |
for (h=0; h<=1; h++) |
297 |
for (u=0; u<=1; u++) |
for (w=0; w<=1; w++) |
298 |
for (h=0; h<=1; h++) |
for (s=0; s<=1; s++) |
299 |
for (w=0; w<=1; w++) |
for (l=0; l<=1; l++) |
300 |
for (s=0; s<=1; s++) |
for (c=0; c<16; c++) { |
301 |
for (l=0; l<=1; l++) |
if (c == 15) |
302 |
for (c=0; c<16; c++) { |
continue; |
303 |
if (c == 15) |
else if (s==0 && h==0) |
304 |
printf("\tarm_instr_nop"); |
continue; |
305 |
else if (s==0 && h==0) |
|
306 |
printf("\tarm_instr_invalid"); |
printf("void arm_instr_%s_%s_%s_%s_%s_%s_%s%s%s" |
307 |
else |
"(struct cpu *, struct arm_instr_call *);\n", |
|
printf("\tarm_instr_%s_%s_%s_%s_%s_%s_%s%s%s", |
|
308 |
l? "load" : "store", |
l? "load" : "store", |
309 |
w? "w1" : "w0", |
w? "w1" : "w0", |
310 |
s? "signed" : "unsigned", |
s? "signed" : "unsigned", |
312 |
u? "u1" : "u0", p? "p1" : "p0", |
u? "u1" : "u0", p? "p1" : "p0", |
313 |
reg? "reg" : "imm", |
reg? "reg" : "imm", |
314 |
c!=14? "__" : "", cond[c]); |
c!=14? "__" : "", cond[c]); |
315 |
n++; |
printf("void arm_instr_%s_%s_%s_%s_%s_%s_" |
316 |
if (n!=2*2*2*2*2*2*2*16) |
"%s_pc%s%s(struct cpu *, struct " |
317 |
printf(","); |
"arm_instr_call *);\n", |
318 |
printf("\n"); |
l? "load" : "store", |
|
} |
|
|
|
|
|
printf("};\n\n"); |
|
|
|
|
|
/* Load/store with the pc register: */ |
|
|
printf("\n\tvoid (*arm_load_store_instr_3_pc[2048])(struct cpu *,\n" |
|
|
"\t\tstruct arm_instr_call *) = {\n"); |
|
|
n = 0; |
|
|
for (reg=0; reg<=1; reg++) |
|
|
for (p=0; p<=1; p++) |
|
|
for (u=0; u<=1; u++) |
|
|
for (h=0; h<=1; h++) |
|
|
for (w=0; w<=1; w++) |
|
|
for (s=0; s<=1; s++) |
|
|
for (l=0; l<=1; l++) |
|
|
for (c=0; c<16; c++) { |
|
|
if (c == 15) |
|
|
printf("\tarm_instr_nop"); |
|
|
else if (s==0 && h==0) |
|
|
printf("\tarm_instr_invalid"); |
|
|
else |
|
|
printf("\tarm_instr_%s_%s_%s_%s_%s_%s_" |
|
|
"%s_pc%s%s", l? "load" : "store", |
|
319 |
w? "w1" : "w0", |
w? "w1" : "w0", |
320 |
s? "signed" : "unsigned", |
s? "signed" : "unsigned", |
321 |
h? "halfword" : "byte", |
h? "halfword" : "byte", |
322 |
u? "u1" : "u0", p? "p1" : "p0", |
u? "u1" : "u0", p? "p1" : "p0", |
323 |
reg? "reg" : "imm", |
reg? "reg" : "imm", |
324 |
c!=14? "__" : "", cond[c]); |
c!=14? "__" : "", cond[c]); |
325 |
n++; |
} |
|
if (n!=2*2*2*2*2*2*2*16) |
|
|
printf(","); |
|
|
printf("\n"); |
|
|
} |
|
326 |
|
|
327 |
printf("};\n\n"); |
printf("\n\tvoid (*arm_load_store_instr_3[2048])" |
328 |
|
"(struct cpu *,\n\t\tstruct arm_instr_call *) = {\n"); |
329 |
|
n = 0; |
330 |
|
for (reg=0; reg<=1; reg++) |
331 |
|
for (p=0; p<=1; p++) |
332 |
|
for (u=0; u<=1; u++) |
333 |
|
for (h=0; h<=1; h++) |
334 |
|
for (w=0; w<=1; w++) |
335 |
|
for (s=0; s<=1; s++) |
336 |
|
for (l=0; l<=1; l++) |
337 |
|
for (c=0; c<16; c++) { |
338 |
|
if (c == 15) |
339 |
|
printf("\tarm_instr_nop"); |
340 |
|
else if (s==0 && h==0) |
341 |
|
printf("\tarm_instr_invalid"); |
342 |
|
else |
343 |
|
printf("\tarm_instr_%s_%s_%s_%s_" |
344 |
|
"%s_%s_%s%s%s", |
345 |
|
l? "load" : "store", |
346 |
|
w? "w1" : "w0", |
347 |
|
s? "signed" : "unsigned", |
348 |
|
h? "halfword" : "byte", |
349 |
|
u? "u1" : "u0", p? "p1" : "p0", |
350 |
|
reg? "reg" : "imm", |
351 |
|
c!=14? "__" : "", cond[c]); |
352 |
|
n++; |
353 |
|
if (n!=2*2*2*2*2*2*2*16) |
354 |
|
printf(","); |
355 |
|
printf("\n"); |
356 |
|
} |
357 |
|
|
358 |
|
printf("};\n\n"); |
359 |
|
|
360 |
|
/* Load/store with the pc register: */ |
361 |
|
printf("\n\tvoid (*arm_load_store_instr_3_pc[2048])" |
362 |
|
"(struct cpu *,\n\t\tstruct arm_instr_call *) = {\n"); |
363 |
|
n = 0; |
364 |
|
for (reg=0; reg<=1; reg++) |
365 |
|
for (p=0; p<=1; p++) |
366 |
|
for (u=0; u<=1; u++) |
367 |
|
for (h=0; h<=1; h++) |
368 |
|
for (w=0; w<=1; w++) |
369 |
|
for (s=0; s<=1; s++) |
370 |
|
for (l=0; l<=1; l++) |
371 |
|
for (c=0; c<16; c++) { |
372 |
|
if (c == 15) |
373 |
|
printf("\tarm_instr_nop"); |
374 |
|
else if (s==0 && h==0) |
375 |
|
printf("\tarm_instr_invalid"); |
376 |
|
else |
377 |
|
printf("\tarm_instr_%s_%s_%s_%s_%s_%s_" |
378 |
|
"%s_pc%s%s", l? "load" : "store", |
379 |
|
w? "w1" : "w0", |
380 |
|
s? "signed" : "unsigned", |
381 |
|
h? "halfword" : "byte", |
382 |
|
u? "u1" : "u0", p? "p1" : "p0", |
383 |
|
reg? "reg" : "imm", |
384 |
|
c!=14? "__" : "", cond[c]); |
385 |
|
n++; |
386 |
|
if (n!=2*2*2*2*2*2*2*16) |
387 |
|
printf(","); |
388 |
|
printf("\n"); |
389 |
|
} |
390 |
|
|
391 |
|
printf("};\n\n"); |
392 |
|
} |
393 |
|
|
394 |
return 0; |
return 0; |
395 |
} |
} |