[ms] [llvm-ml] Add a draft MASM parser
authorEric Astor <epastor@google.com>
Sun, 16 Feb 2020 17:29:51 +0000 (12:29 -0500)
committerEric Astor <epastor@google.com>
Sun, 16 Feb 2020 17:30:46 +0000 (12:30 -0500)
commitee2c0f76d74cc03e54389926c9e626987e1408c3
tree79cfbfe544ac826a96ba6600ac000687f52630b4
parent5f7b92b1b4d6941051380a9fd5b2b85718cce1c2
[ms] [llvm-ml] Add a draft MASM parser

Summary:
Many directives are unavailable, and support for others may be limited.

This first draft has preliminary support for:
    - conditional directives (including errors),
    - data allocation (unsigned types up to 8 bytes, and ALIGN),
    - equates/variables (numeric and text),
    - and procedure directives (without parameters),
as well as COMMENT, ECHO, INCLUDE, INCLUDELIB, PUBLIC, and EXTERN. Text variables (aka text macros) are expanded in-place wherever the identifier occurs.

We deliberately ignore all ml.exe processor directives.

Prominent features not yet supported:
    - structs
    - macros (both procedures and functions)
    - procedures (with specified parameters)
    - substitution & expansion operators

Conditional directives are complicated by the fact that "ifdef rax" is a valid way to check if a file is being assembled for a 64-bit x86 processor; we add support for "ifdef <register>" in general, which requires adding a tryParseRegister method to all MCTargetAsmParsers. (Some targets require backtracking in the non-register case.)

Reviewers: rnk, thakis

Reviewed By: thakis

Subscribers: kerbowa, merge_guards_bot, wuzish, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, mgorny, sbc100, jgravelle-google, hiraditya, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, Jim, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D72680
19 files changed:
llvm/include/llvm/MC/MCAsmInfo.h
llvm/include/llvm/MC/MCParser/AsmLexer.h
llvm/include/llvm/MC/MCParser/MCAsmParser.h
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/MC/MCTargetOptions.h
llvm/lib/MC/MCParser/AsmLexer.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/CMakeLists.txt
llvm/lib/MC/MCParser/COFFMasmParser.cpp [new file with mode: 0644]
llvm/lib/MC/MCParser/MCAsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp [new file with mode: 0644]
llvm/lib/MC/MCTargetOptions.cpp
llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.h
llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
llvm/test/tools/llvm-ml/basic.test
llvm/test/tools/llvm-ml/lit.local.cfg [new file with mode: 0644]
llvm/tools/llvm-ml/llvm-ml.cpp
llvm/utils/gn/secondary/llvm/lib/MC/MCParser/BUILD.gn