macros-gas.s
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// RUN: not llvm-mc -triple i386-linux-gnu %s 2> %t.err | FileCheck %s
// RUN: FileCheck --check-prefix=CHECK-ERRORS %s < %t.err
.macro .test0
.macrobody0
.endm
.macro .test1
.test0
.endm
.test1
// CHECK-ERRORS: <instantiation>:1:1: error: unknown directive
// CHECK-ERRORS-NEXT: macrobody0
// CHECK-ERRORS-NEXT: ^
// CHECK-ERRORS: <instantiation>:1:1: note: while in macro instantiation
// CHECK-ERRORS-NEXT: .test0
// CHECK-ERRORS-NEXT: ^
// CHECK-ERRORS: 11:1: note: while in macro instantiation
// CHECK-ERRORS-NEXT: .test1
// CHECK-ERRORS-NEXT: ^
.macro test2 _a
.byte \_a
.endm
// CHECK: .byte 10
test2 10
.macro test3 _a _b _c
.ascii "\_a \_b \_c \\_c"
.endm
// CHECK: .ascii "1 2 3 \003"
test3 1, 2, 3
// CHECK: .ascii "1 2 3 \003"
test3 1, 2 3
.macro test3_prime _a _b _c
.ascii "\_a \_b \_c"
.endm
// CHECK: .ascii "1 (2 3) "
test3_prime 1, (2 3)
// CHECK: .ascii "1 (2 3) "
test3_prime 1 (2 3)
// CHECK: .ascii "1 2 "
test3_prime 1 2
.macro test5 _a
.globl \_a
.endm
// CHECK: .globl zed1
test5 zed1
.macro test6 $a
.globl \$a
.endm
// CHECK: .globl zed2
test6 zed2
.macro test7 .a
.globl \.a
.endm
// CHECK: .globl zed3
test7 zed3
.macro test8 _a, _b, _c
.ascii "\_a,\_b,\_c"
.endm
.macro test9 _a _b _c
.ascii "\_a \_b \_c"
.endm
// CHECK: .ascii "a,b,c"
test8 a, b, c
// CHECK: .ascii "%1,%2,%3"
test8 %1 %2 %3 #a comment
// CHECK: .ascii "x-y,z,1"
test8 x - y z 1
// CHECK: .ascii "1 2 3"
test9 1, 2,3
// CHECK: .ascii "1,2,3"
test8 1,2 3
// CHECK: .ascii "1,2,3"
test8 1 2, 3
.macro test10
.ascii "$20"
.endm
test10
// CHECK: .ascii "$20"
test10 42
// CHECK-ERRORS: 102:10: error: Wrong number of arguments
// CHECK-ERRORS-NEXT: test10 42
// CHECK-ERRORS-NEXT: ^