[LLVMdev] promoting small integers to 32 bits

Jay Foad jay.foad at antixlabs.com
Tue Aug 14 05:47:49 PDT 2007


Hi,

I'm looking at writing a custom backend targetting a proprietary virtual
machine. I'm basing it on the existing C and MSIL backends. My VM only has
32- and 64-bit integer operations (like the JVM) but C code compiled with
llvmgcc typically has lots of 1-, 8- and 16-bit instructions.

I was thinking of writing a custom pass to promote small integer types and
instructions to 32-bits, adding sign- and/or zero-extension instructions
where necessary. Does this sound reasonable?

If my pass inserts sign/zero-extensions instructions naively then lots of
them will probably turn out to be redundant. Can I run other optimization
passes afterwards to remove the redundant instructions? Is there any danger
that running other optimization passes will re-introduce 8- or 16-bit
instructions?

Alternatively, I noticed that SelectionDAG::Legalize() already contains code
to promote small integer values, but I'm not sure how to take advantage of
it. If I use a SelectionDAG would I have to use all the rest of the target
machinery that's designed for targetting real CPUs? Because I don't think I
want to use SelectionDAG-based instruction selection, and I certainly don't
want to do conventional register allocation.

Thanks for any help,
Jay.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070814/15356b22/attachment.html>


More information about the llvm-dev mailing list