diff options
author | Sam Clegg <sbc@chromium.org> | 2018-02-23 05:08:34 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2018-02-23 05:08:34 +0000 |
commit | 6c899ba6dee1a6cd1e1a49900bb5f3b6353a5487 (patch) | |
tree | 565c8241b9b4a62f0ae1a227d26b4d8f1bbd1023 /llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp | |
parent | 0fd6a530a0b61501ad0da1177e2e4c9dbf138a74 (diff) | |
download | bcm5719-llvm-6c899ba6dee1a6cd1e1a49900bb5f3b6353a5487.tar.gz bcm5719-llvm-6c899ba6dee1a6cd1e1a49900bb5f3b6353a5487.zip |
[WebAssembly] Add first claass symbol table to wasm objects
This is combination of two patches by Nicholas Wilson:
1. https://reviews.llvm.org/D41954
2. https://reviews.llvm.org/D42495
Along with a few local modifications:
- One change I made was to add the UNDEFINED bit to the binary format
to avoid the extra byte used when writing data symbols. Although this
bit is redundant for other symbols types (i.e. undefined can be
implied if a function or global is a wasm import)
- I prefer to be explicit and consistent and not have derived flags.
- Some field renaming.
- Some reverting of unrelated minor changes.
- No test output differences.
Differential Revision: https://reviews.llvm.org/D43147
llvm-svn: 325860
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp index 4a93d4810c7..c8afa39e6e9 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp @@ -74,7 +74,7 @@ WebAssemblyMCInstLower::GetGlobalAddressSymbol(const MachineOperand &MO) const { WasmSym->setReturns(std::move(Returns)); WasmSym->setParams(std::move(Params)); - WasmSym->setIsFunction(true); + WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); } return WasmSym; @@ -91,9 +91,16 @@ MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol( const WebAssemblySubtarget &Subtarget = Printer.getSubtarget(); // __stack_pointer is a global variable; all other external symbols used by - // CodeGen are functions. - if (strcmp(Name, "__stack_pointer") == 0) + // CodeGen are functions. It's OK to hardcode knowledge of specific symbols + // here; this method is precisely there for fetching the signatures of known + // Clang-provided symbols. + if (strcmp(Name, "__stack_pointer") == 0) { + wasm::ValType iPTR = + Subtarget.hasAddr64() ? wasm::ValType::I64 : wasm::ValType::I32; + WasmSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL); + WasmSym->setGlobalType(wasm::WasmGlobalType{int32_t(iPTR), true}); return WasmSym; + } SmallVector<wasm::ValType, 4> Returns; SmallVector<wasm::ValType, 4> Params; @@ -101,7 +108,7 @@ MCSymbol *WebAssemblyMCInstLower::GetExternalSymbolSymbol( WasmSym->setReturns(std::move(Returns)); WasmSym->setParams(std::move(Params)); - WasmSym->setIsFunction(true); + WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); return WasmSym; } @@ -189,7 +196,7 @@ void WebAssemblyMCInstLower::Lower(const MachineInstr *MI, MCSymbolWasm *WasmSym = cast<MCSymbolWasm>(Sym); WasmSym->setReturns(std::move(Returns)); WasmSym->setParams(std::move(Params)); - WasmSym->setIsFunction(true); + WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); const MCExpr *Expr = MCSymbolRefExpr::create(WasmSym, |