[llvm-commits] [llvm-gcc] CastFixes To Make llvm-convert.cpp nearly signless (Review & Commit)

Reid Spencer rspencer at reidspencer.com
Wed Dec 20 15:13:51 PST 2006


The attached patch removes all but one isSigned() calls from
llvm-convert.cpp and otherwise makes it signless. This cleans up the
casting patch committed yesterday and bases signedness only on
TYPE_UNSIGNED(TREE_TYPE(tree)). The one exception can't be removed until
the signed and unsigned integer types are unified.

Although I've tested this extensively and it causes no regressions, it
needs to be reviewed. In particular, in two places I have changed
casts-to-bool into SetCondInst to prevent "trunc to bool" semantics
which could break things. 

Some things to note:

1. EmitAsScalarType was just another name for a CastToType and had
exactly one use
   so I just removed it and replaced its call with a CastToType call.
2. I've added several CastToXXType functions near the beginning of the
file to
   assist with casting int<->int, fp<->fp, and any<->any. This just
prevents a
   little opcode selection logic from being sprinkled throughout the
3. Most of the changes to llvm-types.cpp is just wrapping long lines. I
noticed it
   so figured I'd fix it.
4. I added a tree typed argument to HandleScalarArgument so the
   can be derived. This isn't always used, but its the only accurate way
to get
   the signedness in a couple cases where it is used. If 0 is passed in,
   defaults to unsigned.
5. In two places (1787 and 2516) I removed some casting. These were
remnants from 
   the SHIFT patch. Since shift no longer cares about the sign of its
   there's no need to cast them to force a particular kind of shift.
6. The NOOPCastToType function is a misnomer. The casts it produces are
   not BitCast (the only "noop" cast we have). It can do integer
conversions and
   Ptr<->Int as well. I couldn't think of a better name for this so I
just left it.
7. The rest of the changes are of two forms: (a) change a cast to use a
   cast opcode, or (b) change a cast to use an opcode derived from 
   CastInst::getCastOpcode and the signedness information from the gcc

One small step towards signlessness.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CastFixes-llvmgcc.patch
Type: text/x-patch
Size: 47617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20061220/17b9ae14/attachment.bin>

More information about the llvm-commits mailing list