Skip to content

Commit

Permalink
[ms] [llvm-ml] Add initial MASM STRUCT/UNION support
Browse files Browse the repository at this point in the history
Summary:
Add support for user-defined types to MasmParser, including initialization and field access.

Known issues:
- Omitted entry initializers (e.g., <,0>) do not work consistently for nested structs/arrays.
- Size checking/inference for values with known types is not yet implemented.
- Some ml64.exe syntaxes for accessing STRUCT fields are not recognized.
  - `[<register>.<struct name>].<field>`
  - `[<register>[<struct name>.<field>]]`
  - `(<struct name> PTR [<register>]).<field>`
  - `[<variable>.<struct name>].<field>`
  - `(<struct name> PTR <variable>).<field>`

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D75306
  • Loading branch information
ericastor committed Jul 7, 2020
1 parent 24ed3a9 commit bc8e262
Show file tree
Hide file tree
Showing 6 changed files with 1,646 additions and 233 deletions.
5 changes: 5 additions & 0 deletions llvm/include/llvm/MC/MCParser/MCAsmParser.h
Expand Up @@ -170,6 +170,11 @@ class MCAsmParser {

virtual bool isParsingMasm() const { return false; }

virtual bool LookUpFieldOffset(StringRef Base, StringRef Member,
unsigned &Offset) {
return true;
}

/// Parse MS-style inline assembly.
virtual bool parseMSInlineAsm(
void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
Expand Up @@ -334,7 +334,7 @@ class MCTargetAsmParser : public MCAsmParserExtension {

/// SemaCallback - The Sema callback implementation. Must be set when parsing
/// ms-style inline assembly.
MCAsmParserSemaCallback *SemaCallback;
MCAsmParserSemaCallback *SemaCallback = nullptr;

/// Set of options which affects instrumentation of inline assembly.
MCTargetOptions MCOptions;
Expand Down

0 comments on commit bc8e262

Please sign in to comment.