public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* define-hardware, abs, and modes
@ 2007-03-07 10:27 Joern Rennecke
  0 siblings, 0 replies; only message in thread
From: Joern Rennecke @ 2007-03-07 10:27 UTC (permalink / raw)
  To: cgen

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?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-07 10:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-07 10:27 define-hardware, abs, and modes Joern Rennecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).