Browse Source

jit_type_promote_int: promote ubyte and ushort to uint, not int.

cache-refactoring
Rhys Weatherley 21 years ago
parent
commit
636560c1d5
  1. 3
      ChangeLog
  2. 14
      jit/jit-type.c
  3. 20
      tests/coerce.pas

3
ChangeLog

@ -24,6 +24,9 @@
tests/coerce.pas: check in some initial infrastructure for the
dpas-based test suite.
* jit/jit-type.c (jit_type_promote_int): promote ubyte and ushort
to uint, not int.
2004-05-11 Rhys Weatherley <rweather@southern-storm.com.au>
* include/jit/jit-insn.h, jit/jit-insn.c, jit/jit-interp.cpp,

14
jit/jit-type.c

@ -1540,18 +1540,22 @@ jit_type_t jit_type_remove_tags(jit_type_t type)
/*@
* @deftypefun jit_type_t jit_type_promote_int (jit_type_t type)
* If @code{type} is @code{jit_type_sbyte}, @code{jit_type_ubyte},
* @code{jit_type_short}, or @code{jit_type_ushort}, then return
* @code{jit_type_int}. Otherwise return @code{type} as-is.
* If @code{type} is @code{jit_type_sbyte} or @code{jit_type_short},
* then return @code{jit_type_int}. If @code{type} is
* @code{jit_type_ubyte} or @code{jit_type_ushort}, then return
* @code{jit_type_uint}. Otherwise return @code{type} as-is.
* @end deftypefun
@*/
jit_type_t jit_type_promote_int(jit_type_t type)
{
if(type == jit_type_sbyte || type == jit_type_ubyte ||
type == jit_type_short || type == jit_type_ushort)
if(type == jit_type_sbyte || type == jit_type_short)
{
return jit_type_int;
}
else if(type == jit_type_ubyte || type == jit_type_ushort)
{
return jit_type_uint;
}
else
{
return type;

20
tests/coerce.pas

@ -21,9 +21,9 @@
program coerce;
var
failed: boolean;
failed: Boolean;
procedure run(msg: string; value: boolean);
procedure run(msg: String; value: Boolean);
begin
Write(msg);
Write(" ... ");
@ -36,12 +36,26 @@ begin
end;
procedure run_tests;
var
b: Byte;
s: ShortInt;
begin
b := 3;
s := 67;
run("coerce_byte_short", SameType(Integer, b / s));
run("coerce_int_byte", SameType(Integer, 3 + b));
run("coerce_byte_uint", SameType(Cardinal, b * 080000000H));
run("coerce_int_short", SameType(Integer, 3 + s));
run("coerce_short_uint", SameType(Integer, s * 080000000H));
run("coerce_int_int", SameType(Integer, 3 + 4));
run("coerce_int_uint", SameType(Integer, 3 + 0FFFFFFFFH));
run("coerce_int_uint", SameType(Integer, 3 - 0FFFFFFFFH));
run("coerce_uint_int", SameType(Integer, 0FFFFFFFFH mod 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));
end;
begin

Loading…
Cancel
Save