1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
Eric Astor 5e9623a87c [ms] [llvm-ml] Enable support for MASM-style macro procedures
Allows the MACRO directive to define macro procedures with parameters and macro-local symbols.

Supports required and optional parameters (including default values), and matches ml64.exe for its macro-local symbol handling (up to 65536 macro-local symbols in any translation unit).

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D89729
2020-11-04 10:29:57 -05:00

107 lines
1.9 KiB
Plaintext

; RUN: llvm-ml -m64 -filetype=asm %s | FileCheck %s
.data
x1 DWORD ?
x2 DWORD ?
xa1 DWORD ?
.code
substitution_macro macro a1:req, a2:=<7>
mov eax, a1
mov eax, a1&
mov eax, &a1
mov eax, &a1&
mov eax, xa1
mov eax, x&a1
mov eax, x&a1&
mov eax, a2
mov eax, a2&
mov eax, &a2
mov eax, &a2&
endm
substitution_test_with_default PROC
; CHECK-LABEL: substitution_test_with_default:
substitution_macro 1
; CHECK: mov eax, 1
; CHECK-NEXT: mov eax, 1
; CHECK-NEXT: mov eax, 1
; CHECK-NEXT: mov eax, 1
; CHECK: mov eax, dword ptr [rip + xa1]
; CHECK-NEXT: mov eax, dword ptr [rip + x1]
; CHECK-NEXT: mov eax, dword ptr [rip + x1]
; CHECK: mov eax, 7
; CHECK-NEXT: mov eax, 7
; CHECK-NEXT: mov eax, 7
; CHECK-NEXT: mov eax, 7
ret
substitution_test_with_default ENDP
substitution_test_with_value PROC
; CHECK-LABEL: substitution_test_with_value:
substitution_macro 2, 8
; CHECK: mov eax, 2
; CHECK-NEXT: mov eax, 2
; CHECK-NEXT: mov eax, 2
; CHECK-NEXT: mov eax, 2
; CHECK: mov eax, dword ptr [rip + xa1]
; CHECK-NEXT: mov eax, dword ptr [rip + x2]
; CHECK-NEXT: mov eax, dword ptr [rip + x2]
; CHECK: mov eax, 8
; CHECK-NEXT: mov eax, 8
; CHECK-NEXT: mov eax, 8
; CHECK-NEXT: mov eax, 8
ret
substitution_test_with_value ENDP
optional_parameter_macro MACRO a1:req, a2
mov eax, a1
IFNB <a2>
mov eax, a2
ENDIF
ret
ENDM
optional_parameter_test PROC
; CHECK-LABEL: optional_parameter_test:
optional_parameter_macro 4
; CHECK: mov eax, 4
; CHECK: ret
optional_parameter_macro 5, 9
; CHECK: mov eax, 5
; CHECK: mov eax, 9
; CHECK: ret
optional_parameter_test ENDP
local_symbol_macro MACRO
LOCAL a
a: ret
jmp a
ENDM
local_symbol_test PROC
; CHECK-LABEL: local_symbol_test:
local_symbol_macro
; CHECK: "??0000":
; CHECK-NEXT: ret
; CHECK-NEXT: jmp "??0000"
local_symbol_macro
; CHECK: "??0001":
; CHECK-NEXT: ret
; CHECK-NEXT: jmp "??0001"
local_symbol_test ENDP
END