tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] CValue


From: Edmund Grimley Evans
Subject: Re: [Tinycc-devel] CValue
Date: Sun, 8 Mar 2015 20:43:42 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

In case anyone else wants to play with this or test it on another
architecture. Please do, if you can.

I first changed the code using a one-line "perl -i" command, and was
surprised to find that most of the tests still passed after that. I
then fiddled around to make all the tests pass on arm64. I haven't
tested on other architectures, but it was at least possible to build
the cross compilers on i386.

If you're reading the diff, start by looking at what changed in tcc.h.
Everything else follows from that.


From: Edmund Grimley Evans <address@hidden>
Date: Sun, 8 Mar 2015 20:31:52 +0000
Subject: [PATCH] First attempt at merging all integer members of CValue.

In this patch they have all been replaced by "uint64_t ii" as that
makes it easier to find the affected code. A real commit would
probably use "uint64_t i" to reduce the number of changes.
---
 arm-gen.c    |   50 ++++++++++----------
 arm64-gen.c  |   20 +++-----
 c67-gen.c    |   17 ++++---
 i386-asm.c   |   12 ++---
 i386-gen.c   |   36 +++++++-------
 il-gen.c     |   14 +++---
 tcc.h        |    7 +--
 tccasm.c     |    2 +-
 tccgen.c     |  150 +++++++++++++++++++++++++++++-----------------------------
 tccpe.c      |    4 +-
 tccpp.c      |   30 ++++++------
 x86_64-gen.c |   52 ++++++++++----------
 12 files changed, 193 insertions(+), 201 deletions(-)

diff --git a/arm-gen.c b/arm-gen.c
index 3bb5326..d3b396f 100644
--- a/arm-gen.c
+++ b/arm-gen.c
@@ -528,7 +528,7 @@ void load(int r, SValue *sv)
 
   fr = sv->r;
   ft = sv->type.t;
-  fc = sv->c.ul;
+  fc = sv->c.ii;
 
   if(fc>=0)
     sign=0;
