diff options
-rw-r--r-- | cc.h | 12 | ||||
-rw-r--r-- | decl.c | 6 | ||||
-rw-r--r-- | eval.c | 9 | ||||
-rw-r--r-- | expr.c | 8 | ||||
-rw-r--r-- | qbe.c | 36 | ||||
-rw-r--r-- | stmt.c | 2 | ||||
-rw-r--r-- | tree.c | 2 | ||||
-rw-r--r-- | util.h | 4 |
8 files changed, 40 insertions, 39 deletions
@@ -329,8 +329,8 @@ struct expr { struct decl *decl; } ident; union { - uint64_t u; - int64_t i; + unsigned long long u; + long long i; double f; } constant; struct stringlit string; @@ -474,7 +474,7 @@ struct type *stringconcat(struct stringlit *, _Bool); struct expr *expr(struct scope *); struct expr *assignexpr(struct scope *); struct expr *constexpr(struct scope *); -uint64_t intconstexpr(struct scope *, _Bool); +unsigned long long intconstexpr(struct scope *, _Bool); void delexpr(struct expr *); struct expr *exprconvert(struct expr *, struct type *); @@ -509,15 +509,15 @@ struct switchcases { struct block *defaultlabel; }; -void switchcase(struct switchcases *, uint64_t, struct block *); +void switchcase(struct switchcases *, unsigned long long, struct block *); struct block *mkblock(char *); struct value *mkglobal(char *, _Bool); char *globalname(struct value *); -struct value *mkintconst(uint64_t); -uint64_t intconstvalue(struct value *); +struct value *mkintconst(unsigned long long); +unsigned long long intconstvalue(struct value *); struct func *mkfunc(struct decl *, char *, struct type *, struct scope *); void delfunc(struct func *); @@ -151,7 +151,7 @@ tagspec(struct scope *s) struct decl *d; struct expr *e; struct structbuilder b; - uint64_t i; + unsigned long long i; bool large; switch (tok.kind) { @@ -561,7 +561,7 @@ declaratortypes(struct scope *s, struct list *result, char **name, bool allowabs if (e->kind != EXPRCONST || !(e->type->prop & PROPINT)) error(&tok.loc, "VLAs are not yet supported"); i = e->u.constant.u; - if (e->type->u.basic.issigned && i > INT64_MAX) + if (e->type->u.basic.issigned && i >> 63) error(&tok.loc, "array length must be non-negative"); delexpr(e); t->u.array.length = i; @@ -747,7 +747,7 @@ static bool staticassert(struct scope *s) { struct stringlit msg; - uint64_t c; + unsigned long long c; if (!consume(T_STATIC_ASSERT)) return false; @@ -1,3 +1,4 @@ +#include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> @@ -10,14 +11,14 @@ static void cast(struct expr *expr) { unsigned size; - uint64_t m; + unsigned long long m; size = expr->type->size; if (expr->type->prop & PROPFLOAT) { if (size == 4) expr->u.constant.f = (float)expr->u.constant.f; } else if (expr->type->prop & PROPINT) { - expr->u.constant.u &= UINT64_MAX >> (8 - size) * 8; + expr->u.constant.u &= -1ull >> CHAR_BIT * sizeof(unsigned long long) - size * 8; if (expr->type->u.basic.issigned) { m = 1ull << size * 8 - 1; expr->u.constant.u = (expr->u.constant.u ^ m) - m; @@ -137,11 +138,11 @@ eval(struct expr *expr, enum evalkind kind) expr->u.constant.f = l->u.constant.u; } else if (l->type->prop & PROPFLOAT && t->prop & PROPINT) { if (t->u.basic.issigned) { - if (l->u.constant.f < INT64_MIN || l->u.constant.f > INT64_MAX) + if (l->u.constant.f < -1 - 0x7fffffffffffffff || l->u.constant.f > 0x7fffffffffffffff) error(&tok.loc, "integer part of floating-point constant %g cannot be represented as signed integer", l->u.constant.f); expr->u.constant.i = l->u.constant.f; } else { - if (l->u.constant.f < 0 || l->u.constant.f > UINT64_MAX) + if (l->u.constant.f < 0 || l->u.constant.f > 0xffffffffffffffff) error(&tok.loc, "integer part of floating-point constant %g cannot be represented as unsigned integer", l->u.constant.f); expr->u.constant.u = l->u.constant.f; } @@ -74,7 +74,7 @@ delexpr(struct expr *e) } static struct expr * -mkconstexpr(struct type *t, uint64_t n) +mkconstexpr(struct type *t, unsigned long long n) { struct expr *e; @@ -666,7 +666,7 @@ designator(struct scope *s, struct type *t, unsigned long long *offset) { char *name; struct member *m; - uint64_t i; + unsigned long long i; for (;;) { switch (tok.kind) { @@ -1175,7 +1175,7 @@ constexpr(struct scope *s) return eval(condexpr(s), EVALARITH); } -uint64_t +unsigned long long intconstexpr(struct scope *s, bool allowneg) { struct expr *e; @@ -1183,7 +1183,7 @@ intconstexpr(struct scope *s, bool allowneg) e = constexpr(s); if (e->kind != EXPRCONST || !(e->type->prop & PROPINT)) error(&tok.loc, "not an integer constant expression"); - if (!allowneg && e->type->u.basic.issigned && e->u.constant.u > INT64_MAX) + if (!allowneg && e->type->u.basic.issigned && e->u.constant.u >> 63) error(&tok.loc, "integer constant expression cannot be negative"); return e->u.constant.u; } @@ -1,10 +1,10 @@ #include <assert.h> #include <ctype.h> +#include <inttypes.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <inttypes.h> #include "util.h" #include "cc.h" @@ -22,7 +22,7 @@ struct value { unsigned id; union { char *name; - uint64_t i; + unsigned long long i; double f; } u; }; @@ -96,7 +96,7 @@ struct func { static const int ptrclass = 'l'; void -switchcase(struct switchcases *cases, uint64_t i, struct block *b) +switchcase(struct switchcases *cases, unsigned long long i, struct block *b) { struct switchcase *c; @@ -148,7 +148,7 @@ globalname(struct value *v) } struct value * -mkintconst(uint64_t n) +mkintconst(unsigned long long n) { struct value *v; @@ -159,7 +159,7 @@ mkintconst(uint64_t n) return v; } -uint64_t +unsigned long long intconstvalue(struct value *v) { assert(v->kind == VALUE_INTCONST); @@ -306,12 +306,12 @@ funcbits(struct func *f, struct type *t, struct value *v, struct bitfield b) } static void -funccopy(struct func *f, struct value *dst, struct value *src, uint64_t size, int align) +funccopy(struct func *f, struct value *dst, struct value *src, unsigned long long size, int align) { enum instkind load, store; int class; struct value *tmp, *inc; - uint64_t off; + unsigned long long off; assert((align & align - 1) == 0); class = 'w'; @@ -971,7 +971,7 @@ funcexpr(struct func *f, struct expr *e) } static void -zero(struct func *func, struct value *addr, int align, uint64_t offset, uint64_t end) +zero(struct func *func, struct value *addr, int align, unsigned long long offset, unsigned long long end) { static const enum instkind store[] = { [1] = ISTOREB, @@ -999,7 +999,7 @@ funcinit(struct func *func, struct decl *d, struct init *init) { struct lvalue dst; struct value *src, *v; - uint64_t offset = 0, max = 0; + unsigned long long offset = 0, max = 0; size_t i, w; funcalloc(func, d); @@ -1088,7 +1088,7 @@ emitvalue(struct value *v) switch (v->kind) { case VALUE_INTCONST: - printf("%" PRIu64, v->u.i); + printf("%llu", v->u.i); break; case VALUE_FLTCONST: printf("s_%.17g", v->u.f); @@ -1124,10 +1124,10 @@ emitclass(int class, struct value *v) static void emittype(struct type *t) { - static uint64_t id; + static unsigned id; struct member *m, *other; struct type *sub; - uint64_t i, off; + unsigned long long i, off; if (t->value || t->kind != TYPESTRUCT && t->kind != TYPEUNION) return; @@ -1164,7 +1164,7 @@ emittype(struct type *t) i *= sub->u.array.length; emitclass(qbetype(sub).data, sub->value); if (i > 1) - printf(" %" PRIu64, i); + printf(" %llu", i); if (t->kind == TYPESTRUCT) { fputs(", ", stdout); /* skip subsequent members contained within the same storage unit */ @@ -1310,7 +1310,7 @@ emitfunc(struct func *f, bool global) } static void -dataitem(struct expr *expr, uint64_t size) +dataitem(struct expr *expr, unsigned long long size) { struct decl *decl; size_t i, w; @@ -1339,7 +1339,7 @@ dataitem(struct expr *expr, uint64_t size) if (expr->type->prop & PROPFLOAT) printf("%c_%.17g", expr->type->size == 4 ? 's' : 'd', expr->u.constant.f); else - printf("%" PRIu64, expr->u.constant.u); + printf("%llu", expr->u.constant.u); break; case EXPRSTRING: w = expr->type->base->size; @@ -1363,7 +1363,7 @@ dataitem(struct expr *expr, uint64_t size) } } if (i * w < size) - printf(", z %" PRIu64, size - i * w); + printf(", z %llu", size - (unsigned long long)i * w); break; default: error(&tok.loc, "initializer is not a constant expression"); @@ -1375,7 +1375,7 @@ emitdata(struct decl *d, struct init *init) { struct init *cur; struct type *t; - uint64_t offset = 0, start, end, bits = 0; + unsigned long long offset = 0, start, end, bits = 0; size_t i; if (!d->align) @@ -1415,7 +1415,7 @@ emitdata(struct decl *d, struct init *init) bits = 0; } if (offset < start) - printf("z %" PRIu64 ", ", start - offset); + printf("z %llu, ", start - offset); if (cur->bits.before || cur->bits.after) { /* XXX: little-endian specific */ assert(cur->expr->type->prop & PROPINT); @@ -14,7 +14,7 @@ label(struct func *f, struct scope *s) char *name; struct gotolabel *g; struct block *b; - uint64_t i; + unsigned long long i; switch (tok.kind) { case TCASE: @@ -68,7 +68,7 @@ static int balance(void **p) } void * -treeinsert(void **root, uint64_t key, size_t sz) +treeinsert(void **root, unsigned long long key, size_t sz) { void **a[MAXH]; struct treenode *n = *root; @@ -14,7 +14,7 @@ struct mapkey { }; struct treenode { - uint64_t key; + unsigned long long key; void *child[2]; int height; _Bool new; /* set by treeinsert if this node was newly allocated */ @@ -55,4 +55,4 @@ void *mapget(struct map *, struct mapkey *); /* tree */ -void *treeinsert(void **, uint64_t, size_t); +void *treeinsert(void **, unsigned long long, size_t); |