forked from OSchip/llvm-project
[Statepoint] Factor-out utility function to get non-foldable area of STATEPOINT like instructions. NFC
Reviewers: reames, dantrushin Reviewed By: reames Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D99875
This commit is contained in:
parent
872c57c90a
commit
0057ec8034
|
@ -1064,6 +1064,16 @@ public:
|
|||
/// has the potential of causing nasty silent breakage in out-of-tree targets.
|
||||
virtual bool isSubregFoldable() const { return false; }
|
||||
|
||||
/// For a patchpoint, stackmap, or statepoint intrinsic, return the range of
|
||||
/// operands which can't be folded into stack references. Operands outside
|
||||
/// of the range are most likely foldable but it is not guaranteed.
|
||||
/// These instructions are unique in that stack references for some operands
|
||||
/// have the same execution cost (e.g. none) as the unfolded register forms.
|
||||
/// The ranged return is guaranteed to include all operands which can't be
|
||||
/// folded at zero cost.
|
||||
virtual std::pair<unsigned, unsigned>
|
||||
getPatchpointUnfoldableRange(const MachineInstr &MI) const;
|
||||
|
||||
/// Attempt to fold a load or store of the specified stack
|
||||
/// slot into the specified machine instruction for the specified operand(s).
|
||||
/// If this is possible, a new instruction is returned with the specified
|
||||
|
|
|
@ -474,32 +474,31 @@ static const TargetRegisterClass *canFoldCopy(const MachineInstr &MI,
|
|||
|
||||
MCInst TargetInstrInfo::getNop() const { llvm_unreachable("Not implemented"); }
|
||||
|
||||
std::pair<unsigned, unsigned>
|
||||
TargetInstrInfo::getPatchpointUnfoldableRange(const MachineInstr &MI) const {
|
||||
switch (MI.getOpcode()) {
|
||||
case TargetOpcode::STACKMAP:
|
||||
// StackMapLiveValues are foldable
|
||||
return std::make_pair(0, StackMapOpers(&MI).getVarIdx());
|
||||
case TargetOpcode::PATCHPOINT:
|
||||
// For PatchPoint, the call args are not foldable (even if reported in the
|
||||
// stackmap e.g. via anyregcc).
|
||||
return std::make_pair(0, PatchPointOpers(&MI).getVarIdx());
|
||||
case TargetOpcode::STATEPOINT:
|
||||
// For statepoints, fold deopt and gc arguments, but not call arguments.
|
||||
return std::make_pair(MI.getNumDefs(), StatepointOpers(&MI).getVarIdx());
|
||||
default:
|
||||
llvm_unreachable("unexpected stackmap opcode");
|
||||
}
|
||||
}
|
||||
|
||||
static MachineInstr *foldPatchpoint(MachineFunction &MF, MachineInstr &MI,
|
||||
ArrayRef<unsigned> Ops, int FrameIndex,
|
||||
const TargetInstrInfo &TII) {
|
||||
unsigned StartIdx = 0;
|
||||
unsigned NumDefs = 0;
|
||||
switch (MI.getOpcode()) {
|
||||
case TargetOpcode::STACKMAP: {
|
||||
// StackMapLiveValues are foldable
|
||||
StartIdx = StackMapOpers(&MI).getVarIdx();
|
||||
break;
|
||||
}
|
||||
case TargetOpcode::PATCHPOINT: {
|
||||
// For PatchPoint, the call args are not foldable (even if reported in the
|
||||
// stackmap e.g. via anyregcc).
|
||||
StartIdx = PatchPointOpers(&MI).getVarIdx();
|
||||
break;
|
||||
}
|
||||
case TargetOpcode::STATEPOINT: {
|
||||
// For statepoints, fold deopt and gc arguments, but not call arguments.
|
||||
StartIdx = StatepointOpers(&MI).getVarIdx();
|
||||
NumDefs = MI.getNumDefs();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
llvm_unreachable("unexpected stackmap opcode");
|
||||
}
|
||||
// getPatchpointUnfoldableRange throws guarantee if MI is not a patchpoint.
|
||||
std::tie(NumDefs, StartIdx) = TII.getPatchpointUnfoldableRange(MI);
|
||||
|
||||
unsigned DefToFoldIdx = MI.getNumOperands();
|
||||
|
||||
|
|
Loading…
Reference in New Issue