This is the mail archive of the cgen@sourceware.org mailing list for the CGEN project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

define-hardware, abs, and modes


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]