Add li and mr pseudoinstructions.

This commit is contained in:
David Given 2016-10-18 00:21:32 +02:00
parent 5f0164db62
commit 4a093b9eba
5 changed files with 18 additions and 3 deletions

View file

@ -19,6 +19,8 @@
#undef word_t #undef word_t
#define word_t long #define word_t long
typedef uint32_t quad;
#undef ALIGNWORD #undef ALIGNWORD
#define ALIGNWORD 4 #define ALIGNWORD 4

View file

@ -49,6 +49,7 @@
%token <y_word> OP_RS_RA_NB %token <y_word> OP_RS_RA_NB
%token <y_word> OP_RS_RA_RB %token <y_word> OP_RS_RA_RB
%token <y_word> OP_RS_RA_RB_C %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_MB5_ME5_C
%token <y_word> OP_RS_RA_RB_MB6_C %token <y_word> OP_RS_RA_RB_MB6_C
%token <y_word> OP_RS_RA_RB_ME6_C %token <y_word> OP_RS_RA_RB_ME6_C

View file

@ -99,6 +99,8 @@
/* Special instructions */ /* Special instructions */
0, OP_LA, 0, "la", 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) */ /* Branch processor instructions (page 20) */

View 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_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 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_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_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_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)); } | 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)); }
@ -195,10 +196,17 @@ bda
la la
: GPR ',' expr : GPR ',' expr
{
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); newrelo($3.typ, RELOPPC | FIXUPFLAGS);
emit4((15<<26) | ($1<<21) | (0<<16) | ($3.val >> 16)); /* addis */ emit4((15<<26) | ($1<<21) | (0<<16) | (val >> 16)); /* addis */
emit4((24<<26) | ($1<<21) | ($1<<16) | ($3.val & 0xffff)); /* ori */ emit4((24<<26) | ($1<<21) | ($1<<16) | (val & 0xffff)); /* ori */
}
} }
; ;

View file

@ -8,6 +8,8 @@
* All preprocessor based options/constants/functions * All preprocessor based options/constants/functions
*/ */
#include <stdint.h>
/* ========== ON/OFF options (use #define in mach0.c) ========== */ /* ========== ON/OFF options (use #define in mach0.c) ========== */
/* /*