Changeset 331 for EcnlProtoTool/trunk/tcc-0.9.27/c67-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/c67-gen.c
r321 r331 21 21 #ifdef TARGET_DEFS_ONLY 22 22 23 / /#define ASSEMBLY_LISTING_C6723 /* #define ASSEMBLY_LISTING_C67 */ 24 24 25 25 /* number of available registers */ … … 94 94 95 95 /* defined if function parameters must be evaluated in reverse order */ 96 / /#define INVERT_FUNC_PARAMS96 /* #define INVERT_FUNC_PARAMS */ 97 97 98 98 /* defined if structures are passed as pointers. Otherwise structures 99 99 are directly pushed on stack. */ 100 / /#define FUNC_STRUCT_PARAM_AS_PTR100 /* #define FUNC_STRUCT_PARAM_AS_PTR */ 101 101 102 102 /* pointer size, in bytes */ … … 108 108 /* maximum alignment (for aligned attribute support) */ 109 109 #define MAX_ALIGN 8 110 111 /******************************************************/112 /* ELF defines */113 114 #define EM_TCC_TARGET EM_C60115 116 /* relocation type for 32 bit data relocation */117 #define R_DATA_32 R_C60_32118 #define R_DATA_PTR R_C60_32119 #define R_JMP_SLOT R_C60_JMP_SLOT120 #define R_COPY R_C60_COPY121 122 #define ELF_START_ADDR 0x00000400123 #define ELF_PAGE_SIZE 0x1000124 110 125 111 /******************************************************/ … … 197 183 { 198 184 int ind1; 199 185 if (nocode_wanted) 186 return; 200 187 #ifdef ASSEMBLY_LISTING_C67 201 188 fprintf(f, " %08X", c); … … 246 233 247 234 // these are regs that tcc doesn't really know about, 248 // but as ign them unique values so the mapping routines249 // can distin quish them235 // but assign them unique values so the mapping routines 236 // can distinguish them 250 237 251 238 #define C67_A0 105 … … 254 241 #define C67_FP 108 255 242 #define C67_B2 109 256 #define C67_CREG_ZERO -1 / / Special code for no condition reg test243 #define C67_CREG_ZERO -1 /* Special code for no condition reg test */ 257 244 258 245 … … 1568 1555 fr = sv->r; 1569 1556 ft = sv->type.t; 1570 fc = sv->c. ul;1557 fc = sv->c.i; 1571 1558 1572 1559 v = fr & VT_VALMASK; … … 1575 1562 v1.type.t = VT_INT; 1576 1563 v1.r = VT_LOCAL | VT_LVAL; 1577 v1.c. ul= fc;1564 v1.c.i = fc; 1578 1565 load(r, &v1); 1579 1566 fr = r; … … 1727 1714 1728 1715 ft = v->type.t; 1729 fc = v->c. ul;1716 fc = v->c.i; 1730 1717 fr = v->r & VT_VALMASK; 1731 1718 bt = ft & VT_BTYPE; … … 1880 1867 } 1881 1868 1869 /* Return the number of registers needed to return the struct, or 0 if 1870 returning via struct pointer. */ 1871 ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align, int *regsize) { 1872 *ret_align = 1; // Never have to re-align return values for x86-64 1873 return 0; 1874 } 1875 1882 1876 /* generate function call with address in (vtop->t, vtop->c) and free function 1883 1877 context. Stack entry is popped */ … … 1894 1888 for (i = 0; i < nb_args; i++) { 1895 1889 if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) { 1896 ALWAYS_ASSERT(FALSE);1897 } else if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {1898 1890 ALWAYS_ASSERT(FALSE); 1899 1891 } else { … … 1960 1952 1961 1953 sym = func_type->ref; 1962 func_call = sym-> r;1954 func_call = sym->f.func_call; 1963 1955 addr = 8; 1964 1956 /* if the function returns a structure, then add an 1965 1957 implicit pointer parameter */ 1966 1958 func_vt = sym->type; 1959 func_var = (sym->f.func_type == FUNC_ELLIPSIS); 1967 1960 if ((func_vt.t & VT_BTYPE) == VT_STRUCT) { 1968 1961 func_vc = addr; … … 2047 2040 { 2048 2041 int ind1 = ind; 2042 if (nocode_wanted) 2043 return t; 2049 2044 2050 2045 C67_MVKL(C67_A0, t); //r=reg to load, constant … … 2079 2074 2080 2075 v = vtop->r & VT_VALMASK; 2081 if (v == VT_CMP) { 2076 if (nocode_wanted) { 2077 ; 2078 } else if (v == VT_CMP) { 2082 2079 /* fast case : can jump directly since flags are set */ 2083 2080 // C67 uses B2 sort of as flags register … … 2101 2098 if ((v & 1) == inv) { 2102 2099 /* insert vtop->c jump list in t */ 2103 p = &vtop->c.i;2104 2100 2105 2101 // I guess the idea is to traverse to the … … 2107 2103 // there 2108 2104 2109 n = *p;2105 n = vtop->c.i; 2110 2106 while (n != 0) { 2111 2107 p = (int *) (cur_text_section->data + n); … … 2122 2118 t = gjmp(t); 2123 2119 gsym(vtop->c.i); 2124 }2125 } else {2126 if (is_float(vtop->type.t)) {2127 vpushi(0);2128 gen_op(TOK_NE);2129 }2130 if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {2131 /* constant jmp optimization */2132 if ((vtop->c.i != 0) != inv)2133 t = gjmp(t);2134 } else {2135 // I think we need to get the value on the stack2136 // into a register, test it, and generate a branch2137 // return the address of the branch, so it can be2138 // later patched2139 2140 v = gv(RC_INT); // get value into a reg2141 ind1 = ind;2142 C67_MVKL(C67_A0, t); //r=reg to load, constant2143 C67_MVKH(C67_A0, t); //r=reg to load, constant2144 2145 if (v != TREG_EAX && // check if not already in a conditional test reg2146 v != TREG_EDX && v != TREG_ST0 && v != C67_B2) {2147 C67_MV(v, C67_B2);2148 v = C67_B2;2149 }2150 2151 C67_IREG_B_REG(inv, v, C67_A0); // [!R] B.S2x A02152 C67_NOP(5);2153 t = ind1; //return where we need to patch2154 ind1 = ind;2155 2120 } 2156 2121 } … … 2261 2226 fr = vtop[0].r; 2262 2227 vtop--; 2263 C67_MPYI(fr, r); // 32 bit bultiply fr,r,fr2228 C67_MPYI(fr, r); // 32 bit multiply fr,r,fr 2264 2229 C67_NOP(8); // NOP 8 for worst case 2265 2230 break; … … 2318 2283 2319 2284 /* generate a floating point operation 'v = t1 op t2' instruction. The 2320 two operands are guarante d to have the same floating point type */2285 two operands are guaranteed to have the same floating point type */ 2321 2286 /* XXX: need to use ST1 too */ 2322 2287 void gen_opf(int op) … … 2330 2295 2331 2296 ft = vtop->type.t; 2332 fc = vtop->c. ul;2297 fc = vtop->c.i; 2333 2298 r = vtop->r; 2334 2299 fr = vtop[-1].r; … … 2555 2520 } 2556 2521 2522 /* Save the stack pointer onto the stack and return the location of its address */ 2523 ST_FUNC void gen_vla_sp_save(int addr) { 2524 tcc_error("variable length arrays unsupported for this target"); 2525 } 2526 2527 /* Restore the SP from a location on the stack */ 2528 ST_FUNC void gen_vla_sp_restore(int addr) { 2529 tcc_error("variable length arrays unsupported for this target"); 2530 } 2531 2532 /* Subtract from the stack pointer, and push the resulting value onto the stack */ 2533 ST_FUNC void gen_vla_alloc(CType *type, int align) { 2534 tcc_error("variable length arrays unsupported for this target"); 2535 } 2536 2557 2537 /* end of C67 code generator */ 2558 2538 /*************************************************************/
Note:
See TracChangeset
for help on using the changeset viewer.