start improving constants support
This commit is contained in:
parent
837c46ca81
commit
92be2fdd17
3 changed files with 83 additions and 9 deletions
16
lisc/emit.c
16
lisc/emit.c
|
@ -4,6 +4,8 @@
|
|||
static void
|
||||
eref(Ref r, Fn *fn, FILE *f)
|
||||
{
|
||||
Const *c;
|
||||
|
||||
switch (rtype(r)) {
|
||||
case RSym:
|
||||
assert(fn->sym[r.val].type == SReg);
|
||||
|
@ -13,7 +15,19 @@ eref(Ref r, Fn *fn, FILE *f)
|
|||
fprintf(f, "-%d(%%rbp)", 8 * r.val);
|
||||
break;
|
||||
case RConst:
|
||||
fprintf(f, "$%d", (int)r.val);
|
||||
c = &fn->cst[r.val];
|
||||
switch (c->type) {
|
||||
case CAddr:
|
||||
fprintf(f, "$%s", c->label);
|
||||
if (c->val)
|
||||
fprintf(f, "%+"PRIi64, c->val);
|
||||
break;
|
||||
case CNum:
|
||||
fprintf(f, "$%"PRId64, c->val);
|
||||
break;
|
||||
default:
|
||||
diag("emitref: invalid constant");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
diag("emitref: invalid reference");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue