Skip to content

Commit

Permalink
[AArch64][SME] Disable GlobalISel/FastISel for SME functions.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sdesmalen-arm committed Nov 9, 2022
1 parent e9a2aa6 commit e1e260c
Show file tree
Hide file tree
Showing 4 changed files with 381 additions and 0 deletions.
7 changes: 7 additions & 0 deletions llvm/lib/Target/AArch64/AArch64FastISel.cpp
Expand Up @@ -5032,6 +5032,8 @@ bool AArch64FastISel::selectAtomicCmpXchg(const AtomicCmpXchgInst *I) {
}

bool AArch64FastISel::fastSelectInstruction(const Instruction *I) {
if (TLI.fallBackToDAGISel(*I))
return false;
switch (I->getOpcode()) {
default:
break;
Expand Down Expand Up @@ -5114,5 +5116,10 @@ bool AArch64FastISel::fastSelectInstruction(const Instruction *I) {

FastISel *AArch64::createFastISel(FunctionLoweringInfo &FuncInfo,
const TargetLibraryInfo *LibInfo) {

SMEAttrs CallerAttrs(*FuncInfo.Fn);
if (CallerAttrs.hasZAState() ||
(!CallerAttrs.hasStreamingInterface() && CallerAttrs.hasStreamingBody()))
return nullptr;
return new AArch64FastISel(FuncInfo, LibInfo);
}
9 changes: 9 additions & 0 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Expand Up @@ -22054,6 +22054,15 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
return true;
}

// Checks to allow the use of SME instructions
if (auto *Base = dyn_cast<CallBase>(&Inst)) {
auto CallerAttrs = SMEAttrs(*Inst.getFunction());
auto CalleeAttrs = SMEAttrs(*Base);
if (CallerAttrs.requiresSMChange(CalleeAttrs,
/*BodyOverridesInterface=*/false) ||
CallerAttrs.requiresLazySave(CalleeAttrs))
return true;
}
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
Expand Up @@ -537,6 +537,12 @@ bool AArch64CallLowering::fallBackToDAGISel(const MachineFunction &MF) const {
LLVM_DEBUG(dbgs() << "Falling back to SDAG because we don't support no-NEON\n");
return true;
}

SMEAttrs Attrs(F);
if (Attrs.hasNewZAInterface() ||
(!Attrs.hasStreamingInterface() && Attrs.hasStreamingBody()))
return true;

return false;
}

Expand Down

0 comments on commit e1e260c

Please sign in to comment.