llvm.org GIT mirror llvm / 1b72e98
[RISCV] Fix RISCVAsmParser::ParseRegister and add tests RISCVAsmParser::ParseRegister is called from AsmParser::parseRegisterOrNumber, which in turn is called when processing CFI directives. The RISC-V implementation wasn't setting RegNo, and so was incorrect. This patch address that and adds cfi directive tests that demonstrate the fix. A follow-up patch will factor out the register parsing logic shared between ParseRegister and parseRegister. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356329 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Bradbury 1 year, 8 months ago
3 changed file(s) with 152 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
915915 RegNo = 0;
916916 StringRef Name = getLexer().getTok().getIdentifier();
917917
918 if (!MatchRegisterName(Name) || !MatchRegisterAltName(Name)) {
919 getParser().Lex(); // Eat identifier token.
920 return false;
921 }
922
923 return Error(StartLoc, "invalid register name");
918 RegNo = MatchRegisterName(Name);
919 if (RegNo == 0)
920 RegNo = MatchRegisterAltName(Name);
921 if (RegNo == 0)
922 return Error(StartLoc, "invalid register name");
923
924 getParser().Lex(); // Eat identifier token.
925 return false;
924926 }
925927
926928 OperandMatchResultTy RISCVAsmParser::parseRegister(OperandVector &Operands,
0 # RUN: not llvm-mc -triple riscv32 < %s 2>&1 | FileCheck %s
1 # RUN: not llvm-mc -triple riscv64 < %s 2>&1 | FileCheck %s
2
3 .cfi_startproc
4 .cfi_offset x00, 0 # CHECK: :[[@LINE]]:16: error: invalid register name
5 .cfi_offset a8, 8 # CHECK: :[[@LINE]]:15: error: invalid register name
6 .cfi_endproc
0 # RUN: llvm-mc %s -triple=riscv32 | FileCheck %s
1 # RUN: llvm-mc %s -triple=riscv64 | FileCheck %s
2
3 .cfi_startproc
4 # CHECK: .cfi_offset zero, 0
5 .cfi_offset x0, 0
6 # CHECK: .cfi_offset ra, 8
7 .cfi_offset x1, 8
8 # CHECK: .cfi_offset sp, 16
9 .cfi_offset x2, 16
10 # CHECK: .cfi_offset gp, 24
11 .cfi_offset x3, 24
12 # CHECK: .cfi_offset tp, 32
13 .cfi_offset x4, 32
14 # CHECK: .cfi_offset t0, 40
15 .cfi_offset x5, 40
16 # CHECK: .cfi_offset t1, 48
17 .cfi_offset x6, 48
18 # CHECK: .cfi_offset t2, 56
19 .cfi_offset x7, 56
20 # CHECK: .cfi_offset s0, 64
21 .cfi_offset x8, 64
22 # CHECK: .cfi_offset s1, 72
23 .cfi_offset x9, 72
24 # CHECK: .cfi_offset a0, 80
25 .cfi_offset x10, 80
26 # CHECK: .cfi_offset a1, 88
27 .cfi_offset x11, 88
28 # CHECK: .cfi_offset a2, 96
29 .cfi_offset x12, 96
30 # CHECK: .cfi_offset a3, 104
31 .cfi_offset x13, 104
32 # CHECK: .cfi_offset a4, 112
33 .cfi_offset x14, 112
34 # CHECK: .cfi_offset a5, 120
35 .cfi_offset x15, 120
36 # CHECK: .cfi_offset a6, 128
37 .cfi_offset x16, 128
38 # CHECK: .cfi_offset a7, 136
39 .cfi_offset x17, 136
40 # CHECK: .cfi_offset s2, 144
41 .cfi_offset x18, 144
42 # CHECK: .cfi_offset s3, 152
43 .cfi_offset x19, 152
44 # CHECK: .cfi_offset s4, 160
45 .cfi_offset x20, 160
46 # CHECK: .cfi_offset s5, 168
47 .cfi_offset x21, 168
48 # CHECK: .cfi_offset s6, 176
49 .cfi_offset x22, 176
50 # CHECK: .cfi_offset s7, 184
51 .cfi_offset x23, 184
52 # CHECK: .cfi_offset s8, 192
53 .cfi_offset x24, 192
54 # CHECK: .cfi_offset s9, 200
55 .cfi_offset x25, 200
56 # CHECK: .cfi_offset s10, 208
57 .cfi_offset x26, 208
58 # CHECK: .cfi_offset s11, 216
59 .cfi_offset x27, 216
60 # CHECK: .cfi_offset t3, 224
61 .cfi_offset x28, 224
62 # CHECK: .cfi_offset t4, 232
63 .cfi_offset x29, 232
64 # CHECK: .cfi_offset t5, 240
65 .cfi_offset x30, 240
66 # CHECK: .cfi_offset t6, 248
67 .cfi_offset x31, 248
68 .cfi_endproc
69
70 .cfi_startproc
71 # CHECK: .cfi_offset zero, 0
72 .cfi_offset zero, 0
73 # CHECK: .cfi_offset ra, 8
74 .cfi_offset ra, 8
75 # CHECK: .cfi_offset sp, 16
76 .cfi_offset sp, 16
77 # CHECK: .cfi_offset gp, 24
78 .cfi_offset gp, 24
79 # CHECK: .cfi_offset tp, 32
80 .cfi_offset tp, 32
81 # CHECK: .cfi_offset t0, 40
82 .cfi_offset t0, 40
83 # CHECK: .cfi_offset t1, 48
84 .cfi_offset t1, 48
85 # CHECK: .cfi_offset t2, 56
86 .cfi_offset t2, 56
87 # CHECK: .cfi_offset s0, 64
88 .cfi_offset s0, 64
89 # CHECK: .cfi_offset s1, 72
90 .cfi_offset s1, 72
91 # CHECK: .cfi_offset a0, 80
92 .cfi_offset a0, 80
93 # CHECK: .cfi_offset a1, 88
94 .cfi_offset a1, 88
95 # CHECK: .cfi_offset a2, 96
96 .cfi_offset a2, 96
97 # CHECK: .cfi_offset a3, 104
98 .cfi_offset a3, 104
99 # CHECK: .cfi_offset a4, 112
100 .cfi_offset a4, 112
101 # CHECK: .cfi_offset a5, 120
102 .cfi_offset a5, 120
103 # CHECK: .cfi_offset a6, 128
104 .cfi_offset a6, 128
105 # CHECK: .cfi_offset a7, 136
106 .cfi_offset a7, 136
107 # CHECK: .cfi_offset s2, 144
108 .cfi_offset s2, 144
109 # CHECK: .cfi_offset s3, 152
110 .cfi_offset s3, 152
111 # CHECK: .cfi_offset s4, 160
112 .cfi_offset s4, 160
113 # CHECK: .cfi_offset s5, 168
114 .cfi_offset s5, 168
115 # CHECK: .cfi_offset s6, 176
116 .cfi_offset s6, 176
117 # CHECK: .cfi_offset s7, 184
118 .cfi_offset s7, 184
119 # CHECK: .cfi_offset s8, 192
120 .cfi_offset s8, 192
121 # CHECK: .cfi_offset s9, 200
122 .cfi_offset s9, 200
123 # CHECK: .cfi_offset s10, 208
124 .cfi_offset s10, 208
125 # CHECK: .cfi_offset s11, 216
126 .cfi_offset s11, 216
127 # CHECK: .cfi_offset t3, 224
128 .cfi_offset t3, 224
129 # CHECK: .cfi_offset t4, 232
130 .cfi_offset t4, 232
131 # CHECK: .cfi_offset t5, 240
132 .cfi_offset t5, 240
133 # CHECK: .cfi_offset t6, 248
134 .cfi_offset t6, 248
135
136 .cfi_endproc