macro-arg.s
1.8 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
# RUN: llvm-mc -triple=x86_64 %s | FileCheck %s
.macro empty, cond
.endm
empty ne
# CHECK: .ascii "3 \003"
.macro escape a
.ascii "\a \\a"
.endm
escape 3
.macro double first = -1, second = -1
.long \first
.long \second
.endm
# CHECK: .long -1
# CHECK-NEXT: .long -1
# CHECK-EMPTY:
double
# CHECK: .long -1
# CHECK-NEXT: .long -1
# CHECK-EMPTY:
double ,
# CHECK: .long 1
# CHECK-NEXT: .long -1
double 1
# CHECK: .long 2
# CHECK-NEXT: .long 3
double 2, 3
# CHECK: .long -1
# CHECK-NEXT: .long 4
double , 4
# CHECK: .long 5
# CHECK-NEXT: .long 6
double 5, second = 6
# CHECK: .long 7
# CHECK-NEXT: .long -1
double first = 7
# CHECK: .long -1
# CHECK-NEXT: .long 8
double second = 8
# CHECK: .long 10
# CHECK-NEXT: .long 9
double second = 9, first = 10
# CHECK: .long second+11
# CHECK-NEXT: .long -1
double second + 11
# CHECK: .long -1
# CHECK-NEXT: .long second+12
double , second + 12
# CHECK: .long second
# CHECK-NEXT: .long -1
double second
.macro mixed arg0 = 0, arg1 = 1 arg2 = 2, arg3 = 3
.long \arg0
.long \arg1
.long \arg2
.long \arg3
.endm
# CHECK: .long 1
# CHECK-NEXT: .long 2
# CHECK-NEXT: .long 3
# CHECK-NEXT: .long 3
mixed 1, 2 3
# CHECK: .long 1
# CHECK-NEXT: .long 2
# CHECK-NEXT: .long 3
# CHECK-NEXT: .long 3
mixed 1 2, 3
# CHECK: .long 1
# CHECK-NEXT: .long 2
# CHECK-NEXT: .long 3
# CHECK-NEXT: .long 4
mixed 1 2, 3 4
.macro ascii3 _a _b _c
.ascii "\_a|\_b|\_c"
.endm
## 3 arguments.
# CHECK: .ascii "a|b|c"
ascii3 a, b, c
# CHECK: .ascii "%1|%2|%3"
ascii3 %1 %2 %3
# CHECK: .ascii "1|2|3"
ascii3 1, 2,3
# CHECK: .ascii "1|2|3"
ascii3 1,2 3
# CHECK: .ascii "1|2|3"
ascii3 1 2, 3
# CHECK: .ascii "x-y|z|1"
ascii3 x - y z 1
## 2 arguments.
# CHECK: .ascii "1|(2 3)|"
ascii3 1, (2 3)
# CHECK: .ascii "1|(2 3)|"
ascii3 1 (2 3)