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 105 106 107 108 109 110 111 112 113 114 115 116
|
; RUN: llvm-ml -filetype=s %s /Fo - | FileCheck %s
.code
identity MACRO arg
exitm <arg>
endm
argument_test PROC
; CHECK-LABEL: argument_test:
mov eax, identity(2)
; CHECK: mov eax, 2
ret
argument_test ENDP
argument_with_parens_test PROC
; CHECK-LABEL: argument_with_parens_test:
mov eax, identity((3))
; CHECK: mov eax, 3
mov eax, identity(((4-1)-1))
; CHECK: mov eax, 2
ret
argument_with_parens_test ENDP
offsetof MACRO structure, field
EXITM <structure.&field>
ENDM
S1 STRUCT
W byte 0
X byte 0
Y byte 0
S1 ENDS
substitutions_test PROC
; CHECK-LABEL: substitutions_test:
mov eax, offsetof(S1, X)
; CHECK: mov eax, 1
mov eax, offsetof(S1, Y)
; CHECK: mov eax, 2
ret
substitutions_test ENDP
repeated_invocations_test PROC
; CHECK-LABEL: repeated_invocations_test:
mov eax, identity(identity(1))
; CHECK: mov eax, 1
ret
repeated_invocations_test ENDP
factorial MACRO n
IF n LE 1
EXITM <(1)>
ELSE
EXITM <(n)*factorial(n-1)>
ENDIF
ENDM
; NOTE: This version is more sensitive to unintentional end-of-statement tokens.
factorial2 MACRO n
IF n LE 1
EXITM <(1)>
ELSE
EXITM <(n)*(factorial(n-1))>
ENDIF
ENDM
string_recursive_test PROC
; CHECK-LABEL: string_recursive_test:
mov eax, factorial(5)
; CHECK: mov eax, 120
mov eax, factorial2(4)
; CHECK: mov eax, 24
mov eax, 11 + factorial(6) - 11
; CHECK: mov eax, 720
ret
string_recursive_test ENDP
fibonacci MACRO n
IF n LE 2
EXITM %1
ELSE
EXITM %fibonacci(n-1)+fibonacci(n-2)
ENDIF
ENDM
expr_recursive_test PROC
; CHECK-LABEL: expr_recursive_test:
mov eax, fibonacci(10)
; CHECK: mov eax, 55
ret
expr_recursive_test ENDP
custom_strcat MACRO arg1, arg2
EXITM <arg1&arg2>
ENDM
expand_as_directive_test custom_strcat(P, ROC)
; CHECK-LABEL: expand_as_directive_test:
ret
expand_as_directive_test ENDP
end
|