summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-12-01 10:49:03 -0800
committerSam Clegg <sbc@chromium.org>2019-12-06 15:09:56 -0800
commitb4f4e370b59a753a51f11848f54e9705f43cccaf (patch)
tree351be282fc57ccda21b5fc8fcfcb992d5313d10b /llvm/lib
parent1d9291cc785c453ac189d131271e91f8aaf6858c (diff)
downloadbcm5719-llvm-b4f4e370b59a753a51f11848f54e9705f43cccaf.tar.gz
bcm5719-llvm-b4f4e370b59a753a51f11848f54e9705f43cccaf.zip
[WebAssebmly][MC] Support .import_name/.import_field asm directives
Convert the MC test to use asm rather than bitcode. This is a precursor to https://reviews.llvm.org/D70520. Differential Revision: https://reviews.llvm.org/D70877
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp2
-rw-r--r--llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp24
2 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index c1ff3cc2480..b22a393fcd4 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1452,7 +1452,7 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
Flags |= wasm::WASM_SYMBOL_EXPORTED;
}
}
- if (WS.getName() != WS.getImportName())
+ if (WS.hasImportName())
Flags |= wasm::WASM_SYMBOL_EXPLICIT_NAME;
wasm::WasmSymbolInfo Info;
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
index 53a96fd6a97..138ce85a23f 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -712,6 +712,30 @@ public:
return expect(AsmToken::EndOfStatement, "EOL");
}
+ if (DirectiveID.getString() == ".import_module") {
+ auto SymName = expectIdent();
+ if (SymName.empty())
+ return true;
+ if (expect(AsmToken::Comma, ","))
+ return true;
+ auto ImportModule = expectIdent();
+ auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
+ WasmSym->setImportModule(ImportModule);
+ TOut.emitImportModule(WasmSym, ImportModule);
+ }
+
+ if (DirectiveID.getString() == ".import_name") {
+ auto SymName = expectIdent();
+ if (SymName.empty())
+ return true;
+ if (expect(AsmToken::Comma, ","))
+ return true;
+ auto ImportName = expectIdent();
+ auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
+ WasmSym->setImportName(ImportName);
+ TOut.emitImportName(WasmSym, ImportName);
+ }
+
if (DirectiveID.getString() == ".eventtype") {
auto SymName = expectIdent();
if (SymName.empty())
OpenPOWER on IntegriCloud