diff options
author | Wouter van Oortmerssen <aardappel@gmail.com> | 2018-08-30 15:40:53 +0000 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2018-08-30 15:40:53 +0000 |
commit | a733d08db251c5c12103a30dd9c3a28f2eb82509 (patch) | |
tree | f72e38e9a51ec829044c08f501ca95fc79a21ccc /llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp | |
parent | 2305c049a30216e6dc1703a6a798ad92f38f9d94 (diff) | |
download | llvm-a733d08db251c5c12103a30dd9c3a28f2eb82509.zip llvm-a733d08db251c5c12103a30dd9c3a28f2eb82509.tar.gz llvm-a733d08db251c5c12103a30dd9c3a28f2eb82509.tar.bz2 |
[WebAssembly] Made disassembler only use stack instructions.
Summary:
Now uses the StackBased bit from the tablegen defs to identify
stack instructions (and ignore register based or non-wasm instructions).
Also changed how we store operands, since we now have up to 16 of them
per instruction. To not cause static data bloat, these are compressed
into a tiny table.
+ a few other cleanups.
Tested:
- MCTest
- llvm-lit -v `find test -name WebAssembly`
Reviewers: dschuff, jgravelle-google, sunfish, tlively
Subscribers: sbc100, aheejin, llvm-commits
Differential Revision: https://reviews.llvm.org/D51320
llvm-svn: 341081
Diffstat (limited to 'llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp index 9f6797d..896a722 100644 --- a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -140,7 +140,7 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction( MI.setOpcode(WasmInst->Opcode); // Parse any operands. for (uint8_t OPI = 0; OPI < WasmInst->NumOperands; OPI++) { - switch (WasmInst->Operands[OPI]) { + switch (OperandTable[WasmInst->OperandStart + OPI]) { // ULEB operands: case WebAssembly::OPERAND_BASIC_BLOCK: case WebAssembly::OPERAND_LOCAL: @@ -194,15 +194,12 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction( return MCDisassembler::Fail; break; } - case MCOI::OPERAND_REGISTER: { - // These are NOT actually in the instruction stream, but MC is going to - // expect operands to be present for them! - // FIXME: can MC re-generate register assignments or do we have to - // do this? Since this function decodes a single instruction, we don't - // have the proper context for tracking an operand stack here. - MI.addOperand(MCOperand::createReg(0)); - break; - } + case MCOI::OPERAND_REGISTER: + // The tablegen header currently does not have any register operands since + // we use only the stack (_S) instructions. + // If you hit this that probably means a bad instruction definition in + // tablegen. + llvm_unreachable("Register operand in WebAssemblyDisassembler"); default: llvm_unreachable("Unknown operand type in WebAssemblyDisassembler"); } |