summary refs log tree commit diff
path: root/arm64/emit.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2022-11-22 21:44:44 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2022-11-22 21:56:21 +0100
commitcbee74bdb4f85d6d8d4f192f0018ea023418e216 (patch)
tree4ea3eb41265e44336d81fecf719193c67540f3d3 /arm64/emit.c
parent04e26409011389f7b5759114905195a4fb0b0286 (diff)
downloadroux-cbee74bdb4f85d6d8d4f192f0018ea023418e216.tar.gz
use a new struct for symbols
Symbols are a useful abstraction
that occurs in both Con and Alias.
In this patch they get their own
struct. This new struct packages
a symbol name and a type; the type
tells us where the symbol name
must be interpreted (currently, in
gobal memory or in thread-local
storage).

The refactor fixed a bug in
addcon(), proving the value of
packaging symbol names with their
type.
Diffstat (limited to 'arm64/emit.c')
-rw-r--r--arm64/emit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/arm64/emit.c b/arm64/emit.c
index 292dc79..38b7e1a 100644
--- a/arm64/emit.c
+++ b/arm64/emit.c
@@ -247,10 +247,10 @@ loadaddr(Con *c, char *rn, E *e)
 {
 	char *p, *l, *s;
 
-	switch (c->reloc) {
+	switch (c->sym.type) {
 	default:
 		die("unreachable");
-	case RelDef:
+	case SGlo:
 		if (T.apple)
 			s = "\tadrp\tR, S@pageO\n"
 			    "\tadd\tR, R, S@pageoffO\n";
@@ -258,7 +258,7 @@ loadaddr(Con *c, char *rn, E *e)
 			s = "\tadrp\tR, SO\n"
 			    "\tadd\tR, R, #:lo12:SO\n";
 		break;
-	case RelThr:
+	case SThr:
 		if (T.apple)
 			s = "\tadrp\tR, S@tlvppage\n"
 			    "\tldr\tR, [R, S@tlvppageoff]\n";
@@ -269,7 +269,7 @@ loadaddr(Con *c, char *rn, E *e)
 		break;
 	}
 
-	l = str(c->label);
+	l = str(c->sym.id);
 	p = l[0] == '"' ? "" : T.assym;
 	for (; *s; s++)
 		switch (*s) {
@@ -431,9 +431,11 @@ emitins(Ins *i, E *e)
 		if (rtype(i->arg[0]) != RCon)
 			goto Table;
 		c = &e->fn->con[i->arg[0].val];
-		if (c->type != CAddr || c->bits.i)
+		if (c->type != CAddr
+		|| c->sym.type != SGlo
+		|| c->bits.i)
 			die("invalid call argument");
-		l = str(c->label);
+		l = str(c->sym.id);
 		p = l[0] == '"' ? "" : T.assym;
 		fprintf(e->f, "\tbl\t%s%s\n", p, l);
 		break;