diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-02-21 19:12:08 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2017-02-21 19:12:08 +0000 |
commit | e0bf7d02f037a5ba015dd468b483c17350b7d7b4 (patch) | |
tree | c6718969db45ad3f71106a4a55dceea77e527ce5 /llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h | |
parent | ebfe01c121e304f3e705cfd40536a8ff02ed0547 (diff) | |
download | bcm5719-llvm-e0bf7d02f037a5ba015dd468b483c17350b7d7b4.tar.gz bcm5719-llvm-e0bf7d02f037a5ba015dd468b483c17350b7d7b4.zip |
AMDGPU: Don't use stack space for SGPR->VGPR spills
Before frame offsets are calculated, try to eliminate the
frame indexes used by SGPR spills. Then we can delete them
after.
I think for now we can be sure that no other instruction
will be re-using the same frame indexes. It should be easy
to notice if this assumption ever breaks since everything
asserts if it tries to use a dead frame index later.
The unused emergency stack slot seems to still be left behind,
so an additional 4 bytes is still wasted.
llvm-svn: 295753
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h index dc1f22ae60d..ec1d2c37115 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h @@ -134,7 +134,8 @@ public: // FIXME: Make private unsigned LDSWaveSpillSize; unsigned PSInputEna; - std::map<unsigned, unsigned> LaneVGPRs; + + unsigned ScratchOffsetReg; unsigned NumUserSGPRs; unsigned NumSystemSGPRs; @@ -195,12 +196,29 @@ public: bool hasReg() { return VGPR != AMDGPU::NoRegister;} }; - // SIMachineFunctionInfo definition +private: + // SGPR->VGPR spilling support. + typedef std::pair<unsigned, unsigned> SpillRegMask; + + // Track VGPR + wave index for each subregister of the SGPR spilled to + // frameindex key. + DenseMap<int, std::vector<SpilledReg>> SGPRToVGPRSpills; + unsigned NumVGPRSpillLanes = 0; + SmallVector<unsigned, 2> SpillVGPRs; + +public: SIMachineFunctionInfo(const MachineFunction &MF); - SpilledReg getSpilledReg(MachineFunction *MF, unsigned FrameIndex, - unsigned SubIdx); + ArrayRef<SpilledReg> getSGPRToVGPRSpills(int FrameIndex) const { + auto I = SGPRToVGPRSpills.find(FrameIndex); + return (I == SGPRToVGPRSpills.end()) ? + ArrayRef<SpilledReg>() : makeArrayRef(I->second); + } + + bool allocateSGPRSpillToVGPR(MachineFunction &MF, int FI); + void removeSGPRToVGPRFrameIndices(MachineFrameInfo &MFI); + bool hasCalculatedTID() const { return TIDReg != AMDGPU::NoRegister; }; unsigned getTIDReg() const { return TIDReg; }; void setTIDReg(unsigned Reg) { TIDReg = Reg; } |