summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Wilson <nicholas@nicholaswilson.me.uk>2018-03-28 12:53:29 +0000
committerNicholas Wilson <nicholas@nicholaswilson.me.uk>2018-03-28 12:53:29 +0000
commit0ff4a522675db69cff66fec92bbf27975b0a2109 (patch)
treeb554804fdb5a4682ad2fe2257e47d840434fd184
parent8e2accd4ea619512938b31deaa0aa8b2d95250eb (diff)
[WebAssembly] Name Config members after commandline argument. NFC
This addresses a late review comment from D44427/rLLD328643
-rw-r--r--lld/wasm/Config.h5
-rw-r--r--lld/wasm/Driver.cpp15
-rw-r--r--lld/wasm/Writer.cpp8
3 files changed, 11 insertions, 17 deletions
diff --git a/lld/wasm/Config.h b/lld/wasm/Config.h
index d0f1f55c4d5..adccbfee39e 100644
--- a/lld/wasm/Config.h
+++ b/lld/wasm/Config.h
@@ -17,19 +17,18 @@
namespace lld {
namespace wasm {
-enum class ExposeAs { IMPORT, EXPORT, NONE };
-
struct Configuration {
bool AllowUndefined;
bool CheckSignatures;
bool Demangle;
+ bool ExportTable;
bool GcSections;
bool ImportMemory;
+ bool ImportTable;
bool PrintGcSections;
bool Relocatable;
bool StripAll;
bool StripDebug;
- ExposeAs Table;
uint32_t GlobalBase;
uint32_t InitialMemory;
uint32_t MaxMemory;
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index b86dbc49585..56eb3614fa2 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -216,15 +216,6 @@ static StringRef getEntry(opt::InputArgList &Args, StringRef Default) {
return Arg->getValue();
}
-static ExposeAs getExpose(opt::InputArgList &Args, unsigned Import,
- unsigned Export) {
- auto *Arg = Args.getLastArg(Import, Export);
- if (!Arg)
- return ExposeAs::NONE;
- return Arg->getOption().getID() == Import ? ExposeAs::IMPORT
- : ExposeAs::EXPORT;
-}
-
static const uint8_t UnreachableFn[] = {
0x03 /* ULEB length */, 0x00 /* ULEB num locals */,
0x00 /* opcode unreachable */, 0x0b /* opcode end */
@@ -305,7 +296,11 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
Config->SearchPaths = args::getStrings(Args, OPT_L);
Config->StripAll = Args.hasArg(OPT_strip_all);
Config->StripDebug = Args.hasArg(OPT_strip_debug);
- Config->Table = getExpose(Args, OPT_import_table, OPT_export_table);
+ auto *TableArg = Args.getLastArg(OPT_import_table, OPT_export_table);
+ Config->ImportTable =
+ TableArg && TableArg->getOption().getID() == OPT_import_table;
+ Config->ExportTable =
+ TableArg && TableArg->getOption().getID() == OPT_export_table;
errorHandler().Verbose = Args.hasArg(OPT_verbose);
ThreadsEnabled = Args.hasFlag(OPT_threads, OPT_no_threads, true);
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 69f3f8832ad..a98cfc6b7c9 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -127,7 +127,7 @@ void Writer::createImportSection() {
uint32_t NumImports = ImportedSymbols.size();
if (Config->ImportMemory)
++NumImports;
- if (Config->Table == ExposeAs::IMPORT)
+ if (Config->ImportTable)
++NumImports;
if (NumImports == 0)
@@ -152,7 +152,7 @@ void Writer::createImportSection() {
writeImport(OS, Import);
}
- if (Config->Table == ExposeAs::IMPORT) {
+ if (Config->ImportTable) {
uint32_t TableSize = kInitialTableOffset + IndirectFunctions.size();
WasmImport Import;
Import.Module = "env";
@@ -236,7 +236,7 @@ void Writer::createGlobalSection() {
}
void Writer::createTableSection() {
- if (Config->Table == ExposeAs::IMPORT)
+ if (Config->ImportTable)
return;
// Always output a table section (or table import), even if there are no
@@ -259,7 +259,7 @@ void Writer::createTableSection() {
void Writer::createExportSection() {
bool ExportMemory = !Config->Relocatable && !Config->ImportMemory;
- bool ExportTable = !Config->Relocatable && Config->Table == ExposeAs::EXPORT;
+ bool ExportTable = !Config->Relocatable && Config->ExportTable;
uint32_t NumExports =
(ExportMemory ? 1 : 0) + (ExportTable ? 1 : 0) + ExportedSymbols.size();