[NFC][RemoveDIs] Prefer iterators over inst-pointers in InstCombine
[llvm-project.git] / llvm / test / tools / llvm-ml / macro_function.asm
blobc28d7c8c6222cf6d5e806a5ea5eb6c300fde6423
1 ; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s
3 .code
5 identity MACRO arg
6 exitm <arg>
7 endm
9 argument_test PROC
10 ; CHECK-LABEL: argument_test:
12 mov eax, identity(2)
13 ; CHECK: mov eax, 2
15 ret
16 argument_test ENDP
18 argument_with_parens_test PROC
19 ; CHECK-LABEL: argument_with_parens_test:
21 mov eax, identity((3))
22 ; CHECK: mov eax, 3
23 mov eax, identity(((4-1)-1))
24 ; CHECK: mov eax, 2
26 ret
27 argument_with_parens_test ENDP
29 offsetof MACRO structure, field
30 EXITM <structure.&field>
31 ENDM
33 S1 STRUCT
34 W byte 0
35 X byte 0
36 Y byte 0
37 S1 ENDS
39 substitutions_test PROC
40 ; CHECK-LABEL: substitutions_test:
42 mov eax, offsetof(S1, X)
43 ; CHECK: mov eax, 1
44 mov eax, offsetof(S1, Y)
45 ; CHECK: mov eax, 2
47 ret
48 substitutions_test ENDP
50 repeated_invocations_test PROC
51 ; CHECK-LABEL: repeated_invocations_test:
53 mov eax, identity(identity(1))
54 ; CHECK: mov eax, 1
56 ret
57 repeated_invocations_test ENDP
59 factorial MACRO n
60 IF n LE 1
61 EXITM <(1)>
62 ELSE
63 EXITM <(n)*factorial(n-1)>
64 ENDIF
65 ENDM
67 ; NOTE: This version is more sensitive to unintentional end-of-statement tokens.
68 factorial2 MACRO n
69 IF n LE 1
70 EXITM <(1)>
71 ELSE
72 EXITM <(n)*(factorial(n-1))>
73 ENDIF
74 ENDM
76 string_recursive_test PROC
77 ; CHECK-LABEL: string_recursive_test:
79 mov eax, factorial(5)
80 ; CHECK: mov eax, 120
81 mov eax, factorial2(4)
82 ; CHECK: mov eax, 24
83 mov eax, 11 + factorial(6) - 11
84 ; CHECK: mov eax, 720
86 ret
87 string_recursive_test ENDP
89 fibonacci MACRO n
90 IF n LE 2
91 EXITM %1
92 ELSE
93 EXITM %fibonacci(n-1)+fibonacci(n-2)
94 ENDIF
95 ENDM
97 expr_recursive_test PROC
98 ; CHECK-LABEL: expr_recursive_test:
100 mov eax, fibonacci(10)
101 ; CHECK: mov eax, 55
104 expr_recursive_test ENDP
106 custom_strcat MACRO arg1, arg2
107 EXITM <arg1&arg2>
108 ENDM
110 expand_as_directive_test custom_strcat(P, ROC)
111 ; CHECK-LABEL: expand_as_directive_test:
114 expand_as_directive_test ENDP