History

separated type and value on stack

bellard committed 24 years ago

Commit f7181901 parent f50d0b42 files · +295 −257Browse files

Unified · Split

2 files
  1. i386-gen.c +50 −42
  2. tcc.c +245 −215
i386-gen.c+50−42
@@ -155,10 +155,10 @@ int oad(int c, int s) · 154 unmodified lines
155155 return s;
156156 }
157157
158−/* output constant with relocation if 't & VT_FORWARD' is true */
159−void gen_addr32(int c, int t)
158+/* output constant with relocation if 'r & VT_FORWARD' is true */
159+void gen_addr32(int r, int c)
160160 {
161− if (!(t & VT_FORWARD)) {
161+ if (!(r & VT_FORWARD)) {
162162 gen_le32(c);
163163 } else {
164164 greloc((Sym *)c, ind, RELOC_ADDR32);
@@ -166,16 +166,23 @@ void gen_addr32(int c, int t) · 1 unmodified line
166166 }
167167 }
168168
169−/* XXX: generate correct pointer for forward references to functions */
170−/* r = (ft, fc) */
171−void load(int r, int ft, int fc)
169+/* load 'r' from value 'sv' */
170+void load(int r, SValue *sv)
172171 {
173− int v, t;
172+ int v, t, ft, fc, fr;
173+ SValue v1;
174174
175− v = ft & VT_VALMASK;
176− if (ft & VT_LVAL) {
175+ fr = sv->r;
176+ ft = sv->t;
177+ fc = sv->c.ul;
178+
179+ v = fr & VT_VALMASK;
180+ if (fr & VT_LVAL) {
177181 if (v == VT_LLOCAL) {
178− load(r, VT_LOCAL | VT_LVAL, fc);
182+ v1.t = VT_INT;
183+ v1.r = VT_LOCAL | VT_LVAL;
184+ v1.c.ul = fc;
185+ load(r, &v1);
179186 v = r;
180187 }
181188 if ((ft & VT_BTYPE) == VT_FLOAT) {
@@ -200,7 +207,7 @@ void load(int r, int ft, int fc) · 18 unmodified lines
200207
201208 if (v == VT_CONST) {
202209 o(0x05 + r * 8); /* 0xXX, r */
203− gen_addr32(fc, ft);
210+ gen_addr32(fr, fc);
204211 } else if (v == VT_LOCAL) {
205212 oad(0x85 + r * 8, fc); /* xx(%ebp), r */
206213 } else {
@@ -209,7 +216,7 @@ void load(int r, int ft, int fc) · 2 unmodified lines
209216 } else {
210217 if (v == VT_CONST) {
211218 o(0xb8 + r); /* mov $xx, r */
212− gen_addr32(fc, ft);
219+ gen_addr32(fr, fc);
213220 } else if (v == VT_LOCAL) {
214221 o(0x8d);
215222 oad(0x85 + r * 8, fc); /* lea xxx(%ebp), r */
@@ -231,13 +238,14 @@ void load(int r, int ft, int fc) · 15 unmodified lines
231238 }
232239 }
233240
234−/* (ft, fc) = r */
235−/* WARNING: r must not be allocated on the stack */
236−void store(r, ft, fc)
241+/* store register 'r' in lvalue 'v' */
242+void store(int r, SValue *v)
237243 {
238− int fr, bt;
244+ int fr, bt, ft, fc;
239245
240− fr = ft & VT_VALMASK;
246+ ft = v->t;
247+ fc = v->c.ul;
248+ fr = v->r & VT_VALMASK;
241249 bt = ft & VT_BTYPE;
242250 /* XXX: incorrect if reg to reg */
243251 /* XXX: should not flush float stack */
@@ -261,10 +269,10 @@ void store(r, ft, fc) · 17 unmodified lines
261269 }
262270 if (fr == VT_CONST) {
263271 o(0x05 + r * 8); /* mov r,xxx */
264− gen_addr32(fc, ft);
272+ gen_addr32(v->r, fc);
265273 } else if (fr == VT_LOCAL) {
266274 oad(0x85 + r * 8, fc); /* mov r,xxx(%ebp) */
267− } else if (ft & VT_LVAL) {
275+ } else if (v->r & VT_LVAL) {
268276 g(fr + r * 8); /* mov r, (fr) */
269277 } else if (fr != r) {
270278 o(0xc0 + fr + r * 8); /* mov r, fr */
@@ -283,7 +291,7 @@ void gfunc_param(GFuncContext *c) · 12 unmodified lines
283291 {
284292 int size, align, r;
285293
286− if ((vtop->t & (VT_BTYPE | VT_LVAL)) == (VT_STRUCT | VT_LVAL)) {
294+ if ((vtop->t & VT_BTYPE) == VT_STRUCT) {
287295 size = type_size(vtop->t, &align);
288296 /* align to stack align size */
289297 size = (size + 3) & ~3;
@@ -293,7 +301,7 @@ void gfunc_param(GFuncContext *c) · 3 unmodified lines
293301 r = get_reg(REG_CLASS_INT);
294302 o(0x89); /* mov %esp, r */
295303 o(0xe0 + r);
296− vset(VT_INT | r, 0);
304+ vset(VT_INT, r, 0);
297305 vswap();
298306 vstore();
299307 c->args_size += size;
@@ -328,10 +336,10 @@ void gfunc_param(GFuncContext *c) · 28 unmodified lines
328336 void gfunc_call(GFuncContext *c)
329337 {
330338 int r;
331− if ((vtop->t & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
339+ if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
332340 /* constant case */
333341 /* forward reference */
334− if (vtop->t & VT_FORWARD) {
342+ if (vtop->r & VT_FORWARD) {
335343 greloc(vtop->c.sym, ind + 1, RELOC_REL32);
336344 oad(0xe8, 0);
337345 } else {
@@ -357,7 +365,7 @@ int gjmp(int t) · 19 unmodified lines
357365 int gtst(int inv, int t)
358366 {
359367 int v, *p;
360− v = vtop->t & VT_VALMASK;
368+ v = vtop->r & VT_VALMASK;
361369 if (v == VT_CMP) {
362370 /* fast case : can jump directly since flags are set */
363371 g(0x0f);
@@ -375,7 +383,7 @@ int gtst(int inv, int t) · 11 unmodified lines
375383 t = gjmp(t);
376384 gsym(vtop->c.i);
377385 }
378− } else if ((vtop->t & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
386+ } else if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
379387 /* constant jmp optimization */
380388 if ((vtop->c.i != 0) != inv)
381389 t = gjmp(t);
@@ -438,7 +446,7 @@ void gen_opi(int op) · 56 unmodified lines
438446 o(0xe8 + r);
439447 else
440448 o(0xf8 + r);
441− vtop->t = (vtop->t & VT_TYPE) | r;
449+ vtop->r = r;
442450 } else if (op == '/' | op == TOK_UDIV | op == TOK_PDIV |
443451 op == '%' | op == TOK_UMOD) {
444452 save_reg(2); /* save edx */
@@ -455,12 +463,12 @@ void gen_opi(int op) · 10 unmodified lines
455463 r = 2;
456464 else
457465 r = 0;
458− vtop->t = (vtop->t & VT_TYPE) | r;
466+ vtop->r = r;
459467 } else {
460468 vtop--;
461469 o(0x39);
462470 o(0xc0 + r + fr * 8); /* cmp fr, r */
463− vset(VT_CMP, op);
471+ vset(VT_INT, VT_CMP, op);
464472 }
465473 }
466474
@@ -472,24 +480,24 @@ void gen_opf(int op) · 5 unmodified lines
472480 int a, ft, fc, swapped, r;
473481
474482 /* convert constants to memory references */
475− if ((vtop[-1].t & (VT_CONST | VT_LVAL)) == VT_CONST) {
483+ if ((vtop[-1].r & (VT_CONST | VT_LVAL)) == VT_CONST) {
476484 vswap();
477485 gv();
478486 vswap();
479487 }
480− if ((vtop[0].t & (VT_CONST | VT_LVAL)) == VT_CONST)
488+ if ((vtop[0].r & (VT_CONST | VT_LVAL)) == VT_CONST)
481489 gv();
482490
483491 /* must put at least one value in the floating point register */
484− if ((vtop[-1].t & VT_LVAL) &&
485− (vtop[0].t & VT_LVAL)) {
492+ if ((vtop[-1].r & VT_LVAL) &&
493+ (vtop[0].r & VT_LVAL)) {
486494 vswap();
487495 gv();
488496 vswap();
489497 }
490498 if (op >= TOK_EQ && op <= TOK_GT) {
491499 /* load on stack second operand */
492− load(REG_ST0, vtop->t, vtop->c.ul);
500+ load(REG_ST0, vtop);
493501 if (op == TOK_GE || op == TOK_GT)
494502 o(0xc9d9); /* fxch %st(1) */
495503 o(0xe9da); /* fucompp */
@@ -509,13 +517,13 @@ void gen_opf(int op) · 13 unmodified lines
509517 op = TOK_EQ;
510518 }
511519 vtop--;
512− vtop->t = (vtop->t & VT_TYPE) | VT_CMP;
520+ vtop->r = VT_CMP;
513521 vtop->c.i = op;
514522 } else {
515523 /* swap the stack if needed so that t1 is the register and t2 is
516524 the memory reference */
517525 swapped = 0;
518− if (vtop[-1].t & VT_LVAL) {
526+ if (vtop[-1].r & VT_LVAL) {
519527 vswap();
520528 swapped = 1;
521529 }
@@ -546,10 +554,10 @@ void gen_opf(int op) · 24 unmodified lines
546554 else
547555 o(0xd8);
548556
549− r = ft & VT_VALMASK;
557+ r = vtop->r & VT_VALMASK;
550558 if (r == VT_CONST) {
551559 o(0x05 + a);
552− gen_addr32(fc, ft);
560+ gen_addr32(vtop->r, fc);
553561 } else if (r == VT_LOCAL) {
554562 oad(0x85 + a, fc);
555563 } else {
@@ -567,16 +575,16 @@ void gen_cvt_itof(int t) · 11 unmodified lines
567575 /* unsigned int to float/double/long double */
568576 o(0x6a); /* push $0 */
569577 g(0x00);
570− o(0x50 + (vtop->t & VT_VALMASK)); /* push r */
578+ o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
571579 o(0x242cdf); /* fildll (%esp) */
572580 o(0x08c483); /* add $8, %esp */
573581 } else {
574582 /* int to float/double/long double */
575− o(0x50 + (vtop->t & VT_VALMASK)); /* push r */
583+ o(0x50 + (vtop->r & VT_VALMASK)); /* push r */
576584 o(0x2404db); /* fildl (%esp) */
577585 o(0x04c483); /* add $4, %esp */
578586 }
579− vtop->t = t | REG_ST0;
587+ vtop->r = REG_ST0;
580588 }
581589
582590 /* FPU control word for rounding to nearest mode */
@@ -611,7 +619,7 @@ void gen_cvt_ftoi(int t) · 28 unmodified lines
611619 o(0x58 + r); /* pop r */
612620 if (size == 8)
613621 o(0x04c483); /* add $4, %esp */
614− vtop->t = t | r;
622+ vtop->r = r;
615623 }
616624
617625 /* convert from one floating point type to another */
@@ -625,7 +633,7 @@ void gen_cvt_ftof(int t) · 7 unmodified lines
625633 void vpop(void)
626634 {
627635 /* for x86, we need to pop the FP stack */
628− if ((vtop->t & VT_VALMASK) == REG_ST0) {
636+ if ((vtop->r & VT_VALMASK) == REG_ST0) {
629637 o(0xd9dd); /* fstp %st(1) */
630638 }
631639 vtop--;
tcc.c+245−215
@@ -64,14 +64,15 @@ typedef union CValue { · 63 unmodified lines
6464 long long ll;
6565 unsigned long long ull;
6666 struct TokenSym *ts;
67− int tab[1];
6867 struct Sym *sym;
68+ int tab[1];
6969 } CValue;
7070
7171 /* value on stack */
7272 typedef struct SValue {
73− int t;
74− CValue c;
73+ int t; /* type */
74+ int r; /* register + flags */
75+ CValue c; /* constant */
7576 } SValue;
7677
7778 /* symbol management */
@@ -360,7 +361,7 @@ int pointed_size(int t); · 282 unmodified lines
360361 int ist(void);
361362 int type_decl(int *v, int t, int td);
362363 void error(const char *fmt, ...);
363−void vset(int t, int v);
364+void vset(int t, int r, int v);
364365
365366 /* true if float/double/long double type */
366367 static inline int is_float(int t)
@@ -485,7 +486,7 @@ void skip(int c) · 118 unmodified lines
485486
486487 void test_lvalue(void)
487488 {
488− if (!(vtop->t & VT_LVAL))
489+ if (!(vtop->r & VT_LVAL))
489490 expect("lvalue");
490491 }
491492
@@ -1874,25 +1875,34 @@ void swap(int *p, int *q) · 1382 unmodified lines
18741875 *q = t;
18751876 }
18761877
1877−void vsetc(int t, CValue *vc)
1878+void vsetc(int t, int r, CValue *vc)
18781879 {
18791880 if (vtop >= vstack + VSTACK_SIZE)
18801881 error("memory full");
18811882 /* cannot let cpu flags if other instruction are generated */
18821883 /* XXX: VT_JMP test too ? */
1883− if ((vtop->t & VT_VALMASK) == VT_CMP)
1884+ if ((vtop->r & VT_VALMASK) == VT_CMP)
18841885 gv();
18851886 vtop++;
18861887 vtop->t = t;
1888+ vtop->r = r;
18871889 vtop->c = *vc;
18881890 }
18891891
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)
18911901 {
18921902 CValue cval;
18931903
18941904 cval.i = v;
1895− vsetc(t, &cval);
1905+ vsetc(t, r, &cval);
18961906 }
18971907
18981908 void vswap(void)
@@ -1915,22 +1925,25 @@ void vdup(void) · 16 unmodified lines
19151925 int save_reg_forced(int r)
19161926 {
19171927 int i, l, t;
1918− SValue *p;
1928+ SValue *p, sv;
19191929
19201930 /* store register */
19211931 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);
19231936 l = loc;
19241937
19251938 /* modify all stack values */
19261939 for(p=vstack;p<=vtop;p++) {
1927− i = p->t & VT_VALMASK;
1940+ i = p->r & VT_VALMASK;
19281941 if (i == r) {
1929− if (p->t & VT_LVAL)
1942+ if (p->r & VT_LVAL)
19301943 t = VT_LLOCAL;
19311944 else
19321945 t = VT_LOCAL;
1933− p->t = (p->t & VT_TYPE) | VT_LVAL | t;
1946+ p->r = VT_LVAL | t;
19341947 p->c.ul = l;
19351948 }
19361949 }
@@ -1945,7 +1958,7 @@ void save_reg(int r) · 8 unmodified lines
19451958
19461959 /* modify all stack values */
19471960 for(p=vstack;p<=vtop;p++) {
1948− i = p->t & VT_VALMASK;
1961+ i = p->r & VT_VALMASK;
19491962 if (i == r) {
19501963 save_reg_forced(r);
19511964 break;
@@ -1963,7 +1976,7 @@ int get_reg(int rc) · 11 unmodified lines
19631976 for(r=0;r<NB_REGS;r++) {
19641977 if (reg_classes[r] & rc) {
19651978 for(p=vstack;p<=vtop;p++) {
1966− i = p->t & VT_VALMASK;
1979+ i = p->r & VT_VALMASK;
19671980 if (i == r)
19681981 goto notfound;
19691982 }
@@ -1976,7 +1989,7 @@ int get_reg(int rc) · 6 unmodified lines
19761989 important to start from the bottom to ensure that we don't
19771990 spill registers used in gen_op()) */
19781991 for(p=vstack;p<=vtop;p++) {
1979− r = p->t & VT_VALMASK;
1992+ r = p->r & VT_VALMASK;
19801993 if (r < VT_CONST && (reg_classes[r] & rc)) {
19811994 save_reg(r);
19821995 break;
@@ -1985,13 +1998,13 @@ int get_reg(int rc) · 2 unmodified lines
19851998 return r;
19861999 }
19872000
1988−void save_regs()
2001+void save_regs(void)
19892002 {
19902003 int r;
19912004 SValue *p;
19922005
19932006 for(p=vstack;p<=vtop;p++) {
1994− r = p->t & VT_VALMASK;
2007+ r = p->r & VT_VALMASK;
19952008 if (r < VT_CONST) {
19962009 save_reg(r);
19972010 }
@@ -2002,9 +2015,14 @@ void save_regs() · 4 unmodified lines
20022015 if needed */
20032016 void move_reg(int r, int s)
20042017 {
2018+ SValue sv;
2019+
20052020 if (r != s) {
20062021 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);
20082026 }
20092027 }
20102028
@@ -2022,14 +2040,15 @@ int gv(void) · 11 unmodified lines
20222040 /* remove bit field info to avoid loops */
20232041 vtop->t &= ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT));
20242042 /* generate shifts */
2025− vset(VT_CONST, 32 - (bit_pos + bit_size));
2043+ vpushi(32 - (bit_pos + bit_size));
20262044 gen_op(TOK_SHL);
2027− vset(VT_CONST, 32 - bit_size);
2045+ vpushi(32 - bit_size);
20282046 /* NOTE: transformed to SHR if unsigned */
20292047 gen_op(TOK_SAR);
20302048 r = gv();
20312049 } 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) {
20332052 /* CPUs usually cannot use float constants, so we store them
20342053 generically in data segment */
20352054 size = type_size(vtop->t, &align);
@@ -2038,20 +2057,20 @@ int gv(void) · 2 unmodified lines
20382057 size = size >> 2;
20392058 for(i=0;i<size;i++)
20402059 ((int *)glo)[i] = vtop->c.tab[i];
2041− vtop->t |= VT_LVAL;
2060+ vtop->r |= VT_LVAL;
20422061 vtop->c.ul = glo;
20432062 glo += size << 2;
20442063 }
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)) {
20472066 if (is_float(vtop->t))
20482067 rc = REG_CLASS_FLOAT;
20492068 else
20502069 rc = REG_CLASS_INT;
20512070 r = get_reg(rc);
20522071 }
2053− load(r, vtop->t, vtop->c.ul);
2054− vtop->t = (vtop->t & VT_TYPE) | r;
2072+ load(r, vtop);
2073+ vtop->r = r;
20552074 }
20562075 return r;
20572076 }
@@ -2065,8 +2084,8 @@ void gen_opc(int op) · 7 unmodified lines
20652084 v1 = vtop - 1;
20662085 v2 = vtop;
20672086 /* 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;
20702089 if (c1 && c2) {
20712090 fc = v2->c.i;
20722091 switch(op) {
@@ -2184,9 +2203,9 @@ void gen_op(int op) · 111 unmodified lines
21842203 gen_opf(op);
21852204 if (op >= TOK_EQ && op <= TOK_GT) {
21862205 /* the result is an int */
2187− vtop->t = (vtop->t & ~VT_TYPE) | VT_INT;
2206+ vtop->t = VT_INT;
21882207 } else {
2189− vtop->t = (vtop->t & ~VT_TYPE) | t;
2208+ vtop->t = t;
21902209 }
21912210 } else if (op == '+' || op == '-') {
21922211 if ((t1 & VT_BTYPE) == VT_PTR &&
@@ -2197,8 +2216,8 @@ void gen_op(int op) · 4 unmodified lines
21972216 u = pointed_size(t1);
21982217 gen_opc(op);
21992218 /* 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);
22022221 gen_op(TOK_PDIV);
22032222 } else if ((t1 & VT_BTYPE) == VT_PTR ||
22042223 (t2 & VT_BTYPE) == VT_PTR) {
@@ -2207,11 +2226,11 @@ void gen_op(int op) · 2 unmodified lines
22072226 swap(&t1, &t2);
22082227 }
22092228 /* 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));
22112230 gen_op('*');
22122231 gen_opc(op);
22132232 /* put again type if gen_opc() swaped operands */
2214− vtop->t = (vtop->t & ~VT_TYPE) | (t1 & VT_TYPE);
2233+ vtop->t = t1;
22152234 } else {
22162235 gen_opc(op);
22172236 }
@@ -2242,128 +2261,128 @@ void gen_op(int op) · 24 unmodified lines
22422261 /* cast 'vtop' to 't' type */
22432262 void gen_cast(int t)
22442263 {
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;
23012309 }
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;
23352316 }
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;
23442318 }
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;
23622352 }
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);
23632382 }
23642383 }
23652384 }
2366− vtop->t = (vtop->t & ~VT_TYPE) | t;
2385+ vtop->t = t;
23672386 }
23682387
23692388 /* return type size. Put alignment at 'a' */
@@ -2599,7 +2618,7 @@ void gen_assign_cast(int dt) · 229 unmodified lines
25992618 /* store vtop in lvalue pushed on stack */
26002619 void vstore(void)
26012620 {
2602− int ft, fc, r, t, size, align, bit_size, bit_pos;
2621+ int ft, r, t, size, align, bit_size, bit_pos;
26032622 GFuncContext gf;
26042623
26052624 ft = vtop[-1].t;
@@ -2614,18 +2633,20 @@ void vstore(void) · 8 unmodified lines
26142633 gfunc_start(&gf);
26152634 /* type size */
26162635 size = type_size(vtop->t, &align);
2617− vset(VT_CONST, size);
2636+ vpushi(size);
26182637 gfunc_param(&gf);
26192638 /* source */
2620− vtop->t &= ~VT_LVAL;
2639+ vtop->t = VT_INT;
2640+ vtop->r &= ~VT_LVAL;
26212641 gfunc_param(&gf);
26222642 /* destination */
26232643 vswap();
2624− vtop->t &= ~VT_LVAL;
2644+ vtop->t = VT_INT;
2645+ vtop->r &= ~VT_LVAL;
26252646 gfunc_param(&gf);
26262647
26272648 save_regs();
2628− vset(VT_CONST, (int)&memcpy);
2649+ vpushi((int)&memcpy);
26292650 gfunc_call(&gf);
26302651 /* leave source on stack */
26312652 } else if (ft & VT_BITFIELD) {
@@ -2640,30 +2661,32 @@ void vstore(void) · 8 unmodified lines
26402661 vtop[-1] = vtop[-2];
26412662
26422663 /* mask and shift source */
2643− vset(VT_CONST, (1 << bit_size) - 1);
2664+ vpushi((1 << bit_size) - 1);
26442665 gen_op('&');
2645− vset(VT_CONST, bit_pos);
2666+ vpushi(bit_pos);
26462667 gen_op(TOK_SHL);
26472668 /* load destination, mask and or with source */
26482669 vswap();
2649− vset(VT_CONST, ~(((1 << bit_size) - 1) << bit_pos));
2670+ vpushi(~(((1 << bit_size) - 1) << bit_pos));
26502671 gen_op('&');
26512672 gen_op('|');
26522673 /* store result */
26532674 vstore();
26542675 } else {
26552676 r = gv(); /* generate value */
2656− ft = vtop[-1].t;
2657− fc = vtop[-1].c.i;
26582677 /* 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;
26602680 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;
26632686 }
2664− store(r, ft, fc);
2687+ store(r, vtop - 1);
26652688 vtop--;
2666− vtop->t = (ft & VT_TYPE) | r;
2689+ vtop->r = r;
26672690 vtop->c.i = 0;
26682691 }
26692692 }
@@ -2672,6 +2695,7 @@ void vstore(void) · 2 unmodified lines
26722695 void inc(int post, int c)
26732696 {
26742697 int r, r1;
2698+ SValue sv;
26752699
26762700 test_lvalue();
26772701 if (post)
@@ -2682,13 +2706,16 @@ void inc(int post, int c) · 4 unmodified lines
26822706 /* duplicate value */
26832707 /* XXX: handle floats */
26842708 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 */
26862713 /* duplicates value */
2687− vtop[-2].t = (vtop->t & VT_TYPE) | r1;
2714+ vtop[-2].r = r1;
26882715 vtop[-2].c.i = 0;
26892716 }
26902717 /* add constant */
2691− vset(VT_CONST, c - TOK_MID);
2718+ vpushi(c - TOK_MID);
26922719 gen_op('+');
26932720 vstore(); /* store value */
26942721 if (post)
@@ -3107,13 +3134,13 @@ Sym *external_sym(int v, int u) · 412 unmodified lines
31073134
31083135 void indir(void)
31093136 {
3110− if (vtop->t & VT_LVAL)
3137+ if (vtop->r & VT_LVAL)
31113138 gv();
31123139 if ((vtop->t & VT_BTYPE) != VT_PTR)
31133140 expect("pointer");
31143141 vtop->t = pointed_type(vtop->t);
31153142 if (!(vtop->t & VT_ARRAY)) /* an array is never an lvalue */
3116− vtop->t |= VT_LVAL;
3143+ vtop->r |= VT_LVAL;
31173144 }
31183145
31193146 /* pass a parameter to a function and do type checking and casting */
@@ -3141,21 +3168,21 @@ void unary(void) · 21 unmodified lines
31413168 GFuncContext gf;
31423169
31433170 if (tok == TOK_NUM || tok == TOK_CCHAR || tok == TOK_LCHAR) {
3144− vset(VT_CONST | VT_INT, tokc.i);
3171+ vpushi(tokc.i);
31453172 next();
31463173 } else if (tok == TOK_CFLOAT) {
3147− vsetc(VT_CONST | VT_FLOAT, &tokc);
3174+ vsetc(VT_FLOAT, VT_CONST, &tokc);
31483175 next();
31493176 } else if (tok == TOK_CDOUBLE) {
3150− vsetc(VT_CONST | VT_DOUBLE, &tokc);
3177+ vsetc(VT_DOUBLE, VT_CONST, &tokc);
31513178 next();
31523179 } else if (tok == TOK_CLDOUBLE) {
3153− vsetc(VT_CONST | VT_LDOUBLE, &tokc);
3180+ vsetc(VT_LDOUBLE, VT_CONST, &tokc);
31543181 next();
31553182 } else if (tok == TOK___FUNC__) {
31563183 /* special function name identifier */
31573184 /* generate (char *) type */
3158− vset(VT_CONST | mk_pointer(VT_BYTE), glo);
3185+ vset(mk_pointer(VT_BYTE), VT_CONST, glo);
31593186 strcpy((void *)glo, funcname);
31603187 glo += strlen(funcname) + 1;
31613188 next();
@@ -3174,7 +3201,7 @@ void unary(void) · 12 unmodified lines
31743201 decl_initializer(t, glo, 1, 0);
31753202 glo += type_size(t, &align);
31763203 /* put it as pointer */
3177− vset(t & ~VT_ARRAY, fc);
3204+ vset(t & ~VT_ARRAY, VT_CONST, fc);
31783205 } else {
31793206 t = tok;
31803207 next();
@@ -3194,7 +3221,7 @@ void unary(void) · 13 unmodified lines
31943221 if (!(ft & VT_ARRAY))
31953222 ft |= VT_LVAL;
31963223 fc = decl_initializer_alloc(ft, 1);
3197− vset(ft, fc);
3224+ vset(ft & VT_TYPE, ft & (VT_VALMASK | VT_LVAL), fc);
31983225 } else {
31993226 unary();
32003227 gen_cast(ft);
@@ -3214,20 +3241,21 @@ void unary(void) · 13 unmodified lines
32143241 there and in function calls. */
32153242 if ((vtop->t & VT_BTYPE) != VT_FUNC)
32163243 test_lvalue();
3217− vtop->t = mk_pointer(vtop->t & VT_LVALN);
3244+ vtop->t = mk_pointer(vtop->t);
3245+ vtop->r &= ~VT_LVAL;
32183246 } else
32193247 if (t == '!') {
32203248 unary();
3221− if ((vtop->t & (VT_VALMASK | VT_LVAL)) == VT_CONST)
3249+ if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST)
32223250 vtop->c.i = !vtop->c.i;
3223− else if ((vtop->t & VT_VALMASK) == VT_CMP)
3251+ else if ((vtop->r & VT_VALMASK) == VT_CMP)
32243252 vtop->c.i = vtop->c.i ^ 1;
32253253 else
3226− vset(VT_JMP, gtst(1, 0));
3254+ vset(VT_INT, VT_JMP, gtst(1, 0));
32273255 } else
32283256 if (t == '~') {
32293257 unary();
3230− vset(VT_CONST, -1);
3258+ vpushi(-1);
32313259 gen_op('^');
32323260 } else
32333261 if (t == '+') {
@@ -3251,13 +3279,13 @@ void unary(void) · 17 unmodified lines
32513279 t = vtop->t;
32523280 vpop();
32533281 }
3254− vset(VT_CONST, type_size(t, &t));
3282+ vpushi(type_size(t, &t));
32553283 } else
32563284 if (t == TOK_INC || t == TOK_DEC) {
32573285 unary();
32583286 inc(0, t);
32593287 } else if (t == '-') {
3260− vset(VT_CONST, 0);
3288+ vpushi(0);
32613289 unary();
32623290 gen_op('-');
32633291 } else
@@ -3273,9 +3301,10 @@ void unary(void) · 9 unmodified lines
32733301 /* int() function */
32743302 s = external_sym(t, VT_FUNC | (p << VT_STRUCT_SHIFT));
32753303 }
3276− vset(s->t, s->c);
3304+ vset(s->t & VT_TYPE,
3305+ s->t & (VT_VALMASK | VT_LVAL | VT_FORWARD), s->c);
32773306 /* if forward reference, we must point to s */
3278− if (vtop->t & VT_FORWARD)
3307+ if (vtop->r & VT_FORWARD)
32793308 vtop->c.sym = s;
32803309 }
32813310 }
@@ -3290,7 +3319,7 @@ void unary(void) · 8 unmodified lines
32903319 if (tok == TOK_ARROW)
32913320 indir();
32923321 test_lvalue();
3293− vtop->t &= VT_LVALN;
3322+ vtop->r &= ~VT_LVAL;
32943323 next();
32953324 /* expect pointer on structure */
32963325 if ((vtop->t & VT_BTYPE) != VT_STRUCT)
@@ -3305,14 +3334,14 @@ void unary(void) · 8 unmodified lines
33053334 if (!s)
33063335 error("field not found");
33073336 /* 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);
33103339 gen_op('+');
33113340 /* change type to field type, and set to lvalue */
3312− vtop->t = (vtop->t & ~VT_TYPE) | s->t;
3341+ vtop->t = s->t;
33133342 /* an array is never an lvalue */
33143343 if (!(vtop->t & VT_ARRAY))
3315− vtop->t |= VT_LVAL;
3344+ vtop->r |= VT_LVAL;
33163345 next();
33173346 } else if (tok == '[') {
33183347 next();
@@ -3321,8 +3350,7 @@ void unary(void) · 2 unmodified lines
33213350 indir();
33223351 skip(']');
33233352 } else if (tok == '(') {
3324− int rett;
3325− CValue retc;
3353+ SValue ret;
33263354 Sym *sa;
33273355
33283356 /* function call */
@@ -3337,7 +3365,7 @@ void unary(void) · 8 unmodified lines
33373365 expect("function pointer");
33383366 }
33393367 } else {
3340− vtop->t &= ~VT_LVAL; /* no lvalue */
3368+ vtop->r &= ~VT_LVAL; /* no lvalue */
33413369 }
33423370 /* get return type */
33433371 s = sym_find((unsigned)vtop->t >> VT_STRUCT_SHIFT);
@@ -3403,15 +3431,17 @@ void unary(void) · 59 unmodified lines
34033431 /* get some space for the returned structure */
34043432 size = type_size(s->t, &align);
34053433 loc = (loc - size) & -align;
3406− rett = s->t | VT_LOCAL | VT_LVAL;
3434+ ret.t = s->t;
3435+ ret.r = VT_LOCAL | VT_LVAL;
34073436 /* pass it as 'int' to avoid structure arg passing
34083437 problems */
3409− vset(VT_INT | VT_LOCAL, loc);
3410− retc = vtop->c;
3438+ vset(VT_INT, VT_LOCAL, loc);
3439+ ret.c = vtop->c;
34113440 gfunc_param(&gf);
34123441 } 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;
34153445 }
34163446 #ifndef INVERT_FUNC_PARAMS
34173447 while (tok != ')') {
@@ -3428,7 +3458,7 @@ void unary(void) · 10 unmodified lines
34283458 skip(')');
34293459 gfunc_call(&gf);
34303460 /* return value */
3431− vsetc(rett, &retc);
3461+ vsetc(ret.t, ret.r, &ret.c);
34323462 } else {
34333463 break;
34343464 }
@@ -3496,7 +3526,7 @@ void eand(void) · 61 unmodified lines
34963526 if (tok != TOK_LAND) {
34973527 if (t) {
34983528 t = gtst(1, t);
3499− vset(VT_JMPI, t);
3529+ vset(VT_INT, VT_JMPI, t);
35003530 }
35013531 break;
35023532 }
@@ -3516,7 +3546,7 @@ void eor(void) · 13 unmodified lines
35163546 if (tok != TOK_LOR) {
35173547 if (t) {
35183548 t = gtst(0, t);
3519− vset(VT_JMP, t);
3549+ vset(VT_INT, VT_JMP, t);
35203550 }
35213551 break;
35223552 }
@@ -3561,7 +3591,7 @@ void expr_eq(void) · 38 unmodified lines
35613591 expr_eq();
35623592 r2 = gv();
35633593 move_reg(r1, r2);
3564− vtop->t = (vtop->t & VT_TYPE) | r1;
3594+ vtop->r = r1;
35653595 gsym(u);
35663596 }
35673597 }
@@ -3585,7 +3615,7 @@ void expr_const1(void) · 17 unmodified lines
35853615 a = const_wanted;
35863616 const_wanted = 1;
35873617 expr_eq();
3588− if ((vtop->t & (VT_CONST | VT_LVAL)) != VT_CONST)
3618+ if ((vtop->r & (VT_VALMASK | VT_LVAL)) != VT_CONST)
35893619 expect("constant");
35903620 const_wanted = a;
35913621 }
@@ -3680,7 +3710,7 @@ void block(int *bsym, int *csym, int *case_sym, int *def_sym, int case_reg) · 88 unmodified lines
36803710 if ((func_vt & VT_BTYPE) == VT_STRUCT) {
36813711 /* if returning structure, must copy it to implicit
36823712 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);
36843714 indir();
36853715 vswap();
36863716 /* 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
37853815 /* since a case is like a label, we must skip it with a jmp */
37863816 b = gjmp(0);
37873817 gsym(*case_sym);
3788− vset(case_reg, 0);
3789− vset(VT_CONST, a);
3818+ vset(VT_INT, case_reg, 0);
3819+ vpushi(a);
37903820 gen_op(TOK_EQ);
37913821 *case_sym = gtst(1, 0);
37923822 gsym(b);
@@ -3936,7 +3966,7 @@ void init_putv(int t, int c, int v, int is_expr) · 143 unmodified lines
39363966 expr_const1();
39373967 global_expr = saved_global_expr;
39383968 } else {
3939− vset(VT_CONST | VT_INT, v);
3969+ vpushi(v);
39403970 }
39413971 /* XXX: do casting */
39423972 /* XXX: not portable */
@@ -3965,11 +3995,11 @@ void init_putv(int t, int c, int v, int is_expr) · 22 unmodified lines
39653995 }
39663996 vpop();
39673997 } else {
3968− vset(t, c);
3998+ vset(t & VT_TYPE, t & (VT_VALMASK | VT_LVAL | VT_FORWARD), c);
39693999 if (is_expr)
39704000 expr_eq();
39714001 else
3972− vset(VT_CONST | VT_INT, v);
4002+ vpushi(v);
39734003 vstore();
39744004 vpop();
39754005 }
@@ -3984,13 +4014,13 @@ void init_putz(int t, int c, int size) · 8 unmodified lines
39844014 /* nothing to do because global are already set to zero */
39854015 } else {
39864016 gfunc_start(&gf);
3987− vset(VT_CONST, size);
4017+ vpushi(size);
39884018 gfunc_param(&gf);
3989− vset(VT_CONST, 0);
4019+ vpushi(0);
39904020 gfunc_param(&gf);
3991− vset(VT_LOCAL, c);
4021+ vset(VT_INT, VT_LOCAL, c);
39924022 gfunc_param(&gf);
3993− vset(VT_CONST, (int)&memset);
4023+ vpushi((int)&memset);
39944024 gfunc_call(&gf);
39954025 }
39964026 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t