Skip to content

[ms] [llvm-ml] Support macros with parenthesis and commas delimiters between arguments #132074

@MisterDA

Description

@MisterDA

I have a MASM file that has a macro that I call with parenthesis and which uses a comma as a delimiter between arguments, as parameters may contain spaces:

        i = 0
SubstitutionMacro MACRO _type:REQ, name:REQ
        field_&name EQU i
        i = i + 1
        EXITM <>
ENDM

SubstitutionMacro(int, a)
SubstitutionMacro(int*, b)
SubstitutionMacro(struct type, c)
SubstitutionMacro(struct type*, d)
        .CODE
        mov r12, field_a
        mov r13, field_b
        mov r14, field_c
        mov r15, field_d
        END

llvm-ml currently fails at assembling this file:

$ ml64 -nologo -Cp -c -Fo test.obj test.asm
 Assembling: test.asm
$ objdump -D --section='.text$mn' test.obj

test.obj:     file format pe-x86-64


Disassembly of section .text$mn:

0000000000000000 <.text$mn>:
   0:   49 c7 c4 00 00 00 00    mov    $0x0,%r12
   7:   49 c7 c5 01 00 00 00    mov    $0x1,%r13
   e:   49 c7 c6 02 00 00 00    mov    $0x2,%r14
  15:   49 c7 c7 03 00 00 00    mov    $0x3,%r15
$ llvm-ml64 -c -Fo test.obj test.asm
test.asm:10:40: error: too many positional arguments
        SubstitutionMacro(struct type, c)
                                       ^
test.asm:10:41: error: expected section directive before assembly directive
        SubstitutionMacro(struct type, c)
                                        ^
test.asm:11:41: error: too many positional arguments
        SubstitutionMacro(struct type*, d)
                                        ^

Cf #129905 cc @ericastor

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm-toolsAll llvm tools that do not have corresponding tag

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions