diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-08-24 19:05:43 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-08-24 19:05:43 +0000 |
commit | a273442891ae20fd8192526132e3819ea9e5eda9 (patch) | |
tree | 0e28d05f881cbe240efb9fba0d59f0072c149869 /lib | |
parent | 05ea54e8869a81b8dd846397175f218f97968907 (diff) | |
download | llvm-a273442891ae20fd8192526132e3819ea9e5eda9.tar.gz llvm-a273442891ae20fd8192526132e3819ea9e5eda9.tar.bz2 llvm-a273442891ae20fd8192526132e3819ea9e5eda9.tar.xz |
Move enabling the local stack allocation pass into the target where it belongs.
For now it's still a command line option, but the interface to the generic
code doesn't need to know that.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111942 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/LLVMTargetMachine.cpp | 18 | ||||
-rw-r--r-- | lib/CodeGen/LocalStackSlotAllocation.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/PrologEpilogInserter.cpp | 6 | ||||
-rw-r--r-- | lib/Target/ARM/ARMBaseRegisterInfo.cpp | 10 | ||||
-rw-r--r-- | lib/Target/ARM/ARMBaseRegisterInfo.h | 2 |
5 files changed, 19 insertions, 23 deletions
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index b856d9093e..80dbb988df 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -74,16 +74,6 @@ static cl::opt<bool> EnableMCLogging("enable-mc-api-logging", cl::Hidden, static cl::opt<bool> VerifyMachineCode("verify-machineinstrs", cl::Hidden, cl::desc("Verify generated machine code"), cl::init(getenv("LLVM_VERIFY_MACHINEINSTRS")!=NULL)); -// Enabled or disable local stack object block allocation. This is an -// experimental pass that allocates locals relative to one another before -// register allocation and then assigns them to actual stack slots as a block -// later in PEI. This will eventually allow targets with limited index offset -// range to allocate additional base registers (not just FP and SP) to -// more efficiently reference locals, as well as handle situations where -// locals cannot be referenced via SP or FP at all (dynamic stack realignment -// together with variable sized objects, for example). -cl::opt<bool> EnableLocalStackAlloc("enable-local-stack-alloc", cl::init(false), - cl::Hidden, cl::desc("Enable pre-regalloc stack frame index allocation")); static cl::opt<cl::boolOrDefault> AsmVerbose("asm-verbose", cl::desc("Add comments to directives."), @@ -354,11 +344,9 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM, if (OptLevel != CodeGenOpt::None) PM.add(createOptimizePHIsPass()); - // Assign local variables to stack slots relative to one another and simplify - // frame index references where possible. Final stack slot locations will be - // assigned in PEI. - if (EnableLocalStackAlloc) - PM.add(createLocalStackSlotAllocationPass()); + // If the target requests it, assign local variables to stack slots relative + // to one another and simplify frame index references where possible. + PM.add(createLocalStackSlotAllocationPass()); if (OptLevel != CodeGenOpt::None) { // With optimization, dead code should already be eliminated. However diff --git a/lib/CodeGen/LocalStackSlotAllocation.cpp b/lib/CodeGen/LocalStackSlotAllocation.cpp index 811cb07628..3f79593b4e 100644 --- a/lib/CodeGen/LocalStackSlotAllocation.cpp +++ b/lib/CodeGen/LocalStackSlotAllocation.cpp @@ -74,10 +74,12 @@ FunctionPass *llvm::createLocalStackSlotAllocationPass() { bool LocalStackSlotPass::runOnMachineFunction(MachineFunction &MF) { MachineFrameInfo *MFI = MF.getFrameInfo(); + const TargetRegisterInfo *TRI = MF.getTarget().getRegisterInfo(); unsigned LocalObjectCount = MFI->getObjectIndexEnd(); - // Early exit if there are no locals to consider - if (!LocalObjectCount) + // If the target doesn't want/need this pass, or if there are no locals + // to consider, early exit. + if (!TRI->requiresVirtualBaseRegisters(MF) || LocalObjectCount == 0) return true; // Make sure we have enough space to store the local offsets. diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index e360f2c461..4c3e796f5e 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -41,10 +41,6 @@ using namespace llvm; -// FIXME: For testing purposes only. Remove once the pre-allocation pass -// is done. -extern cl::opt<bool> EnableLocalStackAlloc; - char PEI::ID = 0; INITIALIZE_PASS(PEI, "prologepilog", @@ -560,7 +556,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { // check for whether the frame is large enough to want to use virtual // frame index registers. Functions which don't want/need this optimization // will continue to use the existing code path. - if (EnableLocalStackAlloc && MFI->getUseLocalStackAllocationBlock()) { + if (MFI->getUseLocalStackAllocationBlock()) { unsigned Align = MFI->getLocalFrameMaxAlign(); // Adjust to alignment boundary. diff --git a/lib/Target/ARM/ARMBaseRegisterInfo.cpp b/lib/Target/ARM/ARMBaseRegisterInfo.cpp index cf6507b5d4..edfacc72e0 100644 --- a/lib/Target/ARM/ARMBaseRegisterInfo.cpp +++ b/lib/Target/ARM/ARMBaseRegisterInfo.cpp @@ -43,9 +43,12 @@ namespace llvm { cl::opt<bool> ReuseFrameIndexVals("arm-reuse-frame-index-vals", cl::Hidden, cl::init(true), cl::desc("Reuse repeated frame index values")); -cl::opt<bool> +static cl::opt<bool> ForceAllBaseRegAlloc("arm-force-base-reg-alloc", cl::Hidden, cl::init(true), cl::desc("Force use of virtual base registers for stack load/store")); +static cl::opt<bool> +EnableLocalStackAlloc("enable-local-stack-alloc", cl::init(false), cl::Hidden, + cl::desc("Enable pre-regalloc stack frame index allocation")); } using namespace llvm; @@ -1285,6 +1288,11 @@ requiresFrameIndexScavenging(const MachineFunction &MF) const { return true; } +bool ARMBaseRegisterInfo:: +requiresVirtualBaseRegisters(const MachineFunction &MF) const { + return EnableLocalStackAlloc; +} + // hasReservedCallFrame - Under normal circumstances, when a frame pointer is // not required, we reserve argument space for call sites in the function // immediately on entry to the current function. This eliminates the need for diff --git a/lib/Target/ARM/ARMBaseRegisterInfo.h b/lib/Target/ARM/ARMBaseRegisterInfo.h index afd43eaeb3..7044b74e7d 100644 --- a/lib/Target/ARM/ARMBaseRegisterInfo.h +++ b/lib/Target/ARM/ARMBaseRegisterInfo.h @@ -154,6 +154,8 @@ public: virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const; + virtual bool requiresVirtualBaseRegisters(const MachineFunction &MF) const; + virtual bool hasReservedCallFrame(const MachineFunction &MF) const; virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const; |