diff options
author | Derek Schuff <dschuff@google.com> | 2015-12-11 23:49:46 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2015-12-11 23:49:46 +0000 |
commit | 9769debf88170904006b4b16538085e5dbd2ed44 (patch) | |
tree | b316f68ef161411bf790cf6c5ba27b717873bae5 /llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h | |
parent | e8f9387e0cae74b54a8e77310477626a59a91aed (diff) | |
download | bcm5719-llvm-9769debf88170904006b4b16538085e5dbd2ed44.tar.gz bcm5719-llvm-9769debf88170904006b4b16538085e5dbd2ed44.zip |
[WebAssembly] Implement prolog/epilog insertion and FrameIndex elimination
Summary:
Use the SP32 physical register as the base for FrameIndex
lowering. Update it and the __stack_pointer global var in the prolog and
epilog. Extend the mapping of virtual registers to wasm locals to
include the physical registers.
Rather than modify the target-independent PrologEpilogInserter (which
asserts that there are no virtual registers left) include a
slightly-modified copy for Wasm that does not have this assertion and
only clears the virtual registers if scavenging was needed (which of
course it isn't for wasm).
Differential Revision: http://reviews.llvm.org/D15344
llvm-svn: 255392
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h index af4dabb2c6c..e3c7f41189b 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h +++ b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h @@ -16,6 +16,7 @@ #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYMACHINEFUNCTIONINFO_H #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYMACHINEFUNCTIONINFO_H +#include "MCTargetDesc/WebAssemblyMCTargetDesc.h" #include "llvm/CodeGen/MachineRegisterInfo.h" namespace llvm { @@ -38,8 +39,13 @@ class WebAssemblyFunctionInfo final : public MachineFunctionInfo { /// - defined and used in LIFO order with other stack registers BitVector VRegStackified; + // One entry for each possible target reg. we expect it to be small. + std::vector<unsigned> PhysRegs; + public: - explicit WebAssemblyFunctionInfo(MachineFunction &MF) : MF(MF) {} + explicit WebAssemblyFunctionInfo(MachineFunction &MF) : MF(MF) { + PhysRegs.resize(WebAssembly::NUM_TARGET_REGS, -1U); + } ~WebAssemblyFunctionInfo() override; void addParam(MVT VT) { Params.push_back(VT); } @@ -64,9 +70,12 @@ public: assert(TargetRegisterInfo::virtReg2Index(VReg) < WARegs.size()); WARegs[TargetRegisterInfo::virtReg2Index(VReg)] = WAReg; } - unsigned getWAReg(unsigned VReg) const { - assert(TargetRegisterInfo::virtReg2Index(VReg) < WARegs.size()); - return WARegs[TargetRegisterInfo::virtReg2Index(VReg)]; + unsigned getWAReg(unsigned Reg) const { + if (TargetRegisterInfo::isVirtualRegister(Reg)) { + assert(TargetRegisterInfo::virtReg2Index(Reg) < WARegs.size()); + return WARegs[TargetRegisterInfo::virtReg2Index(Reg)]; + } + return PhysRegs[Reg]; } // If new virtual registers are created after initWARegs has been called, // this function can be used to add WebAssembly register mappings for them. @@ -74,6 +83,12 @@ public: assert(VReg = WARegs.size()); WARegs.push_back(WAReg); } + + void addPReg(unsigned PReg, unsigned WAReg) { + assert(PReg < WebAssembly::NUM_TARGET_REGS); + assert(WAReg < -1U); + PhysRegs[PReg] = WAReg; + } }; } // end namespace llvm |