Add li and mr pseudoinstructions.
authorDavid Given <dg@cowlark.com>
Mon, 17 Oct 2016 22:21:32 +0000 (00:21 +0200)
committerDavid Given <dg@cowlark.com>
Mon, 17 Oct 2016 22:21:32 +0000 (00:21 +0200)
mach/powerpc/as/mach0.c
mach/powerpc/as/mach2.c
mach/powerpc/as/mach3.c
mach/powerpc/as/mach4.c
mach/proto/as/comm0.h

index 3a42f1d..325c089 100644 (file)
@@ -19,6 +19,8 @@
 #undef word_t
 #define word_t long
 
+typedef uint32_t quad;
+
 #undef ALIGNWORD
 #define ALIGNWORD      4
 
index d1a959f..8d72dae 100644 (file)
@@ -49,6 +49,7 @@
 %token <y_word> OP_RS_RA_NB
 %token <y_word> OP_RS_RA_RB
 %token <y_word> OP_RS_RA_RB_C
+%token <y_word> OP_RS_RA_RA_C
 %token <y_word> OP_RS_RA_RB_MB5_ME5_C
 %token <y_word> OP_RS_RA_RB_MB6_C
 %token <y_word> OP_RS_RA_RB_ME6_C
index 278a7e6..7fc5d87 100644 (file)
@@ -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) */
 
index acb4abf..31d85dd 100644 (file)
@@ -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 */
+               }
        }
        ;
 
index 4996350..dedafa4 100644 (file)
@@ -8,6 +8,8 @@
  * All preprocessor based options/constants/functions
  */
 
+#include <stdint.h>
+
 /* ========== ON/OFF options (use #define in mach0.c) ========== */
 
 /*