llvm.org GIT mirror llvm / 25c2850
[mips] [IAS] Add missing constraints and improve testing for the .module directive. Summary: None of the .set directives can be used before the .module directives. The .set mips0/pop/push were not triggering this constraint. Also added testing for all the other implemented directives which are supposed to trigger this constraint. Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7140 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231465 91177308-0d34-0410-b5e6-96231b3b80d8 Toma Tabacu 4 years ago
5 changed file(s) with 304 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
234234 bool parseDirectiveModuleFP();
235235 bool parseFpABIValue(MipsABIFlagsSection::FpABIKind &FpABI,
236236 StringRef Directive);
237
238 bool parseInternalDirectiveReallowModule();
237239
238240 MCSymbolRefExpr::VariantKind getVariantKind(StringRef Symbol);
239241
44284430 if (IDVal == ".module")
44294431 return parseDirectiveModule();
44304432
4433 if (IDVal == ".llvm_internal_mips_reallow_module_directive")
4434 return parseInternalDirectiveReallowModule();
4435
44314436 return true;
4437 }
4438
4439 bool MipsAsmParser::parseInternalDirectiveReallowModule() {
4440 // If this is not the end of the statement, report an error.
4441 if (getLexer().isNot(AsmToken::EndOfStatement)) {
4442 reportParseError("unexpected token, expected end of statement");
4443 return false;
4444 }
4445
4446 getTargetStreamer().reallowModuleDirective();
4447
4448 getParser().Lex(); // Eat EndOfStatement token.
4449 return false;
44324450 }
44334451
44344452 extern "C" void LLVMInitializeMipsAsmParser() {
6161 void MipsTargetStreamer::emitDirectiveSetArch(StringRef Arch) {
6262 forbidModuleDirective();
6363 }
64 void MipsTargetStreamer::emitDirectiveSetMips0() {}
64 void MipsTargetStreamer::emitDirectiveSetMips0() { forbidModuleDirective(); }
6565 void MipsTargetStreamer::emitDirectiveSetMips1() { forbidModuleDirective(); }
6666 void MipsTargetStreamer::emitDirectiveSetMips2() { forbidModuleDirective(); }
6767 void MipsTargetStreamer::emitDirectiveSetMips3() { forbidModuleDirective(); }
7777 void MipsTargetStreamer::emitDirectiveSetMips64R3() { forbidModuleDirective(); }
7878 void MipsTargetStreamer::emitDirectiveSetMips64R5() { forbidModuleDirective(); }
7979 void MipsTargetStreamer::emitDirectiveSetMips64R6() { forbidModuleDirective(); }
80 void MipsTargetStreamer::emitDirectiveSetPop() {}
81 void MipsTargetStreamer::emitDirectiveSetPush() {}
80 void MipsTargetStreamer::emitDirectiveSetPop() { forbidModuleDirective(); }
81 void MipsTargetStreamer::emitDirectiveSetPush() { forbidModuleDirective(); }
8282 void MipsTargetStreamer::emitDirectiveSetDsp() { forbidModuleDirective(); }
8383 void MipsTargetStreamer::emitDirectiveSetNoDsp() { forbidModuleDirective(); }
8484 void MipsTargetStreamer::emitDirectiveCpLoad(unsigned RegNo) {}
8989 bool IsO32ABI) {
9090 if (!Enabled && !IsO32ABI)
9191 report_fatal_error("+nooddspreg is only valid for O32");
92 }
93 void MipsTargetStreamer::emitDirectiveSetFp(
94 MipsABIFlagsSection::FpABIKind Value) {
95 forbidModuleDirective();
9296 }
9397
9498 MipsTargetAsmStreamer::MipsTargetAsmStreamer(MCStreamer &S,
197201 MipsTargetStreamer::emitDirectiveSetArch(Arch);
198202 }
199203
200 void MipsTargetAsmStreamer::emitDirectiveSetMips0() { OS << "\t.set\tmips0\n"; }
204 void MipsTargetAsmStreamer::emitDirectiveSetMips0() {
205 OS << "\t.set\tmips0\n";
206 MipsTargetStreamer::emitDirectiveSetMips0();
207 }
201208
202209 void MipsTargetAsmStreamer::emitDirectiveSetMips1() {
203210 OS << "\t.set\tmips1\n";
284291 MipsTargetStreamer::emitDirectiveSetNoDsp();
285292 }
286293
287 void MipsTargetAsmStreamer::emitDirectiveSetPop() { OS << "\t.set\tpop\n"; }
288
289 void MipsTargetAsmStreamer::emitDirectiveSetPush() { OS << "\t.set\tpush\n"; }
294 void MipsTargetAsmStreamer::emitDirectiveSetPop() {
295 OS << "\t.set\tpop\n";
296 MipsTargetStreamer::emitDirectiveSetPop();
297 }
298
299 void MipsTargetAsmStreamer::emitDirectiveSetPush() {
300 OS << "\t.set\tpush\n";
301 MipsTargetStreamer::emitDirectiveSetPush();
302 }
290303
291304 // Print a 32 bit hex number with all numbers.
292305 static void printHex32(unsigned Value, raw_ostream &OS) {
345358
346359 void MipsTargetAsmStreamer::emitDirectiveSetFp(
347360 MipsABIFlagsSection::FpABIKind Value) {
361 MipsTargetStreamer::emitDirectiveSetFp(Value);
362
348363 StringRef ModuleValue;
349364 OS << "\t.set\tfp=";
350365 OS << ABIFlagsSection.getFpABIString(Value) << "\n";
9191 }
9292
9393 virtual void emitDirectiveModuleOddSPReg(bool Enabled, bool IsO32ABI);
94 virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value){};
94 virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value);
9595 virtual void emitMipsAbiFlags(){};
9696 void forbidModuleDirective() { ModuleDirectiveAllowed = false; }
97 void reallowModuleDirective() { ModuleDirectiveAllowed = true; }
9798 bool isModuleDirectiveAllowed() { return ModuleDirectiveAllowed; }
9899
99100 // This method enables template classes to set internal abi flags
2121 # CHECK: :[[@LINE-1]]:13: error: expected .module option identifier
2222 # CHECK-NEXT: .module 34
2323 # CHECK-NEXT: ^
24
25 .set mips16
26 .module fp=32
27 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
28 # CHECK-NEXT: .module fp=32
29 # CHECK-NEXT: ^
0 # RUN: not llvm-mc -triple mips-unknown-unknown %s 2>%t1
1 # RUN: FileCheck %s < %t1
2
3 .set mips0
4 .module fp=64
5 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
6
7 .llvm_internal_mips_reallow_module_directive
8 .module fp=32
9 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
10
11 .set mips1
12 .module fp=64
13 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
14
15 .llvm_internal_mips_reallow_module_directive
16 .module fp=32
17 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
18
19 .set mips2
20 .module fp=64
21 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
22
23 .llvm_internal_mips_reallow_module_directive
24 .module fp=32
25 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
26
27 .set mips3
28 .module fp=64
29 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
30
31 .llvm_internal_mips_reallow_module_directive
32 .module fp=32
33 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
34
35 .set mips4
36 .module fp=64
37 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
38
39 .llvm_internal_mips_reallow_module_directive
40 .module fp=32
41 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
42
43 .set mips5
44 .module fp=64
45 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
46
47 .llvm_internal_mips_reallow_module_directive
48 .module fp=32
49 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
50
51 .set mips32
52 .module fp=64
53 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
54
55 .llvm_internal_mips_reallow_module_directive
56 .module fp=32
57 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
58
59 .set mips32r2
60 .module fp=64
61 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
62
63 .llvm_internal_mips_reallow_module_directive
64 .module fp=32
65 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
66
67 .set mips32r6
68 .module fp=64
69 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
70
71 .llvm_internal_mips_reallow_module_directive
72 .module fp=32
73 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
74
75 .set mips64
76 .module fp=64
77 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
78
79 .llvm_internal_mips_reallow_module_directive
80 .module fp=32
81 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
82
83 .set mips64r2
84 .module fp=64
85 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
86
87 .llvm_internal_mips_reallow_module_directive
88 .module fp=32
89 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
90
91 .set mips64r6
92 .module fp=64
93 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
94
95 .llvm_internal_mips_reallow_module_directive
96 .module fp=32
97 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
98
99 .set arch=mips32
100 .module fp=64
101 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
102
103 .llvm_internal_mips_reallow_module_directive
104 .module fp=32
105 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
106
107 .set mips16
108 .module fp=64
109 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
110
111 .llvm_internal_mips_reallow_module_directive
112 .module fp=32
113 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
114
115 .set nomips16
116 .module fp=64
117 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
118
119 .llvm_internal_mips_reallow_module_directive
120 .module fp=32
121 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
122
123 .set micromips
124 .module fp=64
125 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
126
127 .llvm_internal_mips_reallow_module_directive
128 .module fp=32
129 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
130
131 .set nomicromips
132 .module fp=64
133 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
134
135 .llvm_internal_mips_reallow_module_directive
136 .module fp=32
137 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
138
139 .set msa
140 .module fp=64
141 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
142
143 .llvm_internal_mips_reallow_module_directive
144 .module fp=32
145 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
146
147 .set nomsa
148 .module fp=64
149 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
150
151 .llvm_internal_mips_reallow_module_directive
152 .module fp=32
153 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
154
155 .set dsp
156 .module fp=64
157 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
158
159 .llvm_internal_mips_reallow_module_directive
160 .module fp=32
161 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
162
163 .set nodsp
164 .module fp=64
165 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
166
167 .llvm_internal_mips_reallow_module_directive
168 .module fp=32
169 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
170
171 .set push
172 .module fp=64
173 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
174
175 .llvm_internal_mips_reallow_module_directive
176 .module fp=32
177 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
178
179 .set pop
180 .module fp=64
181 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
182
183 .llvm_internal_mips_reallow_module_directive
184 .module fp=32
185 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
186
187 .set reorder
188 .module fp=64
189 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
190
191 .llvm_internal_mips_reallow_module_directive
192 .module fp=32
193 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
194
195 .set noreorder
196 .module fp=64
197 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
198
199 .llvm_internal_mips_reallow_module_directive
200 .module fp=32
201 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
202
203 .set macro
204 .module fp=64
205 # FIXME: emitDirectiveSetMacro should call forbidModuleDirective().
206
207 .llvm_internal_mips_reallow_module_directive
208 .module fp=32
209 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
210
211 .set nomacro
212 .module fp=64
213 # FIXME: emitDirectiveSetNoMacro should call forbidModuleDirective().
214
215 .llvm_internal_mips_reallow_module_directive
216 .module fp=32
217 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
218
219 .set at
220 .module fp=64
221 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
222
223 .llvm_internal_mips_reallow_module_directive
224 .module fp=32
225 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
226
227 .set at=$3
228 .module fp=64
229 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
230
231 .llvm_internal_mips_reallow_module_directive
232 .module fp=32
233 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
234
235 .set noat
236 .module fp=64
237 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
238
239 .llvm_internal_mips_reallow_module_directive
240 .module fp=32
241 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
242
243 .set fp=32
244 .module fp=64
245 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
246
247 .llvm_internal_mips_reallow_module_directive
248 .module fp=32
249 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
250
251 .cpload $25
252 .module fp=64
253 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
254
255 .llvm_internal_mips_reallow_module_directive
256 .module fp=32
257 # CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
258
259 .cpsetup $25, 8, __cerror
260 .module fp=64
261 # CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code