aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/antcc.h14
-rw-r--r--src/c.c32
-rw-r--r--src/c.h4
-rw-r--r--src/c_eval.c12
-rw-r--r--src/c_lex.c46
-rw-r--r--src/c_lex.h2
-rw-r--r--src/c_type.h2
-rw-r--r--src/ir.c2
-rw-r--r--src/ir.h12
-rw-r--r--src/ir_builder.c2
-rw-r--r--src/ir_fold.c18
-rw-r--r--src/ir_simpl.c8
-rw-r--r--src/o_elf.c8
-rw-r--r--src/obj.c6
-rw-r--r--src/obj.h2
-rw-r--r--src/t_aarch64.h2
-rw-r--r--src/t_aarch64_emit.c4
-rw-r--r--src/t_aarch64_isel.c26
-rw-r--r--src/t_x86-64_emit.c2
-rw-r--r--src/t_x86-64_isel.c12
-rw-r--r--src/u_endian.h20
-rw-r--r--src/u_io.c14
22 files changed, 125 insertions, 125 deletions
diff --git a/src/antcc.h b/src/antcc.h
index 61170b9..976b766 100644
--- a/src/antcc.h
+++ b/src/antcc.h
@@ -12,8 +12,8 @@
typedef unsigned char uchar;
typedef signed char schar;
typedef unsigned short ushort;
-typedef unsigned long long uvlong;
-typedef signed long long vlong;
+typedef unsigned long long u64int;
+typedef signed long long s64int;
typedef unsigned uint;
#if __STDC_VERSION__ >= 202311L
@@ -46,7 +46,7 @@ void _assertfmt(const char *file, int line, const char *func, const char *expr);
#define popcnt(x) __builtin_popcountll(x)
#else
static inline uint
-popcnt(uvlong x) {
+popcnt(u64int x) {
uint n = 0;
while (x) n += x&1, x >>= 1;
return n;
@@ -54,7 +54,7 @@ popcnt(uvlong x) {
#endif
static inline bool
-ispo2(uvlong x) {
+ispo2(u64int x) {
return (x != 0) & ((x & (x - 1)) == 0);
}
@@ -62,7 +62,7 @@ ispo2(uvlong x) {
#define ilog2(x) __builtin_ctzll(x)
#else
static inline uint
-ilog2(uvlong x) { /* assumes x is a power of 2 */
+ilog2(u64int x) { /* assumes x is a power of 2 */
uint n = 0;
while (x >>= 1) ++n;
return n;
@@ -73,10 +73,10 @@ ilog2(uvlong x) { /* assumes x is a power of 2 */
#define lowestsetbit(x) __builtin_ctzll(x)
#else
static inline uint
-lowestsetbit(uvlong x)
+lowestsetbit(u64int x)
{
int i = 0;
- for (uvlong mask = 1;; ++i, mask <<= 1)
+ for (u64int mask = 1;; ++i, mask <<= 1)
if (x & mask)
break;
return i;
diff --git a/src/c.c b/src/c.c
index 248a095..d6879ad 100644
--- a/src/c.c
+++ b/src/c.c
@@ -1385,7 +1385,7 @@ typedef struct InitParser {
struct InitReloc {
struct InitReloc *link;
internstr sym;
- vlong addend;
+ s64int addend;
uint off;
} *drel;
};
@@ -1427,7 +1427,7 @@ dumpini(InitParser *ip)
}
#endif
-static vlong /* -> returns addend */
+static s64int /* -> returns addend */
expr2reloc(internstr *psym, const Expr *ex)
{
if (ex->t == ESSYMREF) {
@@ -1489,7 +1489,7 @@ iniwrite(CComp *cm, InitParser *ip, uint off, uint bitsiz, uint bitoff, Type ty,
case 4: isint(ty) ? wr32targ(p, e->u) : wrf32targ(p, e->f); break;
case 8: isint(ty) ? wr64targ(p, e->u) : wrf64targ(p, e->f); break;
} else {
- uvlong mask = (bitsiz == 64 ? -1ull : (1ull << bitsiz) - 1) << bitoff;
+ u64int mask = (bitsiz == 64 ? -1ull : (1ull << bitsiz) - 1) << bitoff;
if (bitoff + bitsiz > siz*8) siz <<= 1; /* straddles an allocation boundary */
switch (siz) {
default: assert(0);
@@ -1506,7 +1506,7 @@ iniwrite(CComp *cm, InitParser *ip, uint off, uint bitsiz, uint bitoff, Type ty,
memcpy(p, ex->s.p, n);
} else {
internstr sym;
- vlong addend = expr2reloc(&sym, ex);
+ s64int addend = expr2reloc(&sym, ex);
if (!ip->dyn) {
assert(ip->sec != Srodata || rodatarelocok());
objreloc(sym, targ_64bit ? REL_ABS64 : REL_ABS32,
@@ -1706,7 +1706,7 @@ designators(InitParser *ip, CComp *cm)
for (;;) {
uint off, bitsiz, bitoff;
- uvlong idx = ~0ull;
+ u64int idx = ~0ull;
if (match(cm, &tk, '[')) {
Expr ex = commaexpr(cm);
span = tk.span;
@@ -2110,7 +2110,7 @@ buildagg(CComp *cm, enum typetag tt, internstr name, int id)
}
static inline void
-inttyminmax(vlong *min, uvlong *max, enum typetag tt)
+inttyminmax(s64int *min, u64int *max, enum typetag tt)
{
uint bits = 8*targ_primsizes[tt];
*min = isunsignedt(tt) ? 0 : -(1ull << (bits - 1));
@@ -2130,12 +2130,12 @@ static Type
buildenum(CComp *cm, internstr name, const Span *span, int id)
{
Token tk;
- vlong tymin, minv = 0;
- uvlong tymax, maxv = 0;
+ s64int tymin, minv = 0;
+ u64int tymax, maxv = 0;
TypeData td = {TYENUM, .backing = TYINT};
Type ty = mktype(td.backing);
Span maxvspan;
- vlong iota = 0;
+ s64int iota = 0;
bool somelonglong = 0;
inttyminmax(&tymin, &tymax, td.backing);
@@ -2157,7 +2157,7 @@ buildenum(CComp *cm, internstr name, const Span *span, int id)
lex(cm, NULL);
continue;
}
- while (issigned(ty) ? (iota > (vlong)tymax || iota < tymin) : iota > tymax)
+ while (issigned(ty) ? (iota > (s64int)tymax || iota < tymin) : iota > tymax)
inttyminmax(&tymin, &tymax, ++ty.t);
somelonglong |= ty.t >= TYVLONG;
if ((isunsigned(ty) || iota > 0) && iota > maxv)
@@ -3479,7 +3479,7 @@ genbitfload(Function *fn, Ref *tmpval, const Type ty, Ref *addr,
enum irclass k = type2cls[scalartypet(ty)];
uint off = fld->off, bitsiz = fld->bitsiz, bitoff = fld->bitoff;
Ref tmp;
- uvlong mask;
+ u64int mask;
assert(k);
*addr = irbinop(fn, Oadd, KPTR, *addr, mkintcon(KI32, off));
@@ -3509,7 +3509,7 @@ genbitfstore(Function *fn, const Type ty, Ref addr,
enum irclass k = type2cls[scalartypet(ty)];
uint off = fld->off, bitsiz = fld->bitsiz, bitoff = fld->bitoff;
uint bittypesize = 8*typesize(ty);
- uvlong mask;
+ u64int mask;
assert(k);
if (!tmp.bits) {
@@ -3523,7 +3523,7 @@ genbitfstore(Function *fn, const Type ty, Ref addr,
/* shift and mask source value */
if (isintcon(val)) {
- val = mkintcon(k, ((uvlong)intconval(val) << bitoff) & mask);
+ val = mkintcon(k, ((u64int)intconval(val) << bitoff) & mask);
} else {
val = irbinop(fn, Oshl, k, val, mkref(RICON, bitoff));
if (bitsiz < bittypesize)
@@ -3952,7 +3952,7 @@ loopbody(CComp *cm, Function *fn, Block *brk, Block *cont)
#define EMITS if (doemit && !nerror)
typedef struct {
- vlong val;
+ s64int val;
Block *blk;
Span span;
} SwitchCase;
@@ -3966,7 +3966,7 @@ static int
cmpswcase(const void *aa, const void *bb)
{
const SwitchCase *a = aa, *b = bb;
- vlong v1 = a->val, v2 = b->val;
+ s64int v1 = a->val, v2 = b->val;
if (v1 != v2) return v1 < v2 ? -1 : 1;
return (a > b) - (a < b); /* preserve original order */
}
@@ -4017,7 +4017,7 @@ genswitch(CComp *cm, Function *fn, const Expr *ex)
* 3. binary search
* 4. jump tables? (harder, backend refactoring)
*/
- vlong prev;
+ s64int prev;
for (int i = 0; i < st.cases.n; ++i) {
const SwitchCase *c = &st.cases.p[i];
if (i > 0) {
diff --git a/src/c.h b/src/c.h
index ddb6832..a0142e7 100644
--- a/src/c.h
+++ b/src/c.h
@@ -38,7 +38,7 @@ struct Expr {
uchar bitsiz, bitoff;
} fld; /* EGETF */
};
- uvlong u; vlong i; double f; /* ENUMLIT */
+ u64int u; s64int i; double f; /* ENUMLIT */
struct {
union {
uchar *p;
@@ -107,7 +107,7 @@ typedef struct Decl {
union {
internstr sym; /* static/extern scls */
struct { ushort align; int id; }; /* local var */
- vlong value; /* enum constant */
+ s64int value; /* enum constant */
const Builtin *builtin; /* .isbuiltin */
};
} Decl;
diff --git a/src/c_eval.c b/src/c_eval.c
index e2033a3..0efa7bd 100644
--- a/src/c_eval.c
+++ b/src/c_eval.c
@@ -31,7 +31,7 @@ numcast(Type ty, Expr *dst, const Expr *src)
{
enum typetag td = targ2hosttype(scalartypet(ty)),
ts = targ2hosttype(scalartypet(src->ty));
- vlong isrc;
+ s64int isrc;
Expr tmp;
if (src == dst) tmp = *src, src = &tmp;
@@ -107,7 +107,7 @@ staticaddrof(Expr *ex, enum evalmode mode)
} else if (ex->t == EGETF && (ret = staticaddrof(ex->sub, mode)).t) {
if (ret.t == ESSYMREF) {
ex->t = ESSYMREF;
- vlong off = (vlong) ret.ssym.off + ex->fld.off;
+ s64int off = (s64int) ret.ssym.off + ex->fld.off;
if ((int) off != off) return ret.t = 0, ret;
ret.ssym.off = off;
} else if (ret.t == ENUMLIT) {
@@ -143,7 +143,7 @@ unop(Expr *ex, enum evalmode mode)
Expr *sub = ex->sub, ex2;
if (mode >= EVSTATICINI && ex->t == EDEREF) {
- uvlong off;
+ u64int off;
uchar *p;
uint len;
uint csiz;
@@ -201,7 +201,7 @@ unop(Expr *ex, enum evalmode mode)
} else {
assert(ex2.t == ESSYMREF);
ex->t = ESSYMREF;
- vlong off = (vlong) ex2.ssym.off + ex->fld.off;
+ s64int off = (s64int) ex2.ssym.off + ex->fld.off;
if ((int) off != off) return 0;
ex->ssym = ex2.ssym;
ex->ssym.off = off;
@@ -268,8 +268,8 @@ binop(Expr *ex, enum evalmode mode)
if (a->t == ESTRLIT) {
lit2ssym(a);
} else assert(a->t == ESSYMREF);
- vlong addend = b->i * typesize(typechild(a->ty)),
- off = a->ssym.off + (uvlong) (ex->t == EADD ? addend : -addend);
+ s64int addend = b->i * typesize(typechild(a->ty)),
+ off = a->ssym.off + (u64int) (ex->t == EADD ? addend : -addend);
ex->t = ESSYMREF;
if ((int) off != off) return 0;
ex->ssym = a->ssym;
diff --git a/src/c_lex.c b/src/c_lex.c
index 7b817fd..e986fca 100644
--- a/src/c_lex.c
+++ b/src/c_lex.c
@@ -120,10 +120,10 @@ aissep(int c) {
}
enum typetag
-parsenumlit(uvlong *outi, double *outf, const Token *tk, bool ispp)
+parsenumlit(u64int *outi, double *outf, const Token *tk, bool ispp)
{
if (tk->t == TKCHRLIT) {
- uvlong n = 0;
+ u64int n = 0;
if (!tk->wide) {
for (int i = 0; i < tk->len; ++i)
n = n << 8 | (uchar)tk->s[i];
@@ -158,8 +158,8 @@ parsenumlit(uvlong *outi, double *outf, const Token *tk, bool ispp)
}
return 0;
} else { /* int literal */
- static uvlong max4typ[TYUVLONG-TYINT+1];
- uvlong n = 0;
+ static u64int max4typ[TYUVLONG-TYINT+1];
+ u64int n = 0;
int base = 10, nsx;
bool dec, u = 0, longlongok = ccopt.cstd >= STDC99 || !ccopt.pedant;
enum typetag ty = 0;
@@ -1474,14 +1474,14 @@ tkprec(int tt)
return -1;
}
-static vlong
+static s64int
expr(Lexer *lx, bool *pu, int prec, bool ignore)
{
Token tk;
enum typetag ty;
char unops[16];
int nunop = 0;
- vlong x, y;
+ s64int x, y;
bool xu = 0, yu; /* x unsigned?; y unsigned? */
Unary:
@@ -1505,7 +1505,7 @@ Switch:
break;
case TKNUMLIT:
case TKCHRLIT:
- ty = parsenumlit((uvlong *)&x, NULL, &tk, 1);
+ ty = parsenumlit((u64int *)&x, NULL, &tk, 1);
if (!ty) {
error(&tk.span, "bad number literal");
goto Err;
@@ -1546,7 +1546,7 @@ Switch:
}
while (nunop > 0) switch (unops[--nunop]) {
- case '-': x = -(uvlong)x; break;
+ case '-': x = -(u64int)x; break;
case '~': x = ~x; break;
case '!': x = !x; break;
default: assert(0);
@@ -1562,7 +1562,7 @@ Switch:
xu = 0;
} else if (tk.t == '?') {
Span span = tk.span;
- vlong m = expr(lx, &xu, 1, ignore || !x);
+ s64int m = expr(lx, &xu, 1, ignore || !x);
if (elex(lx, &tk) != ':') {
error(&tk.span, "expected ':'");
note(DGERROR, &span, "to match conditional expression here");
@@ -1575,34 +1575,34 @@ Switch:
y = expr(lx, &yu, opprec + 1, ignore);
bool u = xu | yu;
switch ((int) tk.t) {
- case '+': x += (uvlong) y; break;
- case '-': x -= (uvlong) y; break;
- case '*': x = u ? (uvlong) x * y : x * y; break;
+ case '+': x += (u64int) y; break;
+ case '-': x -= (u64int) y; break;
+ case '*': x = u ? (u64int) x * y : x * y; break;
case '&': x &= y; break;
case '^': x ^= y; break;
case '|': x |= y; break;
- case '/': if (y) x = u ? (uvlong) x / y : x / y;
+ case '/': if (y) x = u ? (u64int) x / y : x / y;
else if (ignore) x = 0;
else goto Div0;
break;
- case '%': if (y) x = u ? (uvlong) x % y : x % y;
+ case '%': if (y) x = u ? (u64int) x % y : x % y;
else if (ignore) x = 0;
else Div0: error(&tk.span, "division by zero");
break;
- case TKSHL: if ((uvlong)y < 64) x <<= y;
+ case TKSHL: if ((u64int)y < 64) x <<= y;
else if (ignore) x = 0;
else goto BadShift;
break;
u = xu;
- case TKSHR: if ((uvlong)y < 64) x = u ? (uvlong) x >> y : x >> y;
+ case TKSHR: if ((u64int)y < 64) x = u ? (u64int) x >> y : x >> y;
else if (ignore) x = 0;
else BadShift: error(&tk.span, "bad shift by %ld", y);
u = xu;
break;
- case '<': x = u ? (uvlong) x < y : x < y; u = 0; break;
- case '>': x = u ? (uvlong) x > y : x > y; u = 0; break;
- case TKLTE: x = u ? (uvlong) x <= y : x <= y; u = 0; break;
- case TKGTE: x = u ? (uvlong) x >= y : x >= y; u = 0; break;
+ case '<': x = u ? (u64int) x < y : x < y; u = 0; break;
+ case '>': x = u ? (u64int) x > y : x > y; u = 0; break;
+ case TKLTE: x = u ? (u64int) x <= y : x <= y; u = 0; break;
+ case TKGTE: x = u ? (u64int) x >= y : x >= y; u = 0; break;
case TKEQU: x = x == y; u = 0; break;
case TKNEQ: x = x != y; u = 0; break;
default: assert(0);
@@ -1644,7 +1644,7 @@ static int includedepth;
static void
ppif(Lexer *lx, const Span *span)
{
- vlong v = expr(lx, NULL, 0, 0);
+ s64int v = expr(lx, NULL, 0, 0);
assert(nppcnd < countof(ppcndstk) && "too many nested #if");
ppcndstk[nppcnd].ifspan = span->sl;
ppcndstk[nppcnd].filedepth = includedepth;
@@ -1675,7 +1675,7 @@ ppifxdef(Lexer *lx, bool defp, const Span *span)
static void
ppelif(Lexer *lx, const Span *span)
{
- vlong v;
+ s64int v;
PPCond *cnd;
if (!nppcnd) {
@@ -1920,7 +1920,7 @@ ppline(Lexer *lx, Token *tk0)
tks[ntk++] = tk;
}
}
- uvlong lineno = 0;
+ u64int lineno = 0;
char *file = NULL;
if (ntk > 0 && tks[0].t == TKNUMLIT) {
if (!parsenumlit(&lineno, NULL, &tks[0], 1) || (lineno == 0 && !ext))
diff --git a/src/c_lex.h b/src/c_lex.h
index 57226ab..d436967 100644
--- a/src/c_lex.h
+++ b/src/c_lex.h
@@ -120,7 +120,7 @@ enum initlexer {
int lex(Lexer *, Token *);
int lexpeek(Lexer *, Token *);
-enum typetag parsenumlit(uvlong *, double *, const Token *, bool ispp);
+enum typetag parsenumlit(u64int *, double *, const Token *, bool ispp);
enum initlexer initlexer(Lexer *, const char **err, const char *file);
void lexerdump(Lexer *, WriteBuf *out);
void lexerfreetemps(Lexer *);
diff --git a/src/c_type.h b/src/c_type.h
index a9d95c4..ecca949 100644
--- a/src/c_type.h
+++ b/src/c_type.h
@@ -70,7 +70,7 @@ static_assert(sizeof(Type) == 4);
typedef struct {
internstr name;
- union { vlong i; uvlong u; };
+ union { s64int i; u64int u; };
} EnumVar;
typedef struct {
diff --git a/src/ir.c b/src/ir.c
index 6cdb43d..f0d58b2 100644
--- a/src/ir.c
+++ b/src/ir.c
@@ -133,7 +133,7 @@ mkirtype(Type t)
}
Ref
-mkintcon(enum irclass k, vlong i)
+mkintcon(enum irclass k, s64int i)
{
if (i < 1l << 28 && i >= -(1l << 28)) {
return mkref(RICON, i);
diff --git a/src/ir.h b/src/ir.h
index fef38b5..7c372bb 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -32,7 +32,7 @@ typedef struct IRCon {
union {
internstr sym;
int dat;
- vlong i;
+ s64int i;
double f;
};
} IRCon;
@@ -84,7 +84,7 @@ typedef struct IRAddr {
} IRAddr;
#define insrescls(ins) (oiscmp((ins).op) ? KI32 : (ins).cls)
-#define NOREF ((Ref) {0})
+#define NOREF ((Ref) {{0}})
#define UNDREF ((Ref) {{ 0, -1 }})
#define ZEROREF ((Ref) {{ RICON, 0 }})
#define mkref(t, x) ((Ref) {{ (t), (x) }})
@@ -161,16 +161,16 @@ typedef struct IRUse {
enum { MAXREGS = 64 };
/** register set **/
-typedef uvlong regset;
+typedef u64int regset;
#define BIT(x) (1ull<<(x))
#define rsset(pS, r) (*(pS) |= 1ull << (r))
#define rsclr(pS, r) (*(pS) &=~ (1ull << (r)))
#define rstest(S, r) ((S) >> (r) & 1)
static inline bool
-rsiter(int *i, uvlong rs)
+rsiter(int *i, u64int rs)
{
if (*i > 63) return 0;
- uvlong mask = -(1ull << *i);
+ u64int mask = -(1ull << *i);
if ((rs & mask) == 0) return 0;
*i = lowestsetbit(rs & mask);
return 1;
@@ -265,7 +265,7 @@ void irfini(Function *);
#define cls2type(k) ((IRType){.cls=(k)})
IRType mkirtype(Type);
Ref newxcon(const IRCon *);
-Ref mkintcon(enum irclass, vlong);
+Ref mkintcon(enum irclass, s64int);
Ref mkfltcon(enum irclass, double);
#define iscon(r) in_range((r).t, RICON, RXCON)
#define concls(r) ((r).t == RICON ? KI32 : contab.p[(r).i].cls)
diff --git a/src/ir_builder.c b/src/ir_builder.c
index 7f46574..8bb11a9 100644
--- a/src/ir_builder.c
+++ b/src/ir_builder.c
@@ -5,7 +5,7 @@ Ref
irbinop(Function *fn, enum op op, enum irclass k, Ref l, Ref r)
{
static const Ref ONE = {.t=RICON, .i=1};
- vlong iv;
+ s64int iv;
Ref c;
if (foldbinop(&c, op, k, l, r))
diff --git a/src/ir_fold.c b/src/ir_fold.c
index 9f0ff72..37edbbc 100644
--- a/src/ir_fold.c
+++ b/src/ir_fold.c
@@ -8,10 +8,10 @@ __attribute__((no_sanitize("float-cast-overflow"))) /* silence UBsan for float->
static Ref
foldint(enum op op, enum irclass k, Ref lr, Ref rr)
{
- vlong x;
+ s64int x;
union {
- vlong s;
- uvlong u;
+ s64int s;
+ u64int u;
} l = {.s = intconval(lr)}, r = {.s = intconval(rr)};
bool w = cls2siz[k] == 8;
if (in_range(op, Odiv, Ourem)) assert(r.u != 0);
@@ -24,10 +24,10 @@ foldint(enum op op, enum irclass k, Ref lr, Ref rr)
if (f != f) x = 0; \
else x = (TI)f; \
} while (0)
- case Ocvtf32s: if (w) CVTF2I(float, vlong); else CVTF2I(float, int); break;
- case Ocvtf32u: if (w) CVTF2I(float, uvlong); else CVTF2I(float, uint); break;
- case Ocvtf64s: if (w) CVTF2I(double, vlong); else CVTF2I(double, int); break;
- case Ocvtf64u: if (w) CVTF2I(double, uvlong); else CVTF2I(double, uint); break;
+ case Ocvtf32s: if (w) CVTF2I(float, s64int); else CVTF2I(float, int); break;
+ case Ocvtf32u: if (w) CVTF2I(float, u64int); else CVTF2I(float, uint); break;
+ case Ocvtf64s: if (w) CVTF2I(double, s64int); else CVTF2I(double, int); break;
+ case Ocvtf64u: if (w) CVTF2I(double, u64int); else CVTF2I(double, uint); break;
#undef CVTF2I
case Oexts8: x = (schar)l.s; break;
case Oextu8: x = (uchar)l.s; break;
@@ -84,8 +84,8 @@ foldflt(enum op op, enum irclass k, Ref lr, Ref rr)
case Ocvtf64f32: x = (float)l; break;
case Ocvts32f: x = (int)intconval(lr); break;
case Ocvtu32f: x = (int)intconval(lr); break;
- case Ocvts64f: x = (vlong)intconval(lr); break;
- case Ocvtu64f: x = (uvlong)intconval(lr); break;
+ case Ocvts64f: x = (s64int)intconval(lr); break;
+ case Ocvtu64f: x = (u64int)intconval(lr); break;
case Oadd: x = l + r; break;
case Osub: x = l - r; break;
case Omul: x = l * r; break;
diff --git a/src/ir_simpl.c b/src/ir_simpl.c
index ad25a9f..d353cfa 100644
--- a/src/ir_simpl.c
+++ b/src/ir_simpl.c
@@ -3,9 +3,9 @@
static int
mulk(Instr *ins, Block *blk, int *curi)
{
- vlong iv = intconval(ins->r);
+ s64int iv = intconval(ins->r);
enum irclass cls = ins->cls;
- assert((uvlong)iv > 1 && "trivial mul not handled by irbinop() ?");
+ assert((u64int)iv > 1 && "trivial mul not handled by irbinop() ?");
bool neg = iv < 0;
if (neg) iv = -iv;
/* This can be generalized to any sequence of shifts and
@@ -41,7 +41,7 @@ divmodk(Instr *ins, Block *blk, int *curi)
{
enum op op = ins->op;
enum irclass cls = ins->cls;
- vlong iv = intconval(ins->r);
+ s64int iv = intconval(ins->r);
uint nbit = 8 * cls2siz[cls];
bool neg = (op == Odiv || op == Orem) && iv < 0;
if (ispo2(iv) || (neg && ispo2(-iv))) { /* simple po2 cases */
@@ -122,7 +122,7 @@ doins(Instr *ins, Block *blk, int *curi)
Instr *lhs = &instrtab[ins->l.i];
enum op o = lhs->op;
if (ins->cls == lhs->cls && (o == Oadd || o == Osub || o == Oxor) && isintcon(lhs->r)) {
- uvlong c = intconval(ins->r), q = intconval(lhs->r);
+ u64int c = intconval(ins->r), q = intconval(lhs->r);
switch (o) { default: assert(0);
case Oadd: c -= q; break; /* x + 3 == C ==> x == C - 3 */
case Osub: c += q; break; /* x - 3 == C ==> x == C + 3 */
diff --git a/src/o_elf.c b/src/o_elf.c
index 336aa81..aae0c3f 100644
--- a/src/o_elf.c
+++ b/src/o_elf.c
@@ -16,7 +16,7 @@ typedef struct {
uchar bind : 4,
type : 4;
ushort shndx;
- uvlong value,
+ u64int value,
size;
} Sym;
static vec_of(Sym) symtab;
@@ -26,7 +26,7 @@ typedef struct {
uchar section;
ushort kind;
uint off;
- vlong addend;
+ s64int addend;
union {
uint symidx;
internstr symname;
@@ -115,7 +115,7 @@ elfhassym(internstr nam, uint *value)
}
void
-elfaddsym(internstr nam, int info, enum section sect, uvlong value, uvlong size)
+elfaddsym(internstr nam, int info, enum section sect, u64int value, u64int size)
{
Sym *sym = findsym(nam), sym0;
if (!sym) {
@@ -160,7 +160,7 @@ static const ushort relktab[][NRELOCKIND] = {
};
void
-elfreloc(internstr sym, enum relockind kind, enum section section, uint off, vlong addend)
+elfreloc(internstr sym, enum relockind kind, enum section section, uint off, s64int addend)
{
switch (section) {
default: assert(0);
diff --git a/src/obj.c b/src/obj.c
index 175334b..b6dd0e6 100644
--- a/src/obj.c
+++ b/src/obj.c
@@ -7,8 +7,8 @@
void elfinit(void);
enum section elfhassym(internstr , uint *value);
-void elfaddsym(internstr , int info, enum section, uvlong value, uvlong size);
-void elfreloc(internstr sym, enum relockind, enum section, uint off, vlong addend);
+void elfaddsym(internstr , int info, enum section, u64int value, u64int size);
+void elfreloc(internstr sym, enum relockind, enum section, uint off, s64int addend);
void elffini(WriteBuf *);
ObjFile objout;
@@ -90,7 +90,7 @@ objnewdat(internstr name, enum section sec, bool globl, uint siz, uint align)
}
void
-objreloc(internstr sym, enum relockind reloc, enum section section, uint off, vlong addend)
+objreloc(internstr sym, enum relockind reloc, enum section section, uint off, s64int addend)
{
switch (mctarg->objkind) {
case OBJELF:
diff --git a/src/obj.h b/src/obj.h
index bd34c8a..d898c55 100644
--- a/src/obj.h
+++ b/src/obj.h
@@ -33,7 +33,7 @@ void objini(const char *infile, const char *outfile);
void objdeffunc(internstr nam, bool globl, uint off, uint siz);
enum section objhassym(internstr name, uint *off);
uint objnewdat(internstr name, enum section, bool globl, uint siz, uint align);
-void objreloc(internstr sym, enum relockind, enum section, uint off, vlong addend);
+void objreloc(internstr sym, enum relockind, enum section, uint off, s64int addend);
void objfini(void);
/* vim:set ts=3 sw=3 expandtab: */
diff --git a/src/t_aarch64.h b/src/t_aarch64.h
index 997a5fd..2779e61 100644
--- a/src/t_aarch64.h
+++ b/src/t_aarch64.h
@@ -8,7 +8,7 @@ enum reg {
#define V(n) (V0+n)
};
-bool aarch64_logimm(uint *enc, enum irclass, uvlong x);
+bool aarch64_logimm(uint *enc, enum irclass, u64int x);
void aarch64_isel(Function *);
void aarch64_emit(Function *);
diff --git a/src/t_aarch64_emit.c b/src/t_aarch64_emit.c
index abf1f3e..52429a3 100644
--- a/src/t_aarch64_emit.c
+++ b/src/t_aarch64_emit.c
@@ -31,7 +31,7 @@ typedef struct Oper {
short disp;
};
} m;
- vlong imm; uvlong uimm; /* OIMM */
+ s64int imm; u64int uimm; /* OIMM */
struct { /* OSYM */
ushort con;
int cdisp;
@@ -541,7 +541,7 @@ gencopy(uchar **pcode, enum irclass cls, Block *blk, int curi, Oper dst, Ref val
if (isintcon(val)) {
assert(dst.reg <= R(31));
/* MOV r, #imm */
- uvlong u = intconval(val);
+ u64int u = intconval(val);
if (~u <= 0xFFFF) {
/* immediate can be encoded with 1 MOVN instruction */
Xmovn(pcode, cls, dst, mkoper(OIMM, .imm = ~u));
diff --git a/src/t_aarch64_isel.c b/src/t_aarch64_isel.c
index 29056bc..0e43ea7 100644
--- a/src/t_aarch64_isel.c
+++ b/src/t_aarch64_isel.c
@@ -3,13 +3,13 @@
#define isimm32(r) (iscon(r) && concls(r) == KI32)
static inline uint
-clz(uvlong x)
+clz(u64int x)
{
#if HAS_BUILTIN(clzll)
return __builtin_clzll(x);
#else
int i = 0;
- for (uvlong mask = BIT(63);; ++i, mask >>= 1)
+ for (u64int mask = BIT(63);; ++i, mask >>= 1)
if (x & mask)
break;
return i;
@@ -18,14 +18,14 @@ clz(uvlong x)
/* Encode logical immediate */
bool
-aarch64_logimm(uint *enc, enum irclass k, uvlong x)
+aarch64_logimm(uint *enc, enum irclass k, u64int x)
{
/* https://github.com/v8/v8/blob/927ccc6076e25a614787c7011315468e40fe39a4/src/codegen/arm64/assembler-arm64.cc#L4409 */
if (k == KI32) x = (uint)x | x << 32;
bool neg;
if ((neg = x & 1)) x = ~x;
if (x == 0) return 0;
- uvlong a = x & (~x + 1),
+ u64int a = x & (~x + 1),
xa = x + a,
b = xa & (~xa + 1),
xa_b = xa - b,
@@ -45,14 +45,14 @@ aarch64_logimm(uint *enc, enum irclass k, uvlong x)
}
if (!ispo2(d)) return 0;
if (((b - a) & ~mask) != 0) return 0;
- static const uvlong M[] = {
+ static const u64int M[] = {
0x0000000000000001, 0x0000000100000001, 0x0001000100010001,
0x0101010101010101, 0x1111111111111111, 0x5555555555555555,
};
int i = clz(d) - 57;
assert((uint)i < countof(M));
- uvlong m = M[i];
- uvlong y = (b - a) * m;
+ u64int m = M[i];
+ u64int y = (b - a) * m;
if (y != x) return 0;
if (enc) {
int clzb = b == 0 ? -1 : clz(b),
@@ -88,7 +88,7 @@ fixarg(Ref *r, Instr *ins, Block *blk, int *curi)
{
enum op op = ins ? ins->op : 0;
if (isintcon(*r)) {
- vlong x = intconval(*r);
+ s64int x = intconval(*r);
switch (op) {
case Ocopy: return;
default:
@@ -98,7 +98,7 @@ fixarg(Ref *r, Instr *ins, Block *blk, int *curi)
if ((x &~ 0xFFF) == 0 || (x &~ 0xFFF000) == 0) return;
break;
case Oshl: case Osar: case Oslr:
- if ((uvlong)x < (ins->cls == KI32 ? 32 : 64)) return;
+ if ((u64int)x < (ins->cls == KI32 ? 32 : 64)) return;
break;
case Oand: case Oior: case Oxor:
if (aarch64_logimm(NULL, ins->cls, x)) return;
@@ -110,12 +110,12 @@ fixarg(Ref *r, Instr *ins, Block *blk, int *curi)
enum irclass k = concls(*r), ki = KI32 + k-KF32;
if (contab.p[r->i].f != 0.0) {
union {
- vlong i64;
+ s64int i64;
int i32;
float f32;
double f64;
} pun;
- vlong i;
+ s64int i;
if (k == KF32) {
pun.f32 = contab.p[r->i].f;
i = pun.i32;
@@ -229,7 +229,7 @@ static bool
aimm(IRAddr *addr, int disp)
{
if (addr->index.bits) return 0;
- vlong a = addr->disp;
+ s64int a = addr->disp;
a += disp;
if ((int)a == a) {
addr->disp = a;
@@ -307,7 +307,7 @@ fuseaddr(Ref *r, Block *blk, int *curi, uint siz/*1,2,4,8*/)
if (r->t != RSTACK && r->t != RTMP) return 0;
if (!aadd(&addr, blk, curi, *r, siz)) return 0;
if (!(addr.disp >= -256 && addr.disp < 256) /* for 9-bit signed unscaled offset */
- && !(!(addr.disp & (siz-1)) && (uvlong)addr.disp < (1<<12)*siz)) /* 12-bit unsigned scaled offset */
+ && !(!(addr.disp & (siz-1)) && (u64int)addr.disp < (1<<12)*siz)) /* 12-bit unsigned scaled offset */
return 0;
if (isaddrcon(addr.base,0) && (!(contab.p[addr.base.i].flag & SLOCAL) || addr.index.bits)) {
/* first load symbol address into a temp register */
diff --git a/src/t_x86-64_emit.c b/src/t_x86-64_emit.c
index 507955a..9224d4b 100644
--- a/src/t_x86-64_emit.c
+++ b/src/t_x86-64_emit.c
@@ -49,7 +49,7 @@ ref2oper(Ref r)
if (contab.p[r.i].cls == KI32)
return mkoper(OIMM, .imm = contab.p[r.i].i);
else if (contab.p[r.i].cls == KI64) {
- vlong i = contab.p[r.i].i;
+ s64int i = contab.p[r.i].i;
assert(i == (int)i);
return mkoper(OIMM, .imm = i);
} else if (!contab.p[r.i].cls) {
diff --git a/src/t_x86-64_isel.c b/src/t_x86-64_isel.c
index d4a22d4..be2f2c7 100644
--- a/src/t_x86-64_isel.c
+++ b/src/t_x86-64_isel.c
@@ -194,9 +194,9 @@ selcall(Function *fn, Instr *ins, Block *blk, int *curi)
}
static bool
-aimm(IRAddr *addr, vlong disp)
+aimm(IRAddr *addr, s64int disp)
{
- vlong a = addr->disp;
+ s64int a = addr->disp;
a += disp;
if ((int)a == a) {
addr->disp = a;
@@ -222,7 +222,7 @@ ascale(IRAddr *addr, Ref a, Ref b)
/* XXX maybe we shouldn't do this here because it should be done by a generic
* arithemetic optimization pass ? */
if (ins->op == Oadd && (ins->l.t == RREG || ins->l.t == RTMP) && isintcon(ins->r)) {
- vlong a = ((vlong) addr->disp + intconval(ins->r)) * (1 << b.i);
+ s64int a = ((s64int) addr->disp + intconval(ins->r)) * (1 << b.i);
if (a != (int) a) return 0;
addr->disp = a;
addr->index = ins->l;
@@ -253,7 +253,7 @@ aadd(IRAddr *out, Block *blk, int *curi, Ref r, bool recurring)
Add2:;
int n1 = !!out->base.bits + !!out->index.bits;
int n2 = !!adr.base.bits + !!adr.index.bits;
- vlong off = (vlong) out->disp + adr.disp;
+ s64int off = (s64int) out->disp + adr.disp;
if (n1+n2 > 2 || (int)off != off) goto Ref;
if (n1 == 0) {
*out = adr;
@@ -453,7 +453,7 @@ sel(Function *fn, Instr *ins, Block *blk, int *curi)
goto ALU;
} else if (kisint(ins->cls) && isintcon(ins->r)) {
ins->op = op = Oadd;
- ins->r = mkintcon(concls(ins->r), -(uvlong)intconval(ins->r));
+ ins->r = mkintcon(concls(ins->r), -(u64int)intconval(ins->r));
} else {
goto ALU;
}
@@ -476,7 +476,7 @@ sel(Function *fn, Instr *ins, Block *blk, int *curi)
case Oneg:
if (kisflt(ins->cls)) {
/* flip sign bit with XORPS/D */
- static const uvlong sd[2] = {0x8000000000000000,0x8000000000000000};
+ static const u64int sd[2] = {0x8000000000000000,0x8000000000000000};
static const uint sf[4] = {0x80000000,80000000,0x80000000,80000000};
ins->op = Oxor;
ins->r = mkdatref(NULL, mktype(ins->cls == KF32 ? TYFLOAT : TYDOUBLE), /*siz*/16,
diff --git a/src/u_endian.h b/src/u_endian.h
index 49bbcc2..a020da8 100644
--- a/src/u_endian.h
+++ b/src/u_endian.h
@@ -29,9 +29,9 @@ bswap32(uint x) {
#if HAS_BUILTIN(bswap64)
#define bswap64 __builtin_bswap64
#else
-static inline uvlong
-bswap64(uvlong x) {
- return (uvlong) bswap32(x) << 32 | bswap32(x >> 32);
+static inline u64int
+bswap64(u64int x) {
+ return (u64int) bswap32(x) << 32 | bswap32(x >> 32);
}
#endif
@@ -68,7 +68,7 @@ wr32le(uchar *p, uint x)
}
static inline void
-wr64le(uchar *p, uvlong x)
+wr64le(uchar *p, u64int x)
{
#ifndef HOST_LIL_ENDIAN
x = bswap64(x);
@@ -97,7 +97,7 @@ wr32be(uchar *p, uint x)
}
static inline void
-wr64be(uchar *p, uvlong x)
+wr64be(uchar *p, u64int x)
{
#ifndef HOST_BIG_ENDIAN
x = bswap64(x);
@@ -125,10 +125,10 @@ rd32targ(uchar *p)
return x;
}
-static inline uvlong
+static inline u64int
rd64targ(uchar *p)
{
- uvlong x;
+ u64int x;
memcpy(&x, p, sizeof x);
if (!hostntarg_sameendian()) x = bswap64(x);
return x;
@@ -144,7 +144,7 @@ rdf32targ(uchar *p)
static inline double
rdf64targ(uchar *p)
{
- union { uvlong i; double f; } u = { rd64targ(p) };
+ union { u64int i; double f; } u = { rd64targ(p) };
return u.f;
}
@@ -163,7 +163,7 @@ wr32targ(uchar *p, uint x)
}
static inline void
-wr64targ(uchar *p, uvlong x)
+wr64targ(uchar *p, u64int x)
{
if (!hostntarg_sameendian()) x = bswap64(x);
memcpy(p, &x, sizeof x);
@@ -179,7 +179,7 @@ wrf32targ(uchar *p, float x)
static inline void
wrf64targ(uchar *p, double x)
{
- union { double f; uvlong i; } u = { x };
+ union { double f; u64int i; } u = { x };
wr64targ(p, u.i);
}
diff --git a/src/u_io.c b/src/u_io.c
index 8de02e3..7506b12 100644
--- a/src/u_io.c
+++ b/src/u_io.c
@@ -133,7 +133,7 @@ putquoted(WriteBuf *buf, uchar c, uchar qchar, int next)
}
static int
-putuint(WriteBuf *buf, uvlong x, int base, bool lower)
+putuint(WriteBuf *buf, u64int x, int base, bool lower)
{
uchar tmp[64];
uchar *end = tmp + sizeof(tmp);
@@ -288,7 +288,7 @@ vbfmt(WriteBuf *out, const char *fmt, va_list ap)
{
bool quote, umod, lmod, zmod, lower, possign;
int base;
- vlong i;
+ s64int i;
int pad, prec, q;
const char *s;
void *p;
@@ -403,14 +403,14 @@ vbfmt(WriteBuf *out, const char *fmt, va_list ap)
base = 10;
Int:
if (base != 10) umod = 1;
- i = lmod ? va_arg(ap, vlong)
+ i = lmod ? va_arg(ap, s64int)
: umod ? va_arg(ap, uint)
- : zmod && sizeof(&i-&i) > sizeof(int) ? va_arg(ap, vlong)
- : (vlong)va_arg(ap, int);
+ : zmod && sizeof(&i-&i) > sizeof(int) ? va_arg(ap, s64int)
+ : (s64int)va_arg(ap, int);
tmp2.len = 0;
if (!umod && i < 0) {
n += bputc(buf, '-');
- i = -(uvlong)i;
+ i = -(u64int)i;
} else if (possign) {
n += bputc(buf, '+');
}
@@ -445,7 +445,7 @@ vbfmt(WriteBuf *out, const char *fmt, va_list ap)
} else {
n += bwriteS(buf, "0x");
tmp2.len = 0;
- n += putuint(prec > 0 ? &tmp2 : buf, (uvlong)p, 16, 1);
+ n += putuint(prec > 0 ? &tmp2 : buf, (u64int)p, 16, 1);
if (prec > 0) {
int fil = prec - tmp2.len;
while (fil-- > 0) n += bputc(buf, '0');