Alan Zhao 8a1b5f2680 [llvm-ml] Add support for extern proc
EXTERN PROC isn't really well documented in MSVC, so after poking around
it seems as if it's just a regular extern symbol.

Interestingly enough, under MSVC the following is allowed:

extern foo:proc

mov eax, foo

MSVC will output:

mov eax, 0

while llvm-ml will currently output:

mov eax, dword ptr [foo]

(since foo is an extern)

Arguably, llvm-ml's output makes more sense, even though it's
inconsistent with MSVC ml. However, since moving an extern proc symbol
to a register doesn't really make sense in the first place, we'll treat
it as undefined behavior for now.

Reviewed By: epastor

Differential Revision: https://reviews.llvm.org/D125582
2022-05-13 17:20:55 -04:00

19 lines
477 B
NASM

; RUN: llvm-ml -m32 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-32
; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s --check-prefixes=CHECK,CHECK-64
extern foo : dword, bar : word, baz : proc
; CHECK: .extern foo
; CHECK: .extern bar
; CHECK: .extern baz
.code
mov ebx, foo
; CHECK-32: mov ebx, dword ptr [foo]
; CHECK-64: mov ebx, dword ptr [rip + foo]
mov bx, bar
; CHECK-32: mov bx, word ptr [bar]
; CHECK-64: mov bx, word ptr [rip + bar]
END