• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s
2
3.data
4
5x1 DWORD ?
6x2 DWORD ?
7xa1 DWORD ?
8
9.code
10
11substitution_macro macro a1:req, a2:=<7>
12  mov eax, a1
13  mov eax, a1&
14  mov eax, &a1
15  mov eax, &a1&
16
17  mov eax, xa1
18  mov eax, x&a1
19  mov eax, x&a1&
20
21  mov eax, a2
22  mov eax, a2&
23  mov eax, &a2
24  mov eax, &a2&
25endm
26
27substitution_test_with_default PROC
28; CHECK-LABEL: substitution_test_with_default:
29
30  substitution_macro 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
42
43  ret
44substitution_test_with_default ENDP
45
46substitution_test_with_value PROC
47; CHECK-LABEL: substitution_test_with_value:
48
49  substitution_macro 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
61
62  ret
63substitution_test_with_value ENDP
64
65ambiguous_substitution_macro MACRO x, y
66  x&y BYTE 0
67ENDM
68
69ambiguous_substitution_test PROC
70; CHECK-LABEL: ambiguous_substitution_test:
71
72; should expand to ab BYTE 0
73  ambiguous_substitution_macro a, b
74
75; CHECK: ab:
76; CHECK-NOT: ay:
77; CHECK-NOT: xb:
78; CHECK-NOT: xy:
79ambiguous_substitution_test ENDP
80
81ambiguous_substitution_in_string_macro MACRO x, y
82  BYTE "x&y"
83ENDM
84
85ambiguous_substitution_in_string_test PROC
86; CHECK-LABEL: ambiguous_substitution_in_string_test:
87
88; should expand to BYTE "5y"
89  ambiguous_substitution_in_string_macro 5, 7
90
91; CHECK: .byte 53
92; CHECK-NEXT: .byte 121
93; CHECK-NOT: .byte
94ambiguous_substitution_in_string_test ENDP
95
96optional_parameter_macro MACRO a1:req, a2
97  mov eax, a1
98IFNB <a2>
99  mov eax, a2
100ENDIF
101  ret
102ENDM
103
104optional_parameter_test PROC
105; CHECK-LABEL: optional_parameter_test:
106
107  optional_parameter_macro 4
108; CHECK: mov eax, 4
109; CHECK: ret
110
111  optional_parameter_macro 5, 9
112; CHECK: mov eax, 5
113; CHECK: mov eax, 9
114; CHECK: ret
115optional_parameter_test ENDP
116
117local_symbol_macro MACRO
118  LOCAL a
119a: ret
120   jmp a
121ENDM
122
123local_symbol_test PROC
124; CHECK-LABEL: local_symbol_test:
125
126  local_symbol_macro
127; CHECK: "??0000":
128; CHECK-NEXT: ret
129; CHECK-NEXT: jmp "??0000"
130
131  local_symbol_macro
132; CHECK: "??0001":
133; CHECK-NEXT: ret
134; CHECK-NEXT: jmp "??0001"
135local_symbol_test ENDP
136
137PURGE ambiguous_substitution_macro, local_symbol_macro,
138      optional_parameter_macro
139
140; Redefinition
141local_symbol_macro MACRO
142  LOCAL b
143b: xor eax, eax
144   jmp b
145ENDM
146
147purge_test PROC
148; CHECK-LABEL: purge_test:
149
150  local_symbol_macro
151; CHECK: "??0002":
152; CHECK-NEXT: xor eax, eax
153; CHECK-NEXT: jmp "??0002"
154purge_test ENDP
155
156END
157