Rev 647 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 647 | Rev 6429 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | * You should have received a copy of the GNU Lesser General Public |
16 | * You should have received a copy of the GNU Lesser General Public |
17 | * License along with this library; if not, write to the Free Software |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
19 | */ |
Line -... | Line 20... | ||
- | 20 | ||
- | 21 | #ifdef TARGET_DEFS_ONLY |
|
20 | 22 | ||
Line 21... | Line 23... | ||
21 | //#define ASSEMBLY_LISTING_C67 |
23 | /* #define ASSEMBLY_LISTING_C67 */ |
22 | 24 | ||
Line 23... | Line 25... | ||
23 | /* number of available registers */ |
25 | /* number of available registers */ |
Line 83... | Line 85... | ||
83 | TREG_C67_A13, |
85 | TREG_C67_A13, |
84 | TREG_C67_B12, |
86 | TREG_C67_B12, |
85 | TREG_C67_B13, |
87 | TREG_C67_B13, |
86 | }; |
88 | }; |
Line -... | Line 89... | ||
- | 89 | ||
- | 90 | /* return registers for function */ |
|
- | 91 | #define REG_IRET TREG_C67_A4 /* single word int return register */ |
|
- | 92 | #define REG_LRET TREG_C67_A5 /* second word return register (for long long) */ |
|
- | 93 | #define REG_FRET TREG_C67_A4 /* float return register */ |
|
- | 94 | ||
- | 95 | /* defined if function parameters must be evaluated in reverse order */ |
|
- | 96 | /* #define INVERT_FUNC_PARAMS */ |
|
- | 97 | ||
- | 98 | /* defined if structures are passed as pointers. Otherwise structures |
|
- | 99 | are directly pushed on stack. */ |
|
- | 100 | /* #define FUNC_STRUCT_PARAM_AS_PTR */ |
|
- | 101 | ||
- | 102 | /* pointer size, in bytes */ |
|
- | 103 | #define PTR_SIZE 4 |
|
- | 104 | ||
- | 105 | /* long double size and alignment, in bytes */ |
|
- | 106 | #define LDOUBLE_SIZE 12 |
|
- | 107 | #define LDOUBLE_ALIGN 4 |
|
- | 108 | /* maximum alignment (for aligned attribute support) */ |
|
- | 109 | #define MAX_ALIGN 8 |
|
- | 110 | ||
- | 111 | /******************************************************/ |
|
- | 112 | /* ELF defines */ |
|
- | 113 | ||
- | 114 | #define EM_TCC_TARGET EM_C60 |
|
- | 115 | ||
- | 116 | /* relocation type for 32 bit data relocation */ |
|
- | 117 | #define R_DATA_32 R_C60_32 |
|
- | 118 | #define R_DATA_PTR R_C60_32 |
|
- | 119 | #define R_JMP_SLOT R_C60_JMP_SLOT |
|
- | 120 | #define R_COPY R_C60_COPY |
|
- | 121 | ||
- | 122 | #define ELF_START_ADDR 0x00000400 |
|
- | 123 | #define ELF_PAGE_SIZE 0x1000 |
|
- | 124 | ||
- | 125 | /******************************************************/ |
|
- | 126 | #else /* ! TARGET_DEFS_ONLY */ |
|
- | 127 | /******************************************************/ |
|
- | 128 | #include "tcc.h" |
|
87 | 129 | ||
88 | int reg_classes[NB_REGS] = { |
130 | ST_DATA const int reg_classes[NB_REGS] = { |
89 | /* eax */ RC_INT | RC_FLOAT | RC_EAX, |
131 | /* eax */ RC_INT | RC_FLOAT | RC_EAX, |
90 | // only allow even regs for floats (allow for doubles) |
132 | // only allow even regs for floats (allow for doubles) |
91 | /* ecx */ RC_INT | RC_ECX, |
133 | /* ecx */ RC_INT | RC_ECX, |
92 | /* edx */ RC_INT | RC_INT_BSIDE | RC_FLOAT | RC_EDX, |
134 | /* edx */ RC_INT | RC_INT_BSIDE | RC_FLOAT | RC_EDX, |
Line 112... | Line 154... | ||
112 | /* A13 */ RC_C67_A11, |
154 | /* A13 */ RC_C67_A11, |
113 | /* B12 */ RC_C67_B10, |
155 | /* B12 */ RC_C67_B10, |
114 | /* B13 */ RC_C67_B11 |
156 | /* B13 */ RC_C67_B11 |
115 | }; |
157 | }; |
Line 116... | Line -... | ||
116 | - | ||
117 | /* return registers for function */ |
- | |
118 | #define REG_IRET TREG_C67_A4 /* single word int return register */ |
- | |
119 | #define REG_LRET TREG_C67_A5 /* second word return register (for long long) */ |
- | |
120 | #define REG_FRET TREG_C67_A4 /* float return register */ |
- | |
121 | - | ||
122 | - | ||
123 | #define ALWAYS_ASSERT(x) \ |
- | |
124 | do {\ |
- | |
125 | if (!(x))\ |
- | |
126 | error("internal compiler error file at %s:%d", __FILE__, __LINE__);\ |
- | |
127 | } while (0) |
- | |
128 | 158 | ||
129 | // although tcc thinks it is passing parameters on the stack, |
159 | // although tcc thinks it is passing parameters on the stack, |
130 | // the C67 really passes up to the first 10 params in special |
160 | // the C67 really passes up to the first 10 params in special |
131 | // regs or regs pairs (for 64 bit params). So keep track of |
161 | // regs or regs pairs (for 64 bit params). So keep track of |
132 | // the stack offsets so we can translate to the appropriate |
162 | // the stack offsets so we can translate to the appropriate |
Line 133... | Line -... | ||
133 | // reg (pair) |
- | |
134 | 163 | // reg (pair) |
|
135 | 164 | ||
136 | #define NoCallArgsPassedOnStack 10 |
165 | #define NoCallArgsPassedOnStack 10 |
137 | int NoOfCurFuncArgs; |
166 | int NoOfCurFuncArgs; |
138 | int TranslateStackToReg[NoCallArgsPassedOnStack]; |
167 | int TranslateStackToReg[NoCallArgsPassedOnStack]; |
Line 139... | Line -... | ||
139 | int ParamLocOnStack[NoCallArgsPassedOnStack]; |
- | |
140 | int TotalBytesPushedOnStack; |
- | |
141 | - | ||
142 | /* defined if function parameters must be evaluated in reverse order */ |
- | |
143 | - | ||
144 | //#define INVERT_FUNC_PARAMS |
- | |
145 | - | ||
146 | /* defined if structures are passed as pointers. Otherwise structures |
- | |
147 | are directly pushed on stack. */ |
- | |
148 | //#define FUNC_STRUCT_PARAM_AS_PTR |
168 | int ParamLocOnStack[NoCallArgsPassedOnStack]; |
149 | - | ||
150 | /* pointer size, in bytes */ |
- | |
151 | #define PTR_SIZE 4 |
169 | int TotalBytesPushedOnStack; |
152 | 170 | ||
153 | /* long double size and alignment, in bytes */ |
- | |
154 | #define LDOUBLE_SIZE 12 |
171 | #ifndef FALSE |
Line 155... | Line 172... | ||
155 | #define LDOUBLE_ALIGN 4 |
172 | # define FALSE 0 |
156 | /* maximum alignment (for aligned attribute support) */ |
173 | # define TRUE 1 |
Line 157... | Line 174... | ||
157 | #define MAX_ALIGN 8 |
174 | #endif |
158 | 175 | ||
159 | /******************************************************/ |
- | |
160 | /* ELF defines */ |
176 | #undef BOOL |
161 | 177 | #define BOOL int |
|
162 | #define EM_TCC_TARGET EM_C60 |
- | |
163 | - | ||
164 | /* relocation type for 32 bit data relocation */ |
- | |
165 | #define R_DATA_32 R_C60_32 |
178 | |
Line 166... | Line 179... | ||
166 | #define R_JMP_SLOT R_C60_JMP_SLOT |
179 | #define ALWAYS_ASSERT(x) \ |
167 | #define R_COPY R_C60_COPY |
- | |
168 | 180 | do {\ |
|
169 | #define ELF_START_ADDR 0x00000400 |
181 | if (!(x))\ |
Line 170... | Line -... | ||
170 | #define ELF_PAGE_SIZE 0x1000 |
- | |
171 | 182 | tcc_error("internal compiler error file at %s:%d", __FILE__, __LINE__);\ |
|
172 | /******************************************************/ |
183 | } while (0) |
Line 173... | Line 184... | ||
173 | 184 | ||
174 | static unsigned long func_sub_sp_offset; |
185 | /******************************************************/ |
175 | static int func_ret_sub; |
186 | static unsigned long func_sub_sp_offset; |
Line 176... | Line -... | ||
176 | - | ||
177 | 187 | static int func_ret_sub; |
|
178 | static BOOL C67_invert_test; |
188 | |
179 | static int C67_compare_reg; |
189 | static BOOL C67_invert_test; |
Line 180... | Line 190... | ||
180 | 190 | static int C67_compare_reg; |
|
Line 233... | Line 243... | ||
233 | { |
243 | { |
234 | gsym_addr(t, ind); |
244 | gsym_addr(t, ind); |
235 | } |
245 | } |
Line 236... | Line 246... | ||
236 | 246 | ||
237 | // these are regs that tcc doesn't really know about, |
247 | // these are regs that tcc doesn't really know about, |
238 | // but asign them unique values so the mapping routines |
248 | // but assign them unique values so the mapping routines |
Line 239... | Line 249... | ||
239 | // can distinquish them |
249 | // can distinguish them |
240 | 250 | ||
241 | #define C67_A0 105 |
251 | #define C67_A0 105 |
242 | #define C67_SP 106 |
252 | #define C67_SP 106 |
243 | #define C67_B3 107 |
253 | #define C67_B3 107 |
244 | #define C67_FP 108 |
254 | #define C67_FP 108 |
Line 245... | Line 255... | ||
245 | #define C67_B2 109 |
255 | #define C67_B2 109 |
246 | #define C67_CREG_ZERO -1 // Special code for no condition reg test |
256 | #define C67_CREG_ZERO -1 /* Special code for no condition reg test */ |
247 | 257 | ||
Line 1550... | Line 1560... | ||
1550 | 1560 | ||
1551 | /* load 'r' from value 'sv' */ |
1561 | /* load 'r' from value 'sv' */ |
1552 | void load(int r, SValue * sv) |
1562 | void load(int r, SValue * sv) |
1553 | { |
1563 | { |
1554 | int v, t, ft, fc, fr, size = 0, element; |
1564 | int v, t, ft, fc, fr, size = 0, element; |
1555 | BOOL Unsigned = false; |
1565 | BOOL Unsigned = FALSE; |
Line 1556... | Line 1566... | ||
1556 | SValue v1; |
1566 | SValue v1; |
1557 | 1567 | ||
1558 | fr = sv->r; |
1568 | fr = sv->r; |
Line 1559... | Line 1569... | ||
1559 | ft = sv->type.t; |
1569 | ft = sv->type.t; |
1560 | fc = sv->c.ul; |
1570 | fc = sv->c.i; |
1561 | 1571 | ||
1562 | v = fr & VT_VALMASK; |
1572 | v = fr & VT_VALMASK; |
1563 | if (fr & VT_LVAL) { |
1573 | if (fr & VT_LVAL) { |
1564 | if (v == VT_LLOCAL) { |
1574 | if (v == VT_LLOCAL) { |
1565 | v1.type.t = VT_INT; |
1575 | v1.type.t = VT_INT; |
1566 | v1.r = VT_LOCAL | VT_LVAL; |
1576 | v1.r = VT_LOCAL | VT_LVAL; |
1567 | v1.c.ul = fc; |
1577 | v1.c.i = fc; |
1568 | load(r, &v1); |
1578 | load(r, &v1); |
1569 | fr = r; |
1579 | fr = r; |
1570 | } else if ((ft & VT_BTYPE) == VT_LDOUBLE) { |
1580 | } else if ((ft & VT_BTYPE) == VT_LDOUBLE) { |
1571 | error("long double not supported"); |
1581 | tcc_error("long double not supported"); |
1572 | } else if ((ft & VT_TYPE) == VT_BYTE) { |
1582 | } else if ((ft & VT_TYPE) == VT_BYTE) { |
1573 | size = 1; |
1583 | size = 1; |
Line 1714... | Line 1724... | ||
1714 | void store(int r, SValue * v) |
1724 | void store(int r, SValue * v) |
1715 | { |
1725 | { |
1716 | int fr, bt, ft, fc, size, t, element; |
1726 | int fr, bt, ft, fc, size, t, element; |
Line 1717... | Line 1727... | ||
1717 | 1727 | ||
1718 | ft = v->type.t; |
1728 | ft = v->type.t; |
1719 | fc = v->c.ul; |
1729 | fc = v->c.i; |
1720 | fr = v->r & VT_VALMASK; |
1730 | fr = v->r & VT_VALMASK; |
1721 | bt = ft & VT_BTYPE; |
1731 | bt = ft & VT_BTYPE; |
Line 1722... | Line 1732... | ||
1722 | /* XXX: incorrect if float reg to reg */ |
1732 | /* XXX: incorrect if float reg to reg */ |
1723 | 1733 | ||
1724 | if (bt == VT_LDOUBLE) { |
1734 | if (bt == VT_LDOUBLE) { |
1725 | error("long double not supported"); |
1735 | tcc_error("long double not supported"); |
1726 | } else { |
1736 | } else { |
1727 | if (bt == VT_SHORT) |
1737 | if (bt == VT_SHORT) |
1728 | size = 2; |
1738 | size = 2; |
Line 1867... | Line 1877... | ||
1867 | C67_NOP(3); // put remaining NOPs |
1877 | C67_NOP(3); // put remaining NOPs |
1868 | } |
1878 | } |
1869 | } |
1879 | } |
1870 | } |
1880 | } |
Line -... | Line 1881... | ||
- | 1881 | ||
- | 1882 | /* Return the number of registers needed to return the struct, or 0 if |
|
- | 1883 | returning via struct pointer. */ |
|
- | 1884 | ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align, int *regsize) { |
|
- | 1885 | *ret_align = 1; // Never have to re-align return values for x86-64 |
|
- | 1886 | return 0; |
|
- | 1887 | } |
|
1871 | 1888 | ||
1872 | /* generate function call with address in (vtop->t, vtop->c) and free function |
1889 | /* generate function call with address in (vtop->t, vtop->c) and free function |
1873 | context. Stack entry is popped */ |
1890 | context. Stack entry is popped */ |
1874 | void gfunc_call(int nb_args) |
1891 | void gfunc_call(int nb_args) |
1875 | { |
1892 | { |
1876 | int i, r, size = 0; |
1893 | int i, r, size = 0; |
Line 1877... | Line 1894... | ||
1877 | int args_sizes[NoCallArgsPassedOnStack]; |
1894 | int args_sizes[NoCallArgsPassedOnStack]; |
1878 | 1895 | ||
1879 | if (nb_args > NoCallArgsPassedOnStack) { |
1896 | if (nb_args > NoCallArgsPassedOnStack) { |
1880 | error("more than 10 function params not currently supported"); |
1897 | tcc_error("more than 10 function params not currently supported"); |
Line 1881... | Line 1898... | ||
1881 | // handle more than 10, put some on the stack |
1898 | // handle more than 10, put some on the stack |
1882 | } |
1899 | } |
1883 | 1900 | ||
1884 | for (i = 0; i < nb_args; i++) { |
- | |
1885 | if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
- | |
1886 | ALWAYS_ASSERT(FALSE); |
1901 | for (i = 0; i < nb_args; i++) { |
1887 | } else if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
1902 | if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) { |
1888 | ALWAYS_ASSERT(FALSE); |
1903 | ALWAYS_ASSERT(FALSE); |
Line 1889... | Line 1904... | ||
1889 | } else { |
1904 | } else { |
1890 | /* simple type (currently always same size) */ |
1905 | /* simple type (currently always same size) */ |
1891 | /* XXX: implicit cast ? */ |
1906 | /* XXX: implicit cast ? */ |
1892 | 1907 | ||
1893 | 1908 | ||
1894 | if ((vtop->type.t & VT_BTYPE) == VT_LLONG) { |
1909 | if ((vtop->type.t & VT_BTYPE) == VT_LLONG) { |
1895 | error("long long not supported"); |
1910 | tcc_error("long long not supported"); |
1896 | } else if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { |
1911 | } else if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) { |
1897 | error("long double not supported"); |
1912 | tcc_error("long double not supported"); |
Line 1952... | Line 1967... | ||
1952 | func_call = sym->r; |
1967 | func_call = sym->r; |
1953 | addr = 8; |
1968 | addr = 8; |
1954 | /* if the function returns a structure, then add an |
1969 | /* if the function returns a structure, then add an |
1955 | implicit pointer parameter */ |
1970 | implicit pointer parameter */ |
1956 | func_vt = sym->type; |
1971 | func_vt = sym->type; |
- | 1972 | func_var = (sym->c == FUNC_ELLIPSIS); |
|
1957 | if ((func_vt.t & VT_BTYPE) == VT_STRUCT) { |
1973 | if ((func_vt.t & VT_BTYPE) == VT_STRUCT) { |
1958 | func_vc = addr; |
1974 | func_vc = addr; |
1959 | addr += 4; |
1975 | addr += 4; |
1960 | } |
1976 | } |
Line 1961... | Line 1977... | ||
1961 | 1977 | ||
Line 1962... | Line 1978... | ||
1962 | NoOfCurFuncArgs = 0; |
1978 | NoOfCurFuncArgs = 0; |
1963 | 1979 | ||
1964 | /* define parameters */ |
1980 | /* define parameters */ |
1965 | while ((sym = sym->next) != NULL) { |
1981 | while ((sym = sym->next) != NULL) { |
1966 | type = &sym->type; |
1982 | type = &sym->type; |
1967 | sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | VT_LVAL, addr); |
1983 | sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), addr); |
Line 1968... | Line 1984... | ||
1968 | size = type_size(type, &align); |
1984 | size = type_size(type, &align); |
1969 | size = (size + 3) & ~3; |
1985 | size = (size + 3) & ~3; |
Line 2088... | Line 2104... | ||
2088 | 2104 | ||
2089 | } else if (v == VT_JMP || v == VT_JMPI) { |
2105 | } else if (v == VT_JMP || v == VT_JMPI) { |
2090 | /* && or || optimization */ |
2106 | /* && or || optimization */ |
2091 | if ((v & 1) == inv) { |
2107 | if ((v & 1) == inv) { |
2092 | /* insert vtop->c jump list in t */ |
- | |
Line 2093... | Line 2108... | ||
2093 | p = &vtop->c.i; |
2108 | /* insert vtop->c jump list in t */ |
2094 | 2109 | ||
2095 | // I guess the idea is to traverse to the |
2110 | // I guess the idea is to traverse to the |
Line 2096... | Line 2111... | ||
2096 | // null at the end of the list and store t |
2111 | // null at the end of the list and store t |
2097 | // there |
2112 | // there |
2098 | 2113 | ||
Line 2099... | Line 2114... | ||
2099 | n = *p; |
2114 | n = vtop->c.i; |
2100 | while (n != 0) { |
2115 | while (n != 0) { |
Line 2110... | Line 2125... | ||
2110 | 2125 | ||
2111 | } else { |
2126 | } else { |
2112 | t = gjmp(t); |
2127 | t = gjmp(t); |
2113 | gsym(vtop->c.i); |
2128 | gsym(vtop->c.i); |
2114 | } |
- | |
2115 | } else { |
- | |
2116 | if (is_float(vtop->type.t)) { |
- | |
2117 | vpushi(0); |
- | |
2118 | gen_op(TOK_NE); |
- | |
2119 | } |
- | |
2120 | if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
- | |
2121 | /* constant jmp optimization */ |
- | |
2122 | if ((vtop->c.i != 0) != inv) |
- | |
2123 | t = gjmp(t); |
- | |
2124 | } else { |
- | |
2125 | // I think we need to get the value on the stack |
- | |
2126 | // into a register, test it, and generate a branch |
- | |
2127 | // return the address of the branch, so it can be |
- | |
2128 | // later patched |
- | |
2129 | - | ||
2130 | v = gv(RC_INT); // get value into a reg |
- | |
2131 | ind1 = ind; |
- | |
2132 | C67_MVKL(C67_A0, t); //r=reg to load, constant |
- | |
2133 | C67_MVKH(C67_A0, t); //r=reg to load, constant |
- | |
2134 | - | ||
2135 | if (v != TREG_EAX && // check if not already in a conditional test reg |
- | |
2136 | v != TREG_EDX && v != TREG_ST0 && v != C67_B2) { |
- | |
2137 | C67_MV(v, C67_B2); |
- | |
2138 | v = C67_B2; |
- | |
2139 | } |
- | |
2140 | - | ||
2141 | C67_IREG_B_REG(inv, v, C67_A0); // [!R] B.S2x A0 |
- | |
2142 | C67_NOP(5); |
- | |
2143 | t = ind1; //return where we need to patch |
- | |
2144 | ind1 = ind; |
- | |
2145 | } |
2129 | } |
2146 | } |
2130 | } |
2147 | vtop--; |
2131 | vtop--; |
2148 | return t; |
2132 | return t; |
Line 2176... | Line 2160... | ||
2176 | C67_compare_reg = C67_B2; |
2160 | C67_compare_reg = C67_B2; |
Line 2177... | Line 2161... | ||
2177 | 2161 | ||
2178 | 2162 | ||
2179 | if (op == TOK_LT) { |
2163 | if (op == TOK_LT) { |
2180 | C67_CMPLT(r, fr, C67_B2); |
2164 | C67_CMPLT(r, fr, C67_B2); |
2181 | C67_invert_test = false; |
2165 | C67_invert_test = FALSE; |
2182 | } else if (op == TOK_GE) { |
2166 | } else if (op == TOK_GE) { |
2183 | C67_CMPLT(r, fr, C67_B2); |
2167 | C67_CMPLT(r, fr, C67_B2); |
2184 | C67_invert_test = true; |
2168 | C67_invert_test = TRUE; |
2185 | } else if (op == TOK_GT) { |
2169 | } else if (op == TOK_GT) { |
2186 | C67_CMPGT(r, fr, C67_B2); |
2170 | C67_CMPGT(r, fr, C67_B2); |
2187 | C67_invert_test = false; |
2171 | C67_invert_test = FALSE; |
2188 | } else if (op == TOK_LE) { |
2172 | } else if (op == TOK_LE) { |
2189 | C67_CMPGT(r, fr, C67_B2); |
2173 | C67_CMPGT(r, fr, C67_B2); |
2190 | C67_invert_test = true; |
2174 | C67_invert_test = TRUE; |
2191 | } else if (op == TOK_EQ) { |
2175 | } else if (op == TOK_EQ) { |
2192 | C67_CMPEQ(r, fr, C67_B2); |
2176 | C67_CMPEQ(r, fr, C67_B2); |
2193 | C67_invert_test = false; |
2177 | C67_invert_test = FALSE; |
2194 | } else if (op == TOK_NE) { |
2178 | } else if (op == TOK_NE) { |
2195 | C67_CMPEQ(r, fr, C67_B2); |
2179 | C67_CMPEQ(r, fr, C67_B2); |
2196 | C67_invert_test = true; |
2180 | C67_invert_test = TRUE; |
2197 | } else if (op == TOK_ULT) { |
2181 | } else if (op == TOK_ULT) { |
2198 | C67_CMPLTU(r, fr, C67_B2); |
2182 | C67_CMPLTU(r, fr, C67_B2); |
2199 | C67_invert_test = false; |
2183 | C67_invert_test = FALSE; |
2200 | } else if (op == TOK_UGE) { |
2184 | } else if (op == TOK_UGE) { |
2201 | C67_CMPLTU(r, fr, C67_B2); |
2185 | C67_CMPLTU(r, fr, C67_B2); |
2202 | C67_invert_test = true; |
2186 | C67_invert_test = TRUE; |
2203 | } else if (op == TOK_UGT) { |
2187 | } else if (op == TOK_UGT) { |
2204 | C67_CMPGTU(r, fr, C67_B2); |
2188 | C67_CMPGTU(r, fr, C67_B2); |
2205 | C67_invert_test = false; |
2189 | C67_invert_test = FALSE; |
2206 | } else if (op == TOK_ULE) { |
2190 | } else if (op == TOK_ULE) { |
2207 | C67_CMPGTU(r, fr, C67_B2); |
2191 | C67_CMPGTU(r, fr, C67_B2); |
2208 | C67_invert_test = true; |
2192 | C67_invert_test = TRUE; |
2209 | } else if (op == '+') |
2193 | } else if (op == '+') |
2210 | C67_ADD(fr, r); // ADD r,fr,r |
2194 | C67_ADD(fr, r); // ADD r,fr,r |
2211 | else if (op == '-') |
2195 | else if (op == '-') |
Line 2317... | Line 2301... | ||
2317 | gv2(RC_EDX, RC_EAX); // make sure src2 is on b side |
2301 | gv2(RC_EDX, RC_EAX); // make sure src2 is on b side |
2318 | else |
2302 | else |
2319 | gv2(RC_FLOAT, RC_FLOAT); // make sure src2 is on b side |
2303 | gv2(RC_FLOAT, RC_FLOAT); // make sure src2 is on b side |
Line 2320... | Line 2304... | ||
2320 | 2304 | ||
2321 | ft = vtop->type.t; |
2305 | ft = vtop->type.t; |
2322 | fc = vtop->c.ul; |
2306 | fc = vtop->c.i; |
2323 | r = vtop->r; |
2307 | r = vtop->r; |
Line 2324... | Line 2308... | ||
2324 | fr = vtop[-1].r; |
2308 | fr = vtop[-1].r; |
2325 | 2309 | ||
Line 2326... | Line 2310... | ||
2326 | 2310 | ||
Line 2327... | Line 2311... | ||
2327 | if ((ft & VT_BTYPE) == VT_LDOUBLE) |
2311 | if ((ft & VT_BTYPE) == VT_LDOUBLE) |
2328 | error("long doubles not supported"); |
2312 | tcc_error("long doubles not supported"); |
Line 2338... | Line 2322... | ||
2338 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2322 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2339 | C67_CMPLTDP(r, fr, C67_B2); |
2323 | C67_CMPLTDP(r, fr, C67_B2); |
2340 | else |
2324 | else |
2341 | C67_CMPLTSP(r, fr, C67_B2); |
2325 | C67_CMPLTSP(r, fr, C67_B2); |
Line 2342... | Line 2326... | ||
2342 | 2326 | ||
2343 | C67_invert_test = false; |
2327 | C67_invert_test = FALSE; |
2344 | } else if (op == TOK_GE) { |
2328 | } else if (op == TOK_GE) { |
2345 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2329 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2346 | C67_CMPLTDP(r, fr, C67_B2); |
2330 | C67_CMPLTDP(r, fr, C67_B2); |
2347 | else |
2331 | else |
Line 2348... | Line 2332... | ||
2348 | C67_CMPLTSP(r, fr, C67_B2); |
2332 | C67_CMPLTSP(r, fr, C67_B2); |
2349 | 2333 | ||
2350 | C67_invert_test = true; |
2334 | C67_invert_test = TRUE; |
2351 | } else if (op == TOK_GT) { |
2335 | } else if (op == TOK_GT) { |
2352 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2336 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2353 | C67_CMPGTDP(r, fr, C67_B2); |
2337 | C67_CMPGTDP(r, fr, C67_B2); |
Line 2354... | Line 2338... | ||
2354 | else |
2338 | else |
2355 | C67_CMPGTSP(r, fr, C67_B2); |
2339 | C67_CMPGTSP(r, fr, C67_B2); |
2356 | 2340 | ||
2357 | C67_invert_test = false; |
2341 | C67_invert_test = FALSE; |
2358 | } else if (op == TOK_LE) { |
2342 | } else if (op == TOK_LE) { |
2359 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2343 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
Line 2360... | Line 2344... | ||
2360 | C67_CMPGTDP(r, fr, C67_B2); |
2344 | C67_CMPGTDP(r, fr, C67_B2); |
2361 | else |
2345 | else |
2362 | C67_CMPGTSP(r, fr, C67_B2); |
2346 | C67_CMPGTSP(r, fr, C67_B2); |
2363 | 2347 | ||
2364 | C67_invert_test = true; |
2348 | C67_invert_test = TRUE; |
2365 | } else if (op == TOK_EQ) { |
2349 | } else if (op == TOK_EQ) { |
Line 2366... | Line 2350... | ||
2366 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2350 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2367 | C67_CMPEQDP(r, fr, C67_B2); |
2351 | C67_CMPEQDP(r, fr, C67_B2); |
2368 | else |
2352 | else |
2369 | C67_CMPEQSP(r, fr, C67_B2); |
2353 | C67_CMPEQSP(r, fr, C67_B2); |
2370 | 2354 | ||
2371 | C67_invert_test = false; |
2355 | C67_invert_test = FALSE; |
Line 2372... | Line 2356... | ||
2372 | } else if (op == TOK_NE) { |
2356 | } else if (op == TOK_NE) { |
2373 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2357 | if ((ft & VT_BTYPE) == VT_DOUBLE) |
2374 | C67_CMPEQDP(r, fr, C67_B2); |
2358 | C67_CMPEQDP(r, fr, C67_B2); |
2375 | else |
2359 | else |
2376 | C67_CMPEQSP(r, fr, C67_B2); |
2360 | C67_CMPEQSP(r, fr, C67_B2); |
2377 | 2361 | ||
Line 2475... | Line 2459... | ||
2475 | 2459 | ||
2476 | gv(RC_FLOAT); |
2460 | gv(RC_FLOAT); |
Line 2477... | Line 2461... | ||
2477 | r = vtop->r; |
2461 | r = vtop->r; |
2478 | 2462 | ||
2479 | if (t != VT_INT) |
2463 | if (t != VT_INT) |
2480 | error("long long not supported"); |
2464 | tcc_error("long long not supported"); |
2481 | else { |
2465 | else { |
2482 | if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) { |
2466 | if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE) { |
2483 | C67_DPTRUNC(r, r); |
2467 | C67_DPTRUNC(r, r); |
Line 2542... | Line 2526... | ||
2542 | { |
2526 | { |
2543 | gcall_or_jmp(1); |
2527 | gcall_or_jmp(1); |
2544 | vtop--; |
2528 | vtop--; |
2545 | } |
2529 | } |
Line -... | Line 2530... | ||
- | 2530 | ||
- | 2531 | /* Save the stack pointer onto the stack and return the location of its address */ |
|
- | 2532 | ST_FUNC void gen_vla_sp_save(int addr) { |
|
- | 2533 | tcc_error("variable length arrays unsupported for this target"); |
|
- | 2534 | } |
|
- | 2535 | ||
- | 2536 | /* Restore the SP from a location on the stack */ |
|
- | 2537 | ST_FUNC void gen_vla_sp_restore(int addr) { |
|
- | 2538 | tcc_error("variable length arrays unsupported for this target"); |
|
- | 2539 | } |
|
- | 2540 | ||
- | 2541 | /* Subtract from the stack pointer, and push the resulting value onto the stack */ |
|
- | 2542 | ST_FUNC void gen_vla_alloc(CType *type, int align) { |
|
- | 2543 | tcc_error("variable length arrays unsupported for this target"); |
|
- | 2544 | } |
|
2546 | 2545 | ||
- | 2546 | /* end of C67 code generator */ |
|
- | 2547 | /*************************************************************/ |
|
2547 | /* end of X86 code generator */ |
2548 | #endif |