Changeset 331 for EcnlProtoTool/trunk/tcc-0.9.27/il-gen.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/tcc-0.9.27
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/tcc-0.9.27/il-gen.c
r321 r331 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 #ifdef TARGET_DEFS_ONLY 20 21 #error this code has bit-rotted since 2003 21 22 22 23 /* number of available registers */ 23 24 #define NB_REGS 3 24 #define NB_ASM_REGS 8 // TODO:25 #define ELF_PAGE_SIZE 0x1000 // TODO:26 #define MAX_ALIGN 8 // TODO:27 #define R_DATA_32 R_386_32 // TODO:28 #define R_DATA_PTR R_386_32 // TODO:29 #define R_JMP_SLOT R_386_JMP_SLOT // TODO:30 #define R_COPY R_386_COPY // TODO:31 #define ELF_START_ADDR 0x08048000 // TODO:32 #define EM_TCC_TARGET 0xFF // TODO:33 25 34 26 /* a register can belong to several classes. The classes must be … … 52 44 }; 53 45 46 const int reg_classes[NB_REGS] = { 47 /* ST0 */ RC_ST | RC_ST0, 48 /* ST1 */ RC_ST | RC_ST1, 49 /* ST2 */ RC_ST, 50 }; 51 54 52 /* return registers for function */ 55 53 #define REG_IRET REG_ST0 /* single word int return register */ … … 58 56 59 57 /* defined if function parameters must be evaluated in reverse order */ 60 / /#define INVERT_FUNC_PARAMS58 /* #define INVERT_FUNC_PARAMS */ 61 59 62 60 /* defined if structures are passed as pointers. Otherwise structures 63 61 are directly pushed on stack. */ 64 / /#define FUNC_STRUCT_PARAM_AS_PTR62 /* #define FUNC_STRUCT_PARAM_AS_PTR */ 65 63 66 64 /* pointer size, in bytes */ … … 82 80 83 81 enum ILOPCodes { 84 #define ENUM_ILOPCODES_DEF85 82 #define OP(name, str, n) IL_OP_ ## name = n, 86 83 #include "il-opcodes.h" 87 84 #undef OP 88 #undef ENUM_ILOPCODES_DEF89 85 }; 90 86 91 /******************************************************/92 #else /* ! TARGET_DEFS_ONLY */93 /******************************************************/94 #include "tcc.h"95 96 const int reg_classes[NB_REGS] = {97 /* ST0 */ RC_ST | RC_ST0,98 /* ST1 */ RC_ST | RC_ST1,99 /* ST2 */ RC_ST,100 };101 102 87 char *il_opcodes_str[] = { 103 #define OP(name, str, n) /*[n] = */str,88 #define OP(name, str, n) [n] = str, 104 89 #include "il-opcodes.h" 105 90 #undef OP … … 115 100 static void out_byte(int c) 116 101 { 117 int ind1 = ind + 1; 118 if (ind1 > cur_text_section->data_allocated) 119 section_realloc(cur_text_section, ind1); 120 *(char *)(cur_text_section->data + ind) = c; 121 ind++; 102 *(char *)ind++ = c; 122 103 } 123 104 … … 219 200 case VT_FUNC: 220 201 s = sym_find((unsigned)t >> VT_STRUCT_SHIFT); 221 if (s == NULL) 222 break; 223 il_type_to_str(buf, buf_size, s->type.t, varstr); 202 il_type_to_str(buf, buf_size, s->t, varstr); 224 203 pstrcat(buf, buf_size, "("); 225 204 sa = s->next; 226 205 while (sa != NULL) { 227 il_type_to_str(buf1, sizeof(buf1), sa->t ype.t, NULL);206 il_type_to_str(buf1, sizeof(buf1), sa->t, NULL); 228 207 pstrcat(buf, buf_size, buf1); 229 208 sa = sa->next; … … 235 214 case VT_PTR: 236 215 s = sym_find((unsigned)t >> VT_STRUCT_SHIFT); 237 if (s == NULL)238 break;239 216 pstrcpy(buf1, sizeof(buf1), "*"); 240 217 if (varstr) 241 218 pstrcat(buf1, sizeof(buf1), varstr); 242 il_type_to_str(buf, buf_size, s->t ype.t, buf1);219 il_type_to_str(buf, buf_size, s->t, buf1); 243 220 goto no_var; 244 221 } … … 250 227 } 251 228 252 #define Reloc void 229 253 230 /* patch relocation entry with value 'val' */ 254 231 void greloc_patch1(Reloc *p, int val) … … 285 262 v = sv->r & VT_VALMASK; 286 263 fc = sv->c.i; 287 ft = sv->t ype.t;264 ft = sv->t; 288 265 289 266 if (sv->r & VT_LVAL) { … … 364 341 v = sv->r & VT_VALMASK; 365 342 fc = sv->c.i; 366 ft = sv->t ype.t;343 ft = sv->t; 367 344 if (v == VT_LOCAL) { 368 345 if (fc >= ARG_BASE) { … … 412 389 void gfunc_param(GFuncContext *c) 413 390 { 414 if ((vtop->t ype.t& VT_BTYPE) == VT_STRUCT) {391 if ((vtop->t & VT_BTYPE) == VT_STRUCT) { 415 392 tcc_error("structures passed as value not handled yet"); 416 393 } else { … … 429 406 if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { 430 407 /* XXX: more info needed from tcc */ 431 il_type_to_str(buf, sizeof(buf), vtop->t ype.t, "xxx");408 il_type_to_str(buf, sizeof(buf), vtop->t, "xxx"); 432 409 fprintf(il_outfile, " call %s\n", buf); 433 410 } else { 434 411 /* indirect call */ 435 412 gv(RC_INT); 436 il_type_to_str(buf, sizeof(buf), vtop->t ype.t, NULL);413 il_type_to_str(buf, sizeof(buf), vtop->t, NULL); 437 414 fprintf(il_outfile, " calli %s\n", buf); 438 415 } … … 461 438 462 439 sym = sym_find((unsigned)t >> VT_STRUCT_SHIFT); 463 if (sym == NULL) 464 return; 440 func_call = sym->r; 465 441 466 442 addr = ARG_BASE; 467 443 /* if the function returns a structure, then add an 468 444 implicit pointer parameter */ 469 func_vt = sym->type; 470 if ((func_vt.t & VT_BTYPE) == VT_STRUCT) { 445 func_vt = sym->t; 446 func_var = (sym->c == FUNC_ELLIPSIS); 447 if ((func_vt & VT_BTYPE) == VT_STRUCT) { 471 448 func_vc = addr; 472 449 addr++; … … 474 451 /* define parameters */ 475 452 while ((sym = sym->next) != NULL) { 476 u = sym->t ype.t;453 u = sym->t; 477 454 sym_push(sym->v & ~SYM_FIELD, u, 478 455 VT_LOCAL | lvalue_type(sym->type.t), addr); … … 555 532 gsym(vtop->c.i); 556 533 } 557 } else {558 if (is_float(vtop->type.t)) {559 vpushi(0);560 gen_op(TOK_NE);561 }562 #define VT_FORWARD 0563 if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST) {564 /* constant jmp optimization */565 if ((vtop->c.i != 0) != inv)566 t = gjmp(t);567 } else {568 v = gv(RC_INT);569 t = out_opj(IL_OP_BRTRUE - inv, t);570 }571 534 } 572 535 vtop--; … … 640 603 641 604 /* generate a floating point operation 'v = t1 op t2' instruction. The 642 two operands are guarante d to have the same floating point type */605 two operands are guaranteed to have the same floating point type */ 643 606 void gen_opf(int op) 644 607 { … … 690 653 } 691 654 692 void ggoto(void) { }693 void gen_bounded_ptr_add(void) {}694 void gen_bounded_ptr_deref(int t) {}695 void gen_expr32(void) {}696 void asm_opcode(TCCState *s1, int opcode) {}697 void asm_compute_constraints(ASMOperand *operands,698 int nb_operands, int nb_outputs,699 const uint8_t *clobber_regs,700 int *pout_reg) {}701 void subst_asm_operand(CString *add_str,702 SValue *sv, int modifier) {}703 void asm_gen_code(ASMOperand *operands, int nb_operands,704 int nb_outputs, int is_output,705 uint8_t *clobber_regs,706 int out_reg) {}707 void asm_clobber(uint8_t *clobber_regs, const char *str) {}708 void gen_le32(int c) {}709 void g(int c) {}710 void gen_le16(int v) {}711 712 655 /* end of CIL code generator */ 713 656 /*************************************************************/ 714 #endif 715 /*************************************************************/ 657
Note:
See TracChangeset
for help on using the changeset viewer.