diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -813,7 +813,21 @@ def WFIT : RegInputSystemI<0b0000, 0b001, "wfit">; } +// Branch Record Buffer two-word mnemonic instructions +class BRBEI op2, string keyword> + : SimpleSystemI<0, (ins), "brb", keyword>, Sched<[WriteSys]> { + let Inst{31-8} = 0b110101010000100101110010; + let Inst{7-5} = op2; + let Predicates = [HasBRBE]; } +def BRB_IALL: BRBEI<0b100, "\tiall">; +def BRB_INJ: BRBEI<0b101, "\tinj">; + +} + +// Allow uppercase and lowercase keyword arguments for BRB IALL and BRB INJ +def : TokenAlias<"INJ", "inj">; +def : TokenAlias<"IALL", "iall">; // ARMv8.2-A Dot Product let Predicates = [HasDotProd] in { diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -159,6 +159,7 @@ bool parseSymbolicImmVal(const MCExpr *&ImmVal); bool parseNeonVectorList(OperandVector &Operands); bool parseOptionalMulOperand(OperandVector &Operands); + bool parseKeywordOperand(OperandVector &Operands); bool parseOperand(OperandVector &Operands, bool isCondCode, bool invertCondCode); bool parseImmExpr(int64_t &Out); @@ -3701,6 +3702,17 @@ return Error(getLoc(), "expected 'vl' or '#'"); } +bool AArch64AsmParser::parseKeywordOperand(OperandVector &Operands) { + MCAsmParser &Parser = getParser(); + auto Tok = Parser.getTok(); + if (Tok.isNot(AsmToken::Identifier)) + return true; + Operands.push_back(AArch64Operand::CreateToken(Tok.getString(), false, + Tok.getLoc(), getContext())); + Parser.Lex(); + return false; +} + /// parseOperand - Parse a arm instruction operand. For now this parses the /// operand regardless of the mnemonic. bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode, @@ -3765,6 +3777,11 @@ if (GotShift != MatchOperand_NoMatch) return GotShift; + // If this is a two-word mnemonic, parse its special keyword + // operand as an identifier. + if (Mnemonic == "brb") + return parseKeywordOperand(Operands); + // This was not a register so parse other operands that start with an // identifier (like labels) as expressions and create them as immediates. const MCExpr *IdVal; diff --git a/llvm/test/MC/AArch64/brbe.s b/llvm/test/MC/AArch64/brbe.s --- a/llvm/test/MC/AArch64/brbe.s +++ b/llvm/test/MC/AArch64/brbe.s @@ -133,3 +133,17 @@ // CHECK: mrs x5, BRBTGT31_EL1 // encoding: [0xc5,0x8f,0x31,0xd5] // ERROR-NO-BRBE: [[@LINE-4]]:5: error: expected writable system register // ERROR-NO-BRBE: [[@LINE-4]]:9: error: expected readable system register + +brb iall +brb inj +// CHECK: brb iall // encoding: [0x9f,0x72,0x09,0xd5] +// CHECK: brb inj // encoding: [0xbf,0x72,0x09,0xd5] +// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe +// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe + +brb IALL +brb INJ +// CHECK: brb iall // encoding: [0x9f,0x72,0x09,0xd5] +// CHECK: brb inj // encoding: [0xbf,0x72,0x09,0xd5] +// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe +// ERROR-NO-BRBE: [[@LINE-4]]:1: error: instruction requires: brbe