forked from OSchip/llvm-project
[CodeGen] Refactor CreateStackTemporary
I've created a new variant of CreateStackTemporary that takes TypeSize and Align arguments, and made the older instances of CreateStackTemporary call this new function. This refactoring is in preparation for more patches in this area related to scalable vectors and improving the alignment calculations. Differential Revision: https://reviews.llvm.org/D79933
This commit is contained in:
parent
4042ada1c1
commit
8ce4a8f6df
|
@ -1595,6 +1595,9 @@ public:
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
|
/// Create a stack temporary based on the size in bytes and the alignment
|
||||||
|
SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment);
|
||||||
|
|
||||||
/// Create a stack temporary, suitable for holding the specified value type.
|
/// Create a stack temporary, suitable for holding the specified value type.
|
||||||
/// If minAlign is specified, the slot size will have at least that alignment.
|
/// If minAlign is specified, the slot size will have at least that alignment.
|
||||||
SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
|
SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
|
||||||
|
|
|
@ -1995,28 +1995,26 @@ SDValue SelectionDAG::expandVACopy(SDNode *Node) {
|
||||||
MachinePointerInfo(VD));
|
MachinePointerInfo(VD));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue SelectionDAG::CreateStackTemporary(EVT VT, unsigned minAlign) {
|
SDValue SelectionDAG::CreateStackTemporary(TypeSize Bytes, Align Alignment) {
|
||||||
MachineFrameInfo &MFI = getMachineFunction().getFrameInfo();
|
MachineFrameInfo &MFI = MF->getFrameInfo();
|
||||||
unsigned ByteSize = VT.getStoreSize();
|
int FrameIdx = MFI.CreateStackObject(Bytes, Alignment, false);
|
||||||
Type *Ty = VT.getTypeForEVT(*getContext());
|
|
||||||
unsigned StackAlign =
|
|
||||||
std::max((unsigned)getDataLayout().getPrefTypeAlignment(Ty), minAlign);
|
|
||||||
|
|
||||||
int FrameIdx = MFI.CreateStackObject(ByteSize, StackAlign, false);
|
|
||||||
return getFrameIndex(FrameIdx, TLI->getFrameIndexTy(getDataLayout()));
|
return getFrameIndex(FrameIdx, TLI->getFrameIndexTy(getDataLayout()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDValue SelectionDAG::CreateStackTemporary(EVT VT, unsigned minAlign) {
|
||||||
|
Type *Ty = VT.getTypeForEVT(*getContext());
|
||||||
|
Align StackAlign =
|
||||||
|
std::max(getDataLayout().getPrefTypeAlign(Ty), Align(minAlign));
|
||||||
|
return CreateStackTemporary(VT.getStoreSize(), StackAlign);
|
||||||
|
}
|
||||||
|
|
||||||
SDValue SelectionDAG::CreateStackTemporary(EVT VT1, EVT VT2) {
|
SDValue SelectionDAG::CreateStackTemporary(EVT VT1, EVT VT2) {
|
||||||
unsigned Bytes = std::max(VT1.getStoreSize(), VT2.getStoreSize());
|
TypeSize Bytes = std::max(VT1.getStoreSize(), VT2.getStoreSize());
|
||||||
Type *Ty1 = VT1.getTypeForEVT(*getContext());
|
Type *Ty1 = VT1.getTypeForEVT(*getContext());
|
||||||
Type *Ty2 = VT2.getTypeForEVT(*getContext());
|
Type *Ty2 = VT2.getTypeForEVT(*getContext());
|
||||||
const DataLayout &DL = getDataLayout();
|
const DataLayout &DL = getDataLayout();
|
||||||
unsigned Align =
|
Align Align = std::max(DL.getPrefTypeAlign(Ty1), DL.getPrefTypeAlign(Ty2));
|
||||||
std::max(DL.getPrefTypeAlignment(Ty1), DL.getPrefTypeAlignment(Ty2));
|
return CreateStackTemporary(Bytes, Align);
|
||||||
|
|
||||||
MachineFrameInfo &MFI = getMachineFunction().getFrameInfo();
|
|
||||||
int FrameIdx = MFI.CreateStackObject(Bytes, Align, false);
|
|
||||||
return getFrameIndex(FrameIdx, TLI->getFrameIndexTy(getDataLayout()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue SelectionDAG::FoldSetCC(EVT VT, SDValue N1, SDValue N2,
|
SDValue SelectionDAG::FoldSetCC(EVT VT, SDValue N1, SDValue N2,
|
||||||
|
|
Loading…
Reference in New Issue