[llvm-commits] New classes for PR1255: Should enhance LLVM switch instruction to take case ranges.

Stepan Dyatkovskiy STPWORLD at narod.ru
Tue Feb 14 03:39:17 PST 2012


Hi, Chris.
You last thoughts relative to pr1255 was here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120102/134424.html
As a reply to all previous discussion a created patch. I reattached it to this post (cr-0.7.17). It is just a two .h files with new classes. I tested it, but current patch adds new classes only and affects nothing.

> Please remind me why it makes sense to use ConstantArray (or something like it) here.  It seems that the case values of the switch could be very reasonably represented with APInts, eliminating the Value*'s for the case values all together (which is what I recommended in Comment 15 of PR1255).  OTOH, I do vaguely remember making the comment about arrays and vectors in some PR (but can't find it).  Thinking about this a third time now, I really think that avoiding Constant*'s is the right thing to do.
What is the main reason to use APInts?
I have some half-implemented version with APInts. IMHO, I looks not very good, since it goes agains LLVM architecture: SwitchInst will first instruction that contains some values that are not inherited from the Value. I was need to do a set of workarounds adapting LLVM infrastructure to this feature: back-ends, asm-writer, lazy-values, Verifier.cpp with its original assertions and so on. APInt numbers will like an aliens from another planet, since the will need to work with entities that are from LLVMContext, and often we need to move it back using ConstantInt::get(...). If you have a time you can look at second draft patch attached to this post (cr-0.5.0). I made it two months ago or so on. It also contains changes in indexing I already applied, filtering it you can see what will wait LLVM if we will use APInt for case values. Patch is really huge, just look how SimplifyCFG, AsmWriter and BitcodeWriter will changed.
Anyway if there are some very reasonable args in favour of the APInt, I'll update all my changes respectively.

-Stepan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cr-0.7.17-newclasses.patch
Type: application/octet-stream
Size: 18087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120214/ffb22aad/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cr-0.5.0.patch
Type: application/octet-stream
Size: 93074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120214/ffb22aad/attachment-0001.obj>


More information about the llvm-commits mailing list