Browse Source

More coercion test cases and fixes.

cache-refactoring
Rhys Weatherley 21 years ago
parent
commit
bc7b7a4279
  1. 2
      ChangeLog
  2. 47
      jit/jit-insn.c
  3. 50
      tests/coerce.pas

2
ChangeLog

@ -27,6 +27,8 @@
* jit/jit-type.c (jit_type_promote_int): promote ubyte and ushort
to uint, not int.
* jit/jit-insn.c, tests/coerce.pas: more coercion test cases and fixes.
2004-05-11 Rhys Weatherley <rweather@southern-storm.com.au>
* include/jit/jit-insn.h, jit/jit-insn.c, jit/jit-interp.cpp,

47
jit/jit-insn.c

@ -2120,7 +2120,52 @@ jit_value_t jit_insn_neg
jit_intrinsic(jit_float64_neg, descr_d_d),
jit_intrinsic(jit_nfloat_neg, descr_D_D)
};
return apply_unary_arith(func, &neg_descr, value1, 0, 0, 0);
int oper;
jit_type_t result_type;
if(!value1)
{
return 0;
}
result_type = common_binary(value1->type, value1->type, 0, 0);
if(result_type == jit_type_int)
{
oper = neg_descr.ioper;
}
else if(result_type == jit_type_uint)
{
result_type = jit_type_int;
oper = neg_descr.ioper;
}
else if(result_type == jit_type_long)
{
oper = neg_descr.loper;
}
else if(result_type == jit_type_ulong)
{
result_type = jit_type_long;
oper = neg_descr.loper;
}
else if(result_type == jit_type_float32)
{
oper = neg_descr.foper;
}
else if(result_type == jit_type_float64)
{
oper = neg_descr.doper;
}
else
{
oper = neg_descr.nfoper;
}
value1 = jit_insn_convert(func, value1, result_type, 0);
if(_jit_opcode_is_supported(oper))
{
return apply_unary(func, oper, value1, result_type);
}
else
{
return apply_intrinsic(func, &neg_descr, value1, 0, result_type);
}
}
/*@

50
tests/coerce.pas

@ -39,9 +39,18 @@ procedure run_tests;
var
b: Byte;
s: ShortInt;
f: ShortReal;
d: Real;
n: LongReal;
begin
{ Initialize some values of odd type sizes }
b := 3;
s := 67;
f := 24.0;
d := 56.0;
n := 123.5;
{ Test libjit's coercion rules for binary operators }
run("coerce_byte_short", SameType(Integer, b / s));
run("coerce_int_byte", SameType(Integer, 3 + b));
run("coerce_byte_uint", SameType(Cardinal, b * 080000000H));
@ -50,12 +59,53 @@ begin
run("coerce_int_int", SameType(Integer, 3 + 4));
run("coerce_int_uint", SameType(Integer, 3 - 0FFFFFFFFH));
run("coerce_uint_int", SameType(Integer, 0FFFFFFFFH mod 3));
run("coerce_uint_int_shift", SameType(Cardinal, 0FFFFFFFFH shr 3));
run("coerce_uint_uint", SameType(Cardinal, 080000000H + 0FFFFFFFFH));
run("coerce_int_long", SameType(LongInt, 3 / 07FFFFFFFFFFFH));
run("coerce_long_int", SameType(LongInt, 07FFFFFFFFFFFH * 3));
run("coerce_long_uint", SameType(LongInt, 07FFFFFFFFFFFH * 0FFFFFFFFH));
run("coerce_uint_ulong",
SameType(LongCard, 0FFFFFFFFH + 08000000000000000H));
run("coerce_int_ulong",
SameType(LongInt, 07FFFFFFFH mod 08000000000000000H));
run("coerce_int_float32", SameType(ShortReal, 23 * f));
run("coerce_float32_uint", SameType(ShortReal, f / 0FFFFFFFFH));
run("coerce_float32_long", SameType(ShortReal, f + 0FFFFFFFF0H));
run("coerce_ulong_float32", SameType(ShortReal, 08000000000000000 mod f));
run("coerce_float32_float32", SameType(ShortReal, f mod f));
run("coerce_int_float64", SameType(Real, 23 * d));
run("coerce_float64_uint", SameType(Real, d / 0FFFFFFFFH));
run("coerce_float64_long", SameType(Real, d + 0FFFFFFFF0H));
run("coerce_ulong_float64", SameType(Real, 08000000000000000 mod d));
run("coerce_float32_float64", SameType(Real, f mod d));
run("coerce_float64_float32", SameType(Real, d - f));
run("coerce_float64_float64", SameType(Real, d * d));
run("coerce_int_nfloat", SameType(LongReal, 23 * n));
run("coerce_nfloat_uint", SameType(LongReal, n / 0FFFFFFFFH));
run("coerce_nfloat_long", SameType(LongReal, n + 0FFFFFFFF0H));
run("coerce_ulong_nfloat", SameType(LongReal, 08000000000000000 mod n));
run("coerce_float32_nfloat", SameType(LongReal, f mod n));
run("coerce_nfloat_float32", SameType(LongReal, n - f));
run("coerce_float64_nfloat", SameType(LongReal, d mod n));
run("coerce_nfloat_float64", SameType(LongReal, n - d));
run("coerce_nfloat_nfloat", SameType(LongReal, n * n));
{ Test libjit's coercion rules for unary operators }
run("coerce_neg_byte", SameType(Integer, -b));
run("coerce_neg_short", SameType(Integer, -s));
run("coerce_neg_int", SameType(Integer, -3));
run("coerce_neg_uint", SameType(Integer, -080000000H));
run("coerce_neg_long", SameType(LongInt, -0800000000H));
run("coerce_neg_ulong", SameType(LongInt, -08000000000000000H));
run("coerce_neg_float32", SameType(ShortReal, -f));
run("coerce_neg_float64", SameType(Real, -d));
run("coerce_neg_nfloat", SameType(LongReal, -n));
run("coerce_not_byte", SameType(Cardinal, not b));
run("coerce_not_short", SameType(Integer, not s));
run("coerce_not_int", SameType(Integer, not 3));
run("coerce_not_uint", SameType(Cardinal, not 080000000H));
run("coerce_not_long", SameType(LongInt, not 0800000000H));
run("coerce_not_ulong", SameType(LongCard, not 08000000000000000H));
end;
begin

Loading…
Cancel
Save