[PATCH] D78650: [MC][AArch64] Fail if x18 is reserved and used
Eugene Leviant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 22 09:12:55 PDT 2020
evgeny777 created this revision.
evgeny777 added reviewers: t.p.northover, fhahn, sdesmalen, jlebar.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
This helps to auto-verify assembly files when project is built with -ffixed-x18
https://reviews.llvm.org/D78650
Files:
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/test/MC/AArch64/reserve-x18.s
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
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78650.259311.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/8f088caf/attachment.bin>
More information about the llvm-commits
mailing list