shithub: scc

Download patch

ref: ebb4a027004359227d10093ff1ef4e57e44d6250
parent: e7d32ccc043605258973593c6da0dc60739eeaa5
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Sep 18 23:59:51 EDT 2019

[as-powerpc] Add GPRS registers

--- a/src/cmd/as/target/powerpc/ins.c
+++ b/src/cmd/as/target/powerpc/ins.c
@@ -3,6 +3,51 @@
 #include <scc/scc.h>
 
 #include "../../as.h"
+#include "proc.h"
+
+static int
+getclass(Node *np)
+{
+	if (np->addr != AREG)
+		return 0;
+
+	switch (np->sym->value) {
+	case AREG_R0:
+	case AREG_R1:
+	case AREG_R2:
+	case AREG_R3:
+	case AREG_R4:
+	case AREG_R5:
+	case AREG_R6:
+	case AREG_R7:
+	case AREG_R8:
+	case AREG_R9:
+	case AREG_R10:
+	case AREG_R11:
+	case AREG_R12:
+	case AREG_R13:
+	case AREG_R14:
+	case AREG_R15:
+	case AREG_R16:
+	case AREG_R17:
+	case AREG_R18:
+	case AREG_R19:
+	case AREG_R20:
+	case AREG_R21:
+	case AREG_R22:
+	case AREG_R23:
+	case AREG_R24:
+	case AREG_R25:
+	case AREG_R26:
+	case AREG_R27:
+	case AREG_R29:
+	case AREG_R30:
+	case AREG_R31:
+		return GPRSCLASS;
+	default:
+		abort();
+	}
+}
 
 int
 match(Op *Op, Node **args)
--- a/src/cmd/as/target/powerpc/powerpc.c
+++ b/src/cmd/as/target/powerpc/powerpc.c
@@ -3,13 +3,60 @@
 #include <scc/scc.h>
 
 #include "../../as.h"
+#include "proc.h"
 
 TUINT maxaddr = 0xFFFF;
 int endian = LITTLE_ENDIAN;
 int left2right = 0;
-#include "proc.h"
 
 void
 iarch(void)
 {
+	static struct {
+		char *name;
+		char type;
+	} regs[] = {
+		"R0", AREG_R0,
+		"R1", AREG_R1,
+		"R2", AREG_R2,
+		"R3", AREG_R3,
+		"R4", AREG_R4,
+		"R5", AREG_R5,
+		"R6", AREG_R6,
+		"R7", AREG_R7,
+		"R8", AREG_R8,
+		"R9", AREG_R9,
+
+		"R10", AREG_R10,
+		"R11", AREG_R11,
+		"R12", AREG_R12,
+		"R13", AREG_R13,
+		"R14", AREG_R14,
+		"R15", AREG_R15,
+		"R16", AREG_R16,
+		"R17", AREG_R17,
+		"R18", AREG_R18,
+		"R19", AREG_R19,
+
+		"R20", AREG_R20,
+		"R21", AREG_R21,
+		"R22", AREG_R22,
+		"R23", AREG_R23,
+		"R24", AREG_R24,
+		"R25", AREG_R25,
+		"R26", AREG_R26,
+		"R27", AREG_R27,
+		"R28", AREG_R28,
+		"R29", AREG_R29,
+		"R30", AREG_R30,
+		"R31", AREG_R31,
+
+		NULL
+	}, *bp;
+
+	for (bp = regs; bp->name; ++bp) {
+		Symbol *sym = lookup(bp->name);
+		sym->flags = FREG;
+		sym->value = bp->type;
+	}
 }
--- a/src/cmd/as/target/powerpc/proc.h
+++ b/src/cmd/as/target/powerpc/proc.h
@@ -1,0 +1,38 @@
+enum args {
+	AREG_R0 = AMAX,
+	AREG_R1,
+	AREG_R2,
+	AREG_R3,
+	AREG_R4,
+	AREG_R5,
+	AREG_R6,
+	AREG_R7,
+	AREG_R8,
+	AREG_R9,
+	AREG_R10,
+	AREG_R11,
+	AREG_R12,
+	AREG_R13,
+	AREG_R14,
+	AREG_R15,
+	AREG_R16,
+	AREG_R17,
+	AREG_R18,
+	AREG_R19,
+	AREG_R20,
+	AREG_R21,
+	AREG_R22,
+	AREG_R23,
+	AREG_R24,
+	AREG_R25,
+	AREG_R26,
+	AREG_R27,
+	AREG_R28,
+	AREG_R29,
+	AREG_R30,
+	AREG_R31,
+};
+
+enum class {
+	GPRSCLASS = 1 << 0,
+};