Skip to content

Commit 2050e7e

Browse files
committed
[Arm][AArch64] Add support for v8.9-A/v9.4-A base extensions
This implements the base extensions that are part of the v8.9-A and v9.4-A architecture versions, including: * The Clear BHB Instruction (FEAT_CLRBHB) * The Speculation Restriction Instruction (FEAT_SPECRES2) * The SLC target for the PRFM instruction * New system registers: * ID_AA64PFR2_EL1 * ID_AA64MMFR3_EL1 * HFGITR2_EL2 * SCTLR2_EL3 More information on the new extensions can be found on: * https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-2022 * https://developer.arm.com/downloads/-/exploration-tools Contributors: Sam Elliott, Tomas Matheson and Son Tuan Vu. Reviewed By: lenary Differential Revision: https://reviews.llvm.org/D139424
1 parent 8a900f2 commit 2050e7e

29 files changed

+431
-78
lines changed

llvm/include/llvm/Support/AArch64TargetParser.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ AARCH64_ARCH_EXT_NAME("sme2p1", AArch64::AEK_SME2p1, "+sme2p1",
151151
AARCH64_ARCH_EXT_NAME("hbc", AArch64::AEK_HBC, "+hbc", "-hbc")
152152
AARCH64_ARCH_EXT_NAME("mops", AArch64::AEK_MOPS, "+mops", "-mops")
153153
AARCH64_ARCH_EXT_NAME("pmuv3", AArch64::AEK_PERFMON, "+perfmon", "-perfmon")
154+
AARCH64_ARCH_EXT_NAME("predres2", AArch64::AEK_SPECRES2, "+specres2", "-specres2")
154155
AARCH64_ARCH_EXT_NAME("cssc", AArch64::AEK_CSSC, "+cssc", "-cssc")
155156
AARCH64_ARCH_EXT_NAME("rcpc3", AArch64::AEK_RCPC3, "+rcpc3", "-rcpc3")
156157
AARCH64_ARCH_EXT_NAME("the", AArch64::AEK_THE, "+the", "-the")

llvm/include/llvm/Support/AArch64TargetParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ enum ArchExtKind : uint64_t {
8282
AEK_THE = 1ULL << 50, // FEAT_THE
8383
AEK_D128 = 1ULL << 51, // FEAT_D128
8484
AEK_LSE128 = 1ULL << 52, // FEAT_LSE128
85+
AEK_SPECRES2 = 1ULL << 53, // FEAT_SPECRES2
8586
};
8687
// clang-format on
8788

llvm/lib/Target/AArch64/AArch64.td

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,16 @@ def FeatureNoBTIAtReturnTwice : SubtargetFeature<"no-bti-at-return-twice",
508508
"Don't place a BTI instruction "
509509
"after a return-twice">;
510510

511+
def FeatureCLRBHB : SubtargetFeature<"clrbhb", "HasCLRBHB",
512+
"true", "Enable Clear BHB instruction (FEAT_CLRBHB)">;
513+
514+
def FeaturePRFM_SLC : SubtargetFeature<"prfm-slc-target", "HasPRFM_SLC",
515+
"true", "Enable SLC target for PRFM instruction">;
516+
517+
def FeatureSPECRES2 : SubtargetFeature<"specres2", "HasSPECRES2",
518+
"true", "Enable Speculation Restriction Instruction (FEAT_SPECRES2)",
519+
[FeaturePredRes]>;
520+
511521
def FeatureMEC : SubtargetFeature<"mec", "HasMEC",
512522
"true", "Enable Memory Encryption Contexts Extension", [FeatureRME]>;
513523

@@ -578,7 +588,8 @@ def HasV8_8aOps : SubtargetFeature<
578588

579589
def HasV8_9aOps : SubtargetFeature<
580590
"v8.9a", "HasV8_9aOps", "true", "Support ARM v8.9a instructions",
581-
[HasV8_8aOps, FeatureCSSC]>;
591+
[HasV8_8aOps, FeatureCLRBHB, FeaturePRFM_SLC, FeatureSPECRES2,
592+
FeatureCSSC]>;
582593

583594
def HasV9_0aOps : SubtargetFeature<
584595
"v9a", "HasV9_0aOps", "true", "Support ARM v9a instructions",

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ def HasHBC : Predicate<"Subtarget->hasHBC()">,
233233
AssemblerPredicateWithAll<(all_of FeatureHBC), "hbc">;
234234
def HasMOPS : Predicate<"Subtarget->hasMOPS()">,
235235
AssemblerPredicateWithAll<(all_of FeatureMOPS), "mops">;
236+
def HasCLRBHB : Predicate<"Subtarget->hasCLRBHB()">,
237+
AssemblerPredicateWithAll<(all_of FeatureCLRBHB), "clrbhb">;
238+
def HasSPECRES2 : Predicate<"Subtarget->hasSPECRES2()">,
239+
AssemblerPredicateWithAll<(all_of FeatureSPECRES2), "specres2">;
236240
def HasITE : Predicate<"Subtarget->hasITE()">,
237241
AssemblerPredicateWithAll<(all_of FeatureITE), "ite">;
238242
def HasTHE : Predicate<"Subtarget->hasTHE()">,
@@ -8546,6 +8550,11 @@ def : Pat<(AArch64AssertZExtBool GPR32:$op),
85468550
//===----------------------------===//
85478551
// 2022 Architecture Extensions:
85488552
//===----------------------------===//
8553+
def : InstAlias<"clrbhb", (HINT 22), 0>;
8554+
let Predicates = [HasCLRBHB] in {
8555+
def : InstAlias<"clrbhb", (HINT 22), 1>;
8556+
}
8557+
85498558
defm RCW : ReadCheckWriteCompareAndSwap;
85508559

85518560
defm RCWCLR : ReadCheckWriteOperation<0b001, "clr">;

llvm/lib/Target/AArch64/AArch64SystemOperands.td

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -230,33 +230,51 @@ def : TSB<"csync", 0>;
230230
// PRFM (prefetch) instruction options.
231231
//===----------------------------------------------------------------------===//
232232

233-
class PRFM<string name, bits<5> encoding> : SearchableTable {
233+
class PRFM<string type, bits<2> type_encoding,
234+
string target, bits<2> target_encoding,
235+
string policy, bits<1> policy_encoding> : SearchableTable {
234236
let SearchableFields = ["Name", "Encoding"];
235237
let EnumValueField = "Encoding";
236238

237-
string Name = name;
239+
string Name = type # target # policy;
238240
bits<5> Encoding;
239-
let Encoding = encoding;
241+
let Encoding{4-3} = type_encoding;
242+
let Encoding{2-1} = target_encoding;
243+
let Encoding{0} = policy_encoding;
244+
245+
code Requires = [{ {} }];
240246
}
241247

242-
def : PRFM<"pldl1keep", 0x00>;
243-
def : PRFM<"pldl1strm", 0x01>;
244-
def : PRFM<"pldl2keep", 0x02>;
245-
def : PRFM<"pldl2strm", 0x03>;
246-
def : PRFM<"pldl3keep", 0x04>;
247-
def : PRFM<"pldl3strm", 0x05>;
248-
def : PRFM<"plil1keep", 0x08>;
249-
def : PRFM<"plil1strm", 0x09>;
250-
def : PRFM<"plil2keep", 0x0a>;
251-
def : PRFM<"plil2strm", 0x0b>;
252-
def : PRFM<"plil3keep", 0x0c>;
253-
def : PRFM<"plil3strm", 0x0d>;
254-
def : PRFM<"pstl1keep", 0x10>;
255-
def : PRFM<"pstl1strm", 0x11>;
256-
def : PRFM<"pstl2keep", 0x12>;
257-
def : PRFM<"pstl2strm", 0x13>;
258-
def : PRFM<"pstl3keep", 0x14>;
259-
def : PRFM<"pstl3strm", 0x15>;
248+
def : PRFM<"pld", 0b00, "l1", 0b00, "keep", 0b0>;
249+
def : PRFM<"pld", 0b00, "l1", 0b00, "strm", 0b1>;
250+
def : PRFM<"pld", 0b00, "l2", 0b01, "keep", 0b0>;
251+
def : PRFM<"pld", 0b00, "l2", 0b01, "strm", 0b1>;
252+
def : PRFM<"pld", 0b00, "l3", 0b10, "keep", 0b0>;
253+
def : PRFM<"pld", 0b00, "l3", 0b10, "strm", 0b1>;
254+
let Requires = [{ {AArch64::FeaturePRFM_SLC} }] in {
255+
def : PRFM<"pld", 0b00, "slc", 0b11, "keep", 0b0>;
256+
def : PRFM<"pld", 0b00, "slc", 0b11, "strm", 0b1>;
257+
}
258+
def : PRFM<"pli", 0b01, "l1", 0b00, "keep", 0b0>;
259+
def : PRFM<"pli", 0b01, "l1", 0b00, "strm", 0b1>;
260+
def : PRFM<"pli", 0b01, "l2", 0b01, "keep", 0b0>;
261+
def : PRFM<"pli", 0b01, "l2", 0b01, "strm", 0b1>;
262+
def : PRFM<"pli", 0b01, "l3", 0b10, "keep", 0b0>;
263+
def : PRFM<"pli", 0b01, "l3", 0b10, "strm", 0b1>;
264+
let Requires = [{ {AArch64::FeaturePRFM_SLC} }] in {
265+
def : PRFM<"pli", 0b01, "slc", 0b11, "keep", 0b0>;
266+
def : PRFM<"pli", 0b01, "slc", 0b11, "strm", 0b1>;
267+
}
268+
def : PRFM<"pst", 0b10, "l1", 0b00, "keep", 0b0>;
269+
def : PRFM<"pst", 0b10, "l1", 0b00, "strm", 0b1>;
270+
def : PRFM<"pst", 0b10, "l2", 0b01, "keep", 0b0>;
271+
def : PRFM<"pst", 0b10, "l2", 0b01, "strm", 0b1>;
272+
def : PRFM<"pst", 0b10, "l3", 0b10, "keep", 0b0>;
273+
def : PRFM<"pst", 0b10, "l3", 0b10, "strm", 0b1>;
274+
let Requires = [{ {AArch64::FeaturePRFM_SLC} }] in {
275+
def : PRFM<"pst", 0b10, "slc", 0b11, "keep", 0b0>;
276+
def : PRFM<"pst", 0b10, "slc", 0b11, "strm", 0b1>;
277+
}
260278

261279
//===----------------------------------------------------------------------===//
262280
// SVE Prefetch instruction options.
@@ -600,23 +618,6 @@ defm : TLBI<"PAALLOS", 0b110, 0b1000, 0b0001, 0b100, 0>;
600618
defm : TLBI<"PAALL", 0b110, 0b1000, 0b0111, 0b100, 0>;
601619
}
602620

603-
// Armv8.5-A Prediction Restriction by Context instruction options:
604-
class PRCTX<string name, bits<4> crm> : SearchableTable {
605-
let SearchableFields = ["Name", "Encoding"];
606-
let EnumValueField = "Encoding";
607-
608-
string Name = name;
609-
bits<11> Encoding;
610-
let Encoding{10-4} = 0b0110111;
611-
let Encoding{3-0} = crm;
612-
bit NeedsReg = 1;
613-
code Requires = [{ {} }];
614-
}
615-
616-
let Requires = [{ {AArch64::FeaturePredRes} }] in {
617-
def : PRCTX<"RCTX", 0b0011>;
618-
}
619-
620621
//===----------------------------------------------------------------------===//
621622
// MRS/MSR (system register read/write) instruction options.
622623
//===----------------------------------------------------------------------===//
@@ -709,6 +710,7 @@ def : ROSysReg<"ID_ISAR6_EL1", 0b11, 0b000, 0b0000, 0b0010, 0b111> {
709710
}
710711
def : ROSysReg<"ID_AA64PFR0_EL1", 0b11, 0b000, 0b0000, 0b0100, 0b000>;
711712
def : ROSysReg<"ID_AA64PFR1_EL1", 0b11, 0b000, 0b0000, 0b0100, 0b001>;
713+
def : ROSysReg<"ID_AA64PFR2_EL1", 0b11, 0b000, 0b0000, 0b0100, 0b010>;
712714
def : ROSysReg<"ID_AA64DFR0_EL1", 0b11, 0b000, 0b0000, 0b0101, 0b000>;
713715
def : ROSysReg<"ID_AA64DFR1_EL1", 0b11, 0b000, 0b0000, 0b0101, 0b001>;
714716
def : ROSysReg<"ID_AA64AFR0_EL1", 0b11, 0b000, 0b0000, 0b0101, 0b100>;
@@ -719,20 +721,21 @@ def : ROSysReg<"ID_AA64ISAR2_EL1", 0b11, 0b000, 0b0000, 0b0110, 0b010>;
719721
def : ROSysReg<"ID_AA64MMFR0_EL1", 0b11, 0b000, 0b0000, 0b0111, 0b000>;
720722
def : ROSysReg<"ID_AA64MMFR1_EL1", 0b11, 0b000, 0b0000, 0b0111, 0b001>;
721723
def : ROSysReg<"ID_AA64MMFR2_EL1", 0b11, 0b000, 0b0000, 0b0111, 0b010>;
722-
def : ROSysReg<"MVFR0_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b000>;
723-
def : ROSysReg<"MVFR1_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b001>;
724-
def : ROSysReg<"MVFR2_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b010>;
725-
def : ROSysReg<"RVBAR_EL1", 0b11, 0b000, 0b1100, 0b0000, 0b001>;
726-
def : ROSysReg<"RVBAR_EL2", 0b11, 0b100, 0b1100, 0b0000, 0b001>;
727-
def : ROSysReg<"RVBAR_EL3", 0b11, 0b110, 0b1100, 0b0000, 0b001>;
728-
def : ROSysReg<"ISR_EL1", 0b11, 0b000, 0b1100, 0b0001, 0b000>;
729-
def : ROSysReg<"CNTPCT_EL0", 0b11, 0b011, 0b1110, 0b0000, 0b001>;
730-
def : ROSysReg<"CNTVCT_EL0", 0b11, 0b011, 0b1110, 0b0000, 0b010>;
731-
def : ROSysReg<"ID_MMFR4_EL1", 0b11, 0b000, 0b0000, 0b0010, 0b110>;
732-
def : ROSysReg<"ID_MMFR5_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b110>;
724+
def : ROSysReg<"ID_AA64MMFR3_EL1", 0b11, 0b000, 0b0000, 0b0111, 0b011>;
725+
def : ROSysReg<"MVFR0_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b000>;
726+
def : ROSysReg<"MVFR1_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b001>;
727+
def : ROSysReg<"MVFR2_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b010>;
728+
def : ROSysReg<"RVBAR_EL1", 0b11, 0b000, 0b1100, 0b0000, 0b001>;
729+
def : ROSysReg<"RVBAR_EL2", 0b11, 0b100, 0b1100, 0b0000, 0b001>;
730+
def : ROSysReg<"RVBAR_EL3", 0b11, 0b110, 0b1100, 0b0000, 0b001>;
731+
def : ROSysReg<"ISR_EL1", 0b11, 0b000, 0b1100, 0b0001, 0b000>;
732+
def : ROSysReg<"CNTPCT_EL0", 0b11, 0b011, 0b1110, 0b0000, 0b001>;
733+
def : ROSysReg<"CNTVCT_EL0", 0b11, 0b011, 0b1110, 0b0000, 0b010>;
734+
def : ROSysReg<"ID_MMFR4_EL1", 0b11, 0b000, 0b0000, 0b0010, 0b110>;
735+
def : ROSysReg<"ID_MMFR5_EL1", 0b11, 0b000, 0b0000, 0b0011, 0b110>;
733736

734737
// Trace registers
735-
// Op0 Op1 CRn CRm Op2
738+
// Op0 Op1 CRn CRm Op2
736739
def : ROSysReg<"TRCSTATR", 0b10, 0b001, 0b0000, 0b0011, 0b000>;
737740
def : ROSysReg<"TRCIDR8", 0b10, 0b001, 0b0000, 0b0000, 0b110>;
738741
def : ROSysReg<"TRCIDR9", 0b10, 0b001, 0b0000, 0b0001, 0b110>;
@@ -1662,6 +1665,7 @@ def : RWSysReg<"HDFGRTR2_EL2", 0b11, 0b100, 0b0011, 0b0001, 0b000>;
16621665
def : RWSysReg<"HDFGWTR2_EL2", 0b11, 0b100, 0b0011, 0b0001, 0b001>;
16631666
def : RWSysReg<"HFGRTR2_EL2", 0b11, 0b100, 0b0011, 0b0001, 0b010>;
16641667
def : RWSysReg<"HFGWTR2_EL2", 0b11, 0b100, 0b0011, 0b0001, 0b011>;
1668+
def : RWSysReg<"HFGITR2_EL2", 0b11, 0b100, 0b0011, 0b0001, 0b111>;
16651669
}
16661670

