Include a frame index in the "fixed stack" pseudo source value

instead of using the frame index for the SVOffset, which was
inconsistent.

llvm-svn: 53486
This commit is contained in:
Dan Gohman 2008-07-11 22:44:52 +00:00
parent d6dcdf8802
commit 4c18394001
6 changed files with 60 additions and 45 deletions

View File

@ -35,9 +35,9 @@ namespace llvm {
return V->getValueID() == PseudoSourceValueVal; return V->getValueID() == PseudoSourceValueVal;
} }
/// A pseudo source value referencing to the stack frame of a function, /// A pseudo source value referencing a fixed stack frame entry,
/// e.g., a spill slot. /// e.g., a spill slot.
static const PseudoSourceValue *getFixedStack(); static const PseudoSourceValue *getFixedStack(int FI);
/// A source value referencing the area below the stack frame of a function, /// A source value referencing the area below the stack frame of a function,
/// e.g., the argument space. /// e.g., the argument space.

View File

@ -13,28 +13,27 @@
#include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
#include <map>
namespace llvm { namespace llvm {
static ManagedStatic<PseudoSourceValue[5]> PSVs; static ManagedStatic<PseudoSourceValue[4]> PSVs;
const PseudoSourceValue *PseudoSourceValue::getFixedStack()
{ return &(*PSVs)[0]; }
const PseudoSourceValue *PseudoSourceValue::getStack() const PseudoSourceValue *PseudoSourceValue::getStack()
{ return &(*PSVs)[1]; } { return &(*PSVs)[0]; }
const PseudoSourceValue *PseudoSourceValue::getGOT() const PseudoSourceValue *PseudoSourceValue::getGOT()
{ return &(*PSVs)[1]; }
const PseudoSourceValue *PseudoSourceValue::getJumpTable()
{ return &(*PSVs)[2]; } { return &(*PSVs)[2]; }
const PseudoSourceValue *PseudoSourceValue::getConstantPool() const PseudoSourceValue *PseudoSourceValue::getConstantPool()
{ return &(*PSVs)[3]; } { return &(*PSVs)[3]; }
const PseudoSourceValue *PseudoSourceValue::getJumpTable()
{ return &(*PSVs)[4]; }
static const char *const PSVNames[] = { static const char *const PSVNames[] = {
"FixedStack",
"Stack", "Stack",
"GOT", "GOT",
"ConstantPool",
"JumpTable" "JumpTable"
"ConstantPool"
}; };
PseudoSourceValue::PseudoSourceValue() : PseudoSourceValue::PseudoSourceValue() :
@ -43,4 +42,26 @@ namespace llvm {
void PseudoSourceValue::print(std::ostream &OS) const { void PseudoSourceValue::print(std::ostream &OS) const {
OS << PSVNames[this - *PSVs]; OS << PSVNames[this - *PSVs];
} }
/// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
/// for holding FixedStack values, which must include a frame
/// index.
class VISIBILITY_HIDDEN FixedStackPseudoSourceValue
: public PseudoSourceValue {
const int FI;
public:
explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {}
virtual void print(std::ostream &OS) const {
OS << "FixedStack" << FI;
}
};
static ManagedStatic<std::map<int, const PseudoSourceValue *> > FSValues;
const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
const PseudoSourceValue *&V = (*FSValues)[FI];
if (!V)
V = new FixedStackPseudoSourceValue(FI);
return V;
}
} }

View File

