[llvm-commits] [llvm] r50166 - in /llvm/trunk/lib/Target/X86: X86.h X86RegisterInfo.cpp X86TargetMachine.cpp X86TargetMachine.h
Anton Korobeynikov
asl at math.spbu.ru
Wed Apr 23 11:23:06 PDT 2008
Author: asl
Date: Wed Apr 23 13:23:05 2008
New Revision: 50166
URL: http://llvm.org/viewvc/llvm-project?rev=50166&view=rev
Log:
Add X86 Maximal Stack Alignment Calculator Pass before RA
Modified:
llvm/trunk/lib/Target/X86/X86.h
llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
llvm/trunk/lib/Target/X86/X86TargetMachine.h
Modified: llvm/trunk/lib/Target/X86/X86.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.h?rev=50166&r1=50165&r2=50166&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86.h (original)
+++ llvm/trunk/lib/Target/X86/X86.h Wed Apr 23 13:23:05 2008
@@ -51,6 +51,11 @@
///
FunctionPass *createEmitX86CodeToMemory();
+/// createX86MaxStackAlignmentCalculatorPass - This function returns a pass which
+/// calculates maximal stack alignment required for function
+///
+FunctionPass *createX86MaxStackAlignmentCalculatorPass();
+
} // End llvm namespace
// Defines symbolic names for X86 registers. This defines a mapping from
Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=50166&r1=50165&r2=50166&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Apr 23 13:23:05 2008
@@ -36,6 +36,7 @@
#include "llvm/Target/TargetOptions.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
using namespace llvm;
X86RegisterInfo::X86RegisterInfo(X86TargetMachine &tm,
@@ -280,16 +281,10 @@
bool X86RegisterInfo::needsStackRealignment(const MachineFunction &MF) const {
MachineFrameInfo *MFI = MF.getFrameInfo();;
- // FIXME: This is really really ugly, but it seems we need to decide, whether
- // we will need stack realignment or not too early (during RA stage).
- unsigned MaxAlign = MFI->getMaxAlignment();
- if (!MaxAlign)
- MaxAlign = calculateMaxStackAlignment(MFI);
-
// FIXME: Currently we don't support stack realignment for functions with
// variable-sized allocas
- return (RealignStack &&
- (MaxAlign > StackAlign &&
+ return (MFI->getMaxAlignment() &&
+ (MFI->getMaxAlignment() > StackAlign &&
!MFI->hasVarSizedObjects()));
}
@@ -1118,3 +1113,31 @@
}
#include "X86GenRegisterInfo.inc"
+
+namespace {
+ struct VISIBILITY_HIDDEN MSAC : public MachineFunctionPass {
+ static char ID;
+ MSAC() : MachineFunctionPass((intptr_t)&ID) {}
+
+ virtual bool runOnMachineFunction(MachineFunction &MF) {
+ MachineFrameInfo *FFI = MF.getFrameInfo();
+
+ // Calculate and set max stack object alignment early, so we can decide
+ // whether we will need stack realignment (and thus FP).
+ unsigned MaxAlign = calculateMaxStackAlignment(FFI);
+
+ FFI->setMaxAlignment(MaxAlign);
+
+ return false;
+ }
+
+ virtual const char *getPassName() const {
+ return "X86 Maximal Stack Alignment Calculator";
+ }
+ };
+
+ char MSAC::ID = 0;
+}
+
+FunctionPass*
+llvm::createX86MaxStackAlignmentCalculatorPass() { return new MSAC(); }
Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=50166&r1=50165&r2=50166&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Wed Apr 23 13:23:05 2008
@@ -161,6 +161,11 @@
return false;
}
+bool X86TargetMachine::addPreRegAlloc(PassManagerBase &PM, bool Fast) {
+ PM.add(createX86MaxStackAlignmentCalculatorPass());
+ return false; // -print-machineinstr shouldn't print after this.
+}
+
bool X86TargetMachine::addPostRegAlloc(PassManagerBase &PM, bool Fast) {
PM.add(createX86FloatingPointStackifierPass());
return true; // -print-machineinstr should print after this.
Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.h?rev=50166&r1=50165&r2=50166&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.h (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.h Wed Apr 23 13:23:05 2008
@@ -61,7 +61,8 @@
static unsigned getJITMatchQuality();
// Set up the pass pipeline.
- virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
+ virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
+ virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast);
virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast);
virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
std::ostream &Out);
More information about the llvm-commits
mailing list