| @@ -64,14 +64,15 @@ typedef union CValue { · 63 unmodified lines |
| 64 | 64 | long long ll; |
| 65 | 65 | unsigned long long ull; |
| 66 | 66 | struct TokenSym *ts; |
| 67 | | − int tab[1]; |
| 68 | 67 | struct Sym *sym; |
| 68 | + int tab[1]; |
| 69 | 69 | } CValue; |
| 70 | 70 | |
| 71 | 71 | /* value on stack */ |
| 72 | 72 | typedef struct SValue { |
| 73 | | − int t; |
| 74 | | − CValue c; |
| 73 | + int t; /* type */ |
| 74 | + int r; /* register + flags */ |
| 75 | + CValue c; /* constant */ |
| 75 | 76 | } SValue; |
| 76 | 77 | |
| 77 | 78 | /* symbol management */ |
| @@ -360,7 +361,7 @@ int pointed_size(int t); · 282 unmodified lines |
| 360 | 361 | int ist(void); |
| 361 | 362 | int type_decl(int *v, int t, int td); |
| 362 | 363 | void error(const char *fmt, ...); |
| 363 | | −void vset(int t, int v); |
| 364 | +void vset(int t, int r, int v); |
| 364 | 365 | |
| 365 | 366 | /* true if float/double/long double type */ |
| 366 | 367 | static inline int is_float(int t) |
| @@ -485,7 +486,7 @@ void skip(int c) · 118 unmodified lines |
| 485 | 486 | |
| 486 | 487 | void test_lvalue(void) |
| 487 | 488 | { |
| 488 | | − if (!(vtop->t & VT_LVAL)) |
| 489 | + if (!(vtop->r & VT_LVAL)) |
| 489 | 490 | expect("lvalue"); |
| 490 | 491 | } |
| 491 | 492 | |
| @@ -1874,25 +1875,34 @@ void swap(int *p, int *q) · 1382 unmodified lines |
| 1874 | 1875 | *q = t; |
| 1875 | 1876 | } |
| 1876 | 1877 | |
| 1877 | | −void vsetc(int t, CValue *vc) |
| 1878 | +void vsetc(int t, int r, CValue *vc) |
| 1878 | 1879 | { |
| 1879 | 1880 | if (vtop >= vstack + VSTACK_SIZE) |
| 1880 | 1881 | error("memory full"); |
| 1881 | 1882 | /* cannot let cpu flags if other instruction are generated */ |
| 1882 | 1883 | /* XXX: VT_JMP test too ? */ |
| 1883 | | − if ((vtop->t & VT_VALMASK) == VT_CMP) |
| 1884 | + if ((vtop->r & VT_VALMASK) == VT_CMP) |
| 1884 | 1885 | gv(); |
| 1885 | 1886 | vtop++; |
| 1886 | 1887 | vtop->t = t; |
| 1888 | + vtop->r = r; |
| 1887 | 1889 | vtop->c = *vc; |
| 1888 | 1890 | } |
| 1889 | 1891 | |
| 1890 | | −void vset(int t, int v) |
| 1892 | +/* push integer constant */ |
| 1893 | +void vpushi(int v) |
| 1894 | +{ |
| 1895 | + CValue cval; |
| 1896 | + cval.i = v; |
| 1897 | + vsetc(VT_INT, VT_CONST, &cval); |
| 1898 | +} |
| 1899 | + |
| 1900 | +void vset(int t, int r, int v) |
| 1891 | 1901 | { |
| 1892 | 1902 | CValue cval; |
| 1893 | 1903 | |
| 1894 | 1904 | cval.i = v; |
| 1895 | | − vsetc(t, &cval); |
| 1905 | + vsetc(t, r, &cval); |
| 1896 | 1906 | } |
| 1897 | 1907 | |
| 1898 | 1908 | void vswap(void) |
| @@ -1915,22 +1925,25 @@ void vdup(void) · 16 unmodified lines |
| 1915 | 1925 | int save_reg_forced(int r) |
| 1916 | 1926 | { |
| 1917 | 1927 | int i, l, t; |
| 1918 | | − SValue *p; |
| 1928 | + SValue *p, sv; |
| 1919 | 1929 | |
| 1920 | 1930 | /* store register */ |
| 1921 | 1931 | loc = (loc - 4) & -3; |
| 1922 | | − store(r, VT_LOCAL, loc); |
| 1932 | + sv.t = VT_INT; |
| 1933 | + sv.r = VT_LOCAL | VT_LVAL; |
| 1934 | + sv.c.ul = loc; |
| 1935 | + store(r, &sv); |
| 1923 | 1936 | l = loc; |
| 1924 | 1937 | |
| 1925 | 1938 | /* modify all stack values */ |
| 1926 | 1939 | for(p=vstack;p<=vtop;p++) { |
| 1927 | | − i = p->t & VT_VALMASK; |
| 1940 | + i = p->r & VT_VALMASK; |
| 1928 | 1941 | if (i == r) { |
| 1929 | | − if (p->t & VT_LVAL) |
| 1942 | + if (p->r & VT_LVAL) |
| 1930 | 1943 | t = VT_LLOCAL; |
| 1931 | 1944 | else |
| 1932 | 1945 | t = VT_LOCAL; |
| 1933 | | − p->t = (p->t & VT_TYPE) | VT_LVAL | t; |
| 1946 | + p->r = VT_LVAL | t; |
| 1934 | 1947 | p->c.ul = l; |
| 1935 | 1948 | } |
| 1936 | 1949 | } |
| @@ -1945,7 +1958,7 @@ void save_reg(int r) · 8 unmodified lines |
| 1945 | 1958 | |
| 1946 | 1959 | /* modify all stack values */ |
| 1947 | 1960 | for(p=vstack;p<=vtop;p++) { |
| 1948 | | − i = p->t & VT_VALMASK; |
| 1961 | + i = p->r & VT_VALMASK; |
| 1949 | 1962 | if (i == r) { |
| 1950 | 1963 | save_reg_forced(r); |
| 1951 | 1964 | break; |
| @@ -1963,7 +1976,7 @@ int get_reg(int rc) · 11 unmodified lines |
| 1963 | 1976 | for(r=0;r<NB_REGS;r++) { |
| 1964 | 1977 | if (reg_classes[r] & rc) { |
| 1965 | 1978 | for(p=vstack;p<=vtop;p++) { |
| 1966 | | − i = p->t & VT_VALMASK; |
| 1979 | + i = p->r & VT_VALMASK; |
| 1967 | 1980 | if (i == r) |
| 1968 | 1981 | goto notfound; |
| 1969 | 1982 | } |
| @@ -1976,7 +1989,7 @@ int get_reg(int rc) · 6 unmodified lines |
| 1976 | 1989 | important to start from the bottom to ensure that we don't |
| 1977 | 1990 | spill registers used in gen_op()) */ |
| 1978 | 1991 | for(p=vstack;p<=vtop;p++) { |
| 1979 | | − r = p->t & VT_VALMASK; |
| 1992 | + r = p->r & VT_VALMASK; |
| 1980 | 1993 | if (r < VT_CONST && (reg_classes[r] & rc)) { |
| 1981 | 1994 | save_reg(r); |
| 1982 | 1995 | break; |
| @@ -1985,13 +1998,13 @@ int get_reg(int rc) · 2 unmodified lines |
| 1985 | 1998 | return r; |
| 1986 | 1999 | } |
| 1987 | 2000 | |
| 1988 | | −void save_regs() |
| 2001 | +void save_regs(void) |
| 1989 | 2002 | { |
| 1990 | 2003 | int r; |
| 1991 | 2004 | SValue *p; |
| 1992 | 2005 | |
| 1993 | 2006 | for(p=vstack;p<=vtop;p++) { |
| 1994 | | − r = p->t & VT_VALMASK; |
| 2007 | + r = p->r & VT_VALMASK; |
| 1995 | 2008 | if (r < VT_CONST) { |
| 1996 | 2009 | save_reg(r); |
| 1997 | 2010 | } |
| @@ -2002,9 +2015,14 @@ void save_regs() · 4 unmodified lines |
| 2002 | 2015 | if needed */ |
| 2003 | 2016 | void move_reg(int r, int s) |
| 2004 | 2017 | { |
| 2018 | + SValue sv; |
| 2019 | + |
| 2005 | 2020 | if (r != s) { |
| 2006 | 2021 | save_reg(r); |
| 2007 | | − load(r, s, 0); |
| 2022 | + sv.t = VT_INT; |
| 2023 | + sv.r = s; |
| 2024 | + sv.c.ul = 0; |
| 2025 | + load(r, &sv); |
| 2008 | 2026 | } |
| 2009 | 2027 | } |
| 2010 | 2028 | |
| @@ -2022,14 +2040,15 @@ int gv(void) · 11 unmodified lines |
| 2022 | 2040 | /* remove bit field info to avoid loops */ |
| 2023 | 2041 | vtop->t &= ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT)); |
| 2024 | 2042 | /* generate shifts */ |
| 2025 | | − vset(VT_CONST, 32 - (bit_pos + bit_size)); |
| 2043 | + vpushi(32 - (bit_pos + bit_size)); |
| 2026 | 2044 | gen_op(TOK_SHL); |
| 2027 | | − vset(VT_CONST, 32 - bit_size); |
| 2045 | + vpushi(32 - bit_size); |
| 2028 | 2046 | /* NOTE: transformed to SHR if unsigned */ |
| 2029 | 2047 | gen_op(TOK_SAR); |
| 2030 | 2048 | r = gv(); |
| 2031 | 2049 | } else { |
| 2032 | | − if (is_float(vtop->t) && (vtop->t & (VT_CONST | VT_LVAL)) == VT_CONST) { |
| 2050 | + if (is_float(vtop->t) && |
| 2051 | + (vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| 2033 | 2052 | /* CPUs usually cannot use float constants, so we store them |
| 2034 | 2053 | generically in data segment */ |
| 2035 | 2054 | size = type_size(vtop->t, &align); |
| @@ -2038,20 +2057,20 @@ int gv(void) · 2 unmodified lines |
| 2038 | 2057 | size = size >> 2; |
| 2039 | 2058 | for(i=0;i<size;i++) |
| 2040 | 2059 | ((int *)glo)[i] = vtop->c.tab[i]; |
| 2041 | | − vtop->t |= VT_LVAL; |
| 2060 | + vtop->r |= VT_LVAL; |
| 2042 | 2061 | vtop->c.ul = glo; |
| 2043 | 2062 | glo += size << 2; |
| 2044 | 2063 | } |
| 2045 | | − r = vtop->t & VT_VALMASK; |
| 2046 | | − if (r >= VT_CONST || (vtop->t & VT_LVAL)) { |
| 2064 | + r = vtop->r & VT_VALMASK; |
| 2065 | + if (r >= VT_CONST || (vtop->r & VT_LVAL)) { |
| 2047 | 2066 | if (is_float(vtop->t)) |
| 2048 | 2067 | rc = REG_CLASS_FLOAT; |
| 2049 | 2068 | else |
| 2050 | 2069 | rc = REG_CLASS_INT; |
| 2051 | 2070 | r = get_reg(rc); |
| 2052 | 2071 | } |
| 2053 | | − load(r, vtop->t, vtop->c.ul); |
| 2054 | | − vtop->t = (vtop->t & VT_TYPE) | r; |
| 2072 | + load(r, vtop); |
| 2073 | + vtop->r = r; |
| 2055 | 2074 | } |
| 2056 | 2075 | return r; |
| 2057 | 2076 | } |
| @@ -2065,8 +2084,8 @@ void gen_opc(int op) · 7 unmodified lines |
| 2065 | 2084 | v1 = vtop - 1; |
| 2066 | 2085 | v2 = vtop; |
| 2067 | 2086 | /* currently, we cannot do computations with forward symbols */ |
| 2068 | | − c1 = (v1->t & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST; |
| 2069 | | − c2 = (v2->t & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST; |
| 2087 | + c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST; |
| 2088 | + c2 = (v2->r & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST; |
| 2070 | 2089 | if (c1 && c2) { |
| 2071 | 2090 | fc = v2->c.i; |
| 2072 | 2091 | switch(op) { |
| @@ -2184,9 +2203,9 @@ void gen_op(int op) · 111 unmodified lines |
| 2184 | 2203 | gen_opf(op); |
| 2185 | 2204 | if (op >= TOK_EQ && op <= TOK_GT) { |
| 2186 | 2205 | /* the result is an int */ |
| 2187 | | − vtop->t = (vtop->t & ~VT_TYPE) | VT_INT; |
| 2206 | + vtop->t = VT_INT; |
| 2188 | 2207 | } else { |
| 2189 | | − vtop->t = (vtop->t & ~VT_TYPE) | t; |
| 2208 | + vtop->t = t; |
| 2190 | 2209 | } |
| 2191 | 2210 | } else if (op == '+' || op == '-') { |
| 2192 | 2211 | if ((t1 & VT_BTYPE) == VT_PTR && |
| @@ -2197,8 +2216,8 @@ void gen_op(int op) · 4 unmodified lines |
| 2197 | 2216 | u = pointed_size(t1); |
| 2198 | 2217 | gen_opc(op); |
| 2199 | 2218 | /* set to integer type */ |
| 2200 | | − vtop->t = (vtop->t & ~VT_TYPE) | VT_INT; |
| 2201 | | − vset(VT_CONST, u); |
| 2219 | + vtop->t = VT_INT; |
| 2220 | + vpushi(u); |
| 2202 | 2221 | gen_op(TOK_PDIV); |
| 2203 | 2222 | } else if ((t1 & VT_BTYPE) == VT_PTR || |
| 2204 | 2223 | (t2 & VT_BTYPE) == VT_PTR) { |
| @@ -2207,11 +2226,11 @@ void gen_op(int op) · 2 unmodified lines |
| 2207 | 2226 | swap(&t1, &t2); |
| 2208 | 2227 | } |
| 2209 | 2228 | /* stack-4 contains pointer, stack-2 value to add */ |
| 2210 | | − vset(VT_CONST, pointed_size(vtop[-1].t)); |
| 2229 | + vpushi(pointed_size(vtop[-1].t)); |
| 2211 | 2230 | gen_op('*'); |
| 2212 | 2231 | gen_opc(op); |
| 2213 | 2232 | /* put again type if gen_opc() swaped operands */ |
| 2214 | | − vtop->t = (vtop->t & ~VT_TYPE) | (t1 & VT_TYPE); |
| 2233 | + vtop->t = t1; |
| 2215 | 2234 | } else { |
| 2216 | 2235 | gen_opc(op); |
| 2217 | 2236 | } |
| @@ -2242,128 +2261,128 @@ void gen_op(int op) · 24 unmodified lines |
| 2242 | 2261 | /* cast 'vtop' to 't' type */ |
| 2243 | 2262 | void gen_cast(int t) |
| 2244 | 2263 | { |
| 2245 | | − int r, bits, sbt, dbt, sf, df, c, st1, dt1; |
| 2246 | | − |
| 2247 | | − r = vtop->t & VT_VALMASK; |
| 2248 | | − if (!(t & VT_LVAL)) { |
| 2249 | | − /* if not lvalue, then we convert now */ |
| 2250 | | − dbt = t & VT_BTYPE; |
| 2251 | | − sbt = vtop->t & VT_BTYPE; |
| 2252 | | − if (sbt != dbt) { |
| 2253 | | − sf = is_float(sbt); |
| 2254 | | − df = is_float(dbt); |
| 2255 | | − c = (vtop->t & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST; |
| 2256 | | − if (sf && df) { |
| 2257 | | − /* convert from fp to fp */ |
| 2258 | | − if (c) { |
| 2259 | | − /* constant case: we can do it now */ |
| 2260 | | − /* XXX: in ISOC, cannot do it if error in convert */ |
| 2261 | | − if (dbt == VT_FLOAT && sbt == VT_DOUBLE) |
| 2262 | | − vtop->c.f = (float)vtop->c.d; |
| 2263 | | − else if (dbt == VT_FLOAT && sbt == VT_LDOUBLE) |
| 2264 | | − vtop->c.f = (float)vtop->c.ld; |
| 2265 | | − else if (dbt == VT_DOUBLE && sbt == VT_FLOAT) |
| 2266 | | − vtop->c.d = (double)vtop->c.f; |
| 2267 | | − else if (dbt == VT_DOUBLE && sbt == VT_LDOUBLE) |
| 2268 | | − vtop->c.d = (double)vtop->c.ld; |
| 2269 | | − else if (dbt == VT_LDOUBLE && sbt == VT_FLOAT) |
| 2270 | | − vtop->c.ld = (long double)vtop->c.f; |
| 2271 | | − else if (dbt == VT_LDOUBLE && sbt == VT_DOUBLE) |
| 2272 | | − vtop->c.ld = (long double)vtop->c.d; |
| 2273 | | − } else { |
| 2274 | | − /* non constant case: generate code */ |
| 2275 | | − gen_cvt_ftof(dbt); |
| 2276 | | − } |
| 2277 | | − } else if (df) { |
| 2278 | | − /* convert int to fp */ |
| 2279 | | − /* XXX: add const cases */ |
| 2280 | | − st1 = vtop->t & (VT_BTYPE | VT_UNSIGNED); |
| 2281 | | − if (c) { |
| 2282 | | − switch(st1) { |
| 2283 | | − case VT_LLONG | VT_UNSIGNED: |
| 2284 | | − case VT_LLONG: |
| 2285 | | − /* well, currently not needed */ |
| 2286 | | − goto do_itof; |
| 2287 | | − case VT_INT | VT_UNSIGNED: |
| 2288 | | − switch(dbt) { |
| 2289 | | − case VT_FLOAT: vtop->c.f = (float)vtop->c.ui; break; |
| 2290 | | − case VT_DOUBLE: vtop->c.d = (double)vtop->c.ui; break; |
| 2291 | | − case VT_LDOUBLE: vtop->c.ld = (long double)vtop->c.ui; break; |
| 2292 | | − } |
| 2293 | | − break; |
| 2294 | | − default: |
| 2295 | | − switch(dbt) { |
| 2296 | | − case VT_FLOAT: vtop->c.f = (float)vtop->c.i; break; |
| 2297 | | − case VT_DOUBLE: vtop->c.d = (double)vtop->c.i; break; |
| 2298 | | − case VT_LDOUBLE: vtop->c.ld = (long double)vtop->c.i; break; |
| 2299 | | − } |
| 2300 | | − break; |
| 2264 | + int bits, sbt, dbt, sf, df, c, st1, dt1; |
| 2265 | + |
| 2266 | + /* if not lvalue, then we convert now */ |
| 2267 | + dbt = t & VT_BTYPE; |
| 2268 | + sbt = vtop->t & VT_BTYPE; |
| 2269 | + if (sbt != dbt) { |
| 2270 | + sf = is_float(sbt); |
| 2271 | + df = is_float(dbt); |
| 2272 | + c = (vtop->r & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST; |
| 2273 | + if (sf && df) { |
| 2274 | + /* convert from fp to fp */ |
| 2275 | + if (c) { |
| 2276 | + /* constant case: we can do it now */ |
| 2277 | + /* XXX: in ISOC, cannot do it if error in convert */ |
| 2278 | + if (dbt == VT_FLOAT && sbt == VT_DOUBLE) |
| 2279 | + vtop->c.f = (float)vtop->c.d; |
| 2280 | + else if (dbt == VT_FLOAT && sbt == VT_LDOUBLE) |
| 2281 | + vtop->c.f = (float)vtop->c.ld; |
| 2282 | + else if (dbt == VT_DOUBLE && sbt == VT_FLOAT) |
| 2283 | + vtop->c.d = (double)vtop->c.f; |
| 2284 | + else if (dbt == VT_DOUBLE && sbt == VT_LDOUBLE) |
| 2285 | + vtop->c.d = (double)vtop->c.ld; |
| 2286 | + else if (dbt == VT_LDOUBLE && sbt == VT_FLOAT) |
| 2287 | + vtop->c.ld = (long double)vtop->c.f; |
| 2288 | + else if (dbt == VT_LDOUBLE && sbt == VT_DOUBLE) |
| 2289 | + vtop->c.ld = (long double)vtop->c.d; |
| 2290 | + } else { |
| 2291 | + /* non constant case: generate code */ |
| 2292 | + gen_cvt_ftof(dbt); |
| 2293 | + } |
| 2294 | + } else if (df) { |
| 2295 | + /* convert int to fp */ |
| 2296 | + /* XXX: add const cases */ |
| 2297 | + st1 = vtop->t & (VT_BTYPE | VT_UNSIGNED); |
| 2298 | + if (c) { |
| 2299 | + switch(st1) { |
| 2300 | + case VT_LLONG | VT_UNSIGNED: |
| 2301 | + case VT_LLONG: |
| 2302 | + /* well, currently not needed */ |
| 2303 | + goto do_itof; |
| 2304 | + case VT_INT | VT_UNSIGNED: |
| 2305 | + switch(dbt) { |
| 2306 | + case VT_FLOAT: vtop->c.f = (float)vtop->c.ui; break; |
| 2307 | + case VT_DOUBLE: vtop->c.d = (double)vtop->c.ui; break; |
| 2308 | + case VT_LDOUBLE: vtop->c.ld = (long double)vtop->c.ui; break; |
| 2301 | 2309 | } |
| 2302 | | − } else { |
| 2303 | | − do_itof: |
| 2304 | | − gen_cvt_itof(dbt); |
| 2305 | | − } |
| 2306 | | − } else if (sf) { |
| 2307 | | − /* convert fp to int */ |
| 2308 | | − dt1 = t & (VT_BTYPE | VT_UNSIGNED); |
| 2309 | | − /* we handle char/short/etc... with generic code */ |
| 2310 | | − if (dt1 != VT_INT | VT_UNSIGNED && |
| 2311 | | − dt1 != VT_LLONG | VT_UNSIGNED && |
| 2312 | | − dt1 != VT_LLONG) |
| 2313 | | − dt1 = VT_INT; |
| 2314 | | − if (c) { |
| 2315 | | − switch(dt1) { |
| 2316 | | − case VT_LLONG | VT_UNSIGNED: |
| 2317 | | − case VT_LLONG: |
| 2318 | | − /* well, currently not needed */ |
| 2319 | | − goto do_ftoi; |
| 2320 | | − case VT_INT | VT_UNSIGNED: |
| 2321 | | − switch(sbt) { |
| 2322 | | − case VT_FLOAT: vtop->c.ui = (unsigned int)vtop->c.d; break; |
| 2323 | | − case VT_DOUBLE: vtop->c.ui = (unsigned int)vtop->c.d; break; |
| 2324 | | − case VT_LDOUBLE: vtop->c.ui = (unsigned int)vtop->c.d; break; |
| 2325 | | − } |
| 2326 | | − break; |
| 2327 | | − default: |
| 2328 | | − /* int case */ |
| 2329 | | − switch(sbt) { |
| 2330 | | − case VT_FLOAT: vtop->c.i = (int)vtop->c.d; break; |
| 2331 | | − case VT_DOUBLE: vtop->c.i = (int)vtop->c.d; break; |
| 2332 | | − case VT_LDOUBLE: vtop->c.i = (int)vtop->c.d; break; |
| 2333 | | − } |
| 2334 | | − break; |
| 2310 | + break; |
| 2311 | + default: |
| 2312 | + switch(dbt) { |
| 2313 | + case VT_FLOAT: vtop->c.f = (float)vtop->c.i; break; |
| 2314 | + case VT_DOUBLE: vtop->c.d = (double)vtop->c.i; break; |
| 2315 | + case VT_LDOUBLE: vtop->c.ld = (long double)vtop->c.i; break; |
| 2335 | 2316 | } |
| 2336 | | − } else { |
| 2337 | | − do_ftoi: |
| 2338 | | − gen_cvt_ftoi(dt1); |
| 2339 | | − } |
| 2340 | | − if (dt1 == VT_INT && (t & (VT_TYPE | VT_UNSIGNED)) != dt1) { |
| 2341 | | − /* additionnal cast for char/short/bool... */ |
| 2342 | | − vtop->t = (vtop->t & ~VT_TYPE) | dt1; |
| 2343 | | − gen_cast(t); |
| 2317 | + break; |
| 2344 | 2318 | } |
| 2345 | | − } else if (dbt == VT_BOOL) { |
| 2346 | | − vset(VT_CONST, 0); |
| 2347 | | − gen_op(TOK_NE); |
| 2348 | | − } else if (dbt == VT_BYTE || dbt == VT_SHORT) { |
| 2349 | | − if (dbt == VT_BYTE) |
| 2350 | | − bits = 8; |
| 2351 | | − else |
| 2352 | | − bits = 16; |
| 2353 | | − if (t & VT_UNSIGNED) { |
| 2354 | | − vset(VT_CONST, (1 << bits) - 1); |
| 2355 | | − gen_op('&'); |
| 2356 | | − } else { |
| 2357 | | − bits = 32 - bits; |
| 2358 | | − vset(VT_CONST, bits); |
| 2359 | | − gen_op(TOK_SHL); |
| 2360 | | − vset(VT_CONST, bits); |
| 2361 | | − gen_op(TOK_SAR); |
| 2319 | + } else { |
| 2320 | + do_itof: |
| 2321 | + gen_cvt_itof(dbt); |
| 2322 | + } |
| 2323 | + } else if (sf) { |
| 2324 | + /* convert fp to int */ |
| 2325 | + dt1 = t & (VT_BTYPE | VT_UNSIGNED); |
| 2326 | + /* we handle char/short/etc... with generic code */ |
| 2327 | + if (dt1 != VT_INT | VT_UNSIGNED && |
| 2328 | + dt1 != VT_LLONG | VT_UNSIGNED && |
| 2329 | + dt1 != VT_LLONG) |
| 2330 | + dt1 = VT_INT; |
| 2331 | + if (c) { |
| 2332 | + switch(dt1) { |
| 2333 | + case VT_LLONG | VT_UNSIGNED: |
| 2334 | + case VT_LLONG: |
| 2335 | + /* well, currently not needed */ |
| 2336 | + goto do_ftoi; |
| 2337 | + case VT_INT | VT_UNSIGNED: |
| 2338 | + switch(sbt) { |
| 2339 | + case VT_FLOAT: vtop->c.ui = (unsigned int)vtop->c.d; break; |
| 2340 | + case VT_DOUBLE: vtop->c.ui = (unsigned int)vtop->c.d; break; |
| 2341 | + case VT_LDOUBLE: vtop->c.ui = (unsigned int)vtop->c.d; break; |
| 2342 | + } |
| 2343 | + break; |
| 2344 | + default: |
| 2345 | + /* int case */ |
| 2346 | + switch(sbt) { |
| 2347 | + case VT_FLOAT: vtop->c.i = (int)vtop->c.d; break; |
| 2348 | + case VT_DOUBLE: vtop->c.i = (int)vtop->c.d; break; |
| 2349 | + case VT_LDOUBLE: vtop->c.i = (int)vtop->c.d; break; |
| 2350 | + } |
| 2351 | + break; |
| 2362 | 2352 | } |
| 2353 | + } else { |
| 2354 | + do_ftoi: |
| 2355 | + gen_cvt_ftoi(dt1); |
| 2356 | + } |
| 2357 | + if (dt1 == VT_INT && (t & (VT_TYPE | VT_UNSIGNED)) != dt1) { |
| 2358 | + /* additionnal cast for char/short/bool... */ |
| 2359 | + vtop->t = (vtop->t & ~VT_TYPE) | dt1; |
| 2360 | + gen_cast(t); |
| 2361 | + } |
| 2362 | + } else if (dbt == VT_BOOL) { |
| 2363 | + vpushi(0); |
| 2364 | + gen_op(TOK_NE); |
| 2365 | + } else if ((dbt == VT_BYTE || dbt == VT_SHORT) && |
| 2366 | + !(vtop->r & VT_LVAL)) { |
| 2367 | + /* no need to apply if lvalue because we do it while |
| 2368 | + loading the value */ |
| 2369 | + if (dbt == VT_BYTE) |
| 2370 | + bits = 8; |
| 2371 | + else |
| 2372 | + bits = 16; |
| 2373 | + if (t & VT_UNSIGNED) { |
| 2374 | + vpushi((1 << bits) - 1); |
| 2375 | + gen_op('&'); |
| 2376 | + } else { |
| 2377 | + bits = 32 - bits; |
| 2378 | + vpushi(bits); |
| 2379 | + gen_op(TOK_SHL); |
| 2380 | + vpushi(bits); |
| 2381 | + gen_op(TOK_SAR); |
| 2363 | 2382 | } |
| 2364 | 2383 | } |
| 2365 | 2384 | } |
| 2366 | | − vtop->t = (vtop->t & ~VT_TYPE) | t; |
| 2385 | + vtop->t = t; |
| 2367 | 2386 | } |
| 2368 | 2387 | |
| 2369 | 2388 | /* return type size. Put alignment at 'a' */ |
| @@ -2599,7 +2618,7 @@ void gen_assign_cast(int dt) · 229 unmodified lines |
| 2599 | 2618 | /* store vtop in lvalue pushed on stack */ |
| 2600 | 2619 | void vstore(void) |
| 2601 | 2620 | { |
| 2602 | | − int ft, fc, r, t, size, align, bit_size, bit_pos; |
| 2621 | + int ft, r, t, size, align, bit_size, bit_pos; |
| 2603 | 2622 | GFuncContext gf; |
| 2604 | 2623 | |
| 2605 | 2624 | ft = vtop[-1].t; |
| @@ -2614,18 +2633,20 @@ void vstore(void) · 8 unmodified lines |
| 2614 | 2633 | gfunc_start(&gf); |
| 2615 | 2634 | /* type size */ |
| 2616 | 2635 | size = type_size(vtop->t, &align); |
| 2617 | | − vset(VT_CONST, size); |
| 2636 | + vpushi(size); |
| 2618 | 2637 | gfunc_param(&gf); |
| 2619 | 2638 | /* source */ |
| 2620 | | − vtop->t &= ~VT_LVAL; |
| 2639 | + vtop->t = VT_INT; |
| 2640 | + vtop->r &= ~VT_LVAL; |
| 2621 | 2641 | gfunc_param(&gf); |
| 2622 | 2642 | /* destination */ |
| 2623 | 2643 | vswap(); |
| 2624 | | − vtop->t &= ~VT_LVAL; |
| 2644 | + vtop->t = VT_INT; |
| 2645 | + vtop->r &= ~VT_LVAL; |
| 2625 | 2646 | gfunc_param(&gf); |
| 2626 | 2647 | |
| 2627 | 2648 | save_regs(); |
| 2628 | | − vset(VT_CONST, (int)&memcpy); |
| 2649 | + vpushi((int)&memcpy); |
| 2629 | 2650 | gfunc_call(&gf); |
| 2630 | 2651 | /* leave source on stack */ |
| 2631 | 2652 | } else if (ft & VT_BITFIELD) { |
| @@ -2640,30 +2661,32 @@ void vstore(void) · 8 unmodified lines |
| 2640 | 2661 | vtop[-1] = vtop[-2]; |
| 2641 | 2662 | |
| 2642 | 2663 | /* mask and shift source */ |
| 2643 | | − vset(VT_CONST, (1 << bit_size) - 1); |
| 2664 | + vpushi((1 << bit_size) - 1); |
| 2644 | 2665 | gen_op('&'); |
| 2645 | | − vset(VT_CONST, bit_pos); |
| 2666 | + vpushi(bit_pos); |
| 2646 | 2667 | gen_op(TOK_SHL); |
| 2647 | 2668 | /* load destination, mask and or with source */ |
| 2648 | 2669 | vswap(); |
| 2649 | | − vset(VT_CONST, ~(((1 << bit_size) - 1) << bit_pos)); |
| 2670 | + vpushi(~(((1 << bit_size) - 1) << bit_pos)); |
| 2650 | 2671 | gen_op('&'); |
| 2651 | 2672 | gen_op('|'); |
| 2652 | 2673 | /* store result */ |
| 2653 | 2674 | vstore(); |
| 2654 | 2675 | } else { |
| 2655 | 2676 | r = gv(); /* generate value */ |
| 2656 | | − ft = vtop[-1].t; |
| 2657 | | − fc = vtop[-1].c.i; |
| 2658 | 2677 | /* if lvalue was saved on stack, must read it */ |
| 2659 | | − if ((ft & VT_VALMASK) == VT_LLOCAL) { |
| 2678 | + if ((vtop[-1].r & VT_VALMASK) == VT_LLOCAL) { |
| 2679 | + SValue sv; |
| 2660 | 2680 | t = get_reg(REG_CLASS_INT); |
| 2661 | | − load(t, VT_LOCAL | VT_LVAL, fc); |
| 2662 | | − ft = (ft & ~VT_VALMASK) | t; |
| 2681 | + sv.t = VT_INT; |
| 2682 | + sv.r = VT_LOCAL | VT_LVAL; |
| 2683 | + sv.c.ul = vtop[-1].c.ul; |
| 2684 | + load(t, &sv); |
| 2685 | + vtop[-1].r = t | VT_LVAL; |
| 2663 | 2686 | } |
| 2664 | | − store(r, ft, fc); |
| 2687 | + store(r, vtop - 1); |
| 2665 | 2688 | vtop--; |
| 2666 | | − vtop->t = (ft & VT_TYPE) | r; |
| 2689 | + vtop->r = r; |
| 2667 | 2690 | vtop->c.i = 0; |
| 2668 | 2691 | } |
| 2669 | 2692 | } |
| @@ -2672,6 +2695,7 @@ void vstore(void) · 2 unmodified lines |
| 2672 | 2695 | void inc(int post, int c) |
| 2673 | 2696 | { |
| 2674 | 2697 | int r, r1; |
| 2698 | + SValue sv; |
| 2675 | 2699 | |
| 2676 | 2700 | test_lvalue(); |
| 2677 | 2701 | if (post) |
| @@ -2682,13 +2706,16 @@ void inc(int post, int c) · 4 unmodified lines |
| 2682 | 2706 | /* duplicate value */ |
| 2683 | 2707 | /* XXX: handle floats */ |
| 2684 | 2708 | r1 = get_reg(REG_CLASS_INT); |
| 2685 | | − load(r1, r, 0); /* move r to r1 */ |
| 2709 | + sv.t = VT_INT; |
| 2710 | + sv.r = r; |
| 2711 | + sv.c.ul = 0; |
| 2712 | + load(r1, &sv); /* move r to r1 */ |
| 2686 | 2713 | /* duplicates value */ |
| 2687 | | − vtop[-2].t = (vtop->t & VT_TYPE) | r1; |
| 2714 | + vtop[-2].r = r1; |
| 2688 | 2715 | vtop[-2].c.i = 0; |
| 2689 | 2716 | } |
| 2690 | 2717 | /* add constant */ |
| 2691 | | − vset(VT_CONST, c - TOK_MID); |
| 2718 | + vpushi(c - TOK_MID); |
| 2692 | 2719 | gen_op('+'); |
| 2693 | 2720 | vstore(); /* store value */ |
| 2694 | 2721 | if (post) |
| @@ -3107,13 +3134,13 @@ Sym *external_sym(int v, int u) · 412 unmodified lines |
| 3107 | 3134 | |
| 3108 | 3135 | void indir(void) |
| 3109 | 3136 | { |
| 3110 | | − if (vtop->t & VT_LVAL) |
| 3137 | + if (vtop->r & VT_LVAL) |
| 3111 | 3138 | gv(); |
| 3112 | 3139 | if ((vtop->t & VT_BTYPE) != VT_PTR) |
| 3113 | 3140 | expect("pointer"); |
| 3114 | 3141 | vtop->t = pointed_type(vtop->t); |
| 3115 | 3142 | if (!(vtop->t & VT_ARRAY)) /* an array is never an lvalue */ |
| 3116 | | − vtop->t |= VT_LVAL; |
| 3143 | + vtop->r |= VT_LVAL; |
| 3117 | 3144 | } |
| 3118 | 3145 | |
| 3119 | 3146 | /* pass a parameter to a function and do type checking and casting */ |
| @@ -3141,21 +3168,21 @@ void unary(void) · 21 unmodified lines |
| 3141 | 3168 | GFuncContext gf; |
| 3142 | 3169 | |
| 3143 | 3170 | if (tok == TOK_NUM || tok == TOK_CCHAR || tok == TOK_LCHAR) { |
| 3144 | | − vset(VT_CONST | VT_INT, tokc.i); |
| 3171 | + vpushi(tokc.i); |
| 3145 | 3172 | next(); |
| 3146 | 3173 | } else if (tok == TOK_CFLOAT) { |
| 3147 | | − vsetc(VT_CONST | VT_FLOAT, &tokc); |
| 3174 | + vsetc(VT_FLOAT, VT_CONST, &tokc); |
| 3148 | 3175 | next(); |
| 3149 | 3176 | } else if (tok == TOK_CDOUBLE) { |
| 3150 | | − vsetc(VT_CONST | VT_DOUBLE, &tokc); |
| 3177 | + vsetc(VT_DOUBLE, VT_CONST, &tokc); |
| 3151 | 3178 | next(); |
| 3152 | 3179 | } else if (tok == TOK_CLDOUBLE) { |
| 3153 | | − vsetc(VT_CONST | VT_LDOUBLE, &tokc); |
| 3180 | + vsetc(VT_LDOUBLE, VT_CONST, &tokc); |
| 3154 | 3181 | next(); |
| 3155 | 3182 | } else if (tok == TOK___FUNC__) { |
| 3156 | 3183 | /* special function name identifier */ |
| 3157 | 3184 | /* generate (char *) type */ |
| 3158 | | − vset(VT_CONST | mk_pointer(VT_BYTE), glo); |
| 3185 | + vset(mk_pointer(VT_BYTE), VT_CONST, glo); |
| 3159 | 3186 | strcpy((void *)glo, funcname); |
| 3160 | 3187 | glo += strlen(funcname) + 1; |
| 3161 | 3188 | next(); |
| @@ -3174,7 +3201,7 @@ void unary(void) · 12 unmodified lines |
| 3174 | 3201 | decl_initializer(t, glo, 1, 0); |
| 3175 | 3202 | glo += type_size(t, &align); |
| 3176 | 3203 | /* put it as pointer */ |
| 3177 | | − vset(t & ~VT_ARRAY, fc); |
| 3204 | + vset(t & ~VT_ARRAY, VT_CONST, fc); |
| 3178 | 3205 | } else { |
| 3179 | 3206 | t = tok; |
| 3180 | 3207 | next(); |
| @@ -3194,7 +3221,7 @@ void unary(void) · 13 unmodified lines |
| 3194 | 3221 | if (!(ft & VT_ARRAY)) |
| 3195 | 3222 | ft |= VT_LVAL; |
| 3196 | 3223 | fc = decl_initializer_alloc(ft, 1); |
| 3197 | | − vset(ft, fc); |
| 3224 | + vset(ft & VT_TYPE, ft & (VT_VALMASK | VT_LVAL), fc); |
| 3198 | 3225 | } else { |
| 3199 | 3226 | unary(); |
| 3200 | 3227 | gen_cast(ft); |
| @@ -3214,20 +3241,21 @@ void unary(void) · 13 unmodified lines |
| 3214 | 3241 | there and in function calls. */ |
| 3215 | 3242 | if ((vtop->t & VT_BTYPE) != VT_FUNC) |
| 3216 | 3243 | test_lvalue(); |
| 3217 | | − vtop->t = mk_pointer(vtop->t & VT_LVALN); |
| 3244 | + vtop->t = mk_pointer(vtop->t); |
| 3245 | + vtop->r &= ~VT_LVAL; |
| 3218 | 3246 | } else |
| 3219 | 3247 | if (t == '!') { |
| 3220 | 3248 | unary(); |
| 3221 | | − if ((vtop->t & (VT_VALMASK | VT_LVAL)) == VT_CONST) |
| 3249 | + if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) |
| 3222 | 3250 | vtop->c.i = !vtop->c.i; |
| 3223 | | − else if ((vtop->t & VT_VALMASK) == VT_CMP) |
| 3251 | + else if ((vtop->r & VT_VALMASK) == VT_CMP) |
| 3224 | 3252 | vtop->c.i = vtop->c.i ^ 1; |
| 3225 | 3253 | else |
| 3226 | | − vset(VT_JMP, gtst(1, 0)); |
| 3254 | + vset(VT_INT, VT_JMP, gtst(1, 0)); |
| 3227 | 3255 | } else |
| 3228 | 3256 | if (t == '~') { |
| 3229 | 3257 | unary(); |
| 3230 | | − vset(VT_CONST, -1); |
| 3258 | + vpushi(-1); |
| 3231 | 3259 | gen_op('^'); |
| 3232 | 3260 | } else |
| 3233 | 3261 | if (t == '+') { |
| @@ -3251,13 +3279,13 @@ void unary(void) · 17 unmodified lines |
| 3251 | 3279 | t = vtop->t; |
| 3252 | 3280 | vpop(); |
| 3253 | 3281 | } |
| 3254 | | − vset(VT_CONST, type_size(t, &t)); |
| 3282 | + vpushi(type_size(t, &t)); |
| 3255 | 3283 | } else |
| 3256 | 3284 | if (t == TOK_INC || t == TOK_DEC) { |
| 3257 | 3285 | unary(); |
| 3258 | 3286 | inc(0, t); |
| 3259 | 3287 | } else if (t == '-') { |
| 3260 | | − vset(VT_CONST, 0); |
| 3288 | + vpushi(0); |
| 3261 | 3289 | unary(); |
| 3262 | 3290 | gen_op('-'); |
| 3263 | 3291 | } else |
| @@ -3273,9 +3301,10 @@ void unary(void) · 9 unmodified lines |
| 3273 | 3301 | /* int() function */ |
| 3274 | 3302 | s = external_sym(t, VT_FUNC | (p << VT_STRUCT_SHIFT)); |
| 3275 | 3303 | } |
| 3276 | | − vset(s->t, s->c); |
| 3304 | + vset(s->t & VT_TYPE, |
| 3305 | + s->t & (VT_VALMASK | VT_LVAL | VT_FORWARD), s->c); |
| 3277 | 3306 | /* if forward reference, we must point to s */ |
| 3278 | | − if (vtop->t & VT_FORWARD) |
| 3307 | + if (vtop->r & VT_FORWARD) |
| 3279 | 3308 | vtop->c.sym = s; |
| 3280 | 3309 | } |
| 3281 | 3310 | } |
| @@ -3290,7 +3319,7 @@ void unary(void) · 8 unmodified lines |
| 3290 | 3319 | if (tok == TOK_ARROW) |
| 3291 | 3320 | indir(); |
| 3292 | 3321 | test_lvalue(); |
| 3293 | | − vtop->t &= VT_LVALN; |
| 3322 | + vtop->r &= ~VT_LVAL; |
| 3294 | 3323 | next(); |
| 3295 | 3324 | /* expect pointer on structure */ |
| 3296 | 3325 | if ((vtop->t & VT_BTYPE) != VT_STRUCT) |
| @@ -3305,14 +3334,14 @@ void unary(void) · 8 unmodified lines |
| 3305 | 3334 | if (!s) |
| 3306 | 3335 | error("field not found"); |
| 3307 | 3336 | /* add field offset to pointer */ |
| 3308 | | − vtop->t = (vtop->t & ~VT_TYPE) | VT_INT; /* change type to int */ |
| 3309 | | − vset(VT_CONST, s->c); |
| 3337 | + vtop->t = VT_INT; /* change type to int */ |
| 3338 | + vpushi(s->c); |
| 3310 | 3339 | gen_op('+'); |
| 3311 | 3340 | /* change type to field type, and set to lvalue */ |
| 3312 | | − vtop->t = (vtop->t & ~VT_TYPE) | s->t; |
| 3341 | + vtop->t = s->t; |
| 3313 | 3342 | /* an array is never an lvalue */ |
| 3314 | 3343 | if (!(vtop->t & VT_ARRAY)) |
| 3315 | | − vtop->t |= VT_LVAL; |
| 3344 | + vtop->r |= VT_LVAL; |
| 3316 | 3345 | next(); |
| 3317 | 3346 | } else if (tok == '[') { |
| 3318 | 3347 | next(); |
| @@ -3321,8 +3350,7 @@ void unary(void) · 2 unmodified lines |
| 3321 | 3350 | indir(); |
| 3322 | 3351 | skip(']'); |
| 3323 | 3352 | } else if (tok == '(') { |
| 3324 | | − int rett; |
| 3325 | | − CValue retc; |
| 3353 | + SValue ret; |
| 3326 | 3354 | Sym *sa; |
| 3327 | 3355 | |
| 3328 | 3356 | /* function call */ |
| @@ -3337,7 +3365,7 @@ void unary(void) · 8 unmodified lines |
| 3337 | 3365 | expect("function pointer"); |
| 3338 | 3366 | } |
| 3339 | 3367 | } else { |
| 3340 | | − vtop->t &= ~VT_LVAL; /* no lvalue */ |
| 3368 | + vtop->r &= ~VT_LVAL; /* no lvalue */ |
| 3341 | 3369 | } |
| 3342 | 3370 | /* get return type */ |
| 3343 | 3371 | s = sym_find((unsigned)vtop->t >> VT_STRUCT_SHIFT); |
| @@ -3403,15 +3431,17 @@ void unary(void) · 59 unmodified lines |
| 3403 | 3431 | /* get some space for the returned structure */ |
| 3404 | 3432 | size = type_size(s->t, &align); |
| 3405 | 3433 | loc = (loc - size) & -align; |
| 3406 | | − rett = s->t | VT_LOCAL | VT_LVAL; |
| 3434 | + ret.t = s->t; |
| 3435 | + ret.r = VT_LOCAL | VT_LVAL; |
| 3407 | 3436 | /* pass it as 'int' to avoid structure arg passing |
| 3408 | 3437 | problems */ |
| 3409 | | − vset(VT_INT | VT_LOCAL, loc); |
| 3410 | | − retc = vtop->c; |
| 3438 | + vset(VT_INT, VT_LOCAL, loc); |
| 3439 | + ret.c = vtop->c; |
| 3411 | 3440 | gfunc_param(&gf); |
| 3412 | 3441 | } else { |
| 3413 | | − rett = s->t | FUNC_RET_REG; /* return in register */ |
| 3414 | | − retc.i = 0; |
| 3442 | + ret.t = s->t; |
| 3443 | + ret.r = FUNC_RET_REG; /* return in register */ |
| 3444 | + ret.c.i = 0; |
| 3415 | 3445 | } |
| 3416 | 3446 | #ifndef INVERT_FUNC_PARAMS |
| 3417 | 3447 | while (tok != ')') { |
| @@ -3428,7 +3458,7 @@ void unary(void) · 10 unmodified lines |
| 3428 | 3458 | skip(')'); |
| 3429 | 3459 | gfunc_call(&gf); |
| 3430 | 3460 | /* return value */ |
| 3431 | | − vsetc(rett, &retc); |
| 3461 | + vsetc(ret.t, ret.r, &ret.c); |
| 3432 | 3462 | } else { |
| 3433 | 3463 | break; |
| 3434 | 3464 | } |
| @@ -3496,7 +3526,7 @@ void eand(void) · 61 unmodified lines |
| 3496 | 3526 | if (tok != TOK_LAND) { |
| 3497 | 3527 | if (t) { |
| 3498 | 3528 | t = gtst(1, t); |
| 3499 | | − vset(VT_JMPI, t); |
| 3529 | + vset(VT_INT, VT_JMPI, t); |
| 3500 | 3530 | } |
| 3501 | 3531 | break; |
| 3502 | 3532 | } |
| @@ -3516,7 +3546,7 @@ void eor(void) · 13 unmodified lines |
| 3516 | 3546 | if (tok != TOK_LOR) { |
| 3517 | 3547 | if (t) { |
| 3518 | 3548 | t = gtst(0, t); |
| 3519 | | − vset(VT_JMP, t); |
| 3549 | + vset(VT_INT, VT_JMP, t); |
| 3520 | 3550 | } |
| 3521 | 3551 | break; |
| 3522 | 3552 | } |
| @@ -3561,7 +3591,7 @@ void expr_eq(void) · 38 unmodified lines |
| 3561 | 3591 | expr_eq(); |
| 3562 | 3592 | r2 = gv(); |
| 3563 | 3593 | move_reg(r1, r2); |
| 3564 | | − vtop->t = (vtop->t & VT_TYPE) | r1; |
| 3594 | + vtop->r = r1; |
| 3565 | 3595 | gsym(u); |
| 3566 | 3596 | } |
| 3567 | 3597 | } |
| @@ -3585,7 +3615,7 @@ void expr_const1(void) · 17 unmodified lines |
| 3585 | 3615 | a = const_wanted; |
| 3586 | 3616 | const_wanted = 1; |
| 3587 | 3617 | expr_eq(); |
| 3588 | | − if ((vtop->t & (VT_CONST | VT_LVAL)) != VT_CONST) |
| 3618 | + if ((vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST) |
| 3589 | 3619 | expect("constant"); |
| 3590 | 3620 | const_wanted = a; |
| 3591 | 3621 | } |
| @@ -3680,7 +3710,7 @@ void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg) · 88 unmodified lines |
| 3680 | 3710 | if ((func_vt & VT_BTYPE) == VT_STRUCT) { |
| 3681 | 3711 | /* if returning structure, must copy it to implicit |
| 3682 | 3712 | first pointer arg location */ |
| 3683 | | − vset(mk_pointer(func_vt) | VT_LOCAL | VT_LVAL, func_vc); |
| 3713 | + vset(mk_pointer(func_vt), VT_LOCAL | VT_LVAL, func_vc); |
| 3684 | 3714 | indir(); |
| 3685 | 3715 | vswap(); |
| 3686 | 3716 | /* copy structure value to pointer */ |
| @@ -3785,8 +3815,8 @@ void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg) · 98 unmodified lines |
| 3785 | 3815 | /* since a case is like a label, we must skip it with a jmp */ |
| 3786 | 3816 | b = gjmp(0); |
| 3787 | 3817 | gsym(*case_sym); |
| 3788 | | − vset(case_reg, 0); |
| 3789 | | − vset(VT_CONST, a); |
| 3818 | + vset(VT_INT, case_reg, 0); |
| 3819 | + vpushi(a); |
| 3790 | 3820 | gen_op(TOK_EQ); |
| 3791 | 3821 | *case_sym = gtst(1, 0); |
| 3792 | 3822 | gsym(b); |
| @@ -3936,7 +3966,7 @@ void init_putv(int t, int c, int v, int is_expr) · 143 unmodified lines |
| 3936 | 3966 | expr_const1(); |
| 3937 | 3967 | global_expr = saved_global_expr; |
| 3938 | 3968 | } else { |
| 3939 | | − vset(VT_CONST | VT_INT, v); |
| 3969 | + vpushi(v); |
| 3940 | 3970 | } |
| 3941 | 3971 | /* XXX: do casting */ |
| 3942 | 3972 | /* XXX: not portable */ |
| @@ -3965,11 +3995,11 @@ void init_putv(int t, int c, int v, int is_expr) · 22 unmodified lines |
| 3965 | 3995 | } |
| 3966 | 3996 | vpop(); |
| 3967 | 3997 | } else { |
| 3968 | | − vset(t, c); |
| 3998 | + vset(t & VT_TYPE, t & (VT_VALMASK | VT_LVAL | VT_FORWARD), c); |
| 3969 | 3999 | if (is_expr) |
| 3970 | 4000 | expr_eq(); |
| 3971 | 4001 | else |
| 3972 | | − vset(VT_CONST | VT_INT, v); |
| 4002 | + vpushi(v); |
| 3973 | 4003 | vstore(); |
| 3974 | 4004 | vpop(); |
| 3975 | 4005 | } |
| @@ -3984,13 +4014,13 @@ void init_putz(int t, int c, int size) · 8 unmodified lines |
| 3984 | 4014 | /* nothing to do because global are already set to zero */ |
| 3985 | 4015 | } else { |
| 3986 | 4016 | gfunc_start(&gf); |
| 3987 | | − vset(VT_CONST, size); |
| 4017 | + vpushi(size); |
| 3988 | 4018 | gfunc_param(&gf); |
| 3989 | | − vset(VT_CONST, 0); |
| 4019 | + vpushi(0); |
| 3990 | 4020 | gfunc_param(&gf); |
| 3991 | | − vset(VT_LOCAL, c); |
| 4021 | + vset(VT_INT, VT_LOCAL, c); |
| 3992 | 4022 | gfunc_param(&gf); |
| 3993 | | − vset(VT_CONST, (int)&memset); |
| 4023 | + vpushi((int)&memset); |
| 3994 | 4024 | gfunc_call(&gf); |
| 3995 | 4025 | } |
| 3996 | 4026 | } |