Added X86FunctionInfo subclass of MachineFunction to record whether the

function that is being lowered is forced to use FP. Currently this is only
true for main() / Cygwin.

llvm-svn: 28703
This commit is contained in:
Evan Cheng 2006-06-06 23:30:24 +00:00
parent 62a09f32c7
commit 2da9d803a4
3 changed files with 41 additions and 7 deletions

View 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);

View File

@ -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

View 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::