mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
74be1319be
AMDGPU normally spills SGPRs to VGPRs. Previously, since all register classes are handled at the same time, this was problematic. We don't know ahead of time how many registers will be needed to be reserved to handle the spilling. If no VGPRs were left for spilling, we would have to try to spill to memory. If the spilled SGPRs were required for exec mask manipulation, it is highly problematic because the lanes active at the point of spill are not necessarily the same as at the restore point. Avoid this problem by fully allocating SGPRs in a separate regalloc run from VGPRs. This way we know the exact number of VGPRs needed, and can reserve them for a second run. This fixes the most serious issues, but it is still possible using inline asm to make all VGPRs unavailable. Start erroring in the case where we ever would require memory for an SGPR spill. This is implemented by giving each regalloc pass a callback which reports if a register class should be handled or not. A few passes need some small changes to deal with leftover virtual registers. In the AMDGPU implementation, a new pass is introduced to take the place of PrologEpilogInserter for SGPR spills emitted during the first run. One disadvantage of this is currently StackSlotColoring is no longer used for SGPR spills. It would need to be run again, which will require more work. Error if the standard -regalloc option is used. Introduce new separate -sgpr-regalloc and -vgpr-regalloc flags, so the two runs can be controlled individually. PBQB is not currently supported, so this also prevents using the unhandled allocator.
33 lines
969 B
C++
33 lines
969 B
C++
//===- RegAllocCommon.h - Utilities shared between allocators ---*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CODEGEN_REGALLOCCOMMON_H
|
|
#define LLVM_CODEGEN_REGALLOCCOMMON_H
|
|
|
|
#include <functional>
|
|
|
|
namespace llvm {
|
|
|
|
class TargetRegisterClass;
|
|
class TargetRegisterInfo;
|
|
|
|
typedef std::function<bool(const TargetRegisterInfo &TRI,
|
|
const TargetRegisterClass &RC)> RegClassFilterFunc;
|
|
|
|
/// Default register class filter function for register allocation. All virtual
|
|
/// registers should be allocated.
|
|
static inline bool allocateAllRegClasses(const TargetRegisterInfo &,
|
|
const TargetRegisterClass &) {
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
#endif // LLVM_CODEGEN_REGALLOCCOMMON_H
|