qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

commit 8ca73af85a2351b99e0d19564548dd35ccf61011
parent faa084cca9c764e86c2751109352a599a8782b8a
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date:   Sun, 14 Aug 2016 18:11:49 -0700

use an enum for aggregate segments

Diffstat:
Mall.h | 11++++++++---
Mparse.c | 13++++++-------
Msysv.c | 13++++++++-----
3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/all.h b/all.h @@ -425,9 +425,14 @@ struct Typ { ulong size; int align; - struct { - uint isflt:1; - uint ispad:1; + struct Seg { + enum { + Spad, + Sint, + Sflt, + Styp, + }; + uint type:2; uint len:30; } seg[NSeg+1]; }; diff --git a/parse.c b/parse.c @@ -791,7 +791,7 @@ static void parsetyp() { Typ *ty; - int t, n, c, a, al, flt; + int t, n, c, a, al, type; ulong sz, s; if (ntyp >= NTyp) @@ -825,12 +825,12 @@ parsetyp() sz = 0; al = 0; while (t != Trbrace) { - flt = 0; + type = Sint; switch (t) { default: err("invalid size specifier %c", tokval.chr); - case Td: flt = 1; + case Td: type = Sflt; case Tl: s = 8; a = 3; break; - case Ts: flt = 1; + case Ts: type = Sflt; case Tw: s = 4; a = 2; break; case Th: s = 2; a = 1; break; case Tb: s = 1; a = 0; break; @@ -841,7 +841,7 @@ parsetyp() a = s - a; if (n < NSeg) { /* padding segment */ - ty->seg[n].ispad = 1; + ty->seg[n].type = Spad; ty->seg[n].len = a; n++; } @@ -854,8 +854,7 @@ parsetyp() c = 1; sz += a + c*s; for (; c>0 && n<NSeg; c--, n++) { - ty->seg[n].isflt = flt; - ty->seg[n].ispad = 0; + ty->seg[n].type = type; ty->seg[n].len = s; } if (t != Tcomma) diff --git a/sysv.c b/sysv.c @@ -49,15 +49,18 @@ aclass(AClass *a, Typ *t) for (e=0, s=0; e<2; e++) { cls = -1; for (n=0; n<8 && t->seg[s].len; s++) { - if (t->seg[s].ispad) { + switch (t->seg[s].type) { + case Spad: /* don't change anything */ - } - else if (t->seg[s].isflt) { + break; + case Sflt: if (cls == -1) cls = Kd; - } - else + break; + case Sint: cls = Kl; + break; + } n += t->seg[s].len; } assert(n <= 8);