16671671
// v8.6a Enhanced Counter Virtualization
@@ -1768,6 +1772,7 @@ def : RWSysReg<"S2POR_EL1", 0b11, 0b000, 0b1010, 0b0010, 0b101>;
17681772
def : RWSysReg<"SCTLR2_EL1", 0b11, 0b000, 0b0001, 0b0000, 0b011>;
17691773
def : RWSysReg<"SCTLR2_EL12", 0b11, 0b101, 0b0001, 0b0000, 0b011>;
17701774
def : RWSysReg<"SCTLR2_EL2", 0b11, 0b100, 0b0001, 0b0000, 0b011>;
1775+
def : RWSysReg<"SCTLR2_EL3", 0b11, 0b110, 0b0001, 0b0000, 0b011>;
17711776

17721777
// v8.9a/v9.4a Extension to Translation Control Registers (FEAT_TCR2)
17731778
// Op0 Op1 CRn CRm Op2

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,6 +3639,7 @@ static const struct Extension {
36393639
{"ras", {AArch64::FeatureRAS}},
36403640
{"lse", {AArch64::FeatureLSE}},
36413641
{"predres", {AArch64::FeaturePredRes}},
3642+
{"predres2", {AArch64::FeatureSPECRES2}},
36423643
{"ccdp", {AArch64::FeatureCacheDeepPersist}},
36433644
{"mte", {AArch64::FeatureMTE}},
36443645
{"memtag", {AArch64::FeatureMTE}},
@@ -3797,23 +3798,31 @@ bool AArch64AsmParser::parseSysAlias(StringRef Name, SMLoc NameLoc,
37973798
return TokError(Str);
37983799
}
37993800
createSysAlias(TLBI->Encoding, Operands, S);
3800-
} else if (Mnemonic == "cfp" || Mnemonic == "dvp" || Mnemonic == "cpp") {
3801-
const AArch64PRCTX::PRCTX *PRCTX = AArch64PRCTX::lookupPRCTXByName(Op);
3802-
if (!PRCTX)
3801+
} else if (Mnemonic == "cfp" || Mnemonic == "dvp" || Mnemonic == "cpp" || Mnemonic == "cosp") {
3802+
3803+
if (Op.lower() != "rctx")
38033804
return TokError("invalid operand for prediction restriction instruction");
3804-
else if (!PRCTX->haveFeatures(getSTI().getFeatureBits())) {
3805-
std::string Str(
3806-
Mnemonic.upper() + std::string(PRCTX->Name) + " requires: ");
3807-
setRequiredFeatureString(PRCTX->getRequiredFeatures(), Str);
3808-
return TokError(Str);
3809-
}
3810-
uint16_t PRCTX_Op2 =
3811-
Mnemonic == "cfp" ? 4 :
3812-
Mnemonic == "dvp" ? 5 :
3813-
Mnemonic == "cpp" ? 7 :
3814-
0;
3815-
assert(PRCTX_Op2 && "Invalid mnemonic for prediction restriction instruction");
3816-
createSysAlias(PRCTX->Encoding << 3 | PRCTX_Op2 , Operands, S);
3805+
3806+
bool hasAll = getSTI().hasFeature(AArch64::FeatureAll);
3807+
bool hasPredres = hasAll || getSTI().hasFeature(AArch64::FeaturePredRes);
3808+
bool hasSpecres2 = hasAll || getSTI().hasFeature(AArch64::FeatureSPECRES2);
3809+
3810+
if (Mnemonic == "cosp" && !hasSpecres2)
3811+
return TokError("COSP requires: predres2");
3812+
if (!hasPredres)
3813+
return TokError(Mnemonic.upper() + "RCTX requires: predres");
3814+
3815+
uint16_t PRCTX_Op2 = Mnemonic == "cfp" ? 0b100
3816+
: Mnemonic == "dvp" ? 0b101
3817+
: Mnemonic == "cosp" ? 0b110
3818+
: Mnemonic == "cpp" ? 0b111
3819+
: 0;
3820+
assert(PRCTX_Op2 &&
3821+
"Invalid mnemonic for prediction restriction instruction");
3822+
const auto SYS_3_7_3 = 0b01101110011; // op=3, CRn=7, CRm=3
3823+
const auto Encoding = SYS_3_7_3 << 3 | PRCTX_Op2;
3824+
3825+
createSysAlias(Encoding, Operands, S);
38173826
}
38183827

