[WebAssembly][CodeGen] IR support for WebAssembly local variables
authorAndy Wingo <wingo@igalia.com>
Wed, 21 Apr 2021 13:41:48 +0000 (15:41 +0200)
committerAndy Wingo <wingo@igalia.com>
Mon, 31 May 2021 08:40:38 +0000 (10:40 +0200)
commitbf35f4af51cddd743435bb6b94a45592c967891a
tree4fe1235b90590209029fee0d60aa2a9a11a5f3b6
parent2290a80b4dcbeb230ea47ea59b00205ccefbaa96
[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
15 files changed:
llvm/include/llvm/CodeGen/MIRYamlMapping.h
llvm/include/llvm/CodeGen/TargetFrameLowering.h
llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.cpp
llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h
llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyISD.def
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
llvm/test/CodeGen/WebAssembly/ir-locals-stackid.ll [new file with mode: 0644]
llvm/test/CodeGen/WebAssembly/ir-locals.ll [new file with mode: 0644]