Mercurial > hg > CbC > old > device
annotate mc-code.h @ 716:21f770a3b298
*** empty log message ***
author | kono |
---|---|
date | Fri, 16 Nov 2007 21:46:20 +0900 |
parents | 83e18db76c96 |
children | a177c65f3e37 |
rev | line source |
---|---|
61 | 1 /* function required by mc-codegen.c |
2 mc-code-*.c have to provied these | |
3 */ | |
4 | |
607 | 5 /************************************************************************ |
6 ** Copyright (C) 2006 Shinji Kono | |
7 ** 連絡先: 琉球大学情報工学科 河野 真治 | |
8 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp) | |
9 ** | |
10 ** このソースのいかなる複写,改変,修正も許諾します。ただし、 | |
11 ** その際には、誰が貢献したを示すこの部分を残すこと。 | |
12 ** 再配布や雑誌の付録などの問い合わせも必要ありません。 | |
13 ** 営利利用も上記に反しない範囲で許可します。 | |
14 ** バイナリの配布の際にはversion messageを保存することを条件とします。 | |
15 ** このプログラムについては特に何の保証もしない、悪しからず。 | |
16 ** | |
17 ** Everyone is permitted to do anything on this program | |
18 ** including copying, modifying, improving, | |
19 ** as long as you don't try to pretend that you wrote it. | |
20 ** i.e., the above copyright notice has to appear in all copies. | |
21 ** Binary distribution requires original version messages. | |
22 ** You don't have to ask before copying, redistribution or publishing. | |
23 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. | |
24 ***********************************************************************/ | |
173 | 25 |
452 | 26 #define MAX_MAX 50 /* architecture independent max registers */ |
599 | 27 |
28 /* | |
29 flag value for regs[] | |
30 */ | |
31 | |
32 #define USING_REG 1 /* unreusable register usage */ | |
452 | 33 #define INPUT_REG 2 /* input register ( can be reused ) */ |
599 | 34 #define REG_VAR 3 /* used as register variable */ |
35 #define PTRC_REG 4 /* used as global variable pointer cache */ | |
144 | 36 |
452 | 37 extern char *l_include_path[]; /* library including path */ |
173 | 38 |
452 | 39 extern int disp_offset; /* displacement offset in code and function */ |
599 | 40 |
41 /* | |
42 function arugment evaluation order | |
43 define compatiblity in inline function generation | |
44 */ | |
555 | 45 #define NORMAL 0 |
46 #define REVERSE 1 | |
47 extern int eval_order; | |
254 | 48 |
83 | 49 extern int MAX_REGISTER; |
50 extern int MAX_REGISTGER_VAR; | |
51 extern int MAX_FREGISTER; | |
103 | 52 |
53 extern int MAX_INPUT_REGISTER_VAR; | |
54 extern int MAX_CODE_INPUT_REGISTER_VAR; | |
55 extern int MAX_INPUT_DREGISTER_VAR; | |
138 | 56 extern int MAX_CODE_INPUT_FREGISTER_VAR; |
103 | 57 extern int MAX_CODE_INPUT_DREGISTER_VAR; |
99 | 58 |
94 | 59 #define REG_LVAR_OFFSET 2 |
83 | 60 |
340 | 61 extern int data_alignment; |
327 | 62 |
452 | 63 extern int code_lassop_p; /* architecture has code_lassop */ |
238 | 64 |
327 | 65 /* used by mc-codegen */ |
66 | |
516 | 67 extern void data_mode(char *name); |
68 extern void text_mode(int align); | |
69 extern void cstring_mode(); | |
70 | |
452 | 71 extern void gexpr_init(void); /* code generator initialize for each statement */ |
327 | 72 extern void emit_init(void); /* called before delcalartion */ |
452 | 73 extern void gen_gdecl(char *n, int gpc); /* global definition */ |
327 | 74 |
75 extern void code_init(); /* called only once */ | |
76 extern void emit_reinit(); /* called for each file */ | |
77 | |
61 | 78 extern void gexpr_code_init(void); |
327 | 79 |
80 extern void code_enter(char *name); | |
81 extern void code_enter1(int args); | |
82 extern void code_leave(char *name); | |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
83 extern void code_label_call(int i); |
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
84 extern void code_ret(); |
327 | 85 extern void enter(char *name); |
86 extern void enter1(); | |
87 extern void leave(int control, char *name); | |
88 extern void jmp(int l); | |
449 | 89 extern int not_simple_p(int l); |
450
eaf9e2746c83
parallel assign for simple expr. (too complex solution)
kono
parents:
449
diff
changeset
|
90 extern void code_save_stacks(); |
715 | 91 extern int code_arg_alignment(int disp0,NMTBL *n,int type0,int sz); |
92 extern int code_lvar_alignment(int disp0,NMTBL *n,int type0,int sz); | |
327 | 93 |
105 | 94 extern int get_register_var(NMTBL *n); |
138 | 95 extern int get_dregister_var(NMTBL *n,int d); |
195 | 96 extern int get_lregister_var(NMTBL *n); |
126 | 97 extern int get_input_register_var(int,NMTBL *,int); |
138 | 98 extern int get_input_dregister_var(int,NMTBL *,int,int); |
195 | 99 extern int get_input_lregister_var(int,NMTBL *,int); |
341 | 100 extern void code_ptr_cache_def(int r,NMTBL *nptr); |
101 extern void use_ptr_cache(int r); | |
345 | 102 extern int code_register_overlap(int s,int t); |
341 | 103 |
426 | 104 extern int emit_push(); |
61 | 105 extern int emit_pop(int type); |
106 extern void gexpr_code_init(); | |
95 | 107 extern int code_csvalue(); |
147 | 108 extern void code_gexpr(int e); |
287 | 109 extern void code_cmpdimm(int e, int csreg,int label,int cond); |
107 | 110 extern void code_gvar(int e1,int reg); |
111 extern void code_rgvar(int e1,int reg); | |
165 | 112 extern void code_crgvar(int e1,int reg,int sign,int sz); |
107 | 113 extern void code_lvar(int e2,int reg); |
114 extern void code_register(int e2,int reg); | |
94 | 115 extern void code_rlvar(int e2,int reg); |
165 | 116 extern void code_crlvar(int e2,int reg,int sign,int sz); |
109 | 117 extern void code_fname(NMTBL *n,int reg); |
107 | 118 extern void code_const(int e2,int reg); |
119 extern void code_neg(int reg); | |
120 extern void code_not(int reg); | |
121 extern void code_lnot(int reg); | |
168 | 122 extern void code_preinc(int e1,int e2,int dir,int sign,int sz,int reg); |
123 extern void code_postinc(int e1,int e2,int dir,int sign,int sz,int reg); | |
107 | 124 extern void code_return(int reg); |
125 extern void code_environment(int reg); | |
221 | 126 extern void code_bool(int e1,int reg); |
287 | 127 extern void code_cmp_crgvar(int e1,int reg,int sz,int label,int cond); |
128 extern void code_cmp_crlvar(int e1,int reg,int sz,int label,int cond); | |
129 extern void code_cmp_rgvar(int e1,int reg,int label,int cond); | |
130 extern void code_cmp_rlvar(int e1,int reg,int label,int cond); | |
131 extern void code_cmp_register(int e2,int label,int cond); | |
107 | 132 extern void code_string(int e1,int reg); |
61 | 133 extern void emit_copy(int from,int to,int length,int offset,int value,int det); |
94 | 134 extern int function(int e1); |
61 | 135 extern void code_frame_pointer(int e3); |
577 | 136 extern int code_frame_pointer_register(); |
61 | 137 extern void code_fix_frame_pointer(int disp_offset); |
138 extern void code_jmp(char *s); | |
139 extern void code_indirect_jmp(int e2); | |
196 | 140 |
355 | 141 extern void code_rindirect(int e1, int reg,int offset, int us,int sz); |
196 | 142 #if FLOAT_CODE |
221 | 143 extern int code_drindirect(int e1, int reg,int offset, int d); |
196 | 144 #endif |
145 #if LONGLONG_CODE | |
221 | 146 extern int code_lrindirect(int e1, int reg,int offset, int us); |
196 | 147 #endif |
148 | |
103 | 149 extern void code_assign_gvar(int e2,int reg,int byte); |
150 extern void code_assign_lvar(int e2,int reg,int byte); | |
111 | 151 extern void code_assign_register(int e2,int byte,int reg); |
118 | 152 extern void code_assign(int e2,int byte,int reg); |
221 | 153 extern void code_register_assop(int e2,int reg,int op,int byte); |
154 extern void code_assop(int op,int reg,int byte,int sign); | |
155 extern void tosop(int op,int reg,int oreg); | |
594 | 156 extern int tosop_operand_safe_p(int); |
66 | 157 extern void code_opening(char *filename); |
158 extern void code_closing(); | |
438
626d705471d5
Unexecuted code in conditional. Lazy jmp code generation.
kono
parents:
430
diff
changeset
|
159 extern int rexpr(int e1, int l1, int cond,int t); |
61 | 160 extern void jmp(int l); |
187 | 161 extern int code_get_fixed_creg(int reg,int type); |
162 extern void code_set_fixed_creg(int reg,int mode,int type); | |
705 | 163 extern int code_set_return_register(int mode); |
66 | 164 extern void global_table(void); |
92 | 165 extern void code_label(int labelno); |
363 | 166 extern void code_label_value(int labelno,int reg); |
92 | 167 |
189 | 168 extern int code_const_op_p(int op,int v); |
221 | 169 extern void oprtc(int op,int reg,int v); |
189 | 170 |
716 | 171 extern void code_align(int t); |
516 | 172 extern void emit_global(NMTBL *n,int t,int e); |
340 | 173 extern void emit_space(int sp); |
174 extern void emit_char(int d); | |
175 extern void emit_short(int d); | |
176 extern void emit_int(int d); | |
177 extern void emit_longlong(int e); | |
178 extern void emit_double(int e); | |
179 extern void emit_float(int e); | |
367 | 180 extern void emit_address(char *s,int offset); |
340 | 181 extern void emit_label(int labelno); |
182 extern int emit_string_label(); | |
518 | 183 extern void emit_string(char *,int type); |
340 | 184 |
353 | 185 extern void code_i2c(int reg); |
186 extern void code_i2s(int reg); | |
187 extern void code_u2uc(int reg); | |
188 extern void code_u2us(int reg); | |
61 | 189 |
195 | 190 #if FLOAT_CODE |
81 | 191 /* floating point part */ |
192 | |
438
626d705471d5
Unexecuted code in conditional. Lazy jmp code generation.
kono
parents:
430
diff
changeset
|
193 extern int drexpr(int e1, int e2,int l1, int op,int cond); |
81 | 194 extern int dpop_register(); |
195 extern int emit_dpop(int); | |
138 | 196 extern void code_dregister(int e2,int reg,int d); |
287 | 197 extern void code_cmp_dregister(int,int,int,int); |
198 extern void code_cmp_drgvar(int,int,int,int,int); | |
199 extern void code_cmp_drlvar(int,int,int,int,int); | |
103 | 200 extern void code_dassign(int,int,int); |
201 extern void code_dassign_gvar(int,int,int); | |
202 extern void code_dassign_lvar(int,int,int); | |
138 | 203 extern void code_dassign_dregister(int e2,int d,int reg); |
204 extern void code_dconst(int,int,int); | |
205 extern void code_dneg(int,int); | |
107 | 206 extern void code_drgvar(int,int,int); |
207 extern void code_drlvar(int,int,int); | |
221 | 208 extern void dtosop(int,int,int); |
138 | 209 extern void emit_dpop_free(int,int); |
133 | 210 extern void emit_dpush(int); |
221 | 211 extern void code_i2d(); |
212 extern void code_d2i(); | |
213 extern void code_u2d(); | |
214 extern void code_d2u(); | |
215 extern void code_d2f(); | |
216 extern void code_f2d(); | |
217 extern void code_f2i(); | |
218 extern void code_f2u(); | |
219 extern void code_i2f(); | |
220 extern void code_u2f(); | |
133 | 221 |
81 | 222 |
107 | 223 extern void code_dpreinc(int e1,int e2,int d,int reg); |
224 extern void code_dpostinc(int e1,int e2,int d,int reg); | |
221 | 225 extern void code_dassop(int op,int reg,int d); |
219 | 226 extern void code_register_dassop(int reg,int op,int d); |
89 | 227 |
195 | 228 #endif |
229 | |
230 #if LONGLONG_CODE | |
231 /* 64bit int part */ | |
232 | |
438
626d705471d5
Unexecuted code in conditional. Lazy jmp code generation.
kono
parents:
430
diff
changeset
|
233 extern int lrexpr(int e1, int e2,int l1, int op,int cond); |
195 | 234 extern int lpop_register(); |
235 extern int emit_lpop(); | |
236 extern void code_lregister(int e2,int reg); | |
287 | 237 extern void code_cmp_lregister(int,int,int); |
238 extern void code_cmp_lrgvar(int,int,int,int); | |
239 extern void code_cmp_lrlvar(int,int,int,int); | |
195 | 240 extern void code_lassign(int,int); |
241 extern void code_lassign_gvar(int,int); | |
242 extern void code_lassign_lvar(int,int); | |
243 extern void code_lassign_lregister(int e2,int reg); | |
244 extern void code_lconst(int,int); | |
212 | 245 extern void code_lneg(int); |
195 | 246 extern void code_lrgvar(int,int); |
247 extern void code_lrlvar(int,int); | |
221 | 248 extern void ltosop(int,int,int); |
195 | 249 extern void emit_lpop_free(int); |
250 extern void emit_lpush(); | |
213 | 251 extern int code_lconst_op_p(int op,int e); |
221 | 252 extern void loprtc(int op,int reg, int e); |
239 | 253 extern void code_i2ll(int reg); |
254 extern void code_i2ull(int reg); | |
255 extern void code_u2ll(int reg); | |
256 extern void code_u2ull(int reg); | |
257 extern void code_ll2i(int reg); | |
258 extern void code_ll2u(int reg); | |
259 extern void code_ull2i(int reg); | |
260 extern void code_ull2u(int reg); | |
195 | 261 #if FLOAT_CODE |
239 | 262 extern void code_d2ll(int reg); |
263 extern void code_d2ull(int reg); | |
264 extern void code_f2ll(int reg); | |
265 extern void code_f2ull(int reg); | |
266 extern void code_ll2d(int reg); | |
267 extern void code_ll2f(int reg); | |
268 extern void code_ull2d(int reg); | |
269 extern void code_ull2f(int reg); | |
195 | 270 #endif |
271 | |
272 | |
273 | |
274 | |
275 extern void code_lpreinc(int e1,int e2,int reg); | |
276 extern void code_lpostinc(int e1,int e2,int reg); | |
221 | 277 extern void code_lassop(int op,int reg); |
219 | 278 extern void code_register_lassop(int reg,int op); |
195 | 279 |
280 #endif | |
281 | |
313 | 282 extern void code_alloca(int e,int reg); |
616 | 283 extern void code_builtin_fabsf(int e); |
284 extern void code_builtin_fabs(int e); | |
285 extern void code_builtin_inff(); | |
286 extern void code_builtin_inf(); | |
137 | 287 extern void code_arg_register(NMTBL *fnptr); |
89 | 288 |
430 | 289 extern int get_register(); |
290 extern int get_dregister(); | |
291 extern int get_lregister(); | |
89 | 292 extern void free_register(int i) ; |
293 extern int pop_register(void); | |
294 extern void emit_pop_free(int xreg); | |
308 | 295 extern void emit_data_closing(NMTBL *n); |
296 | |
89 | 297 |
221 | 298 // extern int use_int(int); |
299 // extern int use_float(int); | |
300 // extern int use_double(int); | |
301 // extern int use_longlong(int); | |
138 | 302 |
300 | 303 #if CASE_CODE |
382 | 304 extern int code_table_jump_p(int delta); |
302 | 305 extern void code_table_jump(int table,int csvalue,int delta,int max,int min,int dlabel); |
300 | 306 extern void code_table_open(int table); |
307 extern void code_table_value(int label,int table); | |
308 extern void code_table_close(); | |
309 #endif | |
310 | |
316 | 311 #if ASM_CODE |
320 | 312 |
327 | 313 extern void code_asm(char *asm_str,int repl); |
314 extern int code_asm_operand(char *p,int e1,int mode,int repl,int n,int repl0); | |
315 extern void code_free_asm_operand(int repl); | |
320 | 316 |
316 | 317 #endif |
318 | |
456 | 319 extern void code_comment(char *s); |
327 | 320 |
329 | 321 #if BIT_FIELD_CODE |
322 | |
323 /* bit field alignment calcuration */ | |
324 | |
331 | 325 extern int code_bit_field_disp(int type,int *offset,int *bfd,int *sz); |
329 | 326 |
327 /* bit field value */ | |
328 | |
329 /* reg contains address of bit_field, result should goto reg */ | |
426 | 330 extern void code_bit_field(int type,int adr,int reg); |
329 | 331 |
332 /* bit field replacement */ | |
333 | |
426 | 334 extern void code_bit_replace(int value,int lvalue,int type); |
329 | 335 /* register, register */ |
426 | 336 extern void code_bit_replace_const(int value,int lvalue,int type); |
365 | 337 /* exp, register */ |
329 | 338 |
339 #endif | |
340 | |
327 | 341 /* end */ |