[WebAssembly] Name Config members after commandline argument. NFC

This addresses a late review comment from D44427/rLLD328643

llvm-svn: 328700
This commit is contained in:
Nicholas Wilson 2018-03-28 12:53:29 +00:00
parent 202f809437
commit fc90b30dc2
3 changed files with 11 additions and 17 deletions

View File

@ -17,19 +17,18 @@
namespace lld { namespace lld {
namespace wasm { namespace wasm {
enum class ExposeAs { IMPORT, EXPORT, NONE };
struct Configuration { struct Configuration {
bool AllowUndefined; bool AllowUndefined;
bool CheckSignatures; bool CheckSignatures;
bool Demangle; bool Demangle;
bool ExportTable;
bool GcSections; bool GcSections;
bool ImportMemory; bool ImportMemory;
bool ImportTable;
bool PrintGcSections; bool PrintGcSections;
bool Relocatable; bool Relocatable;
bool StripAll; bool StripAll;
bool StripDebug; bool StripDebug;
ExposeAs Table;
uint32_t GlobalBase; uint32_t GlobalBase;
uint32_t InitialMemory; uint32_t InitialMemory;
uint32_t MaxMemory; uint32_t MaxMemory;

View File

@ -216,15 +216,6 @@ static StringRef getEntry(opt::InputArgList &Args, StringRef Default) {
return Arg->getValue(); 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[] = { static const uint8_t UnreachableFn[] = {
0x03 /* ULEB length */, 0x00 /* ULEB num locals */, 0x03 /* ULEB length */, 0x00 /* ULEB num locals */,
0x00 /* opcode unreachable */, 0x0b /* opcode end */ 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->SearchPaths = args::getStrings(Args, OPT_L);
Config->StripAll = Args.hasArg(OPT_strip_all); Config->StripAll = Args.hasArg(OPT_strip_all);
Config->StripDebug = Args.hasArg(OPT_strip_debug); 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); errorHandler().Verbose = Args.hasArg(OPT_verbose);
ThreadsEnabled = Args.hasFlag(OPT_threads, OPT_no_threads, true); ThreadsEnabled = Args.hasFlag(OPT_threads, OPT_no_threads, true);

View File

@ -127,7 +127,7 @@ void Writer::createImportSection() {
uint32_t NumImports = ImportedSymbols.size(); uint32_t NumImports = ImportedSymbols.size();
if (Config->ImportMemory) if (Config->ImportMemory)
++NumImports; ++NumImports;
if (Config->Table == ExposeAs::IMPORT) if (Config->ImportTable)
++NumImports; ++NumImports;
if (NumImports == 0) if (NumImports == 0)
@ -152,7 +152,7 @@ void Writer::createImportSection() {
writeImport(OS, Import); writeImport(OS, Import);
} }
if (Config->Table == ExposeAs::IMPORT) { if (Config->ImportTable) {
uint32_t TableSize = kInitialTableOffset + IndirectFunctions.size(); uint32_t TableSize = kInitialTableOffset + IndirectFunctions.size();
WasmImport Import; WasmImport Import;
Import.Module = "env"; Import.Module = "env";
@ -236,7 +236,7 @@ void Writer::createGlobalSection() {
} }
void Writer::createTableSection() { void Writer::createTableSection() {
if (Config->Table == ExposeAs::IMPORT) if (Config->ImportTable)
return; return;
// Always output a table section (or table import), even if there are no // Always output a table section (or table import), even if there are no
@ -259,7 +259,7 @@ void Writer::createTableSection() {
void Writer::createExportSection() { void Writer::createExportSection() {
bool ExportMemory = !Config->Relocatable && !Config->ImportMemory; bool ExportMemory = !Config->Relocatable && !Config->ImportMemory;
bool ExportTable = !Config->Relocatable && Config->Table == ExposeAs::EXPORT; bool ExportTable = !Config->Relocatable && Config->ExportTable;
uint32_t NumExports = uint32_t NumExports =
(ExportMemory ? 1 : 0) + (ExportTable ? 1 : 0) + ExportedSymbols.size(); (ExportMemory ? 1 : 0) + (ExportTable ? 1 : 0) + ExportedSymbols.size();