diff options
author | Evan Cheng <evan.cheng@apple.com> | 2009-05-13 21:42:09 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2009-05-13 21:42:09 +0000 |
commit | 6ebf7bc7405ee79d27d50b70f0c1a474cbea820d (patch) | |
tree | fd3f08887870223c52e3eb8cb257c4377eaeb8bd | |
parent | be1be5ef0d5a2bb52746b6bd69d4b1e88513c81a (diff) |
Run code placement optimization for targets that want it (arm and x86 for now).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71726 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Target/TargetLowering.h | 11 | ||||
-rw-r--r-- | lib/CodeGen/CodePlacementOpt.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/TargetLowering.cpp | 1 | ||||
-rw-r--r-- | lib/Target/ARM/ARMISelLowering.cpp | 1 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 1 |
5 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index dcff47d24b..0576e3e1a8 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -620,6 +620,13 @@ public: return allowUnalignedMemoryAccesses; } + /// This function returns true if the target would benefit from code placement + /// optimization. + /// @brief Determine if the target should perform code placement optimization. + bool shouldOptimizeCodePlacement() const { + return benefitFromCodePlacementOpt; + } + /// getOptimalMemOpType - Returns the target specific optimal type for load /// and store operations as a result of memset, memcpy, and memmove lowering. /// It returns MVT::iAny if SelectionDAG should be responsible for @@ -1652,6 +1659,10 @@ protected: /// operations when copying small arrays and other similar tasks. /// @brief Indicate whether the target permits unaligned memory accesses. bool allowUnalignedMemoryAccesses; + + /// This field specifies whether the target can benefit from code placement + /// optimization. + bool benefitFromCodePlacementOpt; }; } // end llvm namespace diff --git a/lib/CodeGen/CodePlacementOpt.cpp b/lib/CodeGen/CodePlacementOpt.cpp index 61a8b12860..919ee54fb3 100644 --- a/lib/CodeGen/CodePlacementOpt.cpp +++ b/lib/CodeGen/CodePlacementOpt.cpp @@ -104,6 +104,9 @@ FunctionPass *llvm::createCodePlacementOptPass() { /// jcc <cond> C, [exit] /// bool CodePlacementOpt::OptimizeIntraLoopEdges() { + if (!TLI->shouldOptimizeCodePlacement()) + return false; + bool Changed = false; for (unsigned i = 0, e = UncondJmpMBBs.size(); i != e; ++i) { MachineBasicBlock *MBB = UncondJmpMBBs[i].first; diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index d7abd32727..1bb3959e68 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -483,6 +483,7 @@ TargetLowering::TargetLowering(TargetMachine &tm) memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray)); maxStoresPerMemset = maxStoresPerMemcpy = maxStoresPerMemmove = 8; allowUnalignedMemoryAccesses = false; + benefitFromCodePlacementOpt = false; UseUnderscoreSetJmp = false; UseUnderscoreLongJmp = false; SelectIsExpensive = false; diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp index 48e197d04f..f5b33b02ca 100644 --- a/lib/Target/ARM/ARMISelLowering.cpp +++ b/lib/Target/ARM/ARMISelLowering.cpp @@ -288,6 +288,7 @@ ARMTargetLowering::ARMTargetLowering(TargetMachine &TM) setIfCvtDupBlockSizeLimit(Subtarget->isThumb() ? 0 : 2); maxStoresPerMemcpy = 1; //// temporary - rewrite interface to use type + benefitFromCodePlacementOpt = true; } const char *ARMTargetLowering::getTargetNodeName(unsigned Opcode) const { diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 9ac59df5bd..debfac4867 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -844,6 +844,7 @@ X86TargetLowering::X86TargetLowering(X86TargetMachine &TM) maxStoresPerMemmove = 3; // For @llvm.memmove -> sequence of stores allowUnalignedMemoryAccesses = true; // x86 supports it! setPrefLoopAlignment(16); + benefitFromCodePlacementOpt = true; } |