Skip to content

Commit 103fa32

Browse files
authored
[WebAssembly] Use ValType instead of integer types to model wasm tables (#78012)
LLVM models some features found in the binary format with raw integers and others with nested or enumerated types. This PR switches modeling of tables and segments to use wasm::ValType rather than uint32_t. This NFC change is in preparation for modeling more reference types, but IMO is also cleaner and closer to the spec.
1 parent bc90b91 commit 103fa32

File tree

10 files changed

+223
-221
lines changed

10 files changed

+223
-221
lines changed

lld/wasm/InputFiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void ObjFile::addLegacyIndirectFunctionTableIfNeeded(
320320
// it has an unexpected name or type, assume that it's not actually the
321321
// indirect function table.
322322
if (tableImport->Field != functionTableName ||
323-
tableImport->Table.ElemType != uint8_t(ValType::FUNCREF)) {
323+
tableImport->Table.ElemType != ValType::FUNCREF) {
324324
error(toString(this) + ": table import " + Twine(tableImport->Field) +
325325
" is missing a symbol table entry.");
326326
return;

lld/wasm/SymbolTable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ Symbol *SymbolTable::addUndefinedTag(StringRef name,
676676
TableSymbol *SymbolTable::createUndefinedIndirectFunctionTable(StringRef name) {
677677
WasmLimits limits{0, 0, 0}; // Set by the writer.
678678
WasmTableType *type = make<WasmTableType>();
679-
type->ElemType = uint8_t(ValType::FUNCREF);
679+
type->ElemType = ValType::FUNCREF;
680680
type->Limits = limits;
681681
StringRef module(defaultModule);
682682
uint32_t flags = config->exportTable ? 0 : WASM_SYMBOL_VISIBILITY_HIDDEN;
@@ -690,7 +690,7 @@ TableSymbol *SymbolTable::createUndefinedIndirectFunctionTable(StringRef name) {
690690
TableSymbol *SymbolTable::createDefinedIndirectFunctionTable(StringRef name) {
691691
const uint32_t invalidIndex = -1;
692692
WasmLimits limits{0, 0, 0}; // Set by the writer.
693-
WasmTableType type{uint8_t(ValType::FUNCREF), limits};
693+
WasmTableType type{ValType::FUNCREF, limits};
694694
WasmTable desc{invalidIndex, type, name};
695695
InputTable *table = make<InputTable>(desc, nullptr);
696696
uint32_t flags = config->exportTable ? 0 : WASM_SYMBOL_VISIBILITY_HIDDEN;

0 commit comments

Comments
 (0)