diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-10-30 11:23:25 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-10-30 11:23:25 +0000 |
commit | 04d7d13d301df66f6c232e41611145c062183bf3 (patch) | |
tree | 506f923fd1e30024c1b3be9b63fcdb46f52d1f1b /include/llvm | |
parent | c588e0e162fa08c81558871fb0c50fb51569afe3 (diff) |
Use TargetTransformInfo to control switch-to-lookup table transformation
When the switch-to-lookup tables transform landed in SimplifyCFG, it
was pointed out that this could be inappropriate for some targets.
Since there was no way at the time for the pass to know anything about
the target, an awkward reverse-transform was added in CodeGenPrepare
that turned lookup tables back into switches for some targets.
This patch uses the new TargetTransformInfo to determine if a
switch should be transformed, and removes
CodeGenPrepare::ConvertLoadToSwitch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Target/TargetTransformImpl.h | 2 | ||||
-rw-r--r-- | include/llvm/TargetTransformInfo.h | 5 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/Local.h | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/include/llvm/Target/TargetTransformImpl.h b/include/llvm/Target/TargetTransformImpl.h index fd4b737afd..fa1acbea08 100644 --- a/include/llvm/Target/TargetTransformImpl.h +++ b/include/llvm/Target/TargetTransformImpl.h @@ -46,6 +46,8 @@ public: virtual unsigned getJumpBufAlignment() const; virtual unsigned getJumpBufSize() const; + + virtual bool shouldBuildLookupTables() const; }; class VectorTargetTransformImpl : public VectorTargetTransformInfo { diff --git a/include/llvm/TargetTransformInfo.h b/include/llvm/TargetTransformInfo.h index 6ee3b37056..c65ef17dfa 100644 --- a/include/llvm/TargetTransformInfo.h +++ b/include/llvm/TargetTransformInfo.h @@ -117,6 +117,11 @@ public: virtual unsigned getJumpBufSize() const { return 0; } + /// shouldBuildLookupTables - Return true if switches should be turned into + /// lookup tables for the target. + virtual bool shouldBuildLookupTables() const { + return true; + } }; /// VectorTargetTransformInfo - This interface is used by the vectorizers diff --git a/include/llvm/Transforms/Utils/Local.h b/include/llvm/Transforms/Utils/Local.h index 49eeb57622..5c804d877a 100644 --- a/include/llvm/Transforms/Utils/Local.h +++ b/include/llvm/Transforms/Utils/Local.h @@ -37,6 +37,7 @@ class AllocaInst; class ConstantExpr; class DataLayout; class TargetLibraryInfo; +class TargetTransformInfo; class DIBuilder; template<typename T> class SmallVectorImpl; @@ -134,7 +135,8 @@ bool EliminateDuplicatePHINodes(BasicBlock *BB); /// of the CFG. It returns true if a modification was made, possibly deleting /// the basic block that was pointed to. /// -bool SimplifyCFG(BasicBlock *BB, const DataLayout *TD = 0); +bool SimplifyCFG(BasicBlock *BB, const DataLayout *TD = 0, + const TargetTransformInfo *TTI = 0); /// FoldBranchToCommonDest - If this basic block is ONLY a setcc and a branch, /// and if a predecessor branches to us and one of our successors, fold the |