38193828
Lex(); // Eat operand.
@@ -5080,7 +5089,7 @@ bool AArch64AsmParser::ParseInstruction(ParseInstructionInfo &Info,
50805089
// IC, DC, AT, TLBI and Prediction invalidation instructions are aliases for
50815090
// the SYS instruction.
50825091
if (Head == "ic" || Head == "dc" || Head == "at" || Head == "tlbi" ||
5083-
Head == "cfp" || Head == "dvp" || Head == "cpp")
5092+
Head == "cfp" || Head == "dvp" || Head == "cpp" || Head == "cosp")
50845093
return parseSysAlias(Head, NameLoc, Operands);
50855094

50865095
// TLBIP instructions are aliases for the SYSP instruction.

llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -910,18 +910,23 @@ bool AArch64InstPrinter::printSysAlias(const MCInst *MI,
910910
// Prediction Restriction aliases
911911
case 3: {
912912
Search_PRCTX:
913-
const AArch64PRCTX::PRCTX *PRCTX = AArch64PRCTX::lookupPRCTXByEncoding(Encoding >> 3);
914-
if (!PRCTX || !PRCTX->haveFeatures(STI.getFeatureBits()))
913+
if (Op1Val != 3 || CnVal != 7 || CmVal != 3)
915914
return false;
916915

917-
NeedsReg = PRCTX->NeedsReg;
916+
const auto Requires =
917+
Op2Val == 6 ? AArch64::FeatureSPECRES2 : AArch64::FeaturePredRes;
918+
if (!(STI.hasFeature(AArch64::FeatureAll) || STI.hasFeature(Requires)))
919+
return false;
920+
921+
NeedsReg = true;
918922
switch (Op2Val) {
919923
default: return false;
920924
case 4: Ins = "cfp\t"; break;
921925
case 5: Ins = "dvp\t"; break;
926+
case 6: Ins = "cosp\t"; break;
922927
case 7: Ins = "cpp\t"; break;
923928
}
924-
Name = std::string(PRCTX->Name);
929+
Name = "RCTX";
925930
}
926931
break;
927932
// IC aliases
@@ -1433,9 +1438,12 @@ void AArch64InstPrinter::printPrefetchOp(const MCInst *MI, unsigned OpNum,
14331438
O << PRFM->Name;
14341439
return;
14351440
}
1436-
} else if (auto PRFM = AArch64PRFM::lookupPRFMByEncoding(prfop)) {
1437-
O << PRFM->Name;
1438-
return;
1441+
} else {
1442+
auto PRFM = AArch64PRFM::lookupPRFMByEncoding(prfop);
1443+
if (PRFM && PRFM->haveFeatures(STI.getFeatureBits())) {
1444+
O << PRFM->Name;
1445+
return;
1446+
}
14391447
}
14401448

