From 55395c5e81f8769315888bee61b67e6bbf5da5eb Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 29 Sep 2021 14:41:59 -0700 Subject: Use unsigned long long for sizes and offsets We don't need exact-width integer types here. --- cc.h | 14 +++++++------- decl.c | 8 ++++---- expr.c | 6 +++--- init.c | 8 ++++---- qbe.c | 4 ++-- type.c | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cc.h b/cc.h index 49a3fd0..021801e 100644 --- a/cc.h +++ b/cc.h @@ -191,7 +191,7 @@ struct member { char *name; struct type *type; enum typequal qual; - uint64_t offset; + unsigned long long offset; struct bitfield bits; struct member *next; }; @@ -200,7 +200,7 @@ struct type { enum typekind kind; enum typeprop prop; int align; - uint64_t size; + unsigned long long size; struct value *value; /* used by the backend */ union { struct type *base; @@ -214,7 +214,7 @@ struct type { _Bool issigned, iscomplex; } basic; struct { - uint64_t length; + unsigned long long length; } array; struct { _Bool isprototype, isvararg, isnoreturn, paraminfo; @@ -368,7 +368,7 @@ struct expr { }; struct init { - uint64_t start, end; + unsigned long long start, end; struct expr *expr; struct bitfield bits; struct init *next; @@ -410,7 +410,7 @@ _Bool consume(int); struct type *mktype(enum typekind, enum typeprop); struct type *mkpointertype(struct type *, enum typequal); -struct type *mkarraytype(struct type *, enum typequal, uint64_t); +struct type *mkarraytype(struct type *, enum typequal, unsigned long long); _Bool typecompatible(struct type *, struct type *); _Bool typesame(struct type *, struct type *); @@ -420,7 +420,7 @@ struct type *typecommonreal(struct type *, unsigned, struct type *, unsigned); struct type *typepromote(struct type *, unsigned); struct type *typeadjust(struct type *); enum typeprop typeprop(struct type *); -struct member *typemember(struct type *, const char *, uint64_t *); +struct member *typemember(struct type *, const char *, unsigned long long *); struct param *mkparam(char *, struct type *, enum typequal); @@ -493,7 +493,7 @@ struct expr *eval(struct expr *, enum evalkind); /* init */ -struct init *mkinit(uint64_t, uint64_t, struct bitfield, struct expr *); +struct init *mkinit(unsigned long long, unsigned long long, struct bitfield, struct expr *); struct init *parseinit(struct scope *, struct type *); void stmt(struct func *, struct scope *); diff --git a/decl.c b/decl.c index 2483a47..0b07656 100644 --- a/decl.c +++ b/decl.c @@ -261,7 +261,7 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align) enum typespec ts = SPECNONE; enum typequal tq = QUALNONE; int ntypes = 0; - uint64_t i; + unsigned long long i; t = NULL; if (sc) @@ -464,7 +464,7 @@ declaratortypes(struct scope *s, struct list *result, char **name, bool allowabs struct type *t; struct param **p; struct expr *e; - uint64_t i; + unsigned long long i; enum typequal tq; while (consume(TMUL)) { @@ -664,7 +664,7 @@ paramdecl(struct scope *s, struct param *params) } static void -addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, uint64_t width) +addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, unsigned long long width) { struct type *t = b->type; struct member *m; @@ -774,7 +774,7 @@ structdecl(struct scope *s, struct structbuilder *b) { struct qualtype base, mt; char *name; - uint64_t width; + unsigned long long width; int align; if (staticassert(s)) diff --git a/expr.c b/expr.c index 182972e..353d1f3 100644 --- a/expr.c +++ b/expr.c @@ -553,7 +553,7 @@ static struct expr *condexpr(struct scope *); /* TODO: merge with init.c:designator() */ static void -designator(struct scope *s, struct type *t, uint64_t *offset) +designator(struct scope *s, struct type *t, unsigned long long *offset) { char *name; struct member *m; @@ -594,7 +594,7 @@ builtinfunc(struct scope *s, enum builtinkind kind) struct type *t; struct member *m; char *name; - uint64_t offset; + unsigned long long offset; switch (kind) { case BUILTINALLOCA: @@ -717,7 +717,7 @@ postfixexpr(struct scope *s, struct expr *r) struct type *t; struct param *p; struct member *m; - uint64_t offset; + unsigned long long offset; enum typequal tq; enum tokenkind op; bool lvalue; diff --git a/init.c b/init.c index e3090df..08018bc 100644 --- a/init.c +++ b/init.c @@ -7,7 +7,7 @@ #include "cc.h" struct object { - uint64_t offset; + unsigned long long offset; struct type *type; union { struct member *mem; @@ -24,7 +24,7 @@ struct initparser { }; struct init * -mkinit(uint64_t start, uint64_t end, struct bitfield bits, struct expr *expr) +mkinit(unsigned long long start, unsigned long long end, struct bitfield bits, struct expr *expr) { struct init *init; @@ -64,7 +64,7 @@ initadd(struct initparser *p, struct init *new) } static void -updatearray(struct type *t, uint64_t i) +updatearray(struct type *t, unsigned long long i) { if (!t->incomplete) return; @@ -75,7 +75,7 @@ updatearray(struct type *t, uint64_t i) } static void -subobj(struct initparser *p, struct type *t, uint64_t off) +subobj(struct initparser *p, struct type *t, unsigned long long off) { off += p->sub->offset; if (++p->sub == p->obj + LEN(p->obj)) diff --git a/qbe.c b/qbe.c index f6ac39b..529df02 100644 --- a/qbe.c +++ b/qbe.c @@ -1128,7 +1128,7 @@ emittype(struct type *t) fputs("type ", stdout); emitvalue(t->value); if (t == targ->typevalist) { - printf(" = align %d { %" PRIu64 " }\n", t->align, t->size); + printf(" = align %d { %llu }\n", t->align, t->size); return; } fputs(" = { ", stdout); @@ -1427,6 +1427,6 @@ emitdata(struct decl *d, struct init *init) } assert(offset <= d->type->size); if (offset < d->type->size) - printf("z %" PRIu64 " ", d->type->size - offset); + printf("z %llu ", d->type->size - offset); puts("}"); } diff --git a/type.c b/type.c index 2653310..82a2da6 100644 --- a/type.c +++ b/type.c @@ -71,7 +71,7 @@ mkpointertype(struct type *base, enum typequal qual) } struct type * -mkarraytype(struct type *base, enum typequal qual, uint64_t len) +mkarraytype(struct type *base, enum typequal qual, unsigned long long len) { struct type *t; @@ -235,7 +235,7 @@ typeadjust(struct type *t) } struct member * -typemember(struct type *t, const char *name, uint64_t *offset) +typemember(struct type *t, const char *name, unsigned long long *offset) { struct member *m, *sub; -- cgit v1.2.3