Switch case-ranges, new approach (PR1255).
Stepan Dyatkovskiy
stpworld at narod.ru
Tue May 7 12:19:14 PDT 2013
Hello, I propose new approach to switch case-ranges
implementation (PR1255).
Don't modify SwitchInst, but implement new instruction.
In this case:
1. We don't affect current functionality and tests.
2. We keep backward compatibility in natural way. If you need current
functionality (without case ranges) just use 'switch'.
Here I have attached set of patches:
-- New instruction itself. It is called 'SwitchRInst'. Implementation
is ConstantRange based. Internally switch is represented as just an
array of integers. Though i-th and i+1 integer represents a range,
and i-th integer is linked with this-range successor. This is a
result of implementation discussions in IRC and ML.
Patch name: switchr-2013-05-07-instruction.patch
-- Parser/AsmWriter patch. After this patch IR parser will
recognize new instruction and its syntax ('switchr' keyword will
be added).
Patch contains unit-tests.
Patch name: switchr-2013-05-07-parser-writer.patch
Requires: switchr-2013-05-07-instruction.patch
-- Bitcode patch. Patch adds new instruction support
for .bc files with.
Patch contains unit-tests.
Patch name: switchr-2013-05-07-bitcode.patch
Requires: switchr-2013-05-07-instruction.patch
[switchr-2013-05-07-parser-writer.patch] (for unit-tests)
-- "Essential passes" patch. This patch finally enables 'switchr':
it becomes absultely legal on LLVM level. Patch updates next passes:
* SelectionDAGBuilder: lowers 'switchr';
* IRBuilder: "Create" method;
* SCCP: just a stub, that marks all 'switchr' successors
as reachable.
Patch contains unit-tests.
Patch name: switchr-2013-05-07-essential-passes.patch
Requires: switchr-2013-05-07-instruction.patch
[switchr-2013-05-07-parser-writer.patch] (for unit-tests)
-- Switch-to-SwitchR pass patch. Adds function pass that replaces
'switch' instructions with 'switchr'.
Patch name: switchr-2013-05-07-switch-to-switchr.patch
-- Clang patch. Adds '-fforce-switchr' option: with this flag clang
will use 'switchr' instructions instead of 'switch'. Actually, it
inserts SwitchToSwitchR patch.
Patch contains unit-tests.
Patch name: switchr-clang-force-flag-2013-05-07.patch
Requires: switchr-2013-05-07-instruction.patch
switchr-2013-05-07-switch-to-switchr.patch
[switchr-2013-05-07-parser-writer.patch] (for unit-tests)
Also I've attached summary LLVM patch (all-in-one).
-Stepan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switchr-2013-05-07-bitcode.patch
Type: text/x-diff
Size: 9225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130507/fb6a075b/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switchr-2013-05-07-essential-passes.patch
Type: text/x-diff
Size: 10899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130507/fb6a075b/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switchr-2013-05-07-instruction.patch
Type: text/x-diff
Size: 46723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130507/fb6a075b/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switchr-2013-05-07-parser-writer.patch
Type: text/x-diff
Size: 16772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130507/fb6a075b/attachment-0003.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switchr-2013-05-07-summary-llvm.patch
Type: text/x-diff
Size: 81618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130507/fb6a075b/attachment-0004.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switchr-2013-05-07-switch-to-switchr.patch
Type: text/x-diff
Size: 6188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130507/fb6a075b/attachment-0005.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: switchr-clang-force-flag-2013-05-07.patch
Type: text/x-diff
Size: 3790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130507/fb6a075b/attachment-0006.patch>
More information about the llvm-commits
mailing list