diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-20 13:04:07 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-30 13:20:42 -0400 |
commit | b284721c8acae244d054dbe8c8b5878f0e649c0a (patch) | |
tree | 304446e2680f1b43dd76832fa64d15a25136f631 /lisc/emit.c | |
parent | 993416481a5d5c89410488fbab311ee0b943f948 (diff) | |
download | roux-b284721c8acae244d054dbe8c8b5878f0e649c0a.tar.gz |
emit code for extensions, move slots into RAlt
Diffstat (limited to 'lisc/emit.c')
-rw-r--r-- | lisc/emit.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lisc/emit.c b/lisc/emit.c index 9500dc9..b8365c2 100644 --- a/lisc/emit.c +++ b/lisc/emit.c @@ -37,9 +37,10 @@ emitf(Fn *fn, FILE *f, char *fmt, ...) static char stoa[] = "qlwb"; va_list ap; char c, *s, *s1; - int i, ty; + int i, ty, off; Ref ref; Con *con; + struct { int i:AShift; } x; va_start(ap, fmt); ty = SWord; @@ -81,10 +82,9 @@ Next: assert(isreg(ref)); fprintf(f, "%%%s", rsub[ref.val][ty]); break; - case RSlot: - Slot: { - int off; - struct { int i:14; } x = {ref.val}; /* fixme */ + case RASlot: + Slot: + x.i = ref.val & AMask; assert(NAlign == 3); if (x.i < 0) off = -4 * x.i; @@ -94,7 +94,6 @@ Next: } fprintf(f, "%d(%%rbp)", off); break; - } case RCon: fputc('$', f); Con: @@ -117,9 +116,9 @@ Next: case 'M': ref = va_arg(ap, Ref); switch (rtype(ref)) { - default: diag("emit: invalid memory reference"); - case RSlot: goto Slot; - case RCon: goto Con; + default: diag("emit: invalid memory reference"); + case RASlot: goto Slot; + case RCon: goto Con; case RTmp: assert(isreg(ref)); fprintf(f, "(%%%s)", rsub[ref.val][SLong]); @@ -234,6 +233,20 @@ eins(Ins i, Fn *fn, FILE *f) emitf(fn, f, "%s%w %M, %R", otoa[i.op], i.wide, i.arg[0], i.to); break; + case OExt+Tuw: + emitf(fn, f, "movl %R, %R", i.arg[0], i.to); + break; + case OExt+Tsw: + case OExt+Tsh: + case OExt+Tuh: + case OExt+Tsb: + case OExt+Tub: + emitf(fn, f, "mov%s%t%s %R, %W%R", + (i.op-OExt-Tsw)%2 ? "z" : "s", + 1+(i.op-OExt-Tsw)/2, + i.wide ? "q" : "l", + i.arg[0], i.wide, i.to); + break; case OCall: switch (rtype(i.arg[0])) { default: |