aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/TargetTransformImpl.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-10-30 11:23:25 +0000
committerHans Wennborg <hans@hanshq.net>2012-10-30 11:23:25 +0000
commitf3254838e47aa0afc36c8ba5af3207c5912972be (patch)
tree0600d460175725ef379df5f0729ed1dac92ebee1 /llvm/lib/Target/TargetTransformImpl.cpp
parent0c8b7558399e208da7780e5241179ebace813d0b (diff)
downloadllvm-f3254838e47aa0afc36c8ba5af3207c5912972be.zip
llvm-f3254838e47aa0afc36c8ba5af3207c5912972be.tar.gz
llvm-f3254838e47aa0afc36c8ba5af3207c5912972be.tar.bz2
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. llvm-svn: 167011
Diffstat (limited to 'llvm/lib/Target/TargetTransformImpl.cpp')
-rw-r--r--llvm/lib/Target/TargetTransformImpl.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Target/TargetTransformImpl.cpp b/llvm/lib/Target/TargetTransformImpl.cpp
index 27877a9..38c704f 100644
--- a/llvm/lib/Target/TargetTransformImpl.cpp
+++ b/llvm/lib/Target/TargetTransformImpl.cpp
@@ -49,6 +49,12 @@ unsigned ScalarTargetTransformImpl::getJumpBufSize() const {
return TLI->getJumpBufSize();
}
+bool ScalarTargetTransformImpl::shouldBuildLookupTables() const {
+ return TLI->supportJumpTables() &&
+ (TLI->isOperationLegalOrCustom(ISD::BR_JT, MVT::Other) ||
+ TLI->isOperationLegalOrCustom(ISD::BRIND, MVT::Other));
+}
+
//===----------------------------------------------------------------------===//
//
// Calls used by the vectorizers.
@@ -313,4 +319,3 @@ VectorTargetTransformImpl::getNumberOfParts(Type *Tp) const {
getTypeLegalizationCost(Tp->getContext(), TLI->getValueType(Tp));
return LT.first;
}
-