Skip to content

Commit 093f712

Browse files
committed
Fixups
Change-Id: I05e79e16397a3e035f5d35df30c4999987a029d4
1 parent 8320082 commit 093f712

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

llvm/lib/Target/AArch64/MachineSMEABIPass.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ struct PhysRegSave {
110110
Register X0Save = AArch64::NoRegister;
111111
};
112112

113-
/// Contains the needed ZA state (and live registers) at an instruction.
113+
/// Contains the needed ZA state (and live registers) at an instruction. That is
114+
/// the state ZA must be in _before_ "InsertPt".
114115
struct InstInfo {
115116
ZAState NeededState{ZAState::ANY};
116117
MachineBasicBlock::iterator InsertPt;
@@ -135,7 +136,8 @@ struct FunctionInfo {
135136

136137
/// State/helpers that is only needed when emitting code to handle
137138
/// saving/restoring ZA.
138-
struct EmitContext {
139+
class EmitContext {
140+
public:
139141
EmitContext() = default;
140142

141143
/// Get or create a TPIDR2 block in \p MF.
@@ -160,7 +162,11 @@ struct EmitContext {
160162
return AgnosticZABufferPtr;
161163
}
162164

165+
/// Returns true if the function must allocate a ZA save buffer on entry. This
166+
/// will be the case if, at any point in the function, a ZA save was emitted.
163167
bool needsSaveBuffer() const {
168+
assert(!(TPIDR2BlockFI && AgnosticZABufferPtr) &&
169+
"Cannot have both a TPIDR2 block and agnostic ZA buffer");
164170
return TPIDR2BlockFI || AgnosticZABufferPtr != AArch64::NoRegister;
165171
}
166172

@@ -252,13 +258,13 @@ struct MachineSMEABI : public MachineFunctionPass {
252258

253259
/// Assigns each edge bundle a ZA state based on the needed states of blocks
254260
/// that have incoming or outgoing edges in that bundle.
255-
SmallVector<ZAState> assignBundleZAStates(EdgeBundles const &Bundles,
256-
FunctionInfo const &FnInfo);
261+
SmallVector<ZAState> assignBundleZAStates(const EdgeBundles &Bundles,
262+
const FunctionInfo &FnInfo);
257263

258264
/// Inserts code to handle changes between ZA states within the function.
259265
/// E.g., ACTIVE -> LOCAL_SAVED will insert code required to save ZA.
260-
void insertStateChanges(EmitContext &, FunctionInfo const &FnInfo,
261-
EdgeBundles const &Bundles,
266+
void insertStateChanges(EmitContext &, const FunctionInfo &FnInfo,
267+
const EdgeBundles &Bundles,
262268
ArrayRef<ZAState> BundleStates);
263269

264270
// Emission routines for private and shared ZA functions (using lazy saves).
@@ -319,7 +325,7 @@ struct MachineSMEABI : public MachineFunctionPass {
319325
PhysRegSave createPhysRegSave(LiveRegs PhysLiveRegs, MachineBasicBlock &MBB,
320326
MachineBasicBlock::iterator MBBI, DebugLoc DL);
321327
/// Restore physical registers from a save of their previous values.
322-
void restorePhyRegSave(PhysRegSave const &RegSave, MachineBasicBlock &MBB,
328+
void restorePhyRegSave(const PhysRegSave &RegSave, MachineBasicBlock &MBB,
323329
MachineBasicBlock::iterator MBBI, DebugLoc DL);
324330

325331
private:
@@ -410,8 +416,8 @@ FunctionInfo MachineSMEABI::collectNeededZAStates(SMEAttrs SMEFnAttrs) {
410416
/// Assigns each edge bundle a ZA state based on the needed states of blocks
411417
/// that have incoming or outgoing edges in that bundle.
412418
SmallVector<ZAState>
413-
MachineSMEABI::assignBundleZAStates(EdgeBundles const &Bundles,
414-
FunctionInfo const &FnInfo) {
419+
MachineSMEABI::assignBundleZAStates(const EdgeBundles &Bundles,
420+
const FunctionInfo &FnInfo) {
415421
SmallVector<ZAState> BundleStates(Bundles.getNumBundles());
416422
for (unsigned I = 0, E = Bundles.getNumBundles(); I != E; ++I) {
417423
LLVM_DEBUG(dbgs() << "Assigning ZA state for edge bundle: " << I << '\n');
@@ -471,8 +477,8 @@ MachineSMEABI::assignBundleZAStates(EdgeBundles const &Bundles,
471477
}
472478

473479
void MachineSMEABI::insertStateChanges(EmitContext &Context,
474-
FunctionInfo const &FnInfo,
475-
EdgeBundles const &Bundles,
480+
const FunctionInfo &FnInfo,
481+
const EdgeBundles &Bundles,
476482
ArrayRef<ZAState> BundleStates) {
477483
for (MachineBasicBlock &MBB : *MF) {
478484
const BlockInfo &Block = FnInfo.Blocks[MBB.getNumber()];
@@ -551,7 +557,7 @@ PhysRegSave MachineSMEABI::createPhysRegSave(LiveRegs PhysLiveRegs,
551557
return RegSave;
552558
}
553559

554-
void MachineSMEABI::restorePhyRegSave(PhysRegSave const &RegSave,
560+
void MachineSMEABI::restorePhyRegSave(const PhysRegSave &RegSave,
555561
MachineBasicBlock &MBB,
556562
MachineBasicBlock::iterator MBBI,
557563
DebugLoc DL) {
@@ -844,7 +850,7 @@ bool MachineSMEABI::runOnMachineFunction(MachineFunction &MF) {
844850
TRI = Subtarget->getRegisterInfo();
845851
MRI = &MF.getRegInfo();
846852

847-
EdgeBundles const &Bundles =
853+
const EdgeBundles &Bundles =
848854
getAnalysis<EdgeBundlesWrapperLegacy>().getEdgeBundles();
849855

850856
FunctionInfo FnInfo = collectNeededZAStates(SMEFnAttrs);

0 commit comments

Comments
 (0)