summary refs log tree commit diff
path: root/lisc/emit.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-10 22:55:03 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:33 -0400
commit8201c6161e215e4716f3305e3dcb1e6b3de15ea9 (patch)
tree92596cdc92b02bb1039d41ff46002f855c8e607c /lisc/emit.c
parent7e86fc39fcee98595a723daac39aa8a4ee3dfc96 (diff)
downloadroux-8201c6161e215e4716f3305e3dcb1e6b3de15ea9.tar.gz
start function call lowering (wip)
Diffstat (limited to 'lisc/emit.c')
-rw-r--r--lisc/emit.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index 449824c..8f370d9 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -221,11 +221,8 @@ eins(Ins i, Fn *fn, FILE *f)
 		emitf(fn, f, "\t%s%w %M, %R\n", otoa[i.op],
 			i.wide, i.arg[0], i.to);
 		break;
-	case OAlloc:
-		emitf(fn, f, "\tsub%w %R, %R\n",
-			1, i.arg[0], TMP(RSP));
-		emitf(fn, f, "\tmov%w %R, %R\n",
-			1, TMP(RSP), i.to);
+	case OCall:
+		emitf(fn, f, "\tcall%w %R\n", 1, i.arg[0]);
 		break;
 	case OAddr:
 		emitf(fn, f, "\tlea%w %M, %R\n",
@@ -244,6 +241,19 @@ eins(Ins i, Fn *fn, FILE *f)
 		} else
 			diag("emit: unhandled instruction (2)");
 		break;
+	case OSAlloc:
+		emitf(fn, f, "\tsub%w %R, %R\n",
+			1, i.arg[0], TMP(RSP));
+		if (!req(i.to, R))
+			emitf(fn, f, "\tmov%w %R, %R\n",
+				1, TMP(RSP), i.to);
+		break;
+	case OXPush:
+		emitf(fn, f, "\tpush%w %R\n", 1, i.arg[0]);
+		break;
+	case OXMovs:
+		emitf(fn, f, "\trep movsb\n");
+		break;
 	case OXDiv:
 		emitf(fn, f, "\tidiv%w %R\n", i.wide, i.arg[0]);
 		break;