@ -780,13 +780,11 @@ PerformInsertVectorEltInMemory(SDOperand Vec, SDOperand Val, SDOperand Idx) {
MVT PtrVT = TLI.getPointerTy(); MVT PtrVT = TLI.getPointerTy();
SDOperand StackPtr = DAG.CreateStackTemporary(VT); SDOperand StackPtr = DAG.CreateStackTemporary(VT);
FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(StackPtr.Val); int SPFI = cast<FrameIndexSDNode>(StackPtr.Val)->getIndex();
int SPFI = StackPtrFI->getIndex();
// Store the vector. // Store the vector.
SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Tmp1, StackPtr, SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Tmp1, StackPtr,
PseudoSourceValue::getFixedStack(), PseudoSourceValue::getFixedStack(SPFI), 0);
SPFI);
// Truncate or zero extend offset to target pointer type. // Truncate or zero extend offset to target pointer type.
unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND; unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND;
@ -797,9 +795,10 @@ PerformInsertVectorEltInMemory(SDOperand Vec, SDOperand Val, SDOperand Idx) {
SDOperand StackPtr2 = DAG.getNode(ISD::ADD, IdxVT, Tmp3, StackPtr); SDOperand StackPtr2 = DAG.getNode(ISD::ADD, IdxVT, Tmp3, StackPtr);
// Store the scalar value. // Store the scalar value.
Ch = DAG.getTruncStore(Ch, Tmp2, StackPtr2, Ch = DAG.getTruncStore(Ch, Tmp2, StackPtr2,
PseudoSourceValue::getFixedStack(), SPFI, EltVT); PseudoSourceValue::getFixedStack(SPFI), 0, EltVT);
// Load the updated vector. // Load the updated vector.
return DAG.getLoad(VT, Ch, StackPtr, PseudoSourceValue::getFixedStack(),SPFI); return DAG.getLoad(VT, Ch, StackPtr,
PseudoSourceValue::getFixedStack(SPFI), 0);
} }
/// LegalizeOp - We know that the specified value has a legal type, and /// LegalizeOp - We know that the specified value has a legal type, and
@ -4906,12 +4905,12 @@ SDOperand SelectionDAGLegalize::EmitStackConvert(SDOperand SrcOp,
if (SrcSize > SlotSize) if (SrcSize > SlotSize)
Store = DAG.getTruncStore(DAG.getEntryNode(), SrcOp, FIPtr, Store = DAG.getTruncStore(DAG.getEntryNode(), SrcOp, FIPtr,
PseudoSourceValue::getFixedStack(), SPFI, SlotVT, PseudoSourceValue::getFixedStack(SPFI), 0,
false, SrcAlign); SlotVT, false, SrcAlign);
else { else {
assert(SrcSize == SlotSize && "Invalid store"); assert(SrcSize == SlotSize && "Invalid store");
Store = DAG.getStore(DAG.getEntryNode(), SrcOp, FIPtr, Store = DAG.getStore(DAG.getEntryNode(), SrcOp, FIPtr,
PseudoSourceValue::getFixedStack(), SPFI, PseudoSourceValue::getFixedStack(SPFI), 0,
false, SrcAlign); false, SrcAlign);
} }
@ -4933,9 +4932,9 @@ SDOperand SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) {
int SPFI = StackPtrFI->getIndex(); int SPFI = StackPtrFI->getIndex();
SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0), StackPtr, SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0), StackPtr,
PseudoSourceValue::getFixedStack(), SPFI); PseudoSourceValue::getFixedStack(SPFI), 0);
return DAG.getLoad(Node->getValueType(0), Ch, StackPtr, return DAG.getLoad(Node->getValueType(0), Ch, StackPtr,
PseudoSourceValue::getFixedStack(), SPFI); PseudoSourceValue::getFixedStack(SPFI), 0);
} }
@ -7017,15 +7016,13 @@ void SelectionDAGLegalize::SplitVectorOp(SDOperand Op, SDOperand &Lo,
// Lower to a store/load so that it can be split. // Lower to a store/load so that it can be split.
// FIXME: this could be improved probably. // FIXME: this could be improved probably.
SDOperand Ptr = DAG.CreateStackTemporary(InOp.getValueType()); SDOperand Ptr = DAG.CreateStackTemporary(InOp.getValueType());
FrameIndexSDNode *FI = cast<FrameIndexSDNode>(Ptr.Val); int FI = cast<FrameIndexSDNode>(Ptr.Val)->getIndex();
SDOperand St = DAG.getStore(DAG.getEntryNode(), SDOperand St = DAG.getStore(DAG.getEntryNode(),
InOp, Ptr, InOp, Ptr,
PseudoSourceValue::getFixedStack(), PseudoSourceValue::getFixedStack(FI), 0);
FI->getIndex());
InOp = DAG.getLoad(Op.getValueType(), St, Ptr, InOp = DAG.getLoad(Op.getValueType(), St, Ptr,
PseudoSourceValue::getFixedStack(), PseudoSourceValue::getFixedStack(FI), 0);
FI->getIndex());
} }
// Split the vector and convert each of the pieces now. // Split the vector and convert each of the pieces now.
SplitVectorOp(InOp, Lo, Hi); SplitVectorOp(InOp, Lo, Hi);

View File

