diff options
author | Andy Wingo <wingo@igalia.com> | 2020-11-25 07:54:31 -0800 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2020-11-25 08:00:08 -0800 |
commit | 1933c9d41a08cfc4c5c0ae80eedf466b5ae7ef01 (patch) | |
tree | b478a92508bba5d812a4a5f00e0497b101004d97 /llvm/tools/obj2yaml/wasm2yaml.cpp | |
parent | edd675643d5ff49e6ea01af2a2a9b40498b3226c (diff) | |
download | llvm-1933c9d41a08cfc4c5c0ae80eedf466b5ae7ef01.zip llvm-1933c9d41a08cfc4c5c0ae80eedf466b5ae7ef01.tar.gz llvm-1933c9d41a08cfc4c5c0ae80eedf466b5ae7ef01.tar.bz2 |
[WebAssembly] Factor out WasmTableType in binary format
This commit factors out a WasmTableType definition from WasmTable, as is
the case for WasmGlobal and other data types. Also add support for
extracting the SymbolName for a table from the linking section's symbol
table.
Differential Revision: https://reviews.llvm.org/D91849
Diffstat (limited to 'llvm/tools/obj2yaml/wasm2yaml.cpp')
-rw-r--r-- | llvm/tools/obj2yaml/wasm2yaml.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp index 9ca351e1..d47b7be 100644 --- a/llvm/tools/obj2yaml/wasm2yaml.cpp +++ b/llvm/tools/obj2yaml/wasm2yaml.cpp @@ -31,16 +31,6 @@ public: } // namespace -static WasmYAML::Table makeTable(const wasm::WasmTable &Table) { - WasmYAML::Table T; - T.ElemType = Table.ElemType; - T.TableLimits.Flags = Table.Limits.Flags; - T.TableLimits.Initial = Table.Limits.Initial; - T.TableLimits.Maximum = Table.Limits.Maximum; - T.Index = Table.Index; - return T; -} - static WasmYAML::Limits makeLimits(const wasm::WasmLimits &Limits) { WasmYAML::Limits L; L.Flags = Limits.Flags; @@ -49,6 +39,15 @@ static WasmYAML::Limits makeLimits(const wasm::WasmLimits &Limits) { return L; } +static WasmYAML::Table makeTable(uint32_t Index, + const wasm::WasmTableType &Type) { + WasmYAML::Table T; + T.Index = Index; + T.ElemType = Type.ElemType; + T.TableLimits = makeLimits(Type.Limits); + return T; +} + std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const WasmSection &WasmSec) { std::unique_ptr<WasmYAML::CustomSection> CustomSec; @@ -234,7 +233,9 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() { Im.EventImport.SigIndex = Import.Event.SigIndex; break; case wasm::WASM_EXTERNAL_TABLE: - Im.TableImport = makeTable(Import.Table); + // FIXME: Currently we always output an index of 0 for any imported + // table. + Im.TableImport = makeTable(0, Import.Table); break; case wasm::WASM_EXTERNAL_MEMORY: Im.Memory = makeLimits(Import.Memory); @@ -256,7 +257,7 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() { case wasm::WASM_SEC_TABLE: { auto TableSec = std::make_unique<WasmYAML::TableSection>(); for (const wasm::WasmTable &Table : Obj.tables()) { - TableSec->Tables.push_back(makeTable(Table)); + TableSec->Tables.push_back(makeTable(Table.Index, Table.Type)); } S = std::move(TableSec); break; |