[PATCH] Fix for PR20104. Enable GAS compliant coprocessor register name.
Andrey Kuharev
an.kuharev at gmail.com
Mon Jun 23 03:54:03 PDT 2014
Added parsing for parameter names starting with "cr"
Additional compliant GAS names for coprocessor register name
are enabled for all instruction with parameter MCK_CoprocReg:
LDC,LDC2,STC,STC2,CDP,CDP2,MCR,MCR2,MCRR,MCRR2,MRC,MRC2,MRRC,MRRC2
...
http://reviews.llvm.org/D4254
Files:
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
test/MC/ARM/gas-compl-copr-reg.s
Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===================================================================
--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -3083,15 +3083,19 @@
/// MatchCoprocessorOperandName - Try to parse an coprocessor related
/// instruction with a symbolic operand name. Example: "p1", "p7", "c3",
-/// "c5", ...
+/// "c5", cr0, cr5 ...
static int MatchCoprocessorOperandName(StringRef Name, char CoprocOp) {
// Use the same layout as the tablegen'erated register name matcher. Ugly,
// but efficient.
+ if (Name.size() < 2 || Name[0] != CoprocOp)
+ return -1;
+
+ if (Name.startswith("cr")) // For gas compatibility
+ Name = Name.drop_front();
+
switch (Name.size()) {
default: return -1;
case 2:
- if (Name[0] != CoprocOp)
- return -1;
switch (Name[1]) {
default: return -1;
case '0': return 0;
@@ -3106,7 +3110,7 @@
case '9': return 9;
}
case 3:
- if (Name[0] != CoprocOp || Name[1] != '1')
+ if (Name[1] != '1')
return -1;
switch (Name[2]) {
default: return -1;
Index: test/MC/ARM/gas-compl-copr-reg.s
===================================================================
--- test/MC/ARM/gas-compl-copr-reg.s
+++ test/MC/ARM/gas-compl-copr-reg.s
@@ -0,0 +1,7 @@
+@ RUN: llvm-mc -triple=armv7-linux-gnueabi -show-encoding < %s | FileCheck %s
+
+@ CHECK: ldc p12, c4, [r0, #4] @ encoding: [0x01,0x4c,0x90,0xed]
+@ CHECK: stc p14, c6, [r2, #-224] @ encoding: [0x38,0x6e,0x02,0xed]
+
+ ldc p12, cr4, [r0, #4]
+ stc p14, cr6, [r2, #-224]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4254.10742.patch
Type: text/x-patch
Size: 1662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140623/bec3dec2/attachment.bin>
More information about the llvm-commits
mailing list