Add (largely untested) float/int conversion.
--HG-- branch : dtrg-videocore
This commit is contained in:
parent
29af6f1adb
commit
e36d739fa4
6 changed files with 50 additions and 25 deletions
|
@ -25,3 +25,4 @@ extern void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct
|
||||||
extern void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr);
|
extern void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr);
|
||||||
extern void lea_stack_instr(int rd, long va, int rs);
|
extern void lea_stack_instr(int rd, long va, int rs);
|
||||||
extern void lea_address_instr(int rd, struct expr_t* expr);
|
extern void lea_address_instr(int rd, struct expr_t* expr);
|
||||||
|
extern void fltcnv_instr(quad opcode, int cc, int rd, int ra, quad shift);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
%token <y_word> OP_MEM
|
%token <y_word> OP_MEM
|
||||||
%token <y_word> OP_MISC
|
%token <y_word> OP_MISC
|
||||||
%token <y_word> OP_MISCL
|
%token <y_word> OP_MISCL
|
||||||
|
%token <y_word> OP_FLTCNV
|
||||||
%token <y_word> OP_STACK
|
%token <y_word> OP_STACK
|
||||||
%token <y_word> OP_LEA
|
%token <y_word> OP_LEA
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,11 @@
|
||||||
0, OP_MISC, B16(11001001,11100000), "exp2",
|
0, OP_MISC, B16(11001001,11100000), "exp2",
|
||||||
0, OP_MISC, B16(11000101,11100000), "adds256",
|
0, OP_MISC, B16(11000101,11100000), "adds256",
|
||||||
|
|
||||||
|
0, OP_FLTCNV, B16(11001010,00000000), "ftrunc",
|
||||||
|
0, OP_FLTCNV, B16(11001010,00100000), "floor",
|
||||||
|
0, OP_FLTCNV, B16(11001010,01000000), "flts",
|
||||||
|
0, OP_FLTCNV, B16(11001010,01100000), "fltu",
|
||||||
|
|
||||||
0, OP_MISCL, B16(11000100,10000000), "divs",
|
0, OP_MISCL, B16(11000100,10000000), "divs",
|
||||||
0, OP_MISCL, B16(11000100,11100000), "divu",
|
0, OP_MISCL, B16(11000100,11100000), "divu",
|
||||||
|
|
||||||
|
|
|
@ -74,5 +74,14 @@ operation
|
||||||
|
|
||||||
| OP_LEA GPR ',' absexp '(' GPR ')' { lea_stack_instr($2, $4, $6); }
|
| OP_LEA GPR ',' absexp '(' GPR ')' { lea_stack_instr($2, $4, $6); }
|
||||||
| OP_LEA GPR ',' expr { lea_address_instr($2, &$4); }
|
| OP_LEA GPR ',' expr { lea_address_instr($2, &$4); }
|
||||||
|
|
||||||
|
| OP_FLTCNV GPR ',' GPR { fltcnv_instr($1, ALWAYS, $2, $4, 0); }
|
||||||
|
| OP_FLTCNV CC GPR ',' GPR { fltcnv_instr($1, $2, $3, $5, 0); }
|
||||||
|
| OP_FLTCNV GPR ',' GPR ',' shift '#' absexp { fltcnv_instr($1, ALWAYS, $2, $4, $8); }
|
||||||
|
| OP_FLTCNV CC GPR ',' GPR ',' shift '#' absexp { fltcnv_instr($1, $2, $3, $5, $9); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
shift
|
||||||
|
: 'l' 's' 'r'
|
||||||
|
| 'l' 's' 'l';
|
||||||
|
|
||||||
|
|
|
@ -487,3 +487,13 @@ void lea_address_instr(int rd, struct expr_t* expr)
|
||||||
emit4(expr->val - pc);
|
emit4(expr->val - pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Floating point conversion opcodes (ftrunc, floor, flts, fltu). */
|
||||||
|
|
||||||
|
void fltcnv_instr(quad opcode, int cc, int rd, int ra, quad shift)
|
||||||
|
{
|
||||||
|
fitx(shift, 6);
|
||||||
|
|
||||||
|
emit2(opcode | (rd<<0));
|
||||||
|
emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,8 +131,11 @@ INSTRUCTIONS
|
||||||
fadd GPR:wo, GPR:ro, GPR:ro.
|
fadd GPR:wo, GPR:ro, GPR:ro.
|
||||||
fcmp GPR:wo, GPR:ro, GPR:ro.
|
fcmp GPR:wo, GPR:ro, GPR:ro.
|
||||||
fdiv GPR:wo, GPR:ro, GPR:ro.
|
fdiv GPR:wo, GPR:ro, GPR:ro.
|
||||||
|
flts GPR:wo, GPR:ro.
|
||||||
|
fltu GPR:wo, GPR:ro.
|
||||||
fmul GPR:wo, GPR:ro, GPR:ro.
|
fmul GPR:wo, GPR:ro, GPR:ro.
|
||||||
fsub GPR:wo, GPR:ro, GPR:ro.
|
fsub GPR:wo, GPR:ro, GPR:ro.
|
||||||
|
ftrunc GPR:wo, GPR:ro.
|
||||||
ld GPR:wo, GPRINC:rw.
|
ld GPR:wo, GPRINC:rw.
|
||||||
ld GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
ld GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
||||||
ldb GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
ldb GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
||||||
|
@ -1511,36 +1514,32 @@ PATTERNS
|
||||||
nop
|
nop
|
||||||
|
|
||||||
pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */
|
pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */
|
||||||
leaving
|
with GPR
|
||||||
loc 0
|
uses reusing %1, REG
|
||||||
#if 0
|
gen
|
||||||
cal ".cfi"
|
ftrunc %a, %1
|
||||||
lfr QUAD
|
yields %a
|
||||||
#endif
|
|
||||||
|
|
||||||
pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */
|
pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */
|
||||||
leaving
|
with GPR
|
||||||
loc 0
|
uses reusing %1, REG
|
||||||
#if 0
|
gen
|
||||||
cal ".cfu"
|
ftrunc %a, %1
|
||||||
lfr QUAD
|
yields %a
|
||||||
#endif
|
|
||||||
|
|
||||||
pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */
|
pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */
|
||||||
leaving
|
with GPR
|
||||||
loc 0
|
uses reusing %1, REG
|
||||||
#if 0
|
gen
|
||||||
cal ".cif"
|
flts %a, %1
|
||||||
lfr QUAD
|
yields %a
|
||||||
#endif
|
|
||||||
|
|
||||||
pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */
|
pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */
|
||||||
leaving
|
with GPR
|
||||||
loc 0
|
uses reusing %1, REG
|
||||||
#if 0
|
gen
|
||||||
cal ".cuf"
|
fltu %a, %1
|
||||||
lfr QUAD
|
yields %a
|
||||||
#endif
|
|
||||||
|
|
||||||
pat fef /* Split float */
|
pat fef /* Split float */
|
||||||
leaving
|
leaving
|
||||||
|
|
Loading…
Reference in a new issue