Skip to content

Commit 643e3c9

Browse files
committed
[AArch64] Add BRB IALL and BRB INJ instructions
BRB IALL: Invalidate the Branch Record Buffer BRB INJ: Branch Record Injection into the Branch Record Buffer Parser changes based on work by Simon Tatham. These are two-word mnemonics. The assembly parser works by special-casing the mnemonic in order to parse the second word as a plain identifier token. Reviewed by: MarkMurrayARM Differential Revision: https://reviews.llvm.org/D93899
1 parent aa9db51 commit 643e3c9

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,21 @@ def WFET : RegInputSystemI<0b0000, 0b000, "wfet">;
813813
def WFIT : RegInputSystemI<0b0000, 0b001, "wfit">;
814814
}
815815

816+
// Branch Record Buffer two-word mnemonic instructions
817+
class BRBEI<bits<3> op2, string keyword>
818+
: SimpleSystemI<0, (ins), "brb", keyword>, Sched<[WriteSys]> {
819+
let Inst{31-8} = 0b110101010000100101110010;
820+
let Inst{7-5} = op2;
821+
let Predicates = [HasBRBE];
816822
}
823+
def BRB_IALL: BRBEI<0b100, "\tiall">;
824+
def BRB_INJ: BRBEI<0b101, "\tinj">;
825+
826+
}
827+
828+
// Allow uppercase and lowercase keyword arguments for BRB IALL and BRB INJ
829+
def : TokenAlias<"INJ", "inj">;
830+
def : TokenAlias<"IALL", "iall">;
817831

818832
// ARMv8.2-A Dot Product
819833
let Predicates = [HasDotProd] in {

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class AArch64AsmParser : public MCTargetAsmParser {
159159
bool parseSymbolicImmVal(const MCExpr *&ImmVal);
160160
bool parseNeonVectorList(OperandVector &Operands);
161161
bool parseOptionalMulOperand(OperandVector &Operands);
162+
bool parseKeywordOperand(OperandVector &Operands);
162163
bool parseOperand(OperandVector &Operands, bool isCondCode,
163164
bool invertCondCode);
164165
bool parseImmExpr(int64_t &Out);
@@ -3701,6 +3702,17 @@ bool AArch64AsmParser::parseOptionalMulOperand(OperandVector &Operands) {
37013702
return Error(getLoc(), "expected 'vl' or '#<imm>'");
37023703
}
37033704

3705+
bool AArch64AsmParser::parseKeywordOperand(OperandVector &Operands) {
3706+
MCAsmParser &Parser = getParser();
3707+
auto Tok = Parser.getTok();
3708+
if (Tok.isNot(AsmToken::Identifier))
3709+
return true;
3710+
Operands.push_back(AArch64Operand::CreateToken(Tok.getString(), false,
3711+
Tok.getLoc(), getContext()));
3712+
Parser.Lex();
3713+
return false;
3714+
}
3715+
37043716
/// parseOperand - Parse a arm instruction operand. For now this parses the
37053717
/// operand regardless of the mnemonic.
37063718
bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode,
@@ -3765,6 +3777,11 @@ bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode,
37653777
if (GotShift != MatchOperand_NoMatch)
37663778
return GotShift;
37673779

3780+
// If this is a two-word mnemonic, parse its special keyword
3781+
// operand as an identifier.
3782+
if (Mnemonic == "brb")
3783+
return parseKeywordOperand(Operands);
3784+
37683785
// This was not a register so parse other operands that start with an
37693786
// identifier (like labels) as expressions and create them as immediates.
37703787
const MCExpr *IdVal;

llvm/test/MC/AArch64/brbe.s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,17 @@ mrs x5, BRBTGT31_EL1
133133
// CHECK: mrs x5, BRBTGT31_EL1 // encoding: [0xc5,0x8f,0x31,0xd5]
134134
// ERROR-NO-BRBE: [[@LINE-4]]:5: error: expected writable system register
135135
// ERROR-NO-BRBE: [[@LINE-4]]:9: error: expected readable system register
136+
137+
brb iall
138+
brb inj
139+
// CHECK: brb iall // encoding: [0x9f,0x72,0x09,0xd5]
140+
// CHECK: brb inj // encoding: [0xbf,0x72,0x09,0xd5]
141+
// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe
142+
// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe
143+
144+
brb IALL
145+
brb INJ
146+
// CHECK: brb iall // encoding: [0x9f,0x72,0x09,0xd5]
147+
// CHECK: brb inj // encoding: [0xbf,0x72,0x09,0xd5]
148+
// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe
149+
// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe

0 commit comments

Comments
 (0)