[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp X86RegisterInfo.cpp
Evan Cheng
evan.cheng at apple.com
Fri Jun 2 15:38:50 PDT 2006
Changes in directory llvm/lib/Target/X86:
X86ISelDAGToDAG.cpp updated: 1.72 -> 1.73
X86RegisterInfo.cpp updated: 1.155 -> 1.156
---
Log message:
Cygwin support. Patch by Anton Korobeynikov!
---
Diffs of the changes: (+28 -4)
X86ISelDAGToDAG.cpp | 9 +++++++--
X86RegisterInfo.cpp | 23 +++++++++++++++++++++--
2 files changed, 28 insertions(+), 4 deletions(-)
Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.72 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.73
--- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.72 Fri Jun 2 16:20:34 2006
+++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Fri Jun 2 17:38:37 2006
@@ -129,6 +129,8 @@
SDOperand &Base, SDOperand &Scale,
SDOperand &Index, SDOperand &Disp);
+ void EmitSpecialCodeForMain(MachineBasicBlock *BB, MachineFrameInfo *MFI);
+
inline void getAddressOperands(X86ISelAddressMode &AM, SDOperand &Base,
SDOperand &Scale, SDOperand &Index,
SDOperand &Disp) {
@@ -250,8 +252,11 @@
/// EmitSpecialCodeForMain - Emit any code that needs to be executed only in
/// the main function.
-static void EmitSpecialCodeForMain(MachineBasicBlock *BB,
- MachineFrameInfo *MFI) {
+void X86DAGToDAGISel::EmitSpecialCodeForMain(MachineBasicBlock *BB,
+ MachineFrameInfo *MFI) {
+ if (Subtarget->TargetType == X86Subtarget::isCygwin)
+ BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("__main");
+
// Switch the FPU to 64-bit precision mode for better compatibility and speed.
int CWFrameIdx = MFI->CreateStackObject(2, 2);
addFrameReference(BuildMI(BB, X86::FNSTCW16m, 4), CWFrameIdx);
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.155 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.156
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.155 Wed May 31 14:00:07 2006
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp Fri Jun 2 17:38:37 2006
@@ -14,9 +14,12 @@
#include "X86.h"
#include "X86RegisterInfo.h"
+#include "X86Subtarget.h"
+#include "X86TargetMachine.h"
#include "X86InstrBuilder.h"
#include "llvm/Constants.h"
#include "llvm/Type.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -635,7 +638,14 @@
// if frame pointer elimination is disabled.
//
static bool hasFP(MachineFunction &MF) {
- return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects();
+ const Function* Fn = MF.getFunction();
+ const X86Subtarget* Subtarget = &MF.getTarget().getSubtarget<X86Subtarget>();
+
+ return (NoFramePointerElim ||
+ MF.getFrameInfo()->hasVarSizedObjects() ||
+ (Fn->hasExternalLinkage() &&
+ Fn->getName() == "main" &&
+ Subtarget->TargetType == X86Subtarget::isCygwin));
}
void X86RegisterInfo::
@@ -730,6 +740,9 @@
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
MachineBasicBlock::iterator MBBI = MBB.begin();
MachineFrameInfo *MFI = MF.getFrameInfo();
+ unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
+ const Function* Fn = MF.getFunction();
+ const X86Subtarget* Subtarget = &MF.getTarget().getSubtarget<X86Subtarget>();
MachineInstr *MI;
// Get the number of bytes to allocate from the FrameInfo
@@ -744,7 +757,6 @@
// Round the size to a multiple of the alignment (don't forget the 4 byte
// offset though).
- unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
NumBytes = ((NumBytes+4)+Align-1)/Align*Align - 4;
}
@@ -775,6 +787,13 @@
MBB.insert(MBBI, MI);
}
+
+ // If it's main() on Cygwin\Mingw32 we should align stack as well
+ if (Fn->hasExternalLinkage() && Fn->getName() == "main" &&
+ Subtarget->TargetType == X86Subtarget::isCygwin) {
+ MI = BuildMI(X86::AND32ri, 2, X86::ESP).addImm(-Align);
+ MBB.insert(MBBI, MI);
+ }
}
void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
More information about the llvm-commits
mailing list