[Instrumentation] Fix a warning
[llvm-project.git] / llvm / test / tools / llvm-ml / macro.asm
blob3c81b89414fc77f4eb62c448598a35ce1b38e609
1 ; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
3 .data
5 x1 DWORD ?
6 x2 DWORD ?
7 xa1 DWORD ?
9 .code
11 SubstitutionMacro macro a1:req, a2:=<7>
12 mov eax, a1
13 mov eax, a1&
14 mov eax, &a1
15 mov eax, &a1&
17 mov eax, xa1
18 mov eax, x&a1
19 mov eax, x&a1&
21 mov eax, a2
22 mov eax, a2&
23 mov eax, &a2
24 mov eax, &a2&
25 endm
27 substitution_test_with_default PROC
28 ; CHECK-LABEL: substitution_test_with_default:
30 SubstitutionMacro 1
31 ; CHECK: mov eax, 1
32 ; CHECK-NEXT: mov eax, 1
33 ; CHECK-NEXT: mov eax, 1
34 ; CHECK-NEXT: mov eax, 1
35 ; CHECK: mov eax, dword ptr [rip + xa1]
36 ; CHECK-NEXT: mov eax, dword ptr [rip + x1]
37 ; CHECK-NEXT: mov eax, dword ptr [rip + x1]
38 ; CHECK: mov eax, 7
39 ; CHECK-NEXT: mov eax, 7
40 ; CHECK-NEXT: mov eax, 7
41 ; CHECK-NEXT: mov eax, 7
43 ret
44 substitution_test_with_default ENDP
46 substitution_test_with_value PROC
47 ; CHECK-LABEL: substitution_test_with_value:
49 SubstitutionMacro 2, 8
50 ; CHECK: mov eax, 2
51 ; CHECK-NEXT: mov eax, 2
52 ; CHECK-NEXT: mov eax, 2
53 ; CHECK-NEXT: mov eax, 2
54 ; CHECK: mov eax, dword ptr [rip + xa1]
55 ; CHECK-NEXT: mov eax, dword ptr [rip + x2]
56 ; CHECK-NEXT: mov eax, dword ptr [rip + x2]
57 ; CHECK: mov eax, 8
58 ; CHECK-NEXT: mov eax, 8
59 ; CHECK-NEXT: mov eax, 8
60 ; CHECK-NEXT: mov eax, 8
62 ret
63 substitution_test_with_value ENDP
65 substitution_test_lowercase PROC
66 ; CHECK-LABEL: substitution_test_lowercase:
68 substitutionmacro 2, 8
69 ; CHECK: mov eax, 2
70 ; CHECK-NEXT: mov eax, 2
71 ; CHECK-NEXT: mov eax, 2
72 ; CHECK-NEXT: mov eax, 2
73 ; CHECK: mov eax, dword ptr [rip + xa1]
74 ; CHECK-NEXT: mov eax, dword ptr [rip + x2]
75 ; CHECK-NEXT: mov eax, dword ptr [rip + x2]
76 ; CHECK: mov eax, 8
77 ; CHECK-NEXT: mov eax, 8
78 ; CHECK-NEXT: mov eax, 8
79 ; CHECK-NEXT: mov eax, 8
81 ret
82 substitution_test_lowercase ENDP
84 substitution_test_uppercase PROC
85 ; CHECK-LABEL: substitution_test_uppercase:
87 SUBSTITUTIONMACRO 2, 8
88 ; CHECK: mov eax, 2
89 ; CHECK-NEXT: mov eax, 2
90 ; CHECK-NEXT: mov eax, 2
91 ; CHECK-NEXT: mov eax, 2
92 ; CHECK: mov eax, dword ptr [rip + xa1]
93 ; CHECK-NEXT: mov eax, dword ptr [rip + x2]
94 ; CHECK-NEXT: mov eax, dword ptr [rip + x2]
95 ; CHECK: mov eax, 8
96 ; CHECK-NEXT: mov eax, 8
97 ; CHECK-NEXT: mov eax, 8
98 ; CHECK-NEXT: mov eax, 8
101 substitution_test_uppercase ENDP
103 AmbiguousSubstitutionMacro MACRO x, y
104 x&y BYTE 0
105 ENDM
107 ambiguous_substitution_test PROC
108 ; CHECK-LABEL: ambiguous_substitution_test:
110 ; should expand to ab BYTE 0
111 AmbiguousSubstitutionMacro a, b
113 ; CHECK: ab:
114 ; CHECK-NOT: ay:
115 ; CHECK-NOT: xb:
116 ; CHECK-NOT: xy:
117 ambiguous_substitution_test ENDP
119 AmbiguousSubstitutionInStringMacro MACRO x, y
120 BYTE "x&y"
121 ENDM
123 ambiguous_substitution_in_string_test PROC
124 ; CHECK-LABEL: ambiguous_substitution_in_string_test:
126 ; should expand to BYTE "5y"
127 AmbiguousSubstitutionInStringMacro 5, 7
129 ; CHECK: .byte 53
130 ; CHECK-NEXT: .byte 121
131 ; CHECK-NOT: .byte
132 ambiguous_substitution_in_string_test ENDP
134 OptionalParameterMacro MACRO a1:req, a2
135 mov eax, a1
136 IFNB <a2>
137 mov eax, a2
138 ENDIF
140 ENDM
142 optional_parameter_test PROC
143 ; CHECK-LABEL: optional_parameter_test:
145 OptionalParameterMacro 4
146 ; CHECK: mov eax, 4
147 ; CHECK: ret
149 OptionalParameterMacro 5, 9
150 ; CHECK: mov eax, 5
151 ; CHECK: mov eax, 9
152 ; CHECK: ret
153 optional_parameter_test ENDP
155 LocalSymbolMacro MACRO
156 LOCAL a
157 a: ret
158 jmp a
159 ENDM
161 local_symbol_test PROC
162 ; CHECK-LABEL: local_symbol_test:
164 LocalSymbolMacro
165 ; CHECK: "??0000":
166 ; CHECK-NEXT: ret
167 ; CHECK-NEXT: jmp "??0000"
169 LocalSymbolMacro
170 ; CHECK: "??0001":
171 ; CHECK-NEXT: ret
172 ; CHECK-NEXT: jmp "??0001"
173 local_symbol_test ENDP
175 PURGE AmbiguousSubstitutionMacro, LocalSymbolMacro,
176 OptionalParameterMacro
178 ; Redefinition
179 LocalSymbolMacro MACRO
180 LOCAL b
181 b: xor eax, eax
182 jmp b
183 ENDM
185 purge_test PROC
186 ; CHECK-LABEL: purge_test:
188 LocalSymbolMacro
189 ; CHECK: "??0002":
190 ; CHECK-NEXT: xor eax, eax
191 ; CHECK-NEXT: jmp "??0002"
192 purge_test ENDP