summary refs log tree commit diff
path: root/arm64
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-08-29 18:45:52 +0200
committerQuentin Carbonneaux <quentin@c9x.me>2022-08-31 21:42:49 +0200
commit8dddb971d923fa19dced39013e6d4a39676e065a (patch)
tree88192ecf3a60de73f06d03dab51dc51f17fb4ab7 /arm64
parent5490268683c82ad07eac6d2e8296a45702a8381e (diff)
downloadroux-8dddb971d923fa19dced39013e6d4a39676e065a.tar.gz
drop -G flag and add target amd64_apple
apple support is more than assembly syntax
in case of arm64 machines, and apple syntax
is currently useless in all cases but amd64;
rather than having a -G option that only
makes sense with amd64, we add a new target
amd64_apple
Diffstat (limited to 'arm64')
-rw-r--r--arm64/emit.c24
-rw-r--r--arm64/isel.c2
-rw-r--r--arm64/targ.c2
3 files changed, 19 insertions, 9 deletions
diff --git a/arm64/emit.c b/arm64/emit.c
index 2506eea..ec4d350 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -245,7 +245,7 @@ emitf(char *s, Ins *i, E *e)
 static void
 loadcon(Con *c, int r, int k, FILE *f)
 {
-	char *rn, *p, off[32];
+	char *rn, *l, *p, off[32];
 	int64_t n;
 	int w, sh;
 
@@ -258,11 +258,12 @@ loadcon(Con *c, int r, int k, FILE *f)
 			sprintf(off, "+%"PRIi64, n);
 		else
 			off[0] = 0;
-		p = c->local ? ".L" : "";
+		l = str(c->label);
+		p = c->local ? T.asloc : l[0] == '"' ? "" : T.assym;
 		fprintf(f, "\tadrp\t%s, %s%s%s\n",
-			rn, p, str(c->label), off);
+			rn, p, l, off);
 		fprintf(f, "\tadd\t%s, %s, #:lo12:%s%s%s\n",
-			rn, rn, p, str(c->label), off);
+			rn, rn, p, l, off);
 		return;
 	}
 	assert(c->type == CBits);
@@ -451,7 +452,7 @@ arm64_emitfn(Fn *fn, FILE *out)
 	Ins *i;
 	E *e;
 
-	gasemitlnk(fn->name, &fn->lnk, ".text", out);
+	emitlnk(fn->name, &fn->lnk, ".text", out);
 	e = &(E){.f = out, .fn = fn};
 	framelayout(e);
 
@@ -500,7 +501,7 @@ arm64_emitfn(Fn *fn, FILE *out)
 
 	for (lbl=0, b=e->fn->start; b; b=b->link) {
 		if (lbl || b->npred > 1)
-			fprintf(e->f, ".L%d:\n", id0+b->id);
+			fprintf(e->f, "%s%d:\n", T.asloc, id0+b->id);
 		for (i=b->ins; i!=&b->ins[b->nins]; i++)
 			emitins(i, e);
 		lbl = 1;
@@ -550,7 +551,10 @@ arm64_emitfn(Fn *fn, FILE *out)
 		case Jjmp:
 		Jmp:
 			if (b->s1 != b->link)
-				fprintf(e->f, "\tb\t.L%d\n", id0+b->s1->id);
+				fprintf(e->f,
+					"\tb\t%s%d\n",
+					T.asloc, id0+b->s1->id
+				);
 			else
 				lbl = 0;
 			break;
@@ -564,9 +568,13 @@ arm64_emitfn(Fn *fn, FILE *out)
 				b->s2 = t;
 			} else
 				c = cmpneg(c);
-			fprintf(e->f, "\tb%s\t.L%d\n", ctoa[c], id0+b->s2->id);
+			fprintf(e->f,
+				"\tb%s\t%s%d\n",
+				ctoa[c], T.asloc, id0+b->s2->id
+			);
 			goto Jmp;
 		}
 	}
 	id0 += e->fn->nblk;
+	elf_emitfnfin(e->fn->name, e->f);
 }
diff --git a/arm64/isel.c b/arm64/isel.c
index bb5c12b..f064321 100644
--- a/arm64/isel.c
+++ b/arm64/isel.c
@@ -84,7 +84,7 @@ fixarg(Ref *pr, int k, int phi, Fn *fn)
 			emit(Ocopy, k, r1, r0, R);
 		} else {
 			c = &fn->con[r0.val];
-			n = gasstash(&c->bits, KWIDE(k) ? 8 : 4);
+			n = stashbits(&c->bits, KWIDE(k) ? 8 : 4);
 			vgrow(&fn->con, ++fn->ncon);
 			c = &fn->con[fn->ncon-1];
 			sprintf(buf, "fp%d", n);
diff --git a/arm64/targ.c b/arm64/targ.c
index 33b14f4..ddaee2f 100644
--- a/arm64/targ.c
+++ b/arm64/targ.c
@@ -41,6 +41,8 @@ Target T_arm64 = {
 	.abi = arm64_abi,
 	.isel = arm64_isel,
 	.emitfn = arm64_emitfn,
+	.emitfin = elf_emitfin,
+	.asloc = ".L",
 };
 
 MAKESURE(globals_are_not_arguments,