summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2017-06-29 23:28:47 +0000
committerEric Christopher <echristo@gmail.com>2017-06-29 23:28:47 +0000
commit56f481b78e4f3abee9d51e892d9b7618d58f7085 (patch)
tree915c02bd5550df9073eb91fb3eb7b3d86dbb14bb /llvm
parentb16eacf528f8dd38d4170816472fc19450501bd2 (diff)
downloadbcm5719-llvm-56f481b78e4f3abee9d51e892d9b7618d58f7085.tar.gz
bcm5719-llvm-56f481b78e4f3abee9d51e892d9b7618d58f7085.zip
To help readability of mightUseCTR pull out the inline asm handling support into a function.
llvm-svn: 306762
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/PowerPC/PPCCTRLoops.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
index 078646e2a46..094d3e6a61b 100644
--- a/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
+++ b/llvm/lib/Target/PowerPC/PPCCTRLoops.cpp
@@ -223,21 +223,28 @@ static bool memAddrUsesCTR(const PPCTargetMachine &TM, const Value *MemAddr) {
return Model == TLSModel::GeneralDynamic || Model == TLSModel::LocalDynamic;
}
+// Loop through the inline asm constraints and look for something that clobbers
+// ctr.
+static bool asmClobbersCTR(InlineAsm *IA) {
+ InlineAsm::ConstraintInfoVector CIV = IA->ParseConstraints();
+ for (unsigned i = 0, ie = CIV.size(); i < ie; ++i) {
+ InlineAsm::ConstraintInfo &C = CIV[i];
+ if (C.Type != InlineAsm::isInput)
+ for (unsigned j = 0, je = C.Codes.size(); j < je; ++j)
+ if (StringRef(C.Codes[j]).equals_lower("{ctr}"))
+ return true;
+ }
+ return false;
+}
+
bool PPCCTRLoops::mightUseCTR(BasicBlock *BB) {
for (BasicBlock::iterator J = BB->begin(), JE = BB->end();
J != JE; ++J) {
if (CallInst *CI = dyn_cast<CallInst>(J)) {
+ // Inline ASM is okay, unless it clobbers the ctr register.
if (InlineAsm *IA = dyn_cast<InlineAsm>(CI->getCalledValue())) {
- // Inline ASM is okay, unless it clobbers the ctr register.
- InlineAsm::ConstraintInfoVector CIV = IA->ParseConstraints();
- for (unsigned i = 0, ie = CIV.size(); i < ie; ++i) {
- InlineAsm::ConstraintInfo &C = CIV[i];
- if (C.Type != InlineAsm::isInput)
- for (unsigned j = 0, je = C.Codes.size(); j < je; ++j)
- if (StringRef(C.Codes[j]).equals_lower("{ctr}"))
- return true;
- }
-
+ if (asmClobbersCTR(IA))
+ return true;
continue;
}
OpenPOWER on IntegriCloud