[PATCH] D51662: [WebAssembly] Made assembler only use stack instruction tablegen defs
Wouter van Oortmerssen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 4 15:55:31 PDT 2018
aardappel created this revision.
aardappel added a reviewer: dschuff.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, sbc100.
This ensures we have the non-register version of the instruction.
The stack version of call_indirect now wants a type index argument,
so that has been added in the existing tests.
Tested:
llvm-lit -v `find test -name WebAssembly`
Repository:
rL LLVM
https://reviews.llvm.org/D51662
Files:
test/MC/WebAssembly/basic-assembly.s
utils/TableGen/AsmMatcherEmitter.cpp
Index: utils/TableGen/AsmMatcherEmitter.cpp
===================================================================
--- utils/TableGen/AsmMatcherEmitter.cpp
+++ utils/TableGen/AsmMatcherEmitter.cpp
@@ -1479,6 +1479,8 @@
bool ReportMultipleNearMisses =
AsmParser->getValueAsBit("ReportMultipleNearMisses");
+ bool WebAssemblyTarget = Target.getName() == "WebAssembly";
+
// Parse the instructions; we need to do this first so that we can gather the
// singleton register classes.
SmallPtrSet<Record*, 16> SingletonRegisters;
@@ -1514,6 +1516,14 @@
if (!V.empty() && V != Variant.Name)
continue;
+ // [WebAssembly] Ignore non-stack instructions.
+ if (WebAssemblyTarget) {
+ auto Bit = CGI->TheDef->getValue("StackBased")->getValue()->
+ getCastTo(BitRecTy::get());
+ if (!Bit || !reinterpret_cast<const BitInit *>(Bit)->getValue())
+ continue;
+ }
+
auto II = llvm::make_unique<MatchableInfo>(*CGI);
II->initialize(*this, SingletonRegisters, Variant, HasMnemonicFirst);
Index: test/MC/WebAssembly/basic-assembly.s
===================================================================
--- test/MC/WebAssembly/basic-assembly.s
+++ test/MC/WebAssembly/basic-assembly.s
@@ -29,7 +29,7 @@
i64.const 1234
i32.call something2 at FUNCTION
i32.const 0
- call_indirect
+ call_indirect 0
i32.const 1
i32.add
tee_local 0
@@ -68,7 +68,7 @@
# CHECK-NEXT: i64.const 1234
# CHECK-NEXT: i32.call something2 at FUNCTION
# CHECK-NEXT: i32.const 0
-# CHECK-NEXT: call_indirect
+# CHECK-NEXT: call_indirect 0
# CHECK-NEXT: i32.const 1
# CHECK-NEXT: i32.add
# CHECK-NEXT: tee_local 0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51662.163938.patch
Type: text/x-patch
Size: 1767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180904/cd680d13/attachment.bin>
More information about the llvm-commits
mailing list