[WebAssembly] Added initial AsmParser implementation.
authorDerek Schuff <dschuff@google.com>
Tue, 20 Mar 2018 20:06:35 +0000 (20:06 +0000)
committerDerek Schuff <dschuff@google.com>
Tue, 20 Mar 2018 20:06:35 +0000 (20:06 +0000)
commite4825975d83ce596ddcd385ec91fab5b8caf4bc4
tree1c3737f99284e3fbd5a0b4a18cd10b11775fefc3
parent36afbee1d81905d9b6d3a5e1868c7c8be2c3d877
[WebAssembly] Added initial AsmParser implementation.

It uses the MC framework and the tablegen matcher to do the
heavy lifting. Can handle both explicit and implicit locals
(-disable-wasm-explicit-locals). Comes with a small regression
test.

This is a first basic implementation that can parse most llvm .s
output and round-trips most instructions succesfully, but in order
to keep the commit small, does not address all issues.

There are a fair number of mismatches between what MC / assembly
matcher think a "CPU" should look like and what WASM provides,
some already have workarounds in this commit (e.g. the way it
deals with register operands) and some that require further work.
Some of that further work may involve changing what the
Disassembler outputs (and what s2wasm parses), so are probably
best left to followups.

Some known things missing:
- Many directives are ignored and not emitted.
- Vararg calls are parsed but extra args not emitted.
- Loop signatures are likely incorrect.
- $drop= is not emitted.
- Disassembler does not output SIMD types correctly, so assembler
  can't test them.

Patch by Wouter van Oortmerssen

Differential Revision: https://reviews.llvm.org/D44329

llvm-svn: 328028
llvm/lib/MC/MCExpr.cpp
llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt [new file with mode: 0644]
llvm/lib/Target/WebAssembly/AsmParser/LLVMBuild.txt [new file with mode: 0644]
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp [new file with mode: 0644]
llvm/lib/Target/WebAssembly/CMakeLists.txt
llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
llvm/lib/Target/WebAssembly/LLVMBuild.txt
llvm/lib/Target/WebAssembly/WebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyRegisterInfo.td
llvm/test/MC/WebAssembly/basic-assembly.s [new file with mode: 0644]