@ -4361,8 +4361,8 @@ MachineMemOperand MemSDNode::getMemOperand() const {
const FrameIndexSDNode *FI = const FrameIndexSDNode *FI =
dyn_cast<const FrameIndexSDNode>(getBasePtr().Val); dyn_cast<const FrameIndexSDNode>(getBasePtr().Val);
if (!getSrcValue() && FI) if (!getSrcValue() && FI)
return MachineMemOperand(PseudoSourceValue::getFixedStack(), Flags, return MachineMemOperand(PseudoSourceValue::getFixedStack(FI->getIndex()),
FI->getIndex(), Size, getAlignment()); Flags, 0, Size, getAlignment());
else else
return MachineMemOperand(getSrcValue(), Flags, getSrcValueOffset(), return MachineMemOperand(getSrcValue(), Flags, getSrcValueOffset(),
Size, getAlignment()); Size, getAlignment());

View File

@ -1943,8 +1943,8 @@ StoreTailCallArgumentsToStackSlot(SelectionDAG &DAG,
int FI = TailCallArgs[i].FrameIdx; int FI = TailCallArgs[i].FrameIdx;
// Store relative to framepointer. // Store relative to framepointer.
MemOpChains.push_back(DAG.getStore(Chain, Arg, FIN, MemOpChains.push_back(DAG.getStore(Chain, Arg, FIN,
PseudoSourceValue::getFixedStack(), PseudoSourceValue::getFixedStack(FI),
FI)); 0));
} }
} }
@ -1972,10 +1972,10 @@ static SDOperand EmitTailCallStoreFPAndRetAddr(SelectionDAG &DAG,
MVT VT = isPPC64 ? MVT::i64 : MVT::i32; MVT VT = isPPC64 ? MVT::i64 : MVT::i32;
SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT); SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT);
Chain = DAG.getStore(Chain, OldRetAddr, NewRetAddrFrIdx, Chain = DAG.getStore(Chain, OldRetAddr, NewRetAddrFrIdx,
PseudoSourceValue::getFixedStack(), NewRetAddr); PseudoSourceValue::getFixedStack(NewRetAddr), 0);
SDOperand NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT); SDOperand NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT);
Chain = DAG.getStore(Chain, OldFP, NewFramePtrIdx, Chain = DAG.getStore(Chain, OldFP, NewFramePtrIdx,
PseudoSourceValue::getFixedStack(), NewFPIdx); PseudoSourceValue::getFixedStack(NewFPIdx), 0);
} }
return Chain; return Chain;
} }
@ -3029,8 +3029,8 @@ SDOperand PPCTargetLowering::LowerSINT_TO_FP(SDOperand Op, SelectionDAG &DAG) {
Op.getOperand(0)); Op.getOperand(0));
// STD the extended value into the stack slot. // STD the extended value into the stack slot.
MachineMemOperand MO(PseudoSourceValue::getFixedStack(), MachineMemOperand MO(PseudoSourceValue::getFixedStack(FrameIdx),
MachineMemOperand::MOStore, FrameIdx, 8, 8); MachineMemOperand::MOStore, 0, 8, 8);
SDOperand Store = DAG.getNode(PPCISD::STD_32, MVT::Other, SDOperand Store = DAG.getNode(PPCISD::STD_32, MVT::Other,
DAG.getEntryNode(), Ext64, FIdx, DAG.getEntryNode(), Ext64, FIdx,
DAG.getMemOperand(MO)); DAG.getMemOperand(MO));

View File

@ -1134,7 +1134,7 @@ SDOperand X86TargetLowering::LowerMemArgument(SDOperand Op, SelectionDAG &DAG,
if (Flags.isByVal()) if (Flags.isByVal())
return FIN; return FIN;
return DAG.getLoad(VA.getValVT(), Root, FIN, return DAG.getLoad(VA.getValVT(), Root, FIN,
PseudoSourceValue::getFixedStack(), FI); PseudoSourceValue::getFixedStack(FI), 0);
} }
SDOperand SDOperand
@ -1320,8 +1320,7 @@ X86TargetLowering::LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG) {
SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::i64); SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::i64);
SDOperand Store = SDOperand Store =
DAG.getStore(Val.getValue(1), Val, FIN, DAG.getStore(Val.getValue(1), Val, FIN,
PseudoSourceValue::getFixedStack(), PseudoSourceValue::getFixedStack(RegSaveFrameIndex), 0);
RegSaveFrameIndex);
MemOps.push_back(Store); MemOps.push_back(Store);
FIN = DAG.getNode(ISD::ADD, getPointerTy(), FIN, FIN = DAG.getNode(ISD::ADD, getPointerTy(), FIN,
DAG.getIntPtrConstant(8)); DAG.getIntPtrConstant(8));
@ -1336,8 +1335,7 @@ X86TargetLowering::LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG) {
SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::v4f32); SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::v4f32);
SDOperand Store = SDOperand Store =
DAG.getStore(Val.getValue(1), Val, FIN, DAG.getStore(Val.getValue(1), Val, FIN,
PseudoSourceValue::getFixedStack(), PseudoSourceValue::getFixedStack(RegSaveFrameIndex), 0);
RegSaveFrameIndex);
MemOps.push_back(Store); MemOps.push_back(Store);
FIN = DAG.getNode(ISD::ADD, getPointerTy(), FIN, FIN = DAG.getNode(ISD::ADD, getPointerTy(), FIN,
DAG.getIntPtrConstant(16)); DAG.getIntPtrConstant(16));
@ -1435,7 +1433,7 @@ EmitTailCallStoreRetAddr(SelectionDAG & DAG, MachineFunction &MF,
MVT VT = Is64Bit ? MVT::i64 : MVT::i32; MVT VT = Is64Bit ? MVT::i64 : MVT::i32;
SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT);
Chain = DAG.getStore(Chain, RetAddrFrIdx, NewRetAddrFrIdx, Chain = DAG.getStore(Chain, RetAddrFrIdx, NewRetAddrFrIdx,
PseudoSourceValue::getFixedStack(), NewReturnAddrFI); PseudoSourceValue::getFixedStack(NewReturnAddrFI), 0);
return Chain; return Chain;
} }
@ -1652,7 +1650,7 @@ SDOperand X86TargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG) {
// Store relative to framepointer. // Store relative to framepointer.
MemOpChains2.push_back( MemOpChains2.push_back(
DAG.getStore(Chain, Arg, FIN, DAG.getStore(Chain, Arg, FIN,
PseudoSourceValue::getFixedStack(), FI)); PseudoSourceValue::getFixedStack(FI), 0));
} }
} }
} }
@ -4403,8 +4401,7 @@ SDOperand X86TargetLowering::LowerSINT_TO_FP(SDOperand Op, SelectionDAG &DAG) {
SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy());
SDOperand Chain = DAG.getStore(DAG.getEntryNode(), Op.getOperand(0), SDOperand Chain = DAG.getStore(DAG.getEntryNode(), Op.getOperand(0),
StackSlot, StackSlot,
PseudoSourceValue::getFixedStack(), PseudoSourceValue::getFixedStack(SSFI), 0);
SSFI);
// Build the FILD // Build the FILD
SDVTList Tys; SDVTList Tys;
@ -4439,7 +4436,7 @@ SDOperand X86TargetLowering::LowerSINT_TO_FP(SDOperand Op, SelectionDAG &DAG) {
Ops.push_back(InFlag); Ops.push_back(InFlag);
Chain = DAG.getNode(X86ISD::FST, Tys, &Ops[0], Ops.size()); Chain = DAG.getNode(X86ISD::FST, Tys, &Ops[0], Ops.size());
Result = DAG.getLoad(Op.getValueType(), Chain, StackSlot, Result = DAG.getLoad(Op.getValueType(), Chain, StackSlot,
PseudoSourceValue::getFixedStack(), SSFI); PseudoSourceValue::getFixedStack(SSFI), 0);
} }
return Result; return Result;
@ -4479,7 +4476,7 @@ FP_TO_SINTHelper(SDOperand Op, SelectionDAG &DAG) {
if (isScalarFPTypeInSSEReg(Op.getOperand(0).getValueType())) { if (isScalarFPTypeInSSEReg(Op.getOperand(0).getValueType())) {
assert(Op.getValueType() == MVT::i64 && "Invalid FP_TO_SINT to lower!"); assert(Op.getValueType() == MVT::i64 && "Invalid FP_TO_SINT to lower!");
Chain = DAG.getStore(Chain, Value, StackSlot, Chain = DAG.getStore(Chain, Value, StackSlot,
PseudoSourceValue::getFixedStack(), SSFI); PseudoSourceValue::getFixedStack(SSFI), 0);
SDVTList Tys = DAG.getVTList(Op.getOperand(0).getValueType(), MVT::Other); SDVTList Tys = DAG.getVTList(Op.getOperand(0).getValueType(), MVT::Other);
SDOperand Ops[] = { SDOperand Ops[] = {
Chain, StackSlot, DAG.getValueType(Op.getOperand(0).getValueType()) Chain, StackSlot, DAG.getValueType(Op.getOperand(0).getValueType())