Skip to content

Commit e1e260c

Browse files
committed
[AArch64][SME] Disable GlobalISel/FastISel for SME functions.
This patch ensures that GlobalISel and FastISel fall back to regular DAG ISel when: * A function requires streaming-mode to be enabled at the start/end of the function. This happens when the function has no streaming interface, but does have a streaming body. * A function requires a lazy-save to be committed at the start of the function. This happens if the function has the `aarch64_pstate_za_new` attribute. * A call to a function requires a change in streaming-mode. * A call to a function requires a lazy-save buffer to be set up. Patch by @CarolineConcatto Reviewed By: david-arm Differential Revision: https://reviews.llvm.org/D136361
1 parent e9a2aa6 commit e1e260c

File tree

4 files changed

+381
-0
lines changed

4 files changed

+381
-0
lines changed

llvm/lib/Target/AArch64/AArch64FastISel.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5032,6 +5032,8 @@ bool AArch64FastISel::selectAtomicCmpXchg(const AtomicCmpXchgInst *I) {
50325032
}
50335033

50345034
bool AArch64FastISel::fastSelectInstruction(const Instruction *I) {
5035+
if (TLI.fallBackToDAGISel(*I))
5036+
return false;
50355037
switch (I->getOpcode()) {
50365038
default:
50375039
break;
@@ -5114,5 +5116,10 @@ bool AArch64FastISel::fastSelectInstruction(const Instruction *I) {
51145116

51155117
FastISel *AArch64::createFastISel(FunctionLoweringInfo &FuncInfo,
51165118
const TargetLibraryInfo *LibInfo) {
5119+
5120+
SMEAttrs CallerAttrs(*FuncInfo.Fn);
5121+
if (CallerAttrs.hasZAState() ||
5122+
(!CallerAttrs.hasStreamingInterface() && CallerAttrs.hasStreamingBody()))
5123+
return nullptr;
51175124
return new AArch64FastISel(FuncInfo, LibInfo);
51185125
}

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22054,6 +22054,15 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
2205422054
return true;
2205522055
}
2205622056

22057+
// Checks to allow the use of SME instructions
22058+
if (auto *Base = dyn_cast<CallBase>(&Inst)) {
22059+
auto CallerAttrs = SMEAttrs(*Inst.getFunction());
22060+
auto CalleeAttrs = SMEAttrs(*Base);
22061+
if (CallerAttrs.requiresSMChange(CalleeAttrs,
22062+
/*BodyOverridesInterface=*/false) ||
22063+
CallerAttrs.requiresLazySave(CalleeAttrs))
22064+
return true;
22065+
}
2205722066
return false;
2205822067
}
2205922068

llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ bool AArch64CallLowering::fallBackToDAGISel(const MachineFunction &MF) const {
537537
LLVM_DEBUG(dbgs() << "Falling back to SDAG because we don't support no-NEON\n");
538538
return true;
539539
}
540+
541+
SMEAttrs Attrs(F);
542+
if (Attrs.hasNewZAInterface() ||
543+
(!Attrs.hasStreamingInterface() && Attrs.hasStreamingBody()))
544+
return true;
545+
540546
return false;
541547
}
542548

0 commit comments

Comments
 (0)