mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
38550922cc
In order to not waste instructions, the Ruamoko ISA does not provide 1 and 2 component 64-bit load/store instructions since they can be implemented using 2 and 4 component 32-bit instructions (load and store are independent of the interpretation of the data). This fixes the double test, and technically the double-alias test, but it fails due to a problem with the optimizer causing lea to use the wrong reference for the address. It also breaks the quaternion test due to what seems to be a type error that may have been lurking for a while, further investigation is needed there.
106 lines
2.1 KiB
R
106 lines
2.1 KiB
R
void printf (string fmt, ...) = #0;
|
|
# define M_PI 3.14159265358979323846
|
|
|
|
union {
|
|
double d;
|
|
int i[2];
|
|
} type_pun;
|
|
|
|
int
|
|
test_format ()
|
|
{
|
|
int fail = 0;
|
|
type_pun.d = M_PI;
|
|
printf ("%.17g %08x%08x\n", type_pun.d, type_pun.i[1], type_pun.i[0]);
|
|
// this will fail on big-endian systems
|
|
fail = type_pun.i[0] != 0x54442d18 || type_pun.i[1] != 0x400921fb;
|
|
return fail;
|
|
}
|
|
|
|
int
|
|
test_constant ()
|
|
{
|
|
int fail = 0;
|
|
double a, b, c, d, e;
|
|
a = 1;
|
|
b = 2.0;
|
|
c = 3.2f;
|
|
d = 3.2d;
|
|
e = 3.2;
|
|
printf ("%.17g %.17g %.17g %.17g %.17g\n", a, b, c, d, e);
|
|
// this will fail on big-endian systems
|
|
fail |= c == d; // 3.2 is not exactly representable, so must be different
|
|
fail |= c == e; // 3.2 is not exactly representable, so must be different
|
|
fail |= d != e; // 3.2d and 3.2 are both double, so must be the same
|
|
return fail;
|
|
}
|
|
|
|
double less = 3;
|
|
double greater_equal = 3;
|
|
double less_equal = 5;
|
|
double greater = 5;
|
|
|
|
int
|
|
test_copare ()
|
|
{
|
|
int fail = 0;
|
|
|
|
fail |= !(less < greater);
|
|
fail |= (less > greater);
|
|
fail |= !(less != greater);
|
|
fail |= (less == greater);
|
|
fail |= !(less <= greater);
|
|
fail |= (less >= greater);
|
|
|
|
fail |= (less_equal < greater);
|
|
fail |= (less_equal > greater);
|
|
fail |= !(less_equal == greater);
|
|
fail |= (less_equal != greater);
|
|
fail |= !(less_equal <= greater);
|
|
fail |= !(less_equal >= greater);
|
|
|
|
fail |= (greater < less);
|
|
fail |= !(greater > less);
|
|
fail |= !(greater != less);
|
|
fail |= (greater == less);
|
|
fail |= (greater <= less);
|
|
fail |= !(greater >= less);
|
|
|
|
fail |= (greater_equal < less);
|
|
fail |= (greater_equal > less);
|
|
fail |= !(greater_equal == less);
|
|
fail |= (greater_equal != less);
|
|
fail |= !(greater_equal <= less);
|
|
fail |= !(greater_equal >= less);
|
|
return fail;
|
|
}
|
|
|
|
int
|
|
test_ops ()
|
|
{
|
|
int fail = 0;
|
|
double a = 6.25, b = 2.375;
|
|
double c;
|
|
|
|
c = a + b;
|
|
fail |= c != 8.625;
|
|
c = a - b;
|
|
fail |= c != 3.875;
|
|
c = a * b;
|
|
fail |= c != 14.84375;
|
|
c = a / b;
|
|
fail |= c != 50d/19d;
|
|
c = a % b;
|
|
fail |= c != 1.5;
|
|
return fail;
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int fail = 0;
|
|
fail |= test_format ();
|
|
fail |= test_constant ();
|
|
fail |= test_ops ();
|
|
return fail;
|
|
}
|