summary refs log tree commit diff
path: root/amd64
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-10-03 11:08:05 +0200
committerQuentin Carbonneaux <quentin@c9x.me>2022-10-08 21:48:47 +0200
commitb03a8970d7b73959397f0ca5c8f2a532c1905e5d (patch)
tree028eb6726e95352c54b1911abbe609ef3a26bc6f /amd64
parenta7e1602252be24f51afa3dc66e3adc2b88d1e0c1 (diff)
downloadroux-b03a8970d7b73959397f0ca5c8f2a532c1905e5d.tar.gz
mark apple targets with a boolean
It is more natural to branch on a
flag than have different function
pointers for high-level passes.
Diffstat (limited to 'amd64')
-rw-r--r--amd64/all.h3
-rw-r--r--amd64/emit.c19
-rw-r--r--amd64/targ.c4
3 files changed, 7 insertions, 19 deletions
diff --git a/amd64/all.h b/amd64/all.h
index f6ad227..3a2db0e 100644
--- a/amd64/all.h
+++ b/amd64/all.h
@@ -67,5 +67,4 @@ void amd64_sysv_abi(Fn *);
 void amd64_isel(Fn *);
 
 /* emit.c */
-void amd64_sysv_emitfn(Fn *, FILE *);
-void amd64_apple_emitfn(Fn *, FILE *);
+void amd64_emitfn(Fn *, FILE *);
diff --git a/amd64/emit.c b/amd64/emit.c
index 064ee60..84714e8 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -538,8 +538,8 @@ framesz(Fn *fn)
 	return 4*f + 8*o + 176*fn->vararg;
 }
 
-static void
-emitfn(Fn *fn, FILE *f)
+void
+amd64_emitfn(Fn *fn, FILE *f)
 {
 	static char *ctoa[] = {
 	#define X(c, s) [c] = s,
@@ -620,17 +620,6 @@ emitfn(Fn *fn, FILE *f)
 		}
 	}
 	id0 += fn->nblk;
-}
-
-void
-amd64_sysv_emitfn(Fn *fn, FILE *f)
-{
-	emitfn(fn, f);
-	elf_emitfnfin(fn->name, f);
-}
-
-void
-amd64_apple_emitfn(Fn *fn, FILE *f)
-{
-	emitfn(fn, f);
+	if (!T.apple)
+		elf_emitfnfin(fn->name, f);
 }
diff --git a/amd64/targ.c b/amd64/targ.c
index 74fba4d..fba9144 100644
--- a/amd64/targ.c
+++ b/amd64/targ.c
@@ -27,10 +27,10 @@ amd64_memargs(int op)
 	.abi0 = elimsb, \
 	.abi1 = amd64_sysv_abi, \
 	.isel = amd64_isel, \
+	.emitfn = amd64_emitfn, \
 
 Target T_amd64_sysv = {
 	.name = "amd64_sysv",
-	.emitfn = amd64_sysv_emitfn,
 	.emitfin = elf_emitfin,
 	.asloc = ".L",
 	AMD64_COMMON
@@ -38,7 +38,7 @@ Target T_amd64_sysv = {
 
 Target T_amd64_apple = {
 	.name = "amd64_apple",
-	.emitfn = amd64_apple_emitfn,
+	.apple = 1,
 	.emitfin = macho_emitfin,
 	.asloc = "L",
 	.assym = "_",