[PATCH] D43710: [WebAssembly] Use more specific type and simplify code.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 18:30:52 PST 2018
ruiu updated this revision to Diff 135762.
ruiu added a comment.
- simplify
https://reviews.llvm.org/D43710
Files:
lld/wasm/Writer.cpp
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -281,31 +281,24 @@
writeUleb128(OS, NumExports, "export count");
- if (ExportMemory) {
- WasmExport MemoryExport;
- MemoryExport.Name = "memory";
- MemoryExport.Kind = WASM_EXTERNAL_MEMORY;
- MemoryExport.Index = 0;
- writeExport(OS, MemoryExport);
- }
+ if (ExportMemory)
+ writeExport(OS, {"memory", WASM_EXTERNAL_MEMORY, 0});
unsigned FakeGlobalIndex = NumImportedGlobals + InputGlobals.size();
+
for (const Symbol *Sym : ExportedSymbols) {
- DEBUG(dbgs() << "Export: " << Sym->getName() << "\n");
+ StringRef Name = Sym->getName();
WasmExport Export;
- Export.Name = Sym->getName();
- if (isa<FunctionSymbol>(Sym)) {
- Export.Index = Sym->getOutputIndex();
- Export.Kind = WASM_EXTERNAL_FUNCTION;
- } else if (isa<GlobalSymbol>(Sym)) {
- Export.Index = Sym->getOutputIndex();
- Export.Kind = WASM_EXTERNAL_GLOBAL;
- } else if (isa<DataSymbol>(Sym)) {
- Export.Index = FakeGlobalIndex++;
- Export.Kind = WASM_EXTERNAL_GLOBAL;
- } else {
+ DEBUG(dbgs() << "Export: " << Name << "\n");
+
+ if (isa<DefinedFunction>(Sym))
+ Export = {Name, WASM_EXTERNAL_FUNCTION, Sym->getOutputIndex()};
+ else if (isa<DefinedGlobal>(Sym))
+ Export = {Name, WASM_EXTERNAL_GLOBAL, Sym->getOutputIndex()};
+ else if (isa<DefinedData>(Sym))
+ Export = {Name, WASM_EXTERNAL_GLOBAL, FakeGlobalIndex++};
+ else
llvm_unreachable("unexpected symbol type");
- }
writeExport(OS, Export);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43710.135762.patch
Type: text/x-patch
Size: 1653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180224/3cd4a955/attachment.bin>
More information about the llvm-commits
mailing list