[AArch64][SME] Set up a lazy-save/restore around calls.
authorKerry McLaughlin <kerry.mclaughlin@arm.com>
Wed, 5 Oct 2022 13:01:24 +0000 (14:01 +0100)
committerKerry McLaughlin <kerry.mclaughlin@arm.com>
Wed, 5 Oct 2022 13:36:53 +0000 (14:36 +0100)
commitf7f44f018f6ffbd11cd3bd2ffafbdb15725aac86
tree73b8423efc64fd94b800c2167c98dad05a0dabe0
parent93e51fa444cc87caca00122817c64e1fcc366eeb
[AArch64][SME] Set up a lazy-save/restore around calls.

Setting up a lazy-save mechanism around calls is done during SelectionDAG
because calls to intrinsics may be expanded into an actual function call
(e.g. calls to @llvm.cos()), and maintaining an allowed-list in the SMEABI
pass is not feasible.

The approach for conditionally restoring the lazy-save based on the runtime
value of TPIDR2_EL0 is similar to how we handle conditional smstart/smstop.
We create a pseudo-node which gets expanded into a conditional branch and
expands to a call to __arm_tpidr2_restore(%tpidr2_object_ptr).

The lazy-save buffer and TPIDR2 block are only allocated once at the start
of the function. For each call, the TPIDR2 block is initialised, and at
the end of the call, a pseudo node (RestoreZA) is planted.

Patch by Sander de Smalen.

Differential Revision: https://reviews.llvm.org/D133900
llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
llvm/lib/Target/AArch64/AArch64RegisterInfo.h
llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
llvm/test/CodeGen/AArch64/sme-lazy-save-call.ll [new file with mode: 0644]
llvm/test/CodeGen/AArch64/sme-shared-za-interface.ll