Index: llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp =================================================================== --- llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -2314,6 +2314,10 @@ if (Reg == 0) return MatchOperand_NoMatch; + if (getSTI().hasFeature(AArch64::FeatureReserveX18) && + (Reg == AArch64::X18 || Reg == AArch64::W18)) + Error(Tok.getLoc(), "reserved register x18 is used"); + RegNum = Reg; Parser.Lex(); // Eat identifier token. return MatchOperand_Success; Index: llvm/test/MC/AArch64/reserve-x18.s =================================================================== --- /dev/null +++ llvm/test/MC/AArch64/reserve-x18.s @@ -0,0 +1,6 @@ +// RUN: echo "mov x18, 0" | llvm-mc --arch=arm64 | FileCheck %s --check-prefix=OK +// RUN: echo "mov x18, 0" | not llvm-mc --arch=arm64 --mattr=reserve-x18 2>&1 | FileCheck %s --check-prefix=ERROR +// RUN: echo "mov w18, 0" | not llvm-mc --arch=arm64 --mattr=reserve-x18 2>&1 | FileCheck %s --check-prefix=ERROR + +// OK: mov x18, #0 +// ERROR: error: reserved register x18 is used