summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glasm/reg_alloc.h
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-05-05 02:19:08 -0300
committerGravatar ameerj2021-07-22 21:51:30 -0400
commitb10cf64c486d8730fcfeb53a333814915b3b5fbe (patch)
tree59cb4f62ac806071e0f0a341589c164017520f3a /src/shader_recompiler/backend/glasm/reg_alloc.h
parentshader: ISET.X implementation (diff)
downloadyuzu-b10cf64c486d8730fcfeb53a333814915b3b5fbe.tar.gz
yuzu-b10cf64c486d8730fcfeb53a333814915b3b5fbe.tar.xz
yuzu-b10cf64c486d8730fcfeb53a333814915b3b5fbe.zip
glasm: Add GLASM backend infrastructure
Diffstat (limited to 'src/shader_recompiler/backend/glasm/reg_alloc.h')
-rw-r--r--src/shader_recompiler/backend/glasm/reg_alloc.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/reg_alloc.h b/src/shader_recompiler/backend/glasm/reg_alloc.h
new file mode 100644
index 000000000..46018b0c2
--- /dev/null
+++ b/src/shader_recompiler/backend/glasm/reg_alloc.h
@@ -0,0 +1,46 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <bitset>
8
9#include "common/common_types.h"
10
11namespace Shader::IR {
12class Inst;
13class Value;
14} // namespace Shader::IR
15
16namespace Shader::Backend::GLASM {
17
18struct Id {
19 u32 base_element : 2;
20 u32 num_elements_minus_one : 2;
21 u32 index : 26;
22 u32 is_spill : 1;
23 u32 is_condition_code : 1;
24};
25
26class RegAlloc {
27public:
28 std::string Define(IR::Inst& inst, u32 num_elements = 1, u32 alignment = 1);
29
30 std::string Consume(const IR::Value& value);
31
32private:
33 static constexpr size_t NUM_REGS = 4096;
34 static constexpr size_t NUM_ELEMENTS = 4;
35
36 std::string Consume(IR::Inst& inst);
37
38 Id Alloc(u32 num_elements, u32 alignment);
39
40 void Free(Id id);
41
42 size_t num_used_registers{};
43 std::bitset<NUM_REGS> register_use{};
44};
45
46} // namespace Shader::Backend::GLASM