diff options
author | Andy Wingo <wingo@igalia.com> | 2021-04-21 15:41:48 +0200 |
---|---|---|
committer | Andy Wingo <wingo@igalia.com> | 2021-05-28 11:07:41 +0200 |
commit | 00ecf18979e3326b3afee8af3dc701c53ffdc93f (patch) | |
tree | d52d989b7c8b05350818c4ffd8f422a120f8b4c7 /llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | |
parent | bd04d78d649bec9b0e10c42d7dcf48af38c3b8f4 (diff) | |
download | llvm-00ecf18979e3326b3afee8af3dc701c53ffdc93f.zip llvm-00ecf18979e3326b3afee8af3dc701c53ffdc93f.tar.gz llvm-00ecf18979e3326b3afee8af3dc701c53ffdc93f.tar.bz2 |
[WebAssembly][CodeGen] IR support for WebAssembly local variables
This patch adds TargetStackID::WasmLocal. This stack holds locations of
values that are only addressable by name -- not via a pointer to memory.
For the WebAssembly target, these objects are lowered to WebAssembly
local variables, which are managed by the WebAssembly run-time and are
not addressable by linear memory.
For the WebAssembly target IR indicates that an AllocaInst should be put
on TargetStackID::WasmLocal by putting it in the non-integral address
space WASM_ADDRESS_SPACE_WASM_VAR, with value 1. SROA will mostly lift
these allocations to SSA locals, but any alloca that reaches instruction
selection (usually in non-optimized builds) will be assigned the new
TargetStackID there. Loads and stores to those values are transformed
to new WebAssemblyISD::LOCAL_GET / WebAssemblyISD::LOCAL_SET nodes,
which then lower to the type-specific LOCAL_GET_I32 etc instructions via
tablegen patterns.
Differential Revision: https://reviews.llvm.org/D101140
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp index 7ed224d..4a0738d 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp @@ -239,8 +239,10 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) { Changed = true; } - // Start assigning local numbers after the last parameter. + // Start assigning local numbers after the last parameter and after any + // already-assigned locals. unsigned CurLocal = static_cast<unsigned>(MFI.getParams().size()); + CurLocal += static_cast<unsigned>(MFI.getLocals().size()); // Precompute the set of registers that are unused, so that we can insert // drops to their defs. |