-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AArch64][SME] Introduce CHECK_MATCHING_VL pseudo for streaming transitions #157510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
aae8b5b
ac52098
f3f31c9
3a2c02a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2940,6 +2940,52 @@ AArch64TargetLowering::EmitDynamicProbedAlloc(MachineInstr &MI, | |
return NextInst->getParent(); | ||
} | ||
|
||
MachineBasicBlock * | ||
AArch64TargetLowering::EmitCheckVL(MachineInstr &MI, | ||
MachineBasicBlock *MBB) const { | ||
MachineFunction *MF = MBB->getParent(); | ||
const TargetInstrInfo *TII = Subtarget->getInstrInfo(); | ||
const BasicBlock *LLVM_BB = MBB->getBasicBlock(); | ||
DebugLoc DL = MI.getDebugLoc(); | ||
MachineFunction::iterator It = ++MBB->getIterator(); | ||
|
||
|
||
const TargetRegisterClass *RC = &AArch64::GPR64RegClass; | ||
MachineRegisterInfo &MRI = MF->getRegInfo(); | ||
|
||
Register RegVL = MRI.createVirtualRegister(RC); | ||
Register RegSVL = MRI.createVirtualRegister(RC); | ||
Register RegCheck = MRI.createVirtualRegister(RC); | ||
|
||
BuildMI(*MBB, MI, DL, TII->get(AArch64::RDVLI_XI), RegVL).addImm(1); | ||
marykass-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
BuildMI(*MBB, MI, DL, TII->get(AArch64::RDSVLI_XI), RegSVL).addImm(1); | ||
|
||
marykass-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
BuildMI(*MBB, MI, DL, TII->get(AArch64::SUBXrr), RegCheck) | ||
|
||
.addReg(RegVL) | ||
.addReg(RegSVL); | ||
|
||
MachineBasicBlock *TrapBB = MF->CreateMachineBasicBlock(LLVM_BB); | ||
MachineBasicBlock *PassBB = MF->CreateMachineBasicBlock(LLVM_BB); | ||
MF->insert(It, TrapBB); | ||
MF->insert(It, PassBB); | ||
|
||
BuildMI(*MBB, MI, DL, TII->get(AArch64::CBZX)) | ||
.addReg(RegCheck) | ||
.addMBB(PassBB); | ||
|
||
// Transfer rest of current BB to PassBB | ||
PassBB->splice(PassBB->begin(), MBB, | ||
std::next(MachineBasicBlock::iterator(MI)), MBB->end()); | ||
PassBB->transferSuccessorsAndUpdatePHIs(MBB); | ||
|
||
BuildMI(TrapBB, DL, TII->get(AArch64::BRK)).addImm(1); | ||
|
||
MBB->addSuccessor(TrapBB); | ||
MBB->addSuccessor(PassBB); | ||
|
||
MI.eraseFromParent(); | ||
return PassBB; | ||
} | ||
|
||
MachineBasicBlock * | ||
AArch64TargetLowering::EmitTileLoad(unsigned Opc, unsigned BaseReg, | ||
MachineInstr &MI, | ||
|
@@ -3343,6 +3389,9 @@ MachineBasicBlock *AArch64TargetLowering::EmitInstrWithCustomInserter( | |
case AArch64::PROBED_STACKALLOC_DYN: | ||
return EmitDynamicProbedAlloc(MI, BB); | ||
|
||
case AArch64::CHECK_MATCHING_VL: | ||
return EmitCheckVL(MI, BB); | ||
|
||
case AArch64::LD1_MXIPXX_H_PSEUDO_B: | ||
return EmitTileLoad(AArch64::LD1_MXIPXX_H_B, AArch64::ZAB0, MI, BB); | ||
case AArch64::LD1_MXIPXX_H_PSEUDO_H: | ||
|
@@ -9116,7 +9165,8 @@ void AArch64TargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI, | |
SDValue AArch64TargetLowering::changeStreamingMode(SelectionDAG &DAG, SDLoc DL, | ||
bool Enable, SDValue Chain, | ||
SDValue InGlue, | ||
unsigned Condition) const { | ||
unsigned Condition, | ||
bool HasSVECC) const { | ||
MachineFunction &MF = DAG.getMachineFunction(); | ||
AArch64FunctionInfo *FuncInfo = MF.getInfo<AArch64FunctionInfo>(); | ||
FuncInfo->setHasStreamingModeChanges(true); | ||
|
@@ -9147,7 +9197,40 @@ SDValue AArch64TargetLowering::changeStreamingMode(SelectionDAG &DAG, SDLoc DL, | |
if (InGlue) | ||
Ops.push_back(InGlue); | ||
|
||
return DAG.getNode(Opcode, DL, DAG.getVTList(MVT::Other, MVT::Glue), Ops); | ||
if (!HasSVECC) | ||
marykass-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return DAG.getNode(Opcode, DL, DAG.getVTList(MVT::Other, MVT::Glue), Ops); | ||
|
||
auto GetCheckVL = [&](SDValue Chain, SDValue InGlue = SDValue()) -> SDValue { | ||
|
||
SmallVector<SDValue, 2> Ops = {Chain}; | ||
if (InGlue) | ||
Ops.push_back(InGlue); | ||
return SDValue(DAG.getMachineNode(AArch64::CHECK_MATCHING_VL, DL, | ||
DAG.getVTList(MVT::Other, MVT::Glue), | ||
Ops), | ||
0); | ||
marykass-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
}; | ||
|
||
// NS -> S | ||
marykass-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if (Enable) { | ||
SDValue CheckVL = GetCheckVL(Chain, InGlue); | ||
|
||
// Replace chain | ||
Ops[0] = CheckVL.getValue(0); | ||
marykass-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
// Replace/append glue | ||
if (InGlue) | ||
Ops.back() = CheckVL.getValue(1); | ||
else | ||
Ops.push_back(CheckVL.getValue(1)); | ||
|
||
return DAG.getNode(Opcode, DL, DAG.getVTList(MVT::Other, MVT::Glue), Ops); | ||
} | ||
|
||
// S -> NS | ||
marykass-arm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SDValue StreamingModeInstr = | ||
DAG.getNode(Opcode, DL, DAG.getVTList(MVT::Other, MVT::Glue), Ops); | ||
return GetCheckVL(StreamingModeInstr.getValue(0), | ||
StreamingModeInstr.getValue(1)); | ||
} | ||
|
||
// Emit a call to __arm_sme_save or __arm_sme_restore. | ||
|
@@ -9732,7 +9815,8 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI, | |
if (RequiresSMChange) { | ||
Chain = | ||
changeStreamingMode(DAG, DL, CallAttrs.callee().hasStreamingInterface(), | ||
Chain, InGlue, getSMToggleCondition(CallAttrs)); | ||
Chain, InGlue, getSMToggleCondition(CallAttrs), | ||
CallConv == CallingConv::AArch64_SVE_VectorCall); | ||
marykass-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
InGlue = Chain.getValue(1); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.