List Info

Thread: define-hardware, abs, and modes




define-hardware, abs, and modes
user name
2007-03-07 04:26:18
I've found that an 'abs' instruction using the 'abs'
rtl code didn't actually compute the absolute value.
Looking at the generated C code, I found that the
expression inside the ABSSI macro was unsigned,
and the ABSSI macro assumes that the expression is signed.

The expression was generated from a normal operand, which
indexes a register set by an instruction field.
The registe rset was defined with define-hardware using
the mode SI.  However, it had a special get function,
which had a (case SI index ... construct.  One of the
cases uses h-pc.
It turns out that h-pc translates into an unsigned
variable,
and the generated does not actually use the declared modes.

Once the problem was known, I could work around it by
assigning
the operand to a temporary variable with the proper mode
first;
but I don't think that you should be required to do this.
Having abs of an SI value not compute the absolute value
is certainly unexpected.

Do you thing the GET macro generated for the register is
at fault for yielding a value with a type not consistent
with
the declared mode, the ABSSI macro for not casting its
input
to be signed first, or both?

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )