mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +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.
75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
//===- llvm/CodeGen/RegAllocRegistry.h --------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains the implementation for register allocator function
|
|
// pass registry (RegisterRegAlloc).
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CODEGEN_REGALLOCREGISTRY_H
|
|
#define LLVM_CODEGEN_REGALLOCREGISTRY_H
|
|
|
|
#include "llvm/CodeGen/RegAllocCommon.h"
|
|
#include "llvm/CodeGen/MachinePassRegistry.h"
|
|
|
|
namespace llvm {
|
|
|
|
class FunctionPass;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// RegisterRegAllocBase class - Track the registration of register allocators.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
template <class SubClass>
|
|
class RegisterRegAllocBase : public MachinePassRegistryNode<FunctionPass *(*)()> {
|
|
public:
|
|
using FunctionPassCtor = FunctionPass *(*)();
|
|
|
|
static MachinePassRegistry<FunctionPassCtor> Registry;
|
|
|
|
RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C)
|
|
: MachinePassRegistryNode(N, D, C) {
|
|
Registry.Add(this);
|
|
}
|
|
|
|
~RegisterRegAllocBase() { Registry.Remove(this); }
|
|
|
|
// Accessors.
|
|
SubClass *getNext() const {
|
|
return static_cast<SubClass *>(MachinePassRegistryNode::getNext());
|
|
}
|
|
|
|
static SubClass *getList() {
|
|
return static_cast<SubClass *>(Registry.getList());
|
|
}
|
|
|
|
static FunctionPassCtor getDefault() { return Registry.getDefault(); }
|
|
|
|
static void setDefault(FunctionPassCtor C) { Registry.setDefault(C); }
|
|
|
|
static void setListener(MachinePassRegistryListener<FunctionPassCtor> *L) {
|
|
Registry.setListener(L);
|
|
}
|
|
};
|
|
|
|
class RegisterRegAlloc : public RegisterRegAllocBase<RegisterRegAlloc> {
|
|
public:
|
|
RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
|
|
: RegisterRegAllocBase(N, D, C) {}
|
|
};
|
|
|
|
/// RegisterRegAlloc's global Registry tracks allocator registration.
|
|
template <class T>
|
|
MachinePassRegistry<RegisterRegAlloc::FunctionPassCtor>
|
|
RegisterRegAllocBase<T>::Registry;
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_CODEGEN_REGALLOCREGISTRY_H
|