1; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s 2 3.code 4 5identity MACRO arg 6 exitm <arg> 7endm 8 9argument_test PROC 10; CHECK-LABEL: argument_test: 11 12 mov eax, identity(2) 13; CHECK: mov eax, 2 14 15 ret 16argument_test ENDP 17 18argument_with_parens_test PROC 19; CHECK-LABEL: argument_with_parens_test: 20 21 mov eax, identity((3)) 22; CHECK: mov eax, 3 23 mov eax, identity(((4-1)-1)) 24; CHECK: mov eax, 2 25 26 ret 27argument_with_parens_test ENDP 28 29offsetof MACRO structure, field 30 EXITM <structure.&field> 31ENDM 32 33S1 STRUCT 34 W byte 0 35 X byte 0 36 Y byte 0 37S1 ENDS 38 39substitutions_test PROC 40; CHECK-LABEL: substitutions_test: 41 42 mov eax, offsetof(S1, X) 43; CHECK: mov eax, 1 44 mov eax, offsetof(S1, Y) 45; CHECK: mov eax, 2 46 47 ret 48substitutions_test ENDP 49 50repeated_invocations_test PROC 51; CHECK-LABEL: repeated_invocations_test: 52 53 mov eax, identity(identity(1)) 54; CHECK: mov eax, 1 55 56 ret 57repeated_invocations_test ENDP 58 59factorial MACRO n 60 IF n LE 1 61 EXITM <(1)> 62 ELSE 63 EXITM <(n)*factorial(n-1)> 64 ENDIF 65ENDM 66 67; NOTE: This version is more sensitive to unintentional end-of-statement tokens. 68factorial2 MACRO n 69 IF n LE 1 70 EXITM <(1)> 71 ELSE 72 EXITM <(n)*(factorial(n-1))> 73 ENDIF 74ENDM 75 76string_recursive_test PROC 77; CHECK-LABEL: string_recursive_test: 78 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 85 86 ret 87string_recursive_test ENDP 88 89fibonacci MACRO n 90 IF n LE 2 91 EXITM %1 92 ELSE 93 EXITM %fibonacci(n-1)+fibonacci(n-2) 94 ENDIF 95ENDM 96 97expr_recursive_test PROC 98; CHECK-LABEL: expr_recursive_test: 99 100 mov eax, fibonacci(10) 101; CHECK: mov eax, 55 102 103 ret 104expr_recursive_test ENDP 105 106custom_strcat MACRO arg1, arg2 107 EXITM <arg1&arg2> 108ENDM 109 110expand_as_directive_test custom_strcat(P, ROC) 111; CHECK-LABEL: expand_as_directive_test: 112 113 ret 114expand_as_directive_test ENDP 115 116end 117