Turns out Apple's hi16/ha16 exactly match my ha16/has16, so renamed
accordingly. (Memo to self: read the docs *before* doing the work.)
This commit is contained in:
parent
f80acfe9f5
commit
9a346c382d
|
@ -5,5 +5,5 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
extern quad emit_ha(struct expr_t* expr, bool is_signed);
|
extern quad emit_hi(struct expr_t* expr, bool is_signed);
|
||||||
extern quad emit_lo(struct expr_t* expr);
|
extern quad emit_lo(struct expr_t* expr);
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
%token <y_word> OP_LI32
|
%token <y_word> OP_LI32
|
||||||
|
|
||||||
%token <y_word> OP_POWERPC_FIXUP
|
%token <y_word> OP_POWERPC_FIXUP
|
||||||
%token <y_word> OP_HA OP_HAS OP_LO
|
%token <y_word> OP_HI OP_HA OP_LO
|
||||||
|
|
||||||
/* Other token types */
|
/* Other token types */
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,8 @@
|
||||||
0, OP_LA, 0, "la",
|
0, OP_LA, 0, "la",
|
||||||
0, OP_LA, 0, "li",
|
0, OP_LA, 0, "li",
|
||||||
0, OP_RS_RA_RA_C, 31<<26 | 444<<1, "mr",
|
0, OP_RS_RA_RA_C, 31<<26 | 444<<1, "mr",
|
||||||
0, OP_HA, 0, "ha16",
|
0, OP_HI, 0, "hi16",
|
||||||
0, OP_HAS, 0, "has16",
|
0, OP_HA, 0, "ha16",
|
||||||
0, OP_LO, 0, "lo16",
|
0, OP_LO, 0, "lo16",
|
||||||
|
|
||||||
/* Branch processor instructions (page 20) */
|
/* Branch processor instructions (page 20) */
|
||||||
|
|
|
@ -75,8 +75,8 @@ e16
|
||||||
serror("16-bit value out of range");
|
serror("16-bit value out of range");
|
||||||
$$ = (uint16_t) $1;
|
$$ = (uint16_t) $1;
|
||||||
}
|
}
|
||||||
| OP_HA ASC_LPAR expr ASC_RPAR { $$ = emit_ha(&$3, false); }
|
| OP_HI ASC_LPAR expr ASC_RPAR { $$ = emit_hi(&$3, false); }
|
||||||
| OP_HAS ASC_LPAR expr ASC_RPAR { $$ = emit_ha(&$3, true); }
|
| OP_HA ASC_LPAR expr ASC_RPAR { $$ = emit_hi(&$3, true); }
|
||||||
| OP_LO ASC_LPAR expr ASC_RPAR { $$ = emit_lo(&$3); }
|
| OP_LO ASC_LPAR expr ASC_RPAR { $$ = emit_lo(&$3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
quad emit_ha(struct expr_t* expr, bool is_signed)
|
quad emit_hi(struct expr_t* expr, bool is_signed)
|
||||||
{
|
{
|
||||||
/* If this is a symbol reference, discard the symbol and keep only the
|
/* If this is a symbol reference, discard the symbol and keep only the
|
||||||
* offset part. */
|
* offset part. */
|
||||||
|
|
|
@ -175,8 +175,8 @@ TOKENS
|
||||||
/* Primitives */
|
/* Primitives */
|
||||||
|
|
||||||
LABEL = { ADDR adr; } 4 adr.
|
LABEL = { ADDR adr; } 4 adr.
|
||||||
|
LABEL_OFFSET_HI = { ADDR adr; } 4 "hi16[" adr "]".
|
||||||
LABEL_OFFSET_HA = { ADDR adr; } 4 "ha16[" adr "]".
|
LABEL_OFFSET_HA = { ADDR adr; } 4 "ha16[" adr "]".
|
||||||
LABEL_OFFSET_HAS = { ADDR adr; } 4 "has16[" adr "]".
|
|
||||||
LABEL_OFFSET_LO = { ADDR adr; } 4 "lo16[" adr "]".
|
LABEL_OFFSET_LO = { ADDR adr; } 4 "lo16[" adr "]".
|
||||||
LOCAL = { INT off; } 4.
|
LOCAL = { INT off; } 4.
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ INSTRUCTIONS
|
||||||
add GPR:wo, GPR:ro, GPR:ro.
|
add GPR:wo, GPR:ro, GPR:ro.
|
||||||
addX "add." GPR:wo, GPR:ro, GPR:ro.
|
addX "add." GPR:wo, GPR:ro, GPR:ro.
|
||||||
addi GPR:wo, GPR:ro, CONST:ro.
|
addi GPR:wo, GPR:ro, CONST:ro.
|
||||||
addis GPR:wo, GPR:ro, CONST+LABEL_OFFSET_HA+LABEL_OFFSET_HAS:ro.
|
addis GPR:wo, GPR:ro, CONST+LABEL_OFFSET_HI+LABEL_OFFSET_HA:ro.
|
||||||
and GPR:wo, GPR:ro, GPR:ro.
|
and GPR:wo, GPR:ro, GPR:ro.
|
||||||
andc GPR:wo, GPR:ro, GPR:ro.
|
andc GPR:wo, GPR:ro, GPR:ro.
|
||||||
andiX "andi." GPR:wo:cc, GPR:ro, CONST:ro.
|
andiX "andi." GPR:wo:cc, GPR:ro, CONST:ro.
|
||||||
|
@ -408,7 +408,7 @@ MOVES
|
||||||
from LABEL to GPR
|
from LABEL to GPR
|
||||||
gen
|
gen
|
||||||
COMMENT("move LABEL->GPR")
|
COMMENT("move LABEL->GPR")
|
||||||
addis %2, R0, {LABEL_OFFSET_HA, %1.adr}
|
addis %2, R0, {LABEL_OFFSET_HI, %1.adr}
|
||||||
ori %2, %2, {LABEL_OFFSET_LO, %1.adr}
|
ori %2, %2, {LABEL_OFFSET_LO, %1.adr}
|
||||||
|
|
||||||
/* Sign extension */
|
/* Sign extension */
|
||||||
|
@ -1149,7 +1149,7 @@ PATTERNS
|
||||||
with LABEL
|
with LABEL
|
||||||
uses REG
|
uses REG
|
||||||
gen
|
gen
|
||||||
addis %a, R0, {LABEL_OFFSET_HAS, %1.adr}
|
addis %a, R0, {LABEL_OFFSET_HA, %1.adr}
|
||||||
lwz %a, {GPRINDIRECT_OFFSET_LO, %a, %1.adr}
|
lwz %a, {GPRINDIRECT_OFFSET_LO, %a, %1.adr}
|
||||||
yields %a
|
yields %a
|
||||||
with GPR
|
with GPR
|
||||||
|
|
|
@ -297,6 +297,7 @@ static void put_powerpc_valu(char* addr, uint32_t value, uint16_t type)
|
||||||
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
|
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
|
||||||
((opcode2 & 0xfc000000) == 0x60000000))
|
((opcode2 & 0xfc000000) == 0x60000000))
|
||||||
{
|
{
|
||||||
|
/* addis / ori instruction pair */
|
||||||
uint16_t hi = value >> 16;
|
uint16_t hi = value >> 16;
|
||||||
uint16_t lo = value & 0xffff;
|
uint16_t lo = value & 0xffff;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue