scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit db020ae096075a5800c8179979ed45c33cb718ad
parent 17fdc8fbe7c5299743f3c72afc166da09b9c74e0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 19 Sep 2019 03:59:51 +0200

[as-powerpc] Add GPRS registers

Diffstat:
Msrc/cmd/as/target/powerpc/ins.c | 45+++++++++++++++++++++++++++++++++++++++++++++
Msrc/cmd/as/target/powerpc/powerpc.c | 49++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/cmd/as/target/powerpc/proc.h | 38++++++++++++++++++++++++++++++++++++++
3 files changed, 131 insertions(+), 1 deletion(-)

diff --git 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) diff --git 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; + } } diff --git a/src/cmd/as/target/powerpc/proc.h b/src/cmd/as/target/powerpc/proc.h @@ -0,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, +};