summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glasm/reg_alloc.h
diff options
context:
space:
mode:
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;
15 15
16namespace Shader::Backend::GLASM { 16namespace Shader::Backend::GLASM {
17 17
18class EmitContext;
19
18struct Id { 20struct Id {
19 u32 base_element : 2; 21 u32 index : 30;
20 u32 num_elements_minus_one : 2;
21 u32 index : 26;
22 u32 is_spill : 1; 22 u32 is_spill : 1;
23 u32 is_condition_code : 1; 23 u32 is_condition_code : 1;
24}; 24};
25 25
26class RegAlloc { 26class RegAlloc {
27public: 27public:
28 std::string Define(IR::Inst& inst, u32 num_elements = 1, u32 alignment = 1); 28 RegAlloc(EmitContext& ctx_) : ctx{ctx_} {}
29
30 std::string Define(IR::Inst& inst);
29 31
30 std::string Consume(const IR::Value& value); 32 std::string Consume(const IR::Value& value);
31 33
34 [[nodiscard]] size_t NumUsedRegisters() const noexcept {
35 return num_used_registers;
36 }
37
32private: 38private:
33 static constexpr size_t NUM_REGS = 4096; 39 static constexpr size_t NUM_REGS = 4096;
34 static constexpr size_t NUM_ELEMENTS = 4; 40 static constexpr size_t NUM_ELEMENTS = 4;
35 41
42 EmitContext& ctx;
43
36 std::string Consume(IR::Inst& inst); 44 std::string Consume(IR::Inst& inst);
37 45
38 Id Alloc(u32 num_elements, u32 alignment); 46 Id Alloc();
39 47
40 void Free(Id id); 48 void Free(Id id);
41 49