Commit 5aa66153 authored by Russell King's avatar Russell King

[ARM] Fix double compare with zero instructions.

Accessing register index -1 causes vfp_get_double() to enter an
infinite loop.  Use VFP_REG_ZERO (value 16) and provide code to
emulate a sixteenth register which always returns 0.0
parent 3c724643
...@@ -249,6 +249,12 @@ struct vfp_double { ...@@ -249,6 +249,12 @@ struct vfp_double {
u64 significand; u64 significand;
}; };
/*
* VFP_REG_ZERO is a special register number for vfp_get_double
* which returns (double)0.0. This is useful for the compare with
* zero instructions.
*/
#define VFP_REG_ZERO 16
extern u64 vfp_get_double(unsigned int reg); extern u64 vfp_get_double(unsigned int reg);
extern void vfp_put_double(unsigned int reg, u64 val); extern void vfp_put_double(unsigned int reg, u64 val);
......
...@@ -427,12 +427,12 @@ static u32 vfp_double_fcmpe(int dd, int unused, int dm, u32 fpscr) ...@@ -427,12 +427,12 @@ static u32 vfp_double_fcmpe(int dd, int unused, int dm, u32 fpscr)
static u32 vfp_double_fcmpz(int dd, int unused, int dm, u32 fpscr) static u32 vfp_double_fcmpz(int dd, int unused, int dm, u32 fpscr)
{ {
return vfp_compare(dd, 0, -1, fpscr); return vfp_compare(dd, 0, VFP_REG_ZERO, fpscr);
} }
static u32 vfp_double_fcmpez(int dd, int unused, int dm, u32 fpscr) static u32 vfp_double_fcmpez(int dd, int unused, int dm, u32 fpscr)
{ {
return vfp_compare(dd, 1, -1, fpscr); return vfp_compare(dd, 1, VFP_REG_ZERO, fpscr);
} }
static u32 vfp_double_fcvts(int sd, int unused, int dm, u32 fpscr) static u32 vfp_double_fcvts(int sd, int unused, int dm, u32 fpscr)
......
...@@ -199,6 +199,11 @@ vfp_get_double: ...@@ -199,6 +199,11 @@ vfp_get_double:
mov pc, lr mov pc, lr
.endr .endr
@ virtual register 16 for compare with zero
mov r0, #0
mov r1, #0
mov pc, lr
.globl vfp_put_double .globl vfp_put_double
vfp_put_double: vfp_put_double:
mov r0, r0, lsr #1 mov r0, r0, lsr #1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment