get to the point of failing to link programs.
%token <y_word> OP_LI
%token <y_word> OP_LA
+%token <y_word> HI
+%token <y_word> LO
+
%type <y_word> gpr fpr
%type <y_word> e16 e9
%type <y_word> u25 u20 u16 u5 u3
%type <y_word> fcond
%type <y_word> extmsblsb insmsblsb
+%type <y_word> hilo
+%type <y_valu> extabsexp
#include "definitions.y"
0, OP_LI, 0, "li",
0, OP_LA, 0, "la",
+0, HI, RELOMIPSHI, "hi",
+0, LO, RELOMIPS, "lo",
#include "tokens.y"
emit4(0x34000000 | (reg<<16) | (reg<<21) | (val & 0xffff)); /* ori reg, reg, value */
}
+extabsexp
+ : absexp
+ | hilo ASC_LPAR expr ASC_RPAR
+ {
+ newrelo($3.typ, $1 | FIXUPFLAGS);
+ $$ = $3.val;
+ }
+ ;
+
+hilo
+ : HI { $$ = $1; }
+ | LO { $$ = $1; }
+ ;
+
gpr: GPR
fpr: FPR
| OP__DOT_W { $$ = 4; }
| OP__DOT_L { $$ = 5; }
| OP__DOT_PS { $$ = 6; }
-fmt: fmt3 { $$ = $1 + 16; }
+ ;
+
+fmt
+ : fmt3 { $$ = $1 + 16; }
+ ;
fcond
: OP__DOT_F { $$ = 0; }
| OP__DOT_NGE { $$ = 13; }
| OP__DOT_LE { $$ = 14; }
| OP__DOT_NGT { $$ = 15; }
+ ;
e16
- : absexp
+ : extabsexp
{
/* Allow signed or unsigned 16-bit values. */
if (($1 < -0x8000) || ($1 > 0xffff))
;
u16
- : absexp
+ : extabsexp
{
if (($1 < 0) || ($1 > 0xffff))
serror("16-bit unsigned value out of range");
.sect .data
.sect .bss
-.data
-
+.sect .text
.define .c_ud_i
.c_ud_i:
/* Input: f0
* Output: r2
* Only at and f31 may be used.
*/
- li at, hi(.fd_80000000)
- ldc1 f31, lo(.fd_800000000)(at)
+
+ ori at, zero, hi[.fd_80000000]
+ ldc1 f31, lo[.fd_80000000] (at)
c.le.d 0, f31, f0
bc1t toobig
nop
.sect .data
.sect .bss
-.data
-
+.sect .text
.define .c_uf_i
.c_uf_i:
/* Input: f0
* Output: r2
* Only at and f31 may be used.
*/
- li at, hi(.fd_80000000)
- lwc1 f31, lo(.fd_800000000)(at)
- c.le.f 0, f31, f0
+
+ ori at, zero, hi[.ff_80000000]
+ lwc1 f31, lo[.ff_80000000] (at)
+ c.le.s 0, f31, f0
bc1t toobig
nop
- trunc.w.f f0, f0
+ trunc.w.s f0, f0
mfc1 r2, f0
jr ra
nop
toobig:
- sub.f f0, f0, f31
- trunc.w.f f0, f0
+ sub.s f0, f0, f31
+ trunc.w.s f0, f0
mfc1 r2, f0
addiu r2, r2, 0x8000
jr ra
li r3, 20 ! ECASE = 20 in h/em_abs.h
! FALLTHROUGH to .trp
-.trap:
- syscall
+.trp:
+ syscall 0