diff options
| author | Sam Clegg <sbc@chromium.org> | 2018-02-20 23:38:27 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2018-02-20 23:38:27 +0000 |
| commit | 00245539b6426f2cb9eca1a418fb1437b5295dcc (patch) | |
| tree | dd750076e8adac7227febad2eb2e720353be2457 /lld/wasm/Writer.cpp | |
| parent | 83573718611b7765722ee92b6bfda7313a918285 (diff) | |
| download | bcm5719-llvm-00245539b6426f2cb9eca1a418fb1437b5295dcc.tar.gz bcm5719-llvm-00245539b6426f2cb9eca1a418fb1437b5295dcc.zip | |
[WebAssembly] Rename GlobalSymbol types. NFC.
Purely a rename in preparation for adding new global symbol type.
We want to use GlobalSymbol to represent real wasm globals and
DataSymbol for pointers to things in linear memory (what ELF would
call STT_OBJECT).
This reduces the size the patch to add the explicit symbol table
which is coming soon!
Differential Revision: https://reviews.llvm.org/D43476
llvm-svn: 325645
Diffstat (limited to 'lld/wasm/Writer.cpp')
| -rw-r--r-- | lld/wasm/Writer.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index a03fc12bd6d..ffb987ea5b7 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -119,9 +119,9 @@ private: std::vector<const WasmSignature *> Types; DenseMap<WasmSignature, int32_t, WasmSignatureDenseMapInfo> TypeIndices; std::vector<const FunctionSymbol *> ImportedFunctions; - std::vector<const GlobalSymbol *> ImportedGlobals; + std::vector<const DataSymbol *> ImportedGlobals; std::vector<WasmExportEntry> ExportedSymbols; - std::vector<const DefinedGlobal *> DefinedGlobals; + std::vector<const DefinedData *> DefinedDataSymbols; std::vector<InputFunction *> DefinedFunctions; std::vector<const FunctionSymbol *> IndirectFunctions; std::vector<WasmInitFunc> InitFunctions; @@ -226,14 +226,14 @@ void Writer::createMemorySection() { } void Writer::createGlobalSection() { - if (DefinedGlobals.empty()) + if (DefinedDataSymbols.empty()) return; SyntheticSection *Section = createSyntheticSection(WASM_SEC_GLOBAL); raw_ostream &OS = Section->getStream(); - writeUleb128(OS, DefinedGlobals.size(), "global count"); - for (const DefinedGlobal *Sym : DefinedGlobals) { + writeUleb128(OS, DefinedDataSymbols.size(), "global count"); + for (const DefinedData *Sym : DefinedDataSymbols) { WasmGlobal Global; Global.Type.Type = WASM_TYPE_I32; Global.Type.Mutable = Sym == WasmSym::StackPointer; @@ -621,7 +621,7 @@ void Writer::calculateImports() { if (auto *F = dyn_cast<FunctionSymbol>(Sym)) { F->setOutputIndex(ImportedFunctions.size()); ImportedFunctions.push_back(F); - } else if (auto *G = dyn_cast<GlobalSymbol>(Sym)) { + } else if (auto *G = dyn_cast<DataSymbol>(Sym)) { G->setOutputIndex(ImportedGlobals.size()); ImportedGlobals.push_back(G); } @@ -659,7 +659,7 @@ void Writer::calculateExports() { for (Symbol *Sym : File->getSymbols()) { if (!Sym->isDefined() || File != Sym->getFile()) continue; - if (isa<GlobalSymbol>(Sym)) + if (!isa<FunctionSymbol>(Sym)) continue; if (!Sym->getChunk()->Live) continue; @@ -670,7 +670,7 @@ void Writer::calculateExports() { } } - for (const Symbol *Sym : DefinedGlobals) { + for (const Symbol *Sym : DefinedDataSymbols) { // Can't export the SP right now because its mutable, and mutuable globals // are yet supported in the official binary format. // TODO(sbc): Remove this if/when the "mutable global" proposal is accepted. @@ -719,21 +719,21 @@ void Writer::calculateTypes() { } void Writer::assignIndexes() { - uint32_t GlobalIndex = ImportedGlobals.size() + DefinedGlobals.size(); + uint32_t GlobalIndex = ImportedGlobals.size() + DefinedDataSymbols.size(); uint32_t FunctionIndex = ImportedFunctions.size() + DefinedFunctions.size(); - auto AddDefinedGlobal = [&](DefinedGlobal *Sym) { + auto AddDefinedData = [&](DefinedData *Sym) { if (Sym) { - DefinedGlobals.emplace_back(Sym); + DefinedDataSymbols.emplace_back(Sym); Sym->setOutputIndex(GlobalIndex++); } }; - AddDefinedGlobal(WasmSym::StackPointer); - AddDefinedGlobal(WasmSym::HeapBase); - AddDefinedGlobal(WasmSym::DataEnd); + AddDefinedData(WasmSym::StackPointer); + AddDefinedData(WasmSym::HeapBase); + AddDefinedData(WasmSym::DataEnd); if (Config->Relocatable) - DefinedGlobals.reserve(Symtab->getSymbols().size()); + DefinedDataSymbols.reserve(Symtab->getSymbols().size()); uint32_t TableIndex = kInitialTableOffset; @@ -744,8 +744,8 @@ void Writer::assignIndexes() { // Create wasm globals for data symbols defined in this file if (File != Sym->getFile()) continue; - if (auto *G = dyn_cast<DefinedGlobal>(Sym)) - AddDefinedGlobal(G); + if (auto *G = dyn_cast<DefinedData>(Sym)) + AddDefinedData(G); } } } @@ -893,7 +893,7 @@ void Writer::run() { if (errorHandler().Verbose) { log("Defined Functions: " + Twine(DefinedFunctions.size())); - log("Defined Globals : " + Twine(DefinedGlobals.size())); + log("Defined Data Syms: " + Twine(DefinedDataSymbols.size())); log("Function Imports : " + Twine(ImportedFunctions.size())); log("Global Imports : " + Twine(ImportedGlobals.size())); log("Total Imports : " + |

