1 Pull in r200383 from upstream llvm trunk (by David Majnemer):
3 MC: Reorganize macro MC test along dialect lines
5 This commit seeks to do two things:
6 - Run the surfeit of tests under the Darwin dialect. This ends up
7 affecting tests which assumed that spaces could deliminate arguments.
8 - The GAS dialect tests should limit their surface area to things that
9 could plausibly work under GAS. For example, Darwin style arguments
10 have no business being in such a test.
12 Pull in r201784 from upstream llvm trunk (by Benjamin Kramer):
14 AsmParser: Disable Darwin-style macro argument expansion on non-darwin targets.
16 There is code in the wild that relies on $0 not being expanded.
18 This fixes some cases of using $ signs in literals being incorrectly
21 Reported by: Richard Henderson
22 Upstream PR: http://llvm.org/PR21500
24 Introduced here: http://svnweb.freebsd.org/changeset/base/274286
26 Index: lib/MC/MCParser/AsmParser.cpp
27 ===================================================================
28 --- lib/MC/MCParser/AsmParser.cpp
29 +++ lib/MC/MCParser/AsmParser.cpp
30 @@ -1695,7 +1695,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
31 const MCAsmMacroParameters &Parameters,
32 const MCAsmMacroArguments &A, const SMLoc &L) {
33 unsigned NParameters = Parameters.size();
34 - if (NParameters != 0 && NParameters != A.size())
35 + if ((!IsDarwin || NParameters != 0) && NParameters != A.size())
36 return Error(L, "Wrong number of arguments");
38 // A macro without parameters is handled differently on Darwin:
39 @@ -1705,7 +1705,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
40 std::size_t End = Body.size(), Pos = 0;
41 for (; Pos != End; ++Pos) {
42 // Check for a substitution or escape.
44 + if (IsDarwin && !NParameters) {
45 // This macro has no parameters, look for $0, $1, etc.
46 if (Body[Pos] != '$' || Pos + 1 == End)
48 @@ -1728,7 +1728,7 @@ bool AsmParser::expandMacro(raw_svector_ostream &O
53 + if (IsDarwin && !NParameters) {
54 switch (Body[Pos + 1]) {
57 Index: test/MC/AsmParser/exprs.s
58 ===================================================================
59 --- test/MC/AsmParser/exprs.s
60 +++ test/MC/AsmParser/exprs.s
62 -// RUN: llvm-mc -triple i386-unknown-unknown %s > %t
63 +// RUN: llvm-mc -triple i386-apple-darwin %s
67 Index: test/MC/AsmParser/macros.s (deleted)
68 ===================================================================
69 Index: test/MC/AsmParser/macros-darwin.s
70 ===================================================================
71 --- test/MC/AsmParser/macros-darwin.s
72 +++ test/MC/AsmParser/macros-darwin.s
74 -// RUN: llvm-mc -triple i386-apple-darwin10 %s | FileCheck %s
75 +// RUN: not llvm-mc -triple i386-apple-darwin10 %s 2> %t.err | FileCheck %s
76 +// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
87 +// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
88 +// CHECK-ERRORS-NEXT: macrobody0
89 +// CHECK-ERRORS-NEXT: ^
90 +// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
91 +// CHECK-ERRORS-NEXT: .test0
92 +// CHECK-ERRORS-NEXT: ^
93 +// CHECK-ERRORS: 11:1: note: while in macro instantiation
94 +// CHECK-ERRORS-NEXT: .test1
95 +// CHECK-ERRORS-NEXT: ^
104 .globl "$0 $1 $2 $$3 $n"
107 // CHECK: .globl "1 23 $3 2"
111 +// CHECK: .globl "1 (23) $3 2"
114 +// CHECK: .globl "12 $3 1"
121 +// CHECK: .globl "(ab)(,)) -- (cd)"
122 +test4 (a b)(,)),(cd)
124 +// CHECK: .globl "(ab)(,)) -- (cd)"
125 +test4 (a b)(,)),(cd)
131 +// CHECK: .globl zed1
138 +// CHECK: .globl zed2
145 +// CHECK: .globl zed3
148 +.macro test8 _a, _b, _c
149 +.globl "\_a,\_b,\_c"
152 +.macro test9 _a _b _c
153 +.globl "\_a \_b \_c"
156 +// CHECK: .globl "a,b,c"
158 +// CHECK: .globl "%1,%2,%3"
159 +test8 %1, %2, %3 #a comment
160 +// CHECK: .globl "x-y,z,1"
162 +// CHECK: .globl "1 2 3"
166 +// CHECK-ERRORS: error: macro argument '_c' is missing
167 +// CHECK-ERRORS-NEXT: test8 1,2 3
168 +// CHECK-ERRORS-NEXT: ^
171 +// CHECK-ERRORS: error: macro argument '_c' is missing
172 +// CHECK-ERRORS-NEXT:test8 1 2, 3
173 +// CHECK-ERRORS-NEXT: ^
174 Index: test/MC/AsmParser/macros-gas.s
175 ===================================================================
176 --- test/MC/AsmParser/macros-gas.s
177 +++ test/MC/AsmParser/macros-gas.s
179 +// RUN: not llvm-mc -triple i386-linux-gnu %s 2> %t.err | FileCheck %s
180 +// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
190 +// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
191 +// CHECK-ERRORS-NEXT: macrobody0
192 +// CHECK-ERRORS-NEXT: ^
193 +// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
194 +// CHECK-ERRORS-NEXT: .test0
195 +// CHECK-ERRORS-NEXT: ^
196 +// CHECK-ERRORS: 11:1: note: while in macro instantiation
197 +// CHECK-ERRORS-NEXT: .test1
198 +// CHECK-ERRORS-NEXT: ^
206 +.macro test3 _a _b _c
207 +.ascii "\_a \_b \_c \\_c"
210 +// CHECK: .ascii "1 2 3 \003"
213 +// FIXME: test3 1, 2 3 should be treated like test 1, 2, 3
215 +// FIXME: remove the n argument from the remaining test3 examples
216 +// CHECK: .ascii "1 (23) n \n"
219 +// CHECK: .ascii "1 (23) n \n"
222 +// CHECK: .ascii "1 2 n \n"
229 +// CHECK: .globl zed1
236 +// CHECK: .globl zed2
243 +// CHECK: .globl zed3
246 +.macro test8 _a, _b, _c
247 +.ascii "\_a,\_b,\_c"
250 +.macro test9 _a _b _c
251 +.ascii "\_a \_b \_c"
254 +// CHECK: .ascii "a,b,c"
256 +// CHECK: .ascii "%1,%2,%3"
257 +test8 %1 %2 %3 #a comment
258 +// CHECK: .ascii "x-y,z,1"
260 +// CHECK: .ascii "1 2 3"
264 +// CHECK-ERRORS: error: macro argument '_c' is missing
265 +// CHECK-ERRORS-NEXT: test8 1,2 3
266 +// CHECK-ERRORS-NEXT: ^
269 +// CHECK-ERRORS: error: expected ' ' for macro argument separator
270 +// CHECK-ERRORS-NEXT:test8 1 2, 3
271 +// CHECK-ERRORS-NEXT: ^