From 4a093b9eba1005e285b01747e4d7ccf5fff3d4c4 Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 18 Oct 2016 00:21:32 +0200 Subject: [PATCH] Add li and mr pseudoinstructions. --- mach/powerpc/as/mach0.c | 2 ++ mach/powerpc/as/mach2.c | 1 + mach/powerpc/as/mach3.c | 2 ++ mach/powerpc/as/mach4.c | 14 +++++++++++--- mach/proto/as/comm0.h | 2 ++ 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mach/powerpc/as/mach0.c b/mach/powerpc/as/mach0.c index 3a42f1dd8..325c08910 100644 --- a/mach/powerpc/as/mach0.c +++ b/mach/powerpc/as/mach0.c @@ -19,6 +19,8 @@ #undef word_t #define word_t long +typedef uint32_t quad; + #undef ALIGNWORD #define ALIGNWORD 4 diff --git a/mach/powerpc/as/mach2.c b/mach/powerpc/as/mach2.c index d1a959fc3..8d72daef3 100644 --- a/mach/powerpc/as/mach2.c +++ b/mach/powerpc/as/mach2.c @@ -49,6 +49,7 @@ %token OP_RS_RA_NB %token OP_RS_RA_RB %token OP_RS_RA_RB_C +%token OP_RS_RA_RA_C %token OP_RS_RA_RB_MB5_ME5_C %token OP_RS_RA_RB_MB6_C %token OP_RS_RA_RB_ME6_C diff --git a/mach/powerpc/as/mach3.c b/mach/powerpc/as/mach3.c index 278a7e607..7fc5d87f0 100644 --- a/mach/powerpc/as/mach3.c +++ b/mach/powerpc/as/mach3.c @@ -99,6 +99,8 @@ /* Special instructions */ 0, OP_LA, 0, "la", +0, OP_LA, 0, "li", +0, OP_RS_RA_RA_C, 31<<26 | 444<<1, "mr", /* Branch processor instructions (page 20) */ diff --git a/mach/powerpc/as/mach4.c b/mach/powerpc/as/mach4.c index acb4abf1b..31d85dd99 100644 --- a/mach/powerpc/as/mach4.c +++ b/mach/powerpc/as/mach4.c @@ -44,6 +44,7 @@ operation | OP_RS_RA_UI_CC C GPR ',' GPR ',' e16 { emit4($1 | ($5<<21) | ($3<<16) | $7); } | OP_RS_RA_RB GPR ',' GPR ',' GPR { emit4($1 | ($2<<21) | ($4<<16) | ($6<<11)); } | OP_RS_RA_RB_C c GPR ',' GPR ',' GPR { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11)); } + | OP_RS_RA_RA_C c GPR ',' GPR { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($5<<11)); } | OP_RS_RA_RB_MB5_ME5_C c GPR ',' GPR ',' GPR ',' u5 ',' u5 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | ($9<<6) | ($11<<1)); } | OP_RS_RA_RB_MB6_C c GPR ',' GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | (($9&0x1F)<<6) | (($9&0x20)>>0)); } | OP_RS_RA_RB_ME6_C c GPR ',' GPR ',' GPR ',' u6 { emit4($1 | $2 | ($5<<21) | ($3<<16) | ($7<<11) | (($9&0x1F)<<6) | (($9&0x20)>>0)); } @@ -196,9 +197,16 @@ bda la : GPR ',' expr { - newrelo($3.typ, RELOPPC | FIXUPFLAGS); - emit4((15<<26) | ($1<<21) | (0<<16) | ($3.val >> 16)); /* addis */ - emit4((24<<26) | ($1<<21) | ($1<<16) | ($3.val & 0xffff)); /* ori */ + quad type = $3.typ & S_TYP; + quad val = $3.val; + if ((type == S_ABS) && (val <= 0xffff)) + emit4((14<<26) | ($1<<21) | (0<<16) | val); /* addi */ + else + { + newrelo($3.typ, RELOPPC | FIXUPFLAGS); + emit4((15<<26) | ($1<<21) | (0<<16) | (val >> 16)); /* addis */ + emit4((24<<26) | ($1<<21) | ($1<<16) | (val & 0xffff)); /* ori */ + } } ; diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 4996350ac..dedafa4c7 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -8,6 +8,8 @@ * All preprocessor based options/constants/functions */ +#include + /* ========== ON/OFF options (use #define in mach0.c) ========== */ /* -- 2.34.1