Files
FEX-Emu--FEX/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.h
T
Paulo Matos 2b4ec88dae Whole-tree reformat
This follows discussions from #3413.
Followup commits add clang-format file, script and blame ignore lists.
2024-04-12 16:26:02 +02:00

68 lines
2.0 KiB
C++

// SPDX-License-Identifier: MIT
/*
$info$
tags: ir|opts
$end_info$
*/
#pragma once
#include "Interface/IR/PassManager.h"
#include <memory>
#include <stdint.h>
namespace FEXCore::IR {
class RegisterAllocationData;
struct RegisterAllocationDataDeleter;
struct RegisterClassType;
class RegisterAllocationPass : public FEXCore::IR::Pass {
public:
bool HasFullRA() const {
return HadFullRA;
}
virtual void AllocateRegisterSet(uint32_t ClassCount) = 0;
virtual void AddRegisters(FEXCore::IR::RegisterClassType Class, uint32_t RegisterCount) = 0;
/**
* @brief Adds a conflict between the two registers (and their respective classes) so if one is allocated then the other can not be
* allocated in the same live range.
*
* Conflict is added both directions, so only necessary to add a conflict one way
*
* ex:
* AddRegisters(GPRClass, 2); -> {x0, x1} added to register class GPR
* AddRegisters(PairClass, 1); -> {{x0, x1}} pair added to class GPR
* AddRegisterConflict(GPRClass, 0, PairClass, 0); -> Make sure the pair interferes with x0
* AddRegisterConflict(GPRClass, 1, PairClass, 1); -> Make sure the pair interferes with x1
*/
virtual void AddRegisterConflict(FEXCore::IR::RegisterClassType ClassConflict, uint32_t RegConflict, FEXCore::IR::RegisterClassType Class,
uint32_t Reg) = 0;
/**
* @name Inference graph handling
* @{ */
/**
* @brief Returns the register and class map array
*/
virtual RegisterAllocationData* GetAllocationData() = 0;
/**
* @brief Returns and transfers ownership of the register and class map array
*/
virtual std::unique_ptr<RegisterAllocationData, RegisterAllocationDataDeleter> PullAllocationData() = 0;
/** @} */
protected:
bool HasSpills {};
// Debug option to disable split slot reuse
// Can be useful for testing if there is a bug with spill slots
constexpr static bool ReuseSpillSlots {true};
uint32_t SpillSlotCount {};
bool HadFullRA {};
};
} // namespace FEXCore::IR