summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glasm/reg_alloc.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-05-07 11:31:30 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:30 +0200
commitc1ba685d9c9b9ca9e8c479c52097adf943e804eb (patch)
tree015e58378db727b8df4089570ad224e7439b281a /src/shader_recompiler/backend/glasm/reg_alloc.h
parentvk_scheduler: Use locks instead of SPSC a queue (diff)
downloadyuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.gz
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.bz2
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.lz
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.xz
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.zst
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.zip
Diffstat (limited to 'src/shader_recompiler/backend/glasm/reg_alloc.h')
-rw-r--r--src/shader_recompiler/backend/glasm/reg_alloc.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/shader_recompiler/backend/glasm/reg_alloc.h b/src/shader_recompiler/backend/glasm/reg_alloc.h
index 46018b0c2..83d728d20 100644
--- a/src/shader_recompiler/backend/glasm/reg_alloc.h
+++ b/src/shader_recompiler/backend/glasm/reg_alloc.h
@@ -15,27 +15,35 @@ class Value;
namespace Shader::Backend::GLASM {
+class EmitContext;
+
struct Id {
- u32 base_element : 2;
- u32 num_elements_minus_one : 2;
- u32 index : 26;
+ u32 index : 30;
u32 is_spill : 1;
u32 is_condition_code : 1;
};
class RegAlloc {
public:
- std::string Define(IR::Inst& inst, u32 num_elements = 1, u32 alignment = 1);
+ RegAlloc(EmitContext& ctx_) : ctx{ctx_} {}
+
+ std::string Define(IR::Inst& inst);
std::string Consume(const IR::Value& value);
+ [[nodiscard]] size_t NumUsedRegisters() const noexcept {
+ return num_used_registers;
+ }
+
private:
static constexpr size_t NUM_REGS = 4096;
static constexpr size_t NUM_ELEMENTS = 4;
+ EmitContext& ctx;
+
std::string Consume(IR::Inst& inst);
- Id Alloc(u32 num_elements, u32 alignment);
+ Id Alloc();
void Free(Id id);