Added X86FunctionInfo subclass of MachineFunction to record whether the
authorEvan Cheng <evan.cheng@apple.com>
Tue, 6 Jun 2006 23:30:24 +0000 (23:30 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 6 Jun 2006 23:30:24 +0000 (23:30 +0000)
function that is being lowered is forced to use FP. Currently this is only
true for main() / Cygwin.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28703 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86MachineFunctionInfo.h [new file with mode: 0644]
lib/Target/X86/X86RegisterInfo.cpp

index 8608d432738932853f2d9de5fe51426168408cd9..6f20b9cf26cc15ada899a6896ba592ddbc7f9924 100644 (file)
@@ -15,6 +15,7 @@
 #include "X86.h"
 #include "X86InstrBuilder.h"
 #include "X86ISelLowering.h"
+#include "X86MachineFunctionInfo.h"
 #include "X86TargetMachine.h"
 #include "llvm/CallingConv.h"
 #include "llvm/Constants.h"
@@ -3409,6 +3410,13 @@ SDOperand X86TargetLowering::LowerRET(SDOperand Op, SelectionDAG &DAG) {
 
 SDOperand
 X86TargetLowering::LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG) {
+  MachineFunction &MF = DAG.getMachineFunction();
+  const Function* Fn = MF.getFunction();
+  if (Fn->hasExternalLinkage() &&
+      Fn->getName() == "main" &&
+      Subtarget->TargetType == X86Subtarget::isCygwin)
+    MF.getInfo<X86FunctionInfo>()->setForceFramePointer(true);
+
   unsigned CC = cast<ConstantSDNode>(Op.getOperand(1))->getValue();
   if (CC == CallingConv::Fast && EnableFastCC)
     return LowerFastCCArguments(Op, DAG);
diff --git a/lib/Target/X86/X86MachineFunctionInfo.h b/lib/Target/X86/X86MachineFunctionInfo.h
new file mode 100644 (file)
index 0000000..9da2bf9
--- /dev/null
@@ -0,0 +1,30 @@
+//====- X86MachineFuctionInfo.h - X86 machine function info -----*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the Evan Cheng and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
+//
+// This file declares X86-specific per-machine-function information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef X86MACHINEFUNCTIONINFO_H
+#define X86MACHINEFUNCTIONINFO_H
+
+#include "llvm/CodeGen/MachineFunction.h"
+
+namespace llvm {
+
+class X86FunctionInfo : public MachineFunctionInfo {
+  bool ForceFramePointer;  // Function requires use of frame pointer.
+public:
+  X86FunctionInfo(MachineFunction& MF) : ForceFramePointer(false) {}
+  bool getForceFramePointer() const { return ForceFramePointer;} 
+  void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
+};
+} // End llvm namespace
+
+#endif
index ec4a24d503ced4a559eee6199855c42d0896e1d5..86e9151ea341e5f0263cded40519636eede20507 100644 (file)
@@ -15,8 +15,9 @@
 #include "X86.h"
 #include "X86RegisterInfo.h"
 #include "X86Subtarget.h"
-#include "X86TargetMachine.h"
 #include "X86InstrBuilder.h"
+#include "X86MachineFunctionInfo.h"
+#include "X86TargetMachine.h"
 #include "llvm/Constants.h"
 #include "llvm/Type.h"
 #include "llvm/Function.h"
@@ -638,14 +639,9 @@ X86RegisterInfo::getCalleeSaveRegClasses() const {
 // if frame pointer elimination is disabled.
 //
 static bool hasFP(MachineFunction &MF) {
-  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));
+          MF.getInfo<X86FunctionInfo>()->getForceFramePointer());
 }
 
 void X86RegisterInfo::