Skip to content

Commit 5eec8df

Browse files
committed
[AArch64] Add hasSVEorSME() helper and fix some incorrect checks
This adds a little hasSVEorSME() helper, and as a NFC updates existing code to use it. The assertions get[Min|Max]SVEVectorSizeInBits() are also now corrected to use hasSVEorSME() rather than just hasSVE(). Differential Revision: https://reviews.llvm.org/D138575
1 parent 605e22b commit 5eec8df

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
343343
addQRTypeForNEON(MVT::v8bf16);
344344
}
345345

346-
if (Subtarget->hasSVE() || Subtarget->hasSME()) {
346+
if (Subtarget->hasSVEorSME()) {
347347
// Add legal sve predicate types
348348
addRegisterClass(MVT::nxv1i1, &AArch64::PPRRegClass);
349349
addRegisterClass(MVT::nxv2i1, &AArch64::PPRRegClass);
@@ -1155,7 +1155,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
11551155

11561156
// FIXME: Move lowering for more nodes here if those are common between
11571157
// SVE and SME.
1158-
if (Subtarget->hasSVE() || Subtarget->hasSME()) {
1158+
if (Subtarget->hasSVEorSME()) {
11591159
for (auto VT :
11601160
{MVT::nxv16i1, MVT::nxv8i1, MVT::nxv4i1, MVT::nxv2i1, MVT::nxv1i1}) {
11611161
setOperationAction(ISD::SPLAT_VECTOR, VT, Custom);

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,8 +3535,7 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
35353535
// Copy a Predicate register by ORRing with itself.
35363536
if (AArch64::PPRRegClass.contains(DestReg) &&
35373537
AArch64::PPRRegClass.contains(SrcReg)) {
3538-
assert((Subtarget.hasSVE() || Subtarget.hasSME()) &&
3539-
"Unexpected SVE register.");
3538+
assert(Subtarget.hasSVEorSME() && "Unexpected SVE register.");
35403539
BuildMI(MBB, I, DL, get(AArch64::ORR_PPzPP), DestReg)
35413540
.addReg(SrcReg) // Pg
35423541
.addReg(SrcReg)
@@ -3547,8 +3546,7 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
35473546
// Copy a Z register by ORRing with itself.
35483547
if (AArch64::ZPRRegClass.contains(DestReg) &&
35493548
AArch64::ZPRRegClass.contains(SrcReg)) {
3550-
assert((Subtarget.hasSVE() || Subtarget.hasSME()) &&
3551-
"Unexpected SVE register.");
3549+
assert(Subtarget.hasSVEorSME() && "Unexpected SVE register.");
35523550
BuildMI(MBB, I, DL, get(AArch64::ORR_ZZZ), DestReg)
35533551
.addReg(SrcReg)
35543552
.addReg(SrcReg, getKillRegState(KillSrc));
@@ -3558,8 +3556,7 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
35583556
// Copy a Z register pair by copying the individual sub-registers.
35593557
if (AArch64::ZPR2RegClass.contains(DestReg) &&
35603558
AArch64::ZPR2RegClass.contains(SrcReg)) {
3561-
assert((Subtarget.hasSVE() || Subtarget.hasSME()) &&
3562-
"Unexpected SVE register.");
3559+
assert(Subtarget.hasSVEorSME() && "Unexpected SVE register.");
35633560
static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
35643561
copyPhysRegTuple(MBB, I, DL, DestReg, SrcReg, KillSrc, AArch64::ORR_ZZZ,
35653562
Indices);
@@ -3569,8 +3566,7 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
35693566
// Copy a Z register triple by copying the individual sub-registers.
35703567
if (AArch64::ZPR3RegClass.contains(DestReg) &&
35713568
AArch64::ZPR3RegClass.contains(SrcReg)) {
3572-
assert((Subtarget.hasSVE() || Subtarget.hasSME()) &&
3573-
"Unexpected SVE register.");
3569+
assert(Subtarget.hasSVEorSME() && "Unexpected SVE register.");
35743570
static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
35753571
AArch64::zsub2};
35763572
copyPhysRegTuple(MBB, I, DL, DestReg, SrcReg, KillSrc, AArch64::ORR_ZZZ,
@@ -3581,8 +3577,7 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
35813577
// Copy a Z register quad by copying the individual sub-registers.
35823578
if (AArch64::ZPR4RegClass.contains(DestReg) &&
35833579
AArch64::ZPR4RegClass.contains(SrcReg)) {
3584-
assert((Subtarget.hasSVE() || Subtarget.hasSME()) &&
3585-
"Unexpected SVE register.");
3580+
assert(Subtarget.hasSVEorSME() && "Unexpected SVE register.");
35863581
static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
35873582
AArch64::zsub2, AArch64::zsub3};
35883583
copyPhysRegTuple(MBB, I, DL, DestReg, SrcReg, KillSrc, AArch64::ORR_ZZZ,

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def HasSME2p1 : Predicate<"Subtarget->hasSME2p1()">,
166166
// A subset of SVE(2) instructions are legal in Streaming SVE execution mode,
167167
// they should be enabled if either has been specified.
168168
def HasSVEorSME
169-
: Predicate<"Subtarget->hasSVE() || Subtarget->hasSME()">,
169+
: Predicate<"Subtarget->hasSVEorSME()">,
170170
AssemblerPredicateWithAll<(any_of FeatureSVE, FeatureSME),
171171
"sve or sme">;
172172
def HasSVE2orSME

llvm/lib/Target/AArch64/AArch64Subtarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,8 @@ bool AArch64Subtarget::useAA() const { return UseAA; }
459459

460460
bool AArch64Subtarget::forceStreamingCompatibleSVE() const {
461461
if (ForceStreamingCompatibleSVE) {
462-
assert((hasSVE() || hasSME()) && "Expected SVE to be available");
463-
return hasSVE() || hasSME();
462+
assert(hasSVEorSME() && "Expected SVE to be available");
463+
return hasSVEorSME();
464464
}
465465
return false;
466466
}

llvm/lib/Target/AArch64/AArch64Subtarget.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,16 +361,20 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
361361

362362
void mirFileLoaded(MachineFunction &MF) const override;
363363

364+
bool hasSVEorSME() const { return hasSVE() || hasSME(); }
365+
364366
// Return the known range for the bit length of SVE data registers. A value
365367
// of 0 means nothing is known about that particular limit beyong what's
366368
// implied by the architecture.
367369
unsigned getMaxSVEVectorSizeInBits() const {
368-
assert(HasSVE && "Tried to get SVE vector length without SVE support!");
370+
assert(hasSVEorSME() &&
371+
"Tried to get SVE vector length without SVE support!");
369372
return MaxSVEVectorSizeInBits;
370373
}
371374

372375
unsigned getMinSVEVectorSizeInBits() const {
373-
assert(HasSVE && "Tried to get SVE vector length without SVE support!");
376+
assert(hasSVEorSME() &&
377+
"Tried to get SVE vector length without SVE support!");
374378
return MinSVEVectorSizeInBits;
375379
}
376380

0 commit comments

Comments
 (0)