@@ -543,14 +543,14 @@ void load(int r, SValue *sv)
     if(v == VT_LLOCAL) {
       v1.type.t = VT_PTR;
       v1.r = VT_LOCAL | VT_LVAL;
-      v1.c.ul = sv->c.ul;
+      v1.c.ii = sv->c.ii;
       load(base=14 /* lr */, &v1);
       fc=sign=0;
       v=VT_LOCAL;
     } else if(v == VT_CONST) {
       v1.type.t = VT_PTR;
       v1.r = fr&~VT_LVAL;
-      v1.c.ul = sv->c.ul;
+      v1.c.ii = sv->c.ii;
       v1.sym=sv->sym;
       load(base=14, &v1);
       fc=sign=0;
@@ -609,38 +609,38 @@ void load(int r, SValue *sv)
     }
   } else {
     if (v == VT_CONST) {
-      op=stuff_const(0xE3A00000|(intr(r)<<12),sv->c.ul);
+      op=stuff_const(0xE3A00000|(intr(r)<<12),sv->c.ii);
       if (fr & VT_SYM || !op) {
         o(0xE59F0000|(intr(r)<<12));
         o(0xEA000000);
         if(fr & VT_SYM)
          greloc(cur_text_section, sv->sym, ind, R_ARM_ABS32);
-        o(sv->c.ul);
+        o(sv->c.ii);
       } else
         o(op);
       return;
     } else if (v == VT_LOCAL) {
-      op=stuff_const(0xE28B0000|(intr(r)<<12),sv->c.ul);
+      op=stuff_const(0xE28B0000|(intr(r)<<12),sv->c.ii);
       if (fr & VT_SYM || !op) {
        o(0xE59F0000|(intr(r)<<12));
        o(0xEA000000);
        if(fr & VT_SYM) // needed ?
          greloc(cur_text_section, sv->sym, ind, R_ARM_ABS32);
-       o(sv->c.ul);
+       o(sv->c.ii);
        o(0xE08B0000|(intr(r)<<12)|intr(r));
       } else
        o(op);
       return;
     } else if(v == VT_CMP) {
-      o(mapcc(sv->c.ul)|0x3A00001|(intr(r)<<12));
-      o(mapcc(negcc(sv->c.ul))|0x3A00000|(intr(r)<<12));
+      o(mapcc(sv->c.ii)|0x3A00001|(intr(r)<<12));
+      o(mapcc(negcc(sv->c.ii))|0x3A00000|(intr(r)<<12));
       return;
     } else if (v == VT_JMP || v == VT_JMPI) {
       int t;
       t = v & 1;
       o(0xE3A00000|(intr(r)<<12)|t);
       o(0xEA000000);
-      gsym(sv->c.ul);
+      gsym(sv->c.ii);
       o(0xE3A00000|(intr(r)<<12)|(t^1));
       return;
     } else if (v < VT_CONST) {
@@ -667,7 +667,7 @@ void store(int r, SValue *sv)
 
   fr = sv->r;
   ft = sv->type.t;
-  fc = sv->c.ul;
+  fc = sv->c.ii;
 
   if(fc>=0)
     sign=0;
@@ -686,7 +686,7 @@ void store(int r, SValue *sv)
     } else if(v == VT_CONST) {
       v1.type.t = ft;
       v1.r = fr&~VT_LVAL;
-      v1.c.ul = sv->c.ul;
+      v1.c.ii = sv->c.ii;
       v1.sym=sv->sym;
       load(base=14, &v1);
       fc=sign=0;
@@ -751,7 +751,7 @@ static void gcall_or_jmp(int is_jmp)
   if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
     uint32_t x;
     /* constant case */
-    x=encbranch(ind,ind+vtop->c.ul,0);
+    x=encbranch(ind,ind+vtop->c.ii,0);
     if(x) {
       if (vtop->r & VT_SYM) {
        /* relocation case */
@@ -765,7 +765,7 @@ static void gcall_or_jmp(int is_jmp)
       o(0xE51FF004);   // ldr pc,[pc,#-4]
       if (vtop->r & VT_SYM)
        greloc(cur_text_section, vtop->sym, ind, R_ARM_ABS32);
-      o(vtop->c.ul);
+      o(vtop->c.ii);
     }
   } else {
     /* otherwise, indirect call */
@@ -1419,19 +1419,19 @@ int gtst(int inv, int t)
   v = vtop->r & VT_VALMASK;
   r=ind;
   if (v == VT_CMP) {
-    op=mapcc(inv?negcc(vtop->c.i):vtop->c.i);
+    op=mapcc(inv?negcc(vtop->c.ii):vtop->c.ii);
     op|=encbranch(r,t,1);
     o(op);
     t=r;
   } else if (v == VT_JMP || v == VT_JMPI) {
     if ((v & 1) == inv) {
-      if(!vtop->c.i)
-       vtop->c.i=t;
+      if(!vtop->c.ii)
+       vtop->c.ii=t;
       else {
        uint32_t *x;
        int p,lp;
        if(t) {
-          p = vtop->c.i;
+          p = vtop->c.ii;
           do {
            p = decbranch(lp=p);
           } while(p);
@@ -1439,11 +1439,11 @@ int gtst(int inv, int t)
          *x &= 0xff000000;
          *x |= encbranch(lp,t,1);
        }
-       t = vtop->c.i;
+       t = vtop->c.ii;
       }
     } else {
       t = gjmp(t);
-      gsym(vtop->c.i);
+      gsym(vtop->c.ii);
     }
   }
   vtop--;
@@ -1571,7 +1571,7 @@ void gen_opi(int op)
       opc=0xE0000000|(opc<<20)|(c<<16);
       if((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
        uint32_t x;
-       x=stuff_const(opc|0x2000000,vtop->c.i);
+       x=stuff_const(opc|0x2000000,vtop->c.ii);
        if(x) {
          r=intr(vtop[-1].r=get_reg_ex(RC_INT,regmask(vtop[-1].r)));
          o(x|(r<<12));
@@ -1585,7 +1585,7 @@ done:
       vtop--;
       if (op >= TOK_ULT && op <= TOK_GT) {
         vtop->r = VT_CMP;
-        vtop->c.i = op;
+        vtop->c.ii = op;
       }
       break;
     case 2:
@@ -1599,7 +1599,7 @@ done:
       opc|=r;
       if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
        fr=intr(vtop[-1].r=get_reg_ex(RC_INT,regmask(vtop[-1].r)));
-       c = vtop->c.i & 0x1f;
+       c = vtop->c.ii & 0x1f;
        o(opc|(c<<7)|(fr<<12));
       } else {
         fr=intr(gv(RC_INT));
@@ -1704,7 +1704,7 @@ void gen_opf(int op)
       }
 
       vtop->r = VT_CMP;
-      vtop->c.i = op;
+      vtop->c.ii = op;
       return;
   }
   r=gv(RC_FLOAT);
@@ -1907,7 +1907,7 @@ void gen_opf(int op)
          r2=fpr(gv(RC_FLOAT));
        }
        vtop[-1].r = VT_CMP;
-       vtop[-1].c.i = op;
+       vtop[-1].c.ii = op;
       } else {
         tcc_error("unknown fp op %x!",op);
        return;
diff --git a/arm64-gen.c b/arm64-gen.c
index 3581e5d..8cc7b05 100644
--- a/arm64-gen.c
+++ b/arm64-gen.c
@@ -458,7 +458,7 @@ ST_FUNC void load(int r, SValue *sv)
     int svtt = sv->type.t;
     int svr = sv->r & ~VT_LVAL_TYPE;
     int svrv = svr & VT_VALMASK;
-    uint64_t svcul = (int32_t)sv->c.ul;
+    uint64_t svcul = (int32_t)sv->c.ii;
 
     if (svr == (VT_LOCAL | VT_LVAL)) {
         if (IS_FREG(r))
@@ -496,7 +496,7 @@ ST_FUNC void load(int r, SValue *sv)
     if (svr == VT_CONST) {
         if ((svtt & VT_BTYPE) != VT_VOID)
             arm64_movimm(intr(r), arm64_type_size(svtt) == 3 ?
-                         sv->c.ull : (uint32_t)svcul);
+                         sv->c.ii : (uint32_t)svcul);
         return;
     }
 
@@ -552,7 +552,7 @@ ST_FUNC void store(int r, SValue *sv)
     int svtt = sv->type.t;
     int svr = sv->r & ~VT_LVAL_TYPE;
     int svrv = svr & VT_VALMASK;
-    uint64_t svcul = (int32_t)sv->c.ul;
+    uint64_t svcul = (int32_t)sv->c.ii;
 
     if (svr == (VT_LOCAL | VT_LVAL)) {
         if (IS_FREG(r))
@@ -1336,16 +1336,10 @@ static int arm64_iconst(uint64_t *val, SValue *sv)
     if ((sv->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
         return 0;
     if (val) {
-        int t = sv->type.t & (VT_BTYPE | VT_UNSIGNED);
-        // It's crazy how TCC has all these alternatives for storing a value:
-        if (t == (VT_LLONG | VT_UNSIGNED))
-            *val = sv->c.ull;
-        else if (t == VT_LLONG)
-            *val = sv->c.ll;
-        else if (t & VT_UNSIGNED)
-            *val = sv->c.ui;
-        else
-            *val = sv->c.i;
+        int t = sv->type.t;
+        *val = ((t & VT_BTYPE) == VT_LLONG ? sv->c.ii :
+                (uint32_t)sv->c.ii |
+                (t & VT_UNSIGNED ? 0 : -(sv->c.ii & 0x80000000)));
     }
     return 1;
 }
diff --git a/c67-gen.c b/c67-gen.c
index 5a6fd56..6ddd92b 100644
--- a/c67-gen.c
+++ b/c67-gen.c
@@ -1567,14 +1567,14 @@ void load(int r, SValue * sv)
 
     fr = sv->r;
     ft = sv->type.t;
-    fc = sv->c.ul;
+    fc = sv->c.ii;
 
     v = fr & VT_VALMASK;
     if (fr & VT_LVAL) {
        if (v == VT_LLOCAL) {
            v1.type.t = VT_INT;
            v1.r = VT_LOCAL | VT_LVAL;
-           v1.c.ul = fc;
+           v1.c.ii = fc;
            load(r, &v1);
            fr = r;
        } else if ((ft & VT_BTYPE) == VT_LDOUBLE) {
@@ -1726,7 +1726,7 @@ void store(int r, SValue * v)
     int fr, bt, ft, fc, size, t, element;
 
     ft = v->type.t;
-    fc = v->c.ul;
+    fc = v->c.ii;
     fr = v->r & VT_VALMASK;
     bt = ft & VT_BTYPE;
     /* XXX: incorrect if float reg to reg */
@@ -2106,13 +2106,12 @@ int gtst(int inv, int t)
        /* && or || optimization */
        if ((v & 1) == inv) {
            /* insert vtop->c jump list in t */
-           p = &vtop->c.i;
 
            // I guess the idea is to traverse to the
            // null at the end of the list and store t
            // there
 
-           n = *p;
+           n = vtop->c.ii;
            while (n != 0) {
                p = (int *) (cur_text_section->data + n);
 
@@ -2122,11 +2121,11 @@ int gtst(int inv, int t)
            }
            *p |= (t & 0xffff) << 7;
            *(p + 1) |= ((t >> 16) & 0xffff) << 7;
-           t = vtop->c.i;
+           t = vtop->c.ii;
 
        } else {
            t = gjmp(t);
-           gsym(vtop->c.i);
+           gsym(vtop->c.ii);
        }
     }
     vtop--;
@@ -2207,7 +2206,7 @@ void gen_opi(int op)
        vtop--;
        if (op >= TOK_ULT && op <= TOK_GT) {
            vtop->r = VT_CMP;
-           vtop->c.i = op;
+           vtop->c.ii = op;
        }
        break;
     case '-':
@@ -2304,7 +2303,7 @@ void gen_opf(int op)
        gv2(RC_FLOAT, RC_FLOAT);        // make sure src2 is on b side
 
     ft = vtop->type.t;
-    fc = vtop->c.ul;
+    fc = vtop->c.ii;
     r = vtop->r;
     fr = vtop[-1].r;
 
diff --git a/i386-asm.c b/i386-asm.c
index a524658..62c13fd 100644
--- a/i386-asm.c
+++ b/i386-asm.c
@@ -1301,19 +1301,19 @@ ST_FUNC void subst_asm_operand(CString *add_str,
             cstr_ccat(add_str, '$');
         if (r & VT_SYM) {
             cstr_cat(add_str, get_tok_str(sv->sym->v, NULL));
-            if (sv->c.i != 0) {
+            if ((uint32_t)sv->c.ii != 0) {
                 cstr_ccat(add_str, '+');
             } else {
                 return;
             }
         }
-        val = sv->c.i;
+        val = sv->c.ii;
         if (modifier == 'n')
             val = -val;
-        snprintf(buf, sizeof(buf), "%d", sv->c.i);
+        snprintf(buf, sizeof(buf), "%d", (int)sv->c.ii);
         cstr_cat(add_str, buf);
     } else if ((r & VT_VALMASK) == VT_LOCAL) {
-        snprintf(buf, sizeof(buf), "%d(%%ebp)", sv->c.i);
+        snprintf(buf, sizeof(buf), "%d(%%ebp)", (int)sv->c.ii);
         cstr_cat(add_str, buf);
     } else if (r & VT_LVAL) {
         reg = r & VT_VALMASK;
@@ -1431,7 +1431,7 @@ ST_FUNC void asm_gen_code(ASMOperand *operands, int 
nb_operands,
                     if (op->is_llong) {
                         SValue sv;
                         sv = *op->vt;
-                        sv.c.ul += 4;
+                        sv.c.ii += 4;
                         load(TREG_XDX, &sv);
                     }
                 }
@@ -1457,7 +1457,7 @@ ST_FUNC void asm_gen_code(ASMOperand *operands, int 
nb_operands,
                     if (op->is_llong) {
                         SValue sv;
                         sv = *op->vt;
-                        sv.c.ul += 4;
+                        sv.c.ii += 4;
                         store(TREG_XDX, &sv);
                     }
                 }
diff --git a/i386-gen.c b/i386-gen.c
index 9bdf998..5d02aea 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -222,14 +222,14 @@ ST_FUNC void load(int r, SValue *sv)
 
     fr = sv->r;
     ft = sv->type.t;
-    fc = sv->c.ul;
+    fc = sv->c.ii;
 
     v = fr & VT_VALMASK;
     if (fr & VT_LVAL) {
         if (v == VT_LLOCAL) {
             v1.type.t = VT_INT;
             v1.r = VT_LOCAL | VT_LVAL;
-            v1.c.ul = fc;
+            v1.c.ii = fc;
             fr = r;
             if (!(reg_classes[fr] & RC_INT))
                 fr = get_reg(RC_INT);
@@ -297,7 +297,7 @@ ST_FUNC void store(int r, SValue *v)
 #endif
 
     ft = v->type.t;
-    fc = v->c.ul;
+    fc = v->c.ii;
     fr = v->r & VT_VALMASK;
     bt = ft & VT_BTYPE;
     /* XXX: incorrect if float reg to reg */
@@ -362,7 +362,7 @@ static void gcall_or_jmp(int is_jmp)
             put_elf_reloc(symtab_section, cur_text_section, 
                           ind + 1, R_386_PC32, 0);
         }
-        oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */
+        oad(0xe8 + is_jmp, vtop->c.ii - 4); /* call/jmp im */
     } else {
         /* otherwise, indirect call */
         r = gv(RC_INT);
@@ -670,25 +670,27 @@ ST_FUNC void gjmp_addr(int a)
 /* generate a test. set 'inv' to invert test. Stack entry is popped */
 ST_FUNC int gtst(int inv, int t)
 {
-    int v, *p;
+    int v, t1, *p;
 
     v = vtop->r & VT_VALMASK;
     if (v == VT_CMP) {
         /* fast case : can jump directly since flags are set */
         g(0x0f);
-        t = psym((vtop->c.i - 16) ^ inv, t);
+        t = psym((vtop->c.ii - 16) ^ inv, t);
     } else if (v == VT_JMP || v == VT_JMPI) {
         /* && or || optimization */
         if ((v & 1) == inv) {
             /* insert vtop->c jump list in t */
-            p = &vtop->c.i;
+            t1 = vtop->c.ii;
+            p = &t1;
             while (*p != 0)
                 p = (int *)(cur_text_section->data + *p);
             *p = t;
-            t = vtop->c.i;
+            vtop->c.ii = t1;
+            t = t1;
         } else {
             t = gjmp(t);
-            gsym(vtop->c.i);
+            gsym(vtop->c.ii);
         }
     }
     vtop--;
@@ -710,7 +712,7 @@ ST_FUNC void gen_opi(int op)
             vswap();
             r = gv(RC_INT);
             vswap();
-            c = vtop->c.i;
+            c = vtop->c.ii;
             if (c == (char)c) {
                 /* generate inc and dec for smaller code */
                 if (c==1 && opc==0) {
@@ -736,7 +738,7 @@ ST_FUNC void gen_opi(int op)
         vtop--;
         if (op >= TOK_ULT && op <= TOK_GT) {
             vtop->r = VT_CMP;
-            vtop->c.i = op;
+            vtop->c.ii = op;
         }
         break;
     case '-':
@@ -781,7 +783,7 @@ ST_FUNC void gen_opi(int op)
             vswap();
             r = gv(RC_INT);
             vswap();
-            c = vtop->c.i & 0x1f;
+            c = vtop->c.ii & 0x1f;
             o(0xc1); /* shl/shr/sar $xxx, r */
             o(opc | r);
             g(c);
@@ -894,7 +896,7 @@ ST_FUNC void gen_opf(int op)
         }
         vtop--;
         vtop->r = VT_CMP;
-        vtop->c.i = op;
+        vtop->c.ii = op;
     } else {
         /* no memory reference possible for long double operations */
         if ((vtop->type.t & VT_BTYPE) == VT_LDOUBLE) {
@@ -922,7 +924,7 @@ ST_FUNC void gen_opf(int op)
             break;
         }
         ft = vtop->type.t;
-        fc = vtop->c.ul;
+        fc = vtop->c.ii;
         if ((ft & VT_BTYPE) == VT_LDOUBLE) {
             o(0xde); /* fxxxp %st, %st(1) */
             o(0xc1 + (a << 3));
@@ -934,7 +936,7 @@ ST_FUNC void gen_opf(int op)
                 r = get_reg(RC_INT);
                 v1.type.t = VT_INT;
                 v1.r = VT_LOCAL | VT_LVAL;
-                v1.c.ul = fc;
+                v1.c.ii = fc;
                 load(r, &v1);
                 fc = 0;
             }
@@ -1050,7 +1052,7 @@ ST_FUNC void gen_bounded_ptr_add(void)
     vtop++;
     vtop->r = TREG_EAX | VT_BOUNDED;
     /* address of bounding function call point */
-    vtop->c.ul = (cur_text_section->reloc->data_offset - sizeof(Elf32_Rel)); 
+    vtop->c.ii = (cur_text_section->reloc->data_offset - sizeof(Elf32_Rel));
 }
 
 /* patch pointer addition in vtop so that pointer dereferencing is
@@ -1087,7 +1089,7 @@ ST_FUNC void gen_bounded_ptr_deref(void)
 
     /* patch relocation */
     /* XXX: find a better solution ? */
-    rel = (Elf32_Rel *)(cur_text_section->reloc->data + vtop->c.ul);
+    rel = (Elf32_Rel *)(cur_text_section->reloc->data + vtop->c.ii);
     sym = external_global_sym(func, &func_old_type, 0);
     if (!sym->c)
         put_extern_sym(sym, NULL, 0, 0);
diff --git a/il-gen.c b/il-gen.c
index cf3aff5..e64081e 100644
--- a/il-gen.c
+++ b/il-gen.c
@@ -258,7 +258,7 @@ void load(int r, SValue *sv)
     int v, fc, ft;
 
     v = sv->r & VT_VALMASK;
-    fc = sv->c.i;
+    fc = sv->c.ii;
     ft = sv->t;
 
     if (sv->r & VT_LVAL) {
@@ -337,7 +337,7 @@ void store(int r, SValue *sv)
     int v, fc, ft;
 
     v = sv->r & VT_VALMASK;
-    fc = sv->c.i;
+    fc = sv->c.ii;
     ft = sv->t;
     if (v == VT_LOCAL) {
         if (fc >= ARG_BASE) {
@@ -482,7 +482,7 @@ int gtst(int inv, int t)
 
     v = vtop->r & VT_VALMASK;
     if (v == VT_CMP) {
-        c = vtop->c.i ^ inv;
+        c = vtop->c.ii ^ inv;
         switch(c) {
         case TOK_EQ:
             c = IL_OP_BEQ;
@@ -520,14 +520,14 @@ int gtst(int inv, int t)
         /* && or || optimization */
         if ((v & 1) == inv) {
             /* insert vtop->c jump list in t */
-            p = &vtop->c.i;
+            p = &vtop->c.ii;
             while (*p != 0)
                 p = (int *)*p;
             *p = t;
-            t = vtop->c.i;
+            t = vtop->c.ii;
         } else {
             t = gjmp(t);
-            gsym(vtop->c.i);
+            gsym(vtop->c.ii);
         }
     }
     vtop--;
@@ -594,7 +594,7 @@ void gen_opi(int op)
     case TOK_UGE:
         vtop--;
         vtop[0].r = VT_CMP;
-        vtop[0].c.i = op;
+        vtop[0].c.ii = op;
         break;
     }
 }
diff --git a/tcc.h b/tcc.h
index 7d53b9b..59a4ab3 100644
--- a/tcc.h
+++ b/tcc.h
@@ -358,13 +358,8 @@ typedef union CValue {
     long double ld;
     double d;
     float f;
-    int i;
-    unsigned int ui;
-    unsigned int ul; /* address (should be unsigned long on 64 bit cpu) */
-    long long ll;
-    unsigned long long ull;
+    uint64_t ii;
     struct CString *cstr;
-    addr_t ptr_offset;
     int tab[LDOUBLE_SIZE/4];
 } CValue;
 
diff --git a/tccasm.c b/tccasm.c
index d9c929c..1abb241 100644
--- a/tccasm.c
+++ b/tccasm.c
@@ -92,7 +92,7 @@ static void asm_expr_unary(TCCState *s1, ExprValue *pe)
         break;
     case TOK_CCHAR:
     case TOK_LCHAR:
-       pe->v = tokc.i;
+       pe->v = tokc.ii;
        pe->sym = NULL;
        next();
        break;
diff --git a/tccgen.c b/tccgen.c
index 52541e2..2b2d3fc 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -364,7 +364,7 @@ ST_FUNC void vpush(CType *type)
 ST_FUNC void vpushi(int v)
 {
     CValue cval;
-    cval.i = v;
+    cval.ii = v;
     vsetc(&int_type, VT_CONST, &cval);
 }
 
@@ -372,7 +372,7 @@ ST_FUNC void vpushi(int v)
 static void vpushs(addr_t v)
 {
   CValue cval;
-  cval.ptr_offset = v;
+  cval.ii = v;
   vsetc(&size_type, VT_CONST, &cval);
 }
 
@@ -383,7 +383,7 @@ ST_FUNC void vpush64(int ty, unsigned long long v)
     CType ctype;
     ctype.t = ty;
     ctype.ref = NULL;
-    cval.ull = v;
+    cval.ii = v;
     vsetc(&ctype, VT_CONST, &cval);
 }
 
@@ -397,7 +397,7 @@ static inline void vpushll(long long v)
 static inline void vpushsym(CType *type, Sym *sym)
 {
     CValue cval;
-    cval.ptr_offset = 0;
+    cval.ii = 0;
     vsetc(type, VT_CONST | VT_SYM, &cval);
     vtop->sym = sym;
 }
@@ -478,7 +478,7 @@ ST_FUNC void vset(CType *type, int r, int v)
 {
     CValue cval;
 
-    cval.i = v;
+    cval.ii = v;
     vsetc(type, r, &cval);
 }
 
@@ -554,7 +554,7 @@ ST_FUNC void save_reg(int r)
                 loc = (loc - size) & -align;
                 sv.type.t = type->t;
                 sv.r = VT_LOCAL | VT_LVAL;
-                sv.c.ul = loc;
+                sv.c.ii = loc;
                 store(r, &sv);
 #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
                 /* x86 specific: need to pop fp register ST0 if saved */
@@ -565,7 +565,7 @@ ST_FUNC void save_reg(int r)
 #if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
                 /* special long long case */
                 if ((type->t & VT_BTYPE) == VT_LLONG) {
-                    sv.c.ul += 4;
+                    sv.c.ii += 4;
                     store(p->r2, &sv);
                 }
 #endif
@@ -576,13 +576,13 @@ ST_FUNC void save_reg(int r)
             if (p->r & VT_LVAL) {
                 /* also clear the bounded flag because the
                    relocation address of the function was stored in
-                   p->c.ul */
+                   p->c.ii */
                 p->r = (p->r & ~(VT_VALMASK | VT_BOUNDED)) | VT_LLOCAL;
             } else {
                 p->r = lvalue_type(p->type.t) | VT_LOCAL;
             }
             p->r2 = VT_CONST;
-            p->c.ul = l;
+            p->c.ii = l;
         }
     }
 }
@@ -675,7 +675,7 @@ static void move_reg(int r, int s, int t)
         sv.type.t = t;
         sv.type.ref = NULL;
         sv.r = s;
-        sv.c.ul = 0;
+        sv.c.ii = 0;
         load(r, &sv);
     }
 }
@@ -794,7 +794,7 @@ ST_FUNC int gv(int rc)
             sym = get_sym_ref(&vtop->type, data_section, offset, size << 2);
             vtop->r |= VT_LVAL | VT_SYM;
             vtop->sym = sym;
-            vtop->c.ptr_offset = 0;
+            vtop->c.ii = 0;
         }
 #ifdef CONFIG_TCC_BCHECK
         if (vtop->r & VT_MUSTBOUND) 
@@ -843,8 +843,8 @@ ST_FUNC int gv(int rc)
 #if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
                 if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
                     /* load constant */
-                    ll = vtop->c.ull;
-                    vtop->c.ui = ll; /* first word */
+                    ll = vtop->c.ii;
+                    vtop->c.ii = ll; /* first word */
                     load(r, vtop);
                     vtop->r = r; /* save register value */
                     vpushi(ll >> 32); /* second word */
@@ -1005,11 +1005,11 @@ ST_FUNC void lexpand_nr(void)
     vtop->type.t = VT_INT | u;
     v=vtop[-1].r & (VT_VALMASK | VT_LVAL);
     if (v == VT_CONST) {
-      vtop[-1].c.ui = vtop->c.ull;
-      vtop->c.ui = vtop->c.ull >> 32;
+      vtop[-1].c.ii = vtop->c.ii;
+      vtop->c.ii = vtop->c.ii >> 32;
       vtop->r = VT_CONST;
     } else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) {
-      vtop->c.ui += 4;
+      vtop->c.ii += 4;
       vtop->r = vtop[-1].r;
     } else if (v > VT_CONST) {
       vtop--;
@@ -1079,7 +1079,7 @@ ST_FUNC void vpop(void)
 #endif
     if (v == VT_JMP || v == VT_JMPI) {
         /* need to put correct jump if && or || without test */
-        gsym(vtop->c.ul);
+        gsym(vtop->c.ii);
     }
     vtop--;
 }
@@ -1122,7 +1122,7 @@ static void gv_dup(void)
         r = gv(rc);
         r1 = get_reg(rc);
         sv.r = r;
-        sv.c.ul = 0;
+        sv.c.ii = 0;
         load(r1, &sv); /* move r to r1 */
         vdup();
         /* duplicates value */
@@ -1143,7 +1143,7 @@ ST_FUNC int gvtst(int inv, int t)
     }
     if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
         /* constant jmp optimization */
-        if ((vtop->c.i != 0) != inv)
+        if ((vtop->c.ii != 0) != inv)
             t = gjmp(t);
         vtop--;
         return t;
@@ -1260,7 +1260,7 @@ static void gen_opl(int op)
             lexpand();
             vrotb(3);
             /* stack: L H shift */
-            c = (int)vtop->c.i;
+            c = (int)vtop->c.ii;
             /* constant: simpler */
             /* NOTE: all comments are for SHL. the other cases are
                done by swaping words */
@@ -1402,19 +1402,15 @@ static void gen_opic(int op)
     t1 = v1->type.t & VT_BTYPE;
     t2 = v2->type.t & VT_BTYPE;
 
-    if (t1 == VT_LLONG)
-        l1 = v1->c.ll;
-    else if (v1->type.t & VT_UNSIGNED)
-        l1 = v1->c.ui;
-    else
-        l1 = v1->c.i;
+    l1 = v1->c.ii;
+    if (t1 != VT_LLONG)
+        l1 = ((uint32_t)l1 |
+              (v1->type.t & VT_UNSIGNED ? 0 : -(l1 & 0x80000000)));
 
-    if (t2 == VT_LLONG)
-        l2 = v2->c.ll;
-    else if (v2->type.t & VT_UNSIGNED)
-        l2 = v2->c.ui;
-    else
-        l2 = v2->c.i;
+    l2 = v2->c.ii;
+    if (t2 != VT_LLONG)
+        l2 = ((uint32_t)l2 |
+              (v2->type.t & VT_UNSIGNED ? 0 : -(l2 & 0x80000000)));
 
     /* currently, we cannot do computations with forward symbols */
     c1 = (v1->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
@@ -1466,7 +1462,7 @@ static void gen_opic(int op)
         default:
             goto general_case;
         }
-        v1->c.ll = l1;
+        v1->c.ii = l1;
         vtop--;
     } else {
         /* if commutative ops, put c2 as constant */
@@ -1489,7 +1485,7 @@ static void gen_opic(int op)
                           (l2 == 1 && (op == '%' || op == TOK_UMOD)))) {
             /* treat (x & 0), (x * 0), (x | -1) and (x % 1) as constant */
             if (l2 == 1)
-                vtop->c.ll = 0;
+                vtop->c.ii = 0;
             vswap();
             vtop--;
         } else if (c2 && (((op == '*' || op == '/' || op == TOK_UDIV ||
@@ -1510,7 +1506,7 @@ static void gen_opic(int op)
                     l2 >>= 1;
                     n++;
                 }
-                vtop->c.ll = n;
+                vtop->c.ii = n;
                 if (op == '*')
                     op = TOK_SHL;
                 else if (op == TOK_PDIV)
@@ -1526,7 +1522,7 @@ static void gen_opic(int op)
             if (op == '-')
                 l2 = -l2;
             vtop--;
-            vtop->c.ll += l2;
+            vtop->c.ii += l2;
         } else {
         general_case:
             if (!nocode_wanted) {
@@ -1623,9 +1619,10 @@ static inline int is_null_pointer(SValue *p)
 {
     if ((p->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
         return 0;
-    return ((p->type.t & VT_BTYPE) == VT_INT && p->c.i == 0) ||
-        ((p->type.t & VT_BTYPE) == VT_LLONG && p->c.ll == 0) ||
-       ((p->type.t & VT_BTYPE) == VT_PTR && p->c.ptr_offset == 0);
+    return ((p->type.t & VT_BTYPE) == VT_INT && (uint32_t)p->c.ii == 0) ||
+        ((p->type.t & VT_BTYPE) == VT_LLONG && p->c.ii == 0) ||
+        ((p->type.t & VT_BTYPE) == VT_PTR &&
+         (PTR_SIZE == 4 ? (uint32_t)p->c.ii == 0 : p->c.ii == 0));
 }
 
 static inline int is_integer_btype(int bt)
@@ -1973,15 +1970,15 @@ static void gen_cast(CType *type)
 
             if (df) {
                 if ((sbt & VT_BTYPE) == VT_LLONG) {
-                    if (sbt & VT_UNSIGNED)
-                        vtop->c.ld = vtop->c.ull;
+                    if ((sbt & VT_UNSIGNED) || !(vtop->c.ii >> 63))
+                        vtop->c.ld = vtop->c.ii;
                     else
-                        vtop->c.ld = vtop->c.ll;
+                        vtop->c.ld = -(long double)-vtop->c.ii;
                 } else if(!sf) {
-                    if (sbt & VT_UNSIGNED)
-                        vtop->c.ld = vtop->c.ui;
+                    if ((sbt & VT_UNSIGNED) || !(vtop->c.ii >> 31))
+                        vtop->c.ld = (uint32_t)vtop->c.ii;
                     else
-                        vtop->c.ld = vtop->c.i;
+                        vtop->c.ld = -(long double)-(uint32_t)vtop->c.ii;
                 }
 
                 if (dbt == VT_FLOAT)
@@ -1989,27 +1986,28 @@ static void gen_cast(CType *type)
                 else if (dbt == VT_DOUBLE)
                     vtop->c.d = (double)vtop->c.ld;
             } else if (sf && dbt == (VT_LLONG|VT_UNSIGNED)) {
-                vtop->c.ull = (unsigned long long)vtop->c.ld;
+                vtop->c.ii = vtop->c.ld;
             } else if (sf && dbt == VT_BOOL) {
-                vtop->c.i = (vtop->c.ld != 0);
+                vtop->c.ii = (vtop->c.ld != 0);
             } else {
                 if(sf)
-                    vtop->c.ll = (long long)vtop->c.ld;
+                    vtop->c.ii = vtop->c.ld;
                 else if (sbt == (VT_LLONG|VT_UNSIGNED))
-                    vtop->c.ll = vtop->c.ull;
+                    ;
                 else if (sbt & VT_UNSIGNED)
-                    vtop->c.ll = vtop->c.ui;
+                    vtop->c.ii = (uint32_t)vtop->c.ii;
 #if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
                 else if (sbt == VT_PTR)
                     ;
 #endif
                 else if (sbt != VT_LLONG)
-                    vtop->c.ll = vtop->c.i;
+                    vtop->c.ii = ((uint32_t)vtop->c.ii |
+                                  -(vtop->c.ii & 0x80000000));
 
                 if (dbt == (VT_LLONG|VT_UNSIGNED))
-                    vtop->c.ull = vtop->c.ll;
+                    ;
                 else if (dbt == VT_BOOL)
-                    vtop->c.i = (vtop->c.ll != 0);
+                    vtop->c.ii = (vtop->c.ii != 0);
 #if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
                 else if (dbt == VT_PTR)
                     ;
@@ -2021,14 +2019,15 @@ static void gen_cast(CType *type)
                     else if ((dbt & VT_BTYPE) == VT_SHORT)
                         s = 16;
                     if(dbt & VT_UNSIGNED)
-                        vtop->c.ui = ((unsigned int)vtop->c.ll << s) >> s;
+                        vtop->c.ii = ((uint32_t)vtop->c.ii << s) >> s;
                     else
-                        vtop->c.i = ((int)vtop->c.ll << s) >> s;
+                        vtop->c.ii = (uint32_t)vtop->c.ii |
+                            -((uint32_t)vtop->c.ii & (uint32_t)1 << (31 - s));
                 }
             }
         } else if (p && dbt == VT_BOOL) {
             vtop->r = VT_CONST;
-            vtop->c.i = 1;
+            vtop->c.ii = 1;
         } else if (!nocode_wanted) {
             /* non constant case: generate code */
             if (sf && df) {
@@ -2645,7 +2644,7 @@ ST_FUNC void vstore(void)
                 sv.type.t = VT_INT;
 #endif
                 sv.r = VT_LOCAL | VT_LVAL;
-                sv.c.ul = vtop[-1].c.ul;
+                sv.c.ii = vtop[-1].c.ii;
                 load(t, &sv);
                 vtop[-1].r = t | VT_LVAL;
             }
@@ -3430,7 +3429,7 @@ static void post_type(CType *type, AttributeDef *ad)
                  vpushi(expr_const());
             else gexpr();
             if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
-                n = vtop->c.i;
+                n = vtop->c.ii;
                 if (n < 0)
                     tcc_error("invalid array size");
             } else {
@@ -3679,7 +3678,7 @@ ST_FUNC void unary(void)
     case TOK_CINT:
     case TOK_CCHAR: 
     case TOK_LCHAR:
-        vpushi(tokc.i);
+        vpushi(tokc.ii);
         next();
         break;
     case TOK_CUINT:
@@ -3810,9 +3809,9 @@ ST_FUNC void unary(void)
             CType boolean;
             boolean.t = VT_BOOL;
             gen_cast(&boolean);
-            vtop->c.i = !vtop->c.i;
+            vtop->c.ii = !vtop->c.ii;
         } else if ((vtop->r & VT_VALMASK) == VT_CMP)
-            vtop->c.i = vtop->c.i ^ 1;
+            vtop->c.ii ^= 1;
         else {
             save_regs(1);
             vseti(VT_JMP, gvtst(1, 0));
@@ -3896,13 +3895,13 @@ ST_FUNC void unary(void)
             CType type;
             next();
             skip('(');
-            if (tok != TOK_CINT || tokc.i < 0) {
+            if (tok != TOK_CINT) {
                 tcc_error("%s only takes positive integers",
                           tok1 == TOK_builtin_return_address ?
                           "__builtin_return_address" :
                           "__builtin_frame_address");
             }
-            level = tokc.i;
+            level = (uint32_t)tokc.ii;
             next();
             skip(')');
             type.t = VT_VOID;
@@ -4096,7 +4095,7 @@ ST_FUNC void unary(void)
         /* if forward reference, we must point to s */
         if (vtop->r & VT_SYM) {
             vtop->sym = s;
-           vtop->c.ptr_offset = 0;
+            vtop->c.ii = 0;
         }
         break;
     }
@@ -4225,7 +4224,7 @@ ST_FUNC void unary(void)
 #endif
                     ret.r = REG_IRET;
                 }
-                ret.c.i = 0;
+                ret.c.ii = 0;
             }
             if (tok != ')') {
                 for(;;) {
@@ -4454,7 +4453,7 @@ static void expr_cond(void)
             boolean.t = VT_BOOL;
             vdup();
             gen_cast(&boolean);
-            c = vtop->c.i;
+            c = vtop->c.ii;
             vpop();
             next();
             if (tok != ':' || !gnu_ext) {
@@ -4667,7 +4666,7 @@ ST_FUNC int expr_const(void)
     expr_const1();
     if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) != VT_CONST)
         expect("constant expression");
-    c = vtop->c.i;
+    c = vtop->c.ii;
     vpop();
     return c;
 }
@@ -4867,7 +4866,8 @@ static void block(int *bsym, int *csym, int *case_sym, 
int *def_sym,
                     /* returning structure packed into registers */
                     int r, size, addr, align;
                     size = type_size(&func_vt,&align);
-                    if ((vtop->r != (VT_LOCAL | VT_LVAL) || (vtop->c.i & 
(ret_align-1)))
+                    if ((vtop->r != (VT_LOCAL | VT_LVAL) ||
+                         (vtop->c.ii & (ret_align-1)))
                         && (align & (ret_align-1))) {
                         loc = (loc - size) & -align;
                         addr = loc;
@@ -4892,7 +4892,7 @@ static void block(int *bsym, int *csym, int *case_sym, 
int *def_sym,
                            suite s(n) = 2^n */
                         r <<= 1;
                         /* XXX: compatible with arm only: ret_align == 
register_size */
-                        vtop->c.i += ret_align;
+                        vtop->c.ii += ret_align;
                         vtop->r = VT_LOCAL | VT_LVAL;
                     }
                 }
@@ -5320,12 +5320,12 @@ static void init_putv(CType *type, Section *sec, 
unsigned long c,
                same representation on host and target, which is likely to
                be wrong in the case of long double */
         case VT_BOOL:
-            vtop->c.i = (vtop->c.i != 0);
+            vtop->c.ii = (vtop->c.ii != 0);
         case VT_BYTE:
-            *(char *)ptr |= (vtop->c.i & bit_mask) << bit_pos;
+            *(char *)ptr |= (vtop->c.ii & bit_mask) << bit_pos;
             break;
         case VT_SHORT:
-            *(short *)ptr |= (vtop->c.i & bit_mask) << bit_pos;
+            *(short *)ptr |= (vtop->c.ii & bit_mask) << bit_pos;
             break;
         case VT_DOUBLE:
             *(double *)ptr = vtop->c.d;
@@ -5334,10 +5334,10 @@ static void init_putv(CType *type, Section *sec, 
unsigned long c,
             *(long double *)ptr = vtop->c.ld;
             break;
         case VT_LLONG:
-            *(long long *)ptr |= (vtop->c.ll & bit_mask) << bit_pos;
+            *(long long *)ptr |= (vtop->c.ii & bit_mask) << bit_pos;
             break;
         case VT_PTR: {
-            addr_t val = (vtop->c.ptr_offset & bit_mask) << bit_pos;
+            addr_t val = (vtop->c.ii & bit_mask) << bit_pos;
 #if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
             if (vtop->r & VT_SYM)
                 greloca(sec, vtop->sym, c, R_DATA_PTR, val);
@@ -5351,7 +5351,7 @@ static void init_putv(CType *type, Section *sec, unsigned 
long c,
             break;
         }
         default: {
-            int val = (vtop->c.i & bit_mask) << bit_pos;
+            int val = (vtop->c.ii & bit_mask) << bit_pos;
 #if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
             if (vtop->r & VT_SYM)
                 greloca(sec, vtop->sym, c, R_DATA_PTR, val);
diff --git a/tccpe.c b/tccpe.c
index e392f40..1c7cf27 100644
--- a/tccpe.c
+++ b/tccpe.c
@@ -1473,9 +1473,9 @@ ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2)
     load(r2, v2);
     v2->r = r2;
 
-    if (sv->c.ui) {
+    if ((uint32_t)sv->c.ii) {
         vpushv(v2);
-        vpushi(sv->c.ui);
+        vpushi(sv->c.ii);
         gen_opi('+');
         *v2 = *vtop--;
     }
diff --git a/tccpp.c b/tccpp.c
index 45e394f..12f63f3 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -297,22 +297,22 @@ ST_FUNC char *get_tok_str(int v, CValue *cv)
     case TOK_CINT:
     case TOK_CUINT:
         /* XXX: not quite exact, but only useful for testing */
-        sprintf(p, "%u", cv->ui);
+        sprintf(p, "%llu", (unsigned long long)cv->ii);
         break;
     case TOK_CLLONG:
     case TOK_CULLONG:
         /* XXX: not quite exact, but only useful for testing  */
 #ifdef _WIN32
-        sprintf(p, "%u", (unsigned)cv->ull);
+        sprintf(p, "%u", (unsigned)cv->ii);
 #else
-        sprintf(p, "%llu", cv->ull);
+        sprintf(p, "%llu", (unsigned long long)cv->ii);
 #endif
         break;
     case TOK_LCHAR:
         cstr_ccat(&cstr_buf, 'L');
     case TOK_CCHAR:
         cstr_ccat(&cstr_buf, '\'');
-        add_char(&cstr_buf, cv->i);
+        add_char(&cstr_buf, cv->ii);
         cstr_ccat(&cstr_buf, '\'');
         cstr_ccat(&cstr_buf, '\0');
         break;
@@ -978,7 +978,7 @@ ST_FUNC void tok_str_add_tok(TokenString *s)
     /* save line number info */
     if (file->line_num != s->last_line_num) {
         s->last_line_num = file->line_num;
-        cval.i = s->last_line_num;
+        cval.ii = s->last_line_num;
         tok_str_add2(s, TOK_LINENUM, &cval);
     }
     tok_str_add2(s, tok, &tokc);
@@ -1241,11 +1241,11 @@ static int expr_preprocess(void)
             if (t == '(')
                 next_nomacro();
             tok = TOK_CINT;
-            tokc.i = c;
+            tokc.ii = c;
         } else if (tok >= TOK_IDENT) {
             /* if undefined macro */
             tok = TOK_CINT;
-            tokc.i = 0;
+            tokc.ii = 0;
         }
         tok_str_add_tok(&str);
     }
@@ -1421,7 +1421,7 @@ static void pragma_parse(TCCState *s1)
                 pack_error:
                     tcc_error("invalid pack pragma");
                 }
-                val = tokc.i;
+                val = tokc.ii;
                 if (val < 1 || val > 16 || (val & (val - 1)) != 0)
                     goto pack_error;
                 next();
@@ -1677,9 +1677,9 @@ include_done:
     case TOK_PPNUM:
        if (tok != TOK_CINT) {
             char *p = tokc.cstr->data;
-           tokc.i = strtoul(p, (char **)&p, 10);
+            tokc.ii = strtoul(p, (char **)&p, 10);
        }
-        file->line_num = tokc.i - 1; /* the line number will be incremented 
after */
+        file->line_num = tokc.ii - 1; /* the line number will be incremented 
after */
         next();
         if (tok != TOK_LINEFEED) {
             if (tok != TOK_STR)
@@ -2149,9 +2149,9 @@ static void parse_number(const char *p)
         }
 
         if (tok == TOK_CINT || tok == TOK_CUINT)
-            tokc.ui = n;
+            tokc.ii = n;
         else
-            tokc.ull = n;
+            tokc.ii = n;
     }
     if (ch)
         tcc_error("invalid number\n");
@@ -2437,10 +2437,10 @@ maybe_newline:
                 if (tokcstr.size > 2 * char_size)
                     tcc_warning("multi-character character constant");
                 if (!is_long) {
-                    tokc.i = *(int8_t *)tokcstr.data;
+                    tokc.ii = *(int8_t *)tokcstr.data;
                     tok = TOK_CCHAR;
                 } else {
-                    tokc.i = *(nwchar_t *)tokcstr.data;
+                    tokc.ii = *(nwchar_t *)tokcstr.data;
                     tok = TOK_LCHAR;
                 }
             } else {
@@ -2609,7 +2609,7 @@ static void next_nomacro_spc(void)
         if (tok) {
             TOK_GET(&tok, &macro_ptr, &tokc);
             if (tok == TOK_LINENUM) {
-                file->line_num = tokc.i;
+                file->line_num = tokc.ii;
                 goto redo;
             }
         }
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 67aaadc..638198e 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -368,7 +368,7 @@ void load(int r, SValue *sv)
 
     fr = sv->r;
     ft = sv->type.t & ~VT_DEFSIGN;
-    fc = sv->c.ul;
+    fc = sv->c.ii;
 
 #ifndef TCC_TARGET_PE
     /* we use indirect access via got */
@@ -393,7 +393,7 @@ void load(int r, SValue *sv)
         if (v == VT_LLOCAL) {
             v1.type.t = VT_PTR;
             v1.r = VT_LOCAL | VT_LVAL;
-            v1.c.ul = fc;
+            v1.c.ii = fc;
             fr = r;
             if (!(reg_classes[fr] & RC_INT))
                 fr = get_reg(RC_INT);
@@ -449,7 +449,7 @@ void load(int r, SValue *sv)
 #endif
             } else if (is64_type(ft)) {
                 orex(1,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */
-                gen_le64(sv->c.ull);
+                gen_le64(sv->c.ii);
             } else {
                 orex(0,r,0, 0xb8 + REG_VALUE(r)); /* mov $xx, r */
                 gen_le32(fc);
@@ -531,7 +531,7 @@ void store(int r, SValue *v)
 #endif
 
     ft = v->type.t;
-    fc = v->c.ul;
+    fc = v->c.ii;
     fr = v->r & VT_VALMASK;
     bt = ft & VT_BTYPE;
 
@@ -540,7 +540,7 @@ void store(int r, SValue *v)
     if (fr == VT_CONST && (v->r & VT_SYM)) {
         /* mov xx(%rip), %r11 */
         o(0x1d8b4c);
-        gen_gotpcrel(TREG_R11, v->sym, v->c.ul);
+        gen_gotpcrel(TREG_R11, v->sym, v->c.ii);
         pic = is64_type(bt) ? 0x49 : 0x41;
     }
 #endif
@@ -614,7 +614,7 @@ static void gcall_or_jmp(int is_jmp)
             put_elf_reloc(symtab_section, cur_text_section,
                           ind + 1, R_X86_64_PC32, 0);
         }
-        oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */
+        oad(0xe8 + is_jmp, vtop->c.ii - 4); /* call/jmp im */
     } else {
         /* otherwise, indirect call */
         r = TREG_R11;
@@ -1567,12 +1567,12 @@ void gjmp_addr(int a)
 /* generate a test. set 'inv' to invert test. Stack entry is popped */
 int gtst(int inv, int t)
 {
-    int v, *p;
+    int v, t1, *p;
 
     v = vtop->r & VT_VALMASK;
     if (v == VT_CMP) {
         /* fast case : can jump directly since flags are set */
-       if (vtop->c.i & 0x100)
+       if (vtop->c.ii & 0x100)
          {
            /* This was a float compare.  If the parity flag is set
               the result was unordered.  For anything except != this
@@ -1581,8 +1581,8 @@ int gtst(int inv, int t)
               Take care about inverting the test.  We need to jump
               to our target if the result was unordered and test wasn't NE,
               otherwise if unordered we don't want to jump.  */
-           vtop->c.i &= ~0x100;
-           if (!inv == (vtop->c.i != TOK_NE))
+           vtop->c.ii &= ~0x100;
+           if (!inv == (vtop->c.ii != TOK_NE))
              o(0x067a);  /* jp +6 */
            else
              {
@@ -1591,19 +1591,21 @@ int gtst(int inv, int t)
              }
          }
         g(0x0f);
-        t = psym((vtop->c.i - 16) ^ inv, t);
+        t = psym((vtop->c.ii - 16) ^ inv, t);
     } else if (v == VT_JMP || v == VT_JMPI) {
         /* && or || optimization */
         if ((v & 1) == inv) {
             /* insert vtop->c jump list in t */
-            p = &vtop->c.i;
+            t1 = vtop->c.ii;
+            p = &t1;
             while (*p != 0)
                 p = (int *)(cur_text_section->data + *p);
             *p = t;
-            t = vtop->c.i;
+            vtop->c.ii = t1;
+            t = t1;
         } else {
             t = gjmp(t);
-            gsym(vtop->c.i);
+            gsym(vtop->c.ii);
         }
     }
     vtop--;
@@ -1625,12 +1627,12 @@ void gen_opi(int op)
     case TOK_ADDC1: /* add with carry generation */
         opc = 0;
     gen_op8:
-        if (cc && (!ll || (int)vtop->c.ll == vtop->c.ll)) {
+        if (cc && (!ll || (int)vtop->c.ii == vtop->c.ii)) {
             /* constant case */
             vswap();
             r = gv(RC_INT);
             vswap();
-            c = vtop->c.i;
+            c = vtop->c.ii;
             if (c == (char)c) {
                 /* XXX: generate inc and dec for smaller code ? */
                 orex(ll, r, 0, 0x83);
@@ -1650,7 +1652,7 @@ void gen_opi(int op)
         vtop--;
         if (op >= TOK_ULT && op <= TOK_GT) {
             vtop->r = VT_CMP;
-            vtop->c.i = op;
+            vtop->c.ii = op;
         }
         break;
     case '-':
@@ -1697,7 +1699,7 @@ void gen_opi(int op)
             vswap();
             orex(ll, r, 0, 0xc1); /* shl/shr/sar $xxx, r */
             o(opc | REG_VALUE(r));
-            g(vtop->c.i & (ll ? 63 : 31));
+            g(vtop->c.ii & (ll ? 63 : 31));
         } else {
             /* we generate the shift in ecx */
             gv2(RC_INT, RC_RCX);
@@ -1807,7 +1809,7 @@ void gen_opf(int op)
             }
             vtop--;
             vtop->r = VT_CMP;
-            vtop->c.i = op;
+            vtop->c.ii = op;
         } else {
             /* no memory reference possible for long double operations */
             load(TREG_ST0, vtop);
@@ -1833,7 +1835,7 @@ void gen_opf(int op)
                 break;
             }
             ft = vtop->type.t;
-            fc = vtop->c.ul;
+            fc = vtop->c.ii;
             o(0xde); /* fxxxp %st, %st(1) */
             o(0xc1 + (a << 3));
             vtop--;
@@ -1842,13 +1844,13 @@ void gen_opf(int op)
         if (op >= TOK_ULT && op <= TOK_GT) {
             /* if saved lvalue, then we must reload it */
             r = vtop->r;
-            fc = vtop->c.ul;
+            fc = vtop->c.ii;
             if ((r & VT_VALMASK) == VT_LLOCAL) {
                 SValue v1;
                 r = get_reg(RC_INT);
                 v1.type.t = VT_PTR;
                 v1.r = VT_LOCAL | VT_LVAL;
-                v1.c.ul = fc;
+                v1.c.ii = fc;
                 load(r, &v1);
                 fc = 0;
             }
@@ -1886,7 +1888,7 @@ void gen_opf(int op)
 
             vtop--;
             vtop->r = VT_CMP;
-            vtop->c.i = op | 0x100;
+            vtop->c.ii = op | 0x100;
         } else {
             assert((vtop->type.t & VT_BTYPE) != VT_LDOUBLE);
             switch(op) {
@@ -1905,7 +1907,7 @@ void gen_opf(int op)
                 break;
             }
             ft = vtop->type.t;
-            fc = vtop->c.ul;
+            fc = vtop->c.ii;
             assert((ft & VT_BTYPE) != VT_LDOUBLE);
             
             r = vtop->r;
@@ -1915,7 +1917,7 @@ void gen_opf(int op)
                 r = get_reg(RC_INT);
                 v1.type.t = VT_PTR;
                 v1.r = VT_LOCAL | VT_LVAL;
-                v1.c.ul = fc;
+                v1.c.ii = fc;
                 load(r, &v1);
                 fc = 0;
             }
-- 
1.7.10.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]