summary refs log tree commit diff
path: root/amd64
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 /amd64
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 'amd64')
-rw-r--r--amd64/emit.c6
-rw-r--r--amd64/isel.c7
2 files changed, 7 insertions, 6 deletions
diff --git a/amd64/emit.c b/amd64/emit.c
index 37dd1e9..a034a66 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -165,9 +165,9 @@ emitcon(Con *con, FILE *f)
 
 	switch (con->type) {
 	case CAddr:
-		l = str(con->label);
+		l = str(con->sym.id);
 		p = l[0] == '"' ? "" : T.assym;
-		if (con->reloc == RelThr) {
+		if (con->sym.type == SThr) {
 			if (T.apple)
 				fprintf(f, "%s%s@TLVP", p, l);
 			else
@@ -344,7 +344,7 @@ Next:
 			off = fn->con[ref.val];
 			emitcon(&off, f);
 			if (off.type == CAddr)
-			if (off.reloc != RelThr || T.apple)
+			if (off.sym.type != SThr || T.apple)
 				fprintf(f, "(%%rip)");
 			break;
 		case RTmp:
diff --git a/amd64/isel.c b/amd64/isel.c
index 8c89378..63c304a 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -81,7 +81,7 @@ fixarg(Ref *r, int k, Ins *i, Fn *fn)
 		a.offset.type = CAddr;
 		n = stashbits(&fn->con[r0.val].bits, KWIDE(k) ? 8 : 4);
 		sprintf(buf, "\"%sfp%d\"", T.asloc, n);
-		a.offset.label = intern(buf);
+		a.offset.sym.id = intern(buf);
 		fn->mem[fn->nmem-1] = a;
 	}
 	else if (op != Ocopy && k == Kl && noimm(r0, fn)) {
@@ -124,7 +124,7 @@ fixarg(Ref *r, int k, Ins *i, Fn *fn)
 		}
 	} else if (T.apple && rtype(r0) == RCon
 	&& (c = &fn->con[r0.val])->type == CAddr
-	&& c->reloc == RelThr) {
+	&& c->sym.type == SThr) {
 		r1 = newtmp("isel", Kl, fn);
 		if (c->bits.i) {
 			r2 = newtmp("isel", Kl, fn);
@@ -612,7 +612,8 @@ amatch(Addr *a, Ref r, int n, ANum *ai, Fn *fn)
 	if (rtype(r) == RCon) {
 		if (!addcon(&a->offset, &fn->con[r.val]))
 			err("unlikely sum of $%s and $%s",
-				str(a->offset.label), str(fn->con[r.val].label));
+				str(a->offset.sym.id),
+				str(fn->con[r.val].sym.id));
 		return 1;
 	}
 	assert(rtype(r) == RTmp);