[llvm-dev] [ms] RFC: MASM support
Eric Astor via llvm-dev
llvm-dev at lists.llvm.org
Thu Nov 21 05:35:57 PST 2019
I'm proposing to add MASM support to LLVM's assembler capabilities, which
should nearly complete LLVM's support for cross-platform Windows
Goal: Match the functionality of Microsoft's ml.exe and ml64.exe.
I'm currently trying to implement this as a set of extensions to the
assembler; it will correctly handle assembly files containing both GNU and
The features would be added to AsmParser and controlled via MCAsmInfo, and
would be available through both llvm-mc and clang. Both tools would remain
able to parse GNU-syntax assembler, but when passed the appropriate flags,
would also handle MASM. My first thought is to trigger MASM support
whenever we're targeting Windows, but we could also make it a discrete
function controlled by a different command-line flag.
We will also define a new driver (llvm-ml) that matches the command-line
interface of ml.exe and/or ml64.exe. This will likely be similar to
clang-cl and llvm-lib in building on top of a previous driver: either
llvm-mc or clang.
1. Support for "ifdef <register>": already completed, with a new
tryParseRegister method added to all TargetAsmParsers.
2. Syntax variations: MASM uses infix notation for many directives, and
does not use "."-prefixes on its directives.
3. Macro functions: MASM includes macro functions, which can emit
parameters and not just full instructions. (Probably tricky.)
4. Richer macro language in general: some MASM files rely heavily on
text-substitution for named symbols, as well as resolution of fields in
3 & 4 might be best handled by adding a preprocessor stage, but the syntax
is not similar to the C preprocessor... I'm going to try to augmenting
existing macro support first.
Any obstacles I've missed, or critiques of the approaches, would be very
- Eric Astor
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev