72#define DEBUG_TYPE "aarch64-machine-sme-abi"
131 ZAState NeededState{ZAState::ANY};
133 LiveRegs PhysLiveRegs = LiveRegs::None;
140 ZAState FixedEntryState{ZAState::ANY};
141 ZAState DesiredIncomingState{ZAState::ANY};
142 ZAState DesiredOutgoingState{ZAState::ANY};
143 LiveRegs PhysLiveRegsAtEntry = LiveRegs::None;
144 LiveRegs PhysLiveRegsAtExit = LiveRegs::None;
150 std::optional<MachineBasicBlock::iterator> AfterSMEProloguePt;
151 LiveRegs PhysLiveRegsAfterSMEPrologue = LiveRegs::None;
158 EmitContext() =
default;
163 return *TPIDR2BlockFI;
166 return *TPIDR2BlockFI;
171 if (AgnosticZABufferPtr.isValid())
172 return AgnosticZABufferPtr;
175 AgnosticZABufferPtr =
179 return AgnosticZABufferPtr;
192 bool needsSaveBuffer()
const {
193 assert(!(TPIDR2BlockFI && AgnosticZABufferPtr) &&
194 "Cannot have both a TPIDR2 block and agnostic ZA buffer");
195 return TPIDR2BlockFI || AgnosticZABufferPtr.isValid();
199 std::optional<int> ZT0SaveFI;
200 std::optional<int> TPIDR2BlockFI;
204StringRef getZAStateString(ZAState State) {
205#define MAKE_CASE(V) \
227 return AArch64::MPR128RegClass.contains(SR) ||
228 AArch64::ZTRRegClass.contains(SR);
234static std::pair<ZAState, MachineBasicBlock::iterator>
244 if (
MI.getOpcode() == AArch64::InOutZAUsePseudo)
245 return {ZAState::ACTIVE, std::prev(InsertPt)};
248 if (
MI.getOpcode() == AArch64::RequiresZASavePseudo)
249 return {ZAState::LOCAL_SAVED, std::prev(InsertPt)};
258 if (
MI.getOpcode() == AArch64::RequiresZT0SavePseudo) {
259 return {SMEFnAttrs.
hasZAState() ? ZAState::ACTIVE_ZT0_SAVED
260 : ZAState::LOCAL_COMMITTED,
261 std::prev(InsertPt)};
266 return {ZAOffAtReturn ? ZAState::OFF : ZAState::ACTIVE, InsertPt};
269 for (
auto &MO :
MI.operands()) {
270 if (isZAorZTRegOp(
TRI, MO))
271 return {ZAState::ACTIVE, InsertPt};
274 return {ZAState::ANY, InsertPt};
278 inline static char ID = 0;
284 StringRef getPassName()
const override {
return "Machine SME ABI pass"; }
298 FunctionInfo collectNeededZAStates(
SMEAttrs SMEFnAttrs);
303 const FunctionInfo &FnInfo);
307 void insertStateChanges(EmitContext &,
const FunctionInfo &FnInfo,
328 bool ClearTPIDR2,
bool On);
339 LiveRegs PhysLiveRegs,
bool IsSave);
347 std::pair<MachineBasicBlock::iterator, LiveRegs>
357 if (AFI->getSMEFnAttrs().hasAgnosticZAInterface())
358 return emitFullZASaveRestore(Context,
MBB,
MBBI, PhysLiveRegs,
360 return emitSetupLazySave(Context,
MBB,
MBBI);
364 if (AFI->getSMEFnAttrs().hasAgnosticZAInterface())
365 return emitFullZASaveRestore(Context,
MBB,
MBBI, PhysLiveRegs,
367 return emitRestoreLazySave(Context,
MBB,
MBBI, PhysLiveRegs);
372 if (AFI->getSMEFnAttrs().hasAgnosticZAInterface())
373 return emitAllocateFullZASaveBuffer(Context,
MBB,
MBBI, PhysLiveRegs);
374 return emitAllocateLazySaveBuffer(Context,
MBB,
MBBI);
383 unsigned Marker)
const;
390 void emitError(
const Twine &Message) {
415 LiveRegs PhysLiveRegs = LiveRegs::None;
417 PhysLiveRegs |= LiveRegs::NZCV;
421 PhysLiveRegs |= LiveRegs::W0;
422 if (!LiveUnits.
available(AArch64::W0_HI))
423 PhysLiveRegs |= LiveRegs::W0_HI;
428 if (PhysLiveRegs & LiveRegs::NZCV)
429 LiveUnits.
addReg(AArch64::NZCV);
430 if (PhysLiveRegs & LiveRegs::W0)
431 LiveUnits.
addReg(AArch64::W0);
432 if (PhysLiveRegs & LiveRegs::W0_HI)
433 LiveUnits.
addReg(AArch64::W0_HI);
436[[maybe_unused]]
bool isCallStartOpcode(
unsigned Opc) {
440 case AArch64::TLSDESC_CALLSEQ:
441 case AArch64::TLSDESC_AUTH_CALLSEQ:
442 case AArch64::ADJCALLSTACKDOWN:
449FunctionInfo MachineSMEABI::collectNeededZAStates(
SMEAttrs SMEFnAttrs) {
452 "Expected function to have ZA/ZT0 state!");
455 LiveRegs PhysLiveRegsAfterSMEPrologue = LiveRegs::None;
456 std::optional<MachineBasicBlock::iterator> AfterSMEProloguePt;
459 BlockInfo &
Block = Blocks[
MBB.getNumber()];
461 if (
MBB.isEntryBlock()) {
463 Block.FixedEntryState = ZAState::ENTRY;
464 }
else if (
MBB.isEHPad()) {
466 Block.FixedEntryState = ZAState::LOCAL_COMMITTED;
472 Block.PhysLiveRegsAtExit = getPhysLiveRegs(LiveUnits);
473 auto FirstTerminatorInsertPt =
MBB.getFirstTerminator();
474 auto FirstNonPhiInsertPt =
MBB.getFirstNonPHI();
476 if (
MI.isDebugInstr())
481 LiveRegs PhysLiveRegs = getPhysLiveRegs(LiveUnits);
486 if (
MI.getOpcode() == AArch64::SMEStateAllocPseudo) {
487 AfterSMEProloguePt =
MBBI;
488 PhysLiveRegsAfterSMEPrologue = PhysLiveRegs;
491 auto [NeededState, InsertPt] = getInstNeededZAState(*
TRI,
MI, SMEFnAttrs);
492 assert((InsertPt ==
MBBI || isCallStartOpcode(InsertPt->getOpcode())) &&
493 "Unexpected state change insertion point!");
494 if (
MBBI == FirstTerminatorInsertPt)
495 Block.PhysLiveRegsAtExit = PhysLiveRegs;
496 if (
MBBI == FirstNonPhiInsertPt)
497 Block.PhysLiveRegsAtEntry = PhysLiveRegs;
498 if (NeededState != ZAState::ANY)
499 Block.Insts.push_back({NeededState, InsertPt, PhysLiveRegs});
503 std::reverse(
Block.Insts.begin(),
Block.Insts.end());
507 if (!
Block.Insts.empty()) {
508 Block.DesiredIncomingState =
Block.Insts.front().NeededState;
509 Block.DesiredOutgoingState =
Block.Insts.back().NeededState;
513 return FunctionInfo{std::move(Blocks), AfterSMEProloguePt,
514 PhysLiveRegsAfterSMEPrologue};
520MachineSMEABI::assignBundleZAStates(
const EdgeBundles &Bundles,
521 const FunctionInfo &FnInfo) {
524 std::optional<ZAState> BundleState;
525 for (
unsigned BlockID : Bundles.
getBlocks(
I)) {
526 const BlockInfo &
Block = FnInfo.Blocks[BlockID];
530 if (
Block.FixedEntryState != ZAState::ANY ||
538 BundleState =
Block.DesiredIncomingState;
539 else if (BundleState !=
Block.DesiredIncomingState)
540 BundleState = ZAState::ACTIVE;
543 if (!BundleState || BundleState == ZAState::ANY)
544 BundleState = ZAState::ACTIVE;
546 BundleStates[
I] = *BundleState;
552std::pair<MachineBasicBlock::iterator, LiveRegs>
553MachineSMEABI::findStateChangeInsertionPoint(
558 if (Inst !=
Block.Insts.end()) {
559 InsertPt = Inst->InsertPt;
560 PhysLiveRegs = Inst->PhysLiveRegs;
562 InsertPt =
MBB.getFirstTerminator();
563 PhysLiveRegs =
Block.PhysLiveRegsAtExit;
566 if (PhysLiveRegs == LiveRegs::None)
567 return {InsertPt, PhysLiveRegs};
571 if (Inst ==
Block.Insts.begin()) {
572 PrevStateChangeI =
MBB.begin();
578 PrevStateChangeI = std::prev(Inst)->InsertPt;
583 setPhysLiveRegs(LiveUnits, PhysLiveRegs);
584 auto BestCandidate = std::make_pair(InsertPt, PhysLiveRegs);
586 if (
I->isDebugInstr())
590 if (
I->getOpcode() ==
TII->getCallFrameDestroyOpcode() ||
I->isCall())
593 LiveRegs CurrentPhysLiveRegs = getPhysLiveRegs(LiveUnits);
596 if (!(CurrentPhysLiveRegs & LiveRegs::NZCV))
597 BestCandidate = {
I, CurrentPhysLiveRegs};
598 if (CurrentPhysLiveRegs == LiveRegs::None)
601 return BestCandidate;
604void MachineSMEABI::insertStateChanges(EmitContext &Context,
605 const FunctionInfo &FnInfo,
609 const BlockInfo &
Block = FnInfo.Blocks[
MBB.getNumber()];
610 ZAState InState = BundleStates[Bundles.
getBundle(
MBB.getNumber(),
613 ZAState CurrentState =
Block.FixedEntryState;
614 if (CurrentState == ZAState::ANY)
615 CurrentState = InState;
617 for (
auto &Inst :
Block.Insts) {
618 if (CurrentState != Inst.NeededState) {
619 auto [InsertPt, PhysLiveRegs] =
620 findStateChangeInsertionPoint(
MBB,
Block, &Inst);
621 emitStateChange(Context,
MBB, InsertPt, CurrentState, Inst.NeededState,
623 CurrentState = Inst.NeededState;
627 if (
MBB.succ_empty())
632 if (CurrentState != OutState) {
633 auto [InsertPt, PhysLiveRegs] =
634 findStateChangeInsertionPoint(
MBB,
Block,
Block.Insts.end());
635 emitStateChange(Context,
MBB, InsertPt, CurrentState, OutState,
645 return MBBI !=
MBB.end() ?
MBBI->getDebugLoc() :
MBB.back().getDebugLoc();
655 unsigned Marker,
unsigned CallDestroyOpcode) {
656 auto IsMarker = [&](
auto &
MI) {
return MI.getOpcode() == Marker; };
657 auto MarkerInst = std::find_if(
MBBI,
MBB.end(), IsMarker);
658 if (MarkerInst ==
MBB.end())
661 while (++
I !=
MBB.end()) {
662 if (
I->isCall() ||
I->getOpcode() == CallDestroyOpcode)
665 if (
I !=
MBB.end() &&
I->isCall())
671void MachineSMEABI::collectReachableMarkedCalls(
675 assert(Marker == AArch64::InOutZAUsePseudo ||
676 Marker == AArch64::RequiresZASavePseudo ||
677 Marker == AArch64::RequiresZT0SavePseudo);
678 unsigned CallDestroyOpcode =
TII->getCallFrameDestroyOpcode();
679 if (findMarkedCall(StartMBB, StartInst, Calls, Marker, CallDestroyOpcode))
685 while (!Worklist.
empty()) {
691 if (!findMarkedCall(*
MBB,
MBB->begin(), Calls, Marker, CallDestroyOpcode))
715 StringRef StateName = Marker == AArch64::RequiresZT0SavePseudo ?
"ZT0" :
"ZA";
717 return SaveRemark(
DL,
MBB) << SaveName <<
" of " << StateName
718 <<
" emitted in '" << MF->
getName() <<
"'";
723 collectReachableMarkedCalls(
MBB,
MBBI, CallsRequiringSaves, Marker);
728 R <<
" to '" << CalleeName <<
"'";
729 R <<
" requires " << StateName <<
" save";
734void MachineSMEABI::emitSetupLazySave(EmitContext &Context,
739 emitCallSaveRemarks(
MBB,
MBBI,
DL, AArch64::RequiresZASavePseudo,
740 "SMELazySaveZA",
"lazy save");
743 Register TPIDR2 =
MRI->createVirtualRegister(&AArch64::GPR64spRegClass);
744 Register TPIDR2Ptr =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
753 .
addImm(AArch64SysReg::TPIDR2_EL0)
757PhysRegSave MachineSMEABI::createPhysRegSave(
LiveRegs PhysLiveRegs,
761 PhysRegSave RegSave{PhysLiveRegs};
762 if (PhysLiveRegs & LiveRegs::NZCV) {
763 RegSave.StatusFlags =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
765 .
addImm(AArch64SysReg::NZCV)
771 if (PhysLiveRegs & LiveRegs::W0) {
772 RegSave.X0Save =
MRI->createVirtualRegister(PhysLiveRegs & LiveRegs::W0_HI
773 ? &AArch64::GPR64RegClass
774 : &AArch64::GPR32RegClass);
776 .
addReg(PhysLiveRegs & LiveRegs::W0_HI ? AArch64::X0 : AArch64::W0);
781void MachineSMEABI::restorePhyRegSave(
const PhysRegSave &RegSave,
785 if (RegSave.StatusFlags.
isValid())
787 .
addImm(AArch64SysReg::NZCV)
788 .
addReg(RegSave.StatusFlags)
793 RegSave.PhysLiveRegs & LiveRegs::W0_HI ? AArch64::X0 : AArch64::W0)
800 if (LCImpl == RTLIB::Unsupported)
801 emitError(
"cannot lower SME ABI (SME routines unsupported)");
804 if (
CC != ExpectedCC)
805 emitError(
"invalid calling convention for SME routine: '" + ImplName +
"'");
811void MachineSMEABI::emitRestoreLazySave(EmitContext &Context,
816 Register TPIDR2EL0 =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
820 PhysRegSave RegSave = createPhysRegSave(PhysLiveRegs,
MBB,
MBBI,
DL);
824 .
addImm(AArch64SVCR::SVCRZA)
828 .
addImm(AArch64SysReg::TPIDR2_EL0)
840 RestoreZA, RTLIB::SMEABI_TPIDR2_RESTORE,
844 .
addImm(AArch64SysReg::TPIDR2_EL0)
847 restorePhyRegSave(RegSave,
MBB,
MBBI,
DL);
852 bool ClearTPIDR2,
bool On) {
857 .
addImm(AArch64SysReg::TPIDR2_EL0)
862 .
addImm(AArch64SVCR::SVCRZA)
866void MachineSMEABI::emitAllocateLazySaveBuffer(
871 Register SP =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
872 Register SVL =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
887 "Lazy ZA save is not yet supported on Windows or UEFI");
888 Buffer =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
909 "TPIDR2 block initialization is not supported on big-endian targets");
931 Register TPIDR2EL0 =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
934 .
addImm(AArch64SysReg::TPIDR2_EL0)
944 CommitZASave, RTLIB::SMEABI_TPIDR2_SAVE,
952 .
addImm(AArch64SVCR::SVCRZA)
964void MachineSMEABI::emitFullZASaveRestore(EmitContext &Context,
967 LiveRegs PhysLiveRegs,
bool IsSave) {
971 emitCallSaveRemarks(
MBB,
MBBI,
DL, AArch64::RequiresZASavePseudo,
972 "SMEFullZASave",
"full save");
974 PhysRegSave RegSave = createPhysRegSave(PhysLiveRegs,
MBB,
MBBI,
DL);
979 .
addReg(Context.getAgnosticZABufferPtr(*MF));
986 IsSave ? RTLIB::SMEABI_SME_SAVE : RTLIB::SMEABI_SME_RESTORE,
989 restorePhyRegSave(RegSave,
MBB,
MBBI,
DL);
992void MachineSMEABI::emitZT0SaveRestore(EmitContext &Context,
1002 emitCallSaveRemarks(
MBB,
MBBI,
DL, AArch64::RequiresZT0SavePseudo,
1003 "SMEZT0Save",
"spill");
1005 Register ZT0Save =
MRI->createVirtualRegister(&AArch64::GPR64spRegClass);
1022void MachineSMEABI::emitAllocateFullZASaveBuffer(
1030 Register BufferPtr = Context.getAgnosticZABufferPtr(*MF);
1031 Register BufferSize =
MRI->createVirtualRegister(&AArch64::GPR64RegClass);
1033 PhysRegSave RegSave = createPhysRegSave(PhysLiveRegs,
MBB,
MBBI,
DL);
1040 SMEStateSize, RTLIB::SMEABI_SME_STATE_SIZE,
1060 restorePhyRegSave(RegSave,
MBB,
MBBI,
DL);
1066 constexpr uint8_t to(ZAState To)
const {
1067 static_assert(NUM_ZA_STATE < 16,
"expected ZAState to fit in 4-bits");
1072constexpr FromState transitionFrom(ZAState From) {
return FromState{From}; }
1074void MachineSMEABI::emitStateChange(EmitContext &Context,
1077 ZAState From, ZAState To,
1080 if (From == ZAState::ANY || To == ZAState::ANY)
1085 if (From == ZAState::ENTRY && To == ZAState::OFF)
1090 if (From == ZAState::ENTRY) {
1092 "ENTRY state only valid in entry block");
1093 emitSMEPrologue(
MBB,
MBB.getFirstNonPHI());
1094 if (To == ZAState::ACTIVE)
1100 From = ZAState::ACTIVE;
1106 bool HasZAState = IsAgnosticZA || SMEFnAttrs.
hasZAState();
1108 switch (transitionFrom(From).to(To)) {
1110 case transitionFrom(ZAState::ACTIVE).to(ZAState::ACTIVE_ZT0_SAVED):
1111 emitZT0SaveRestore(Context,
MBB, InsertPt,
true);
1113 case transitionFrom(ZAState::ACTIVE_ZT0_SAVED).to(ZAState::ACTIVE):
1114 emitZT0SaveRestore(Context,
MBB, InsertPt,
false);
1118 case transitionFrom(ZAState::ACTIVE).to(ZAState::LOCAL_SAVED):
1119 case transitionFrom(ZAState::ACTIVE_ZT0_SAVED).to(ZAState::LOCAL_SAVED):
1120 if (HasZT0State && From == ZAState::ACTIVE)
1121 emitZT0SaveRestore(Context,
MBB, InsertPt,
true);
1123 emitZASave(Context,
MBB, InsertPt, PhysLiveRegs);
1127 case transitionFrom(ZAState::ACTIVE).to(ZAState::LOCAL_COMMITTED):
1130 assert(HasZT0State && !HasZAState &&
"Expect to only have ZT0 state.");
1131 emitZT0SaveRestore(Context,
MBB, InsertPt,
true);
1132 emitZAMode(
MBB, InsertPt,
false,
false);
1136 case transitionFrom(ZAState::LOCAL_COMMITTED).to(ZAState::OFF):
1137 case transitionFrom(ZAState::LOCAL_COMMITTED).to(ZAState::LOCAL_SAVED):
1142 case transitionFrom(ZAState::LOCAL_COMMITTED).to(ZAState::ACTIVE):
1143 case transitionFrom(ZAState::LOCAL_COMMITTED).to(ZAState::ACTIVE_ZT0_SAVED):
1144 case transitionFrom(ZAState::LOCAL_SAVED).to(ZAState::ACTIVE):
1145 case transitionFrom(ZAState::LOCAL_SAVED).to(ZAState::ACTIVE_ZT0_SAVED):
1147 emitZARestore(Context,
MBB, InsertPt, PhysLiveRegs);
1149 emitZAMode(
MBB, InsertPt,
false,
true);
1150 if (HasZT0State && To == ZAState::ACTIVE)
1151 emitZT0SaveRestore(Context,
MBB, InsertPt,
false);
1155 case transitionFrom(ZAState::ACTIVE).to(ZAState::OFF):
1156 case transitionFrom(ZAState::ACTIVE_ZT0_SAVED).to(ZAState::OFF):
1157 case transitionFrom(ZAState::LOCAL_SAVED).to(ZAState::OFF):
1159 "Did not expect to turn ZA off in shared/agnostic ZA function");
1160 emitZAMode(
MBB, InsertPt, From == ZAState::LOCAL_SAVED,
1165 dbgs() <<
"Error: Transition from " << getZAStateString(From) <<
" to "
1166 << getZAStateString(To) <<
'\n';
1173static bool canElidePrivateZASetup(
const FunctionInfo &FnInfo) {
1174 for (
const BlockInfo &BlockInfo : FnInfo.Blocks) {
1175 for (
const InstInfo &InstInfo : BlockInfo.Insts) {
1176 if (InstInfo.NeededState == ZAState::ACTIVE ||
1177 InstInfo.NeededState == ZAState::ACTIVE_ZT0_SAVED)
1191 SMEAttrs SMEFnAttrs = AFI->getSMEFnAttrs();
1200 assert(MF.getRegInfo().isSSA() &&
"Expected to be run on SSA form!");
1203 ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();
1204 LLI = &getAnalysis<LibcallLoweringInfoWrapper>().getLibcallLowering(
1205 *MF.getFunction().getParent(), *
Subtarget);
1208 MRI = &MF.getRegInfo();
1211 getAnalysis<EdgeBundlesWrapperLegacy>().getEdgeBundles();
1213 FunctionInfo FnInfo = collectNeededZAStates(SMEFnAttrs);
1220 EmitContext Context;
1221 insertStateChanges(Context, FnInfo, Bundles, BundleStates);
1223 if (Context.needsSaveBuffer()) {
1224 if (FnInfo.AfterSMEProloguePt) {
1228 emitAllocateZASaveBuffer(Context, *
MBBI->getParent(),
MBBI,
1229 FnInfo.PhysLiveRegsAfterSMEPrologue);
1232 emitAllocateZASaveBuffer(
1234 FnInfo.Blocks[EntryBlock.
getNumber()].PhysLiveRegsAtEntry);
static constexpr unsigned ZERO_ALL_ZA_MASK
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
#define ENTRY(ASMNAME, ENUM)
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
MachineRegisterInfo & MRI
This file defines the SmallVector class.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
Register getEarlyAllocSMESaveBuffer() const
SMEAttrs getSMEFnAttrs() const
Represent the analysis usage information of a pass.
AnalysisUsage & addPreservedID(const void *ID)
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents a function call, abstracting a target machine's calling convention.
ArrayRef< unsigned > getBlocks(unsigned Bundle) const
getBlocks - Return an array of blocks that are connected to Bundle.
unsigned getBundle(unsigned N, bool Out) const
getBundle - Return the ingoing (Out = false) or outgoing (Out = true) bundle number for basic block N
unsigned getNumBundles() const
getNumBundles - Return the total number of bundles in the CFG.
FunctionPass class - This class is used to implement most global optimizations.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void emitError(const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
Tracks which library functions to use for a particular subtarget or function.
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall.
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Return the lowering's selection of implementation call for Call.
A set of register units used to track register liveness.
bool available(MCRegister Reg) const
Returns true if no part of physical register Reg is live.
void addReg(MCRegister Reg)
Adds register units covered by physical register Reg.
LLVM_ABI void stepBackward(const MachineInstr &MI)
Updates liveness when stepping backwards over the instruction MI.
LLVM_ABI void addLiveOuts(const MachineBasicBlock &MBB)
Adds registers living out of block MBB.
MachineInstrBundleIterator< const MachineInstr > const_iterator
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
LLVM_ABI iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
succ_reverse_iterator succ_rbegin()
MachineInstrBundleIterator< MachineInstr > iterator
succ_reverse_iterator succ_rend()
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
LLVM_ABI int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
LLVM_ABI int CreateSpillStackObject(uint64_t Size, Align Alignment, TargetStackID::Value StackID=TargetStackID::Default)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
LLVM_ABI int CreateVariableSizedObject(Align Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
const MachineInstrBuilder & setOperandDead(unsigned OpIdx) const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
SMEAttrs is a utility class to parse the SME ACLE attributes on functions.
bool hasAgnosticZAInterface() const
bool hasPrivateZAInterface() const
bool hasSharedZAInterface() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::const_iterator const_iterator
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static unsigned getArithExtendImm(AArch64_AM::ShiftExtendType ET, unsigned Imm)
getArithExtendImm - Encode the extend type and shift amount for an arithmetic instruction: imm: 3-bit...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0
Preserve X0-X13, X19-X29, SP, Z0-Z31, P0-P15.
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1
Preserve X1-X15, X19-X29, SP, Z0-Z31, P0-P15.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createMachineSMEABIPass()
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Define
Register definition.
@ LLVM_MARK_AS_BITMASK_ENUM
LLVM_ABI char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
LLVM_ABI char & MachineLoopInfoID
MachineLoopInfo - This pass is a loop analysis pass.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
This struct is a compact representation of a valid (non-zero power of two) alignment.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.