14411449
O << markup("<imm:") << '#' << formatImm(prfop) << markup(">");

llvm/lib/Target/ARM/ARM.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,11 @@ def FeatureNoBTIAtReturnTwice : SubtargetFeature<"no-bti-at-return-twice",
542542
"Don't place a BTI instruction "
543543
"after a return-twice">;
544544

545+
// Armv8.9-A/Armv9.4-A 2022 Architecture Extensions
546+
def FeatureCLRBHB : SubtargetFeature<"clrbhb", "HasCLRBHB", "true",
547+
"Enable Clear BHB instruction">;
548+
549+
545550
def FeatureFixCortexA57AES1742098 : SubtargetFeature<"fix-cortex-a57-aes-1742098",
546551
"FixCortexA57AES1742098", "true",
547552
"Work around Cortex-A57 Erratum 1742098 / Cortex-A72 Erratum 1655431 (AES)">;
@@ -674,7 +679,7 @@ def HasV8_8aOps : SubtargetFeature<"v8.8a", "HasV8_8aOps", "true",
674679

675680
def HasV8_9aOps : SubtargetFeature<"v8.9a", "HasV8_9aOps", "true",
676681
"Support ARM v8.9a instructions",
677-
[HasV8_8aOps]>;
682+
[HasV8_8aOps, FeatureCLRBHB]>;
678683

679684
def HasV9_0aOps : SubtargetFeature<"v9a", "HasV9_0aOps", "true",
680685
"Support ARM v9a instructions",

llvm/lib/Target/ARM/ARMInstrInfo.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,10 @@ def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
21892189
def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>;
21902190
def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>;
21912191

2192+
// Clear BHB instruction
2193+
def : InstAlias<"clrbhb$p", (HINT 22, pred:$p), 0>, Requires<[IsARM, HasV8]>;
2194+
def : InstAlias<"clrbhb$p", (HINT 22, pred:$p), 1>, Requires<[IsARM, HasV8, HasCLRBHB]>;
2195+
21922196
def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
21932197
"\t$Rd, $Rn, $Rm",
21942198
[(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,

llvm/lib/Target/ARM/ARMInstrThumb2.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4089,6 +4089,10 @@ def : t2InstAlias<"bti$p", (t2HINT 15, pred:$p), 1>;
40894089
def : t2InstAlias<"pac$p r12,lr,sp", (t2HINT 29, pred:$p), 1>;
40904090
def : t2InstAlias<"aut$p r12,lr,sp", (t2HINT 45, pred:$p), 1>;
40914091

4092+
// Clear BHB instruction
4093+
def : InstAlias<"clrbhb$p", (t2HINT 22, pred:$p), 0>, Requires<[IsThumb2, HasV8]>;
4094+
def : InstAlias<"clrbhb$p", (t2HINT 22, pred:$p), 1>, Requires<[IsThumb2, HasV8, HasCLRBHB]>;
4095+
40924096
def t2DBG : T2I<(outs), (ins imm0_15:$opt), NoItinerary, "dbg", "\t$opt",
40934097
[(int_arm_dbg imm0_15:$opt)]> {
40944098
bits<4> opt;

llvm/lib/Target/ARM/ARMPredicates.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,7 @@ def GenExecuteOnly : Predicate<"Subtarget->genExecuteOnly()">;
226226
// Armv8.5-A extensions
227227
def HasSB : Predicate<"Subtarget->hasSB()">,
228228
AssemblerPredicate<(all_of FeatureSB), "sb">;
229+
230+
// Armv8.9-A/9.4-A 2022 Architecture extensions
231+
def HasCLRBHB : Predicate<"Subtarget->hasCLRBHB()">,
232+
AssemblerPredicate<(all_of FeatureCLRBHB), "clrbhb">;

0 commit comments

Comments
 (0)