llvm.org GIT mirror llvm / a54cf17
Include a frame index in the "fixed stack" pseudo source value instead of using the frame index for the SVOffset, which was inconsistent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53486 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 11 years ago
6 changed file(s) with 60 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
3434 return V->getValueID() == PseudoSourceValueVal;
3535 }
3636
37 /// A pseudo source value referencing to the stack frame of a function,
37 /// A pseudo source value referencing a fixed stack frame entry,
3838 /// e.g., a spill slot.
39 static const PseudoSourceValue *getFixedStack();
39 static const PseudoSourceValue *getFixedStack(int FI);
4040
4141 /// A source value referencing the area below the stack frame of a function,
4242 /// e.g., the argument space.
1212
1313 #include "llvm/CodeGen/PseudoSourceValue.h"
1414 #include "llvm/DerivedTypes.h"
15 #include "llvm/Support/Compiler.h"
1516 #include "llvm/Support/ManagedStatic.h"
17 #include
1618
1719 namespace llvm {
18 static ManagedStatic5]> PSVs;
20 static ManagedStatic4]> PSVs;
1921
20 const PseudoSourceValue *PseudoSourceValue::getFixedStack()
22 const PseudoSourceValue *PseudoSourceValue::getStack()
2123 { return &(*PSVs)[0]; }
22 const PseudoSourceValue *PseudoSourceValue::getStack()
24 const PseudoSourceValue *PseudoSourceValue::getGOT()
2325 { return &(*PSVs)[1]; }
24 const PseudoSourceValue *PseudoSourceValue::getGOT()
26 const PseudoSourceValue *PseudoSourceValue::getJumpTable()
2527 { return &(*PSVs)[2]; }
2628 const PseudoSourceValue *PseudoSourceValue::getConstantPool()
2729 { return &(*PSVs)[3]; }
28 const PseudoSourceValue *PseudoSourceValue::getJumpTable()
29 { return &(*PSVs)[4]; }
3030
3131 static const char *const PSVNames[] = {
32 "FixedStack",
3332 "Stack",
3433 "GOT",
35 "ConstantPool",
3634 "JumpTable"
35 "ConstantPool"
3736 };
3837
3938 PseudoSourceValue::PseudoSourceValue() :
4241 void PseudoSourceValue::print(std::ostream &OS) const {
4342 OS << PSVNames[this - *PSVs];
4443 }
44
45 /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
46 /// for holding FixedStack values, which must include a frame
47 /// index.
48 class VISIBILITY_HIDDEN FixedStackPseudoSourceValue
49 : public PseudoSourceValue {
50 const int FI;
51 public:
52 explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {}
53 virtual void print(std::ostream &OS) const {
54 OS << "FixedStack" << FI;
55 }
56 };
57
58 static ManagedStatic > FSValues;
59
60 const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
61 const PseudoSourceValue *&V = (*FSValues)[FI];
62 if (!V)
63 V = new FixedStackPseudoSourceValue(FI);
64 return V;
65 }
4566 }
779779 MVT PtrVT = TLI.getPointerTy();
780780 SDOperand StackPtr = DAG.CreateStackTemporary(VT);
781781
782 FrameIndexSDNode *StackPtrFI = cast(StackPtr.Val);
783 int SPFI = StackPtrFI->getIndex();
782 int SPFI = cast(StackPtr.Val)->getIndex();
784783
785784 // Store the vector.
786785 SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Tmp1, StackPtr,
787 PseudoSourceValue::getFixedStack(),
788 SPFI);
786 PseudoSourceValue::getFixedStack(SPFI), 0);
789787
790788 // Truncate or zero extend offset to target pointer type.
791789 unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND;
796794 SDOperand StackPtr2 = DAG.getNode(ISD::ADD, IdxVT, Tmp3, StackPtr);
797795 // Store the scalar value.
798796 Ch = DAG.getTruncStore(Ch, Tmp2, StackPtr2,
799 PseudoSourceValue::getFixedStack(), SPFI, EltVT);
797 PseudoSourceValue::getFixedStack(SPFI), 0, EltVT);
800798 // Load the updated vector.
801 return DAG.getLoad(VT, Ch, StackPtr, PseudoSourceValue::getFixedStack(),SPFI);
799 return DAG.getLoad(VT, Ch, StackPtr,
800 PseudoSourceValue::getFixedStack(SPFI), 0);
802801 }
803802
804803 /// LegalizeOp - We know that the specified value has a legal type, and
49054904
49064905 if (SrcSize > SlotSize)
49074906 Store = DAG.getTruncStore(DAG.getEntryNode(), SrcOp, FIPtr,
4908 PseudoSourceValue::getFixedStack(), SPFI, SlotVT,
4909 false, SrcAlign);
4907 PseudoSourceValue::getFixedStack(SPFI), 0,
4908 SlotVT, false, SrcAlign);
49104909 else {
49114910 assert(SrcSize == SlotSize && "Invalid store");
49124911 Store = DAG.getStore(DAG.getEntryNode(), SrcOp, FIPtr,
4913 PseudoSourceValue::getFixedStack(), SPFI,
4912 PseudoSourceValue::getFixedStack(SPFI), 0,
49144913 false, SrcAlign);
49154914 }
49164915
49324931 int SPFI = StackPtrFI->getIndex();
49334932
49344933 SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0), StackPtr,
4935 PseudoSourceValue::getFixedStack(), SPFI);
4934 PseudoSourceValue::getFixedStack(SPFI), 0);
49364935 return DAG.getLoad(Node->getValueType(0), Ch, StackPtr,
4937 PseudoSourceValue::getFixedStack(), SPFI);
4936 PseudoSourceValue::getFixedStack(SPFI), 0);
49384937 }
49394938
49404939
70167015 // Lower to a store/load so that it can be split.
70177016 // FIXME: this could be improved probably.
70187017 SDOperand Ptr = DAG.CreateStackTemporary(InOp.getValueType());
7019 FrameIndexSDNode *FI = cast(Ptr.Val);
7018 int FI = cast(Ptr.Val)->getIndex();
70207019
70217020 SDOperand St = DAG.getStore(DAG.getEntryNode(),
70227021 InOp, Ptr,
7023 PseudoSourceValue::getFixedStack(),
7024 FI->getIndex());
7022 PseudoSourceValue::getFixedStack(FI), 0);
70257023 InOp = DAG.getLoad(Op.getValueType(), St, Ptr,
7026 PseudoSourceValue::getFixedStack(),
7027 FI->getIndex());
7024 PseudoSourceValue::getFixedStack(FI), 0);
70287025 }
70297026 // Split the vector and convert each of the pieces now.
70307027 SplitVectorOp(InOp, Lo, Hi);
43604360 const FrameIndexSDNode *FI =
43614361 dyn_cast(getBasePtr().Val);
43624362 if (!getSrcValue() && FI)
4363 return MachineMemOperand(PseudoSourceValue::getFixedStack(), Flags,
4364 FI->getIndex(), Size, getAlignment());
4363 return MachineMemOperand(PseudoSourceValue::getFixedStack(FI->getIndex()),
4364 Flags, 0, Size, getAlignment());
43654365 else
43664366 return MachineMemOperand(getSrcValue(), Flags, getSrcValueOffset(),
43674367 Size, getAlignment());
19421942 int FI = TailCallArgs[i].FrameIdx;
19431943 // Store relative to framepointer.
19441944 MemOpChains.push_back(DAG.getStore(Chain, Arg, FIN,
1945 PseudoSourceValue::getFixedStack(),
1946 FI));
1945 PseudoSourceValue::getFixedStack(FI),
1946 0));
19471947 }
19481948 }
19491949
19711971 MVT VT = isPPC64 ? MVT::i64 : MVT::i32;
19721972 SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT);
19731973 Chain = DAG.getStore(Chain, OldRetAddr, NewRetAddrFrIdx,
1974 PseudoSourceValue::getFixedStack(), NewRetAddr);
1974 PseudoSourceValue::getFixedStack(NewRetAddr), 0);
19751975 SDOperand NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT);
19761976 Chain = DAG.getStore(Chain, OldFP, NewFramePtrIdx,
1977 PseudoSourceValue::getFixedStack(), NewFPIdx);
1977 PseudoSourceValue::getFixedStack(NewFPIdx), 0);
19781978 }
19791979 return Chain;
19801980 }
30283028 Op.getOperand(0));
30293029
30303030 // STD the extended value into the stack slot.
3031 MachineMemOperand MO(PseudoSourceValue::getFixedStack(),
3032 MachineMemOperand::MOStore, FrameIdx, 8, 8);
3031 MachineMemOperand MO(PseudoSourceValue::getFixedStack(FrameIdx),
3032 MachineMemOperand::MOStore, 0, 8, 8);
30333033 SDOperand Store = DAG.getNode(PPCISD::STD_32, MVT::Other,
30343034 DAG.getEntryNode(), Ext64, FIdx,
30353035 DAG.getMemOperand(MO));
11331133 if (Flags.isByVal())
11341134 return FIN;
11351135 return DAG.getLoad(VA.getValVT(), Root, FIN,
1136 PseudoSourceValue::getFixedStack(), FI);
1136 PseudoSourceValue::getFixedStack(FI), 0);
11371137 }
11381138
11391139 SDOperand
13191319 SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::i64);
13201320 SDOperand Store =
13211321 DAG.getStore(Val.getValue(1), Val, FIN,
1322 PseudoSourceValue::getFixedStack(),
1323 RegSaveFrameIndex);
1322 PseudoSourceValue::getFixedStack(RegSaveFrameIndex), 0);
13241323 MemOps.push_back(Store);
13251324 FIN = DAG.getNode(ISD::ADD, getPointerTy(), FIN,
13261325 DAG.getIntPtrConstant(8));
13351334 SDOperand Val = DAG.getCopyFromReg(Root, VReg, MVT::v4f32);
13361335 SDOperand Store =
13371336 DAG.getStore(Val.getValue(1), Val, FIN,
1338 PseudoSourceValue::getFixedStack(),
1339 RegSaveFrameIndex);
1337 PseudoSourceValue::getFixedStack(RegSaveFrameIndex), 0);
13401338 MemOps.push_back(Store);
13411339 FIN = DAG.getNode(ISD::ADD, getPointerTy(), FIN,
13421340 DAG.getIntPtrConstant(16));
14341432 MVT VT = Is64Bit ? MVT::i64 : MVT::i32;
14351433 SDOperand NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT);
14361434 Chain = DAG.getStore(Chain, RetAddrFrIdx, NewRetAddrFrIdx,
1437 PseudoSourceValue::getFixedStack(), NewReturnAddrFI);
1435 PseudoSourceValue::getFixedStack(NewReturnAddrFI), 0);
14381436 return Chain;
14391437 }
14401438
16511649 // Store relative to framepointer.
16521650 MemOpChains2.push_back(
16531651 DAG.getStore(Chain, Arg, FIN,
1654 PseudoSourceValue::getFixedStack(), FI));
1652 PseudoSourceValue::getFixedStack(FI), 0));
16551653 }
16561654 }
16571655 }
44024400 SDOperand StackSlot = DAG.getFrameIndex(SSFI, getPointerTy());
44034401 SDOperand Chain = DAG.getStore(DAG.getEntryNode(), Op.getOperand(0),
44044402 StackSlot,
4405 PseudoSourceValue::getFixedStack(),
4406 SSFI);
4403 PseudoSourceValue::getFixedStack(SSFI), 0);
44074404
44084405 // Build the FILD
44094406 SDVTList Tys;
44384435 Ops.push_back(InFlag);
44394436 Chain = DAG.getNode(X86ISD::FST, Tys, &Ops[0], Ops.size());
44404437 Result = DAG.getLoad(Op.getValueType(), Chain, StackSlot,
4441 PseudoSourceValue::getFixedStack(), SSFI);
4438 PseudoSourceValue::getFixedStack(SSFI), 0);
44424439 }
44434440
44444441 return Result;
44784475 if (isScalarFPTypeInSSEReg(Op.getOperand(0).getValueType())) {
44794476 assert(Op.getValueType() == MVT::i64 && "Invalid FP_TO_SINT to lower!");
44804477 Chain = DAG.getStore(Chain, Value, StackSlot,
4481 PseudoSourceValue::getFixedStack(), SSFI);
4478 PseudoSourceValue::getFixedStack(SSFI), 0);
44824479 SDVTList Tys = DAG.getVTList(Op.getOperand(0).getValueType(), MVT::Other);
44834480 SDOperand Ops[] = {
44844481 Chain, StackSlot, DAG.getValueType(Op.getOperand(0).getValueType())