summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir/basic_block.h
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-02-02 21:07:00 -0300
committerGravatar ameerj2021-07-22 21:51:21 -0400
commit6c4cc0cd062fbbba5349da1108d3c23cb330ca8a (patch)
tree544291931da8a85fafcea71964c77d9278ec7f29 /src/shader_recompiler/frontend/ir/basic_block.h
parentshader: Initial recompiler work (diff)
downloadyuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.gz
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.tar.xz
yuzu-6c4cc0cd062fbbba5349da1108d3c23cb330ca8a.zip
shader: SSA and dominance
Diffstat (limited to 'src/shader_recompiler/frontend/ir/basic_block.h')
-rw-r--r--src/shader_recompiler/frontend/ir/basic_block.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/shader_recompiler/frontend/ir/basic_block.h b/src/shader_recompiler/frontend/ir/basic_block.h
index 3ed2eb957..4b6b80c4b 100644
--- a/src/shader_recompiler/frontend/ir/basic_block.h
+++ b/src/shader_recompiler/frontend/ir/basic_block.h
@@ -6,6 +6,8 @@
6 6
7#include <initializer_list> 7#include <initializer_list>
8#include <map> 8#include <map>
9#include <span>
10#include <vector>
9 11
10#include <boost/intrusive/list.hpp> 12#include <boost/intrusive/list.hpp>
11#include <boost/pool/pool_alloc.hpp> 13#include <boost/pool/pool_alloc.hpp>
@@ -36,7 +38,11 @@ public:
36 void AppendNewInst(Opcode op, std::initializer_list<Value> args); 38 void AppendNewInst(Opcode op, std::initializer_list<Value> args);
37 39
38 /// Prepends a new instruction to this basic block before the insertion point. 40 /// Prepends a new instruction to this basic block before the insertion point.
39 iterator PrependNewInst(iterator insertion_point, Opcode op, std::initializer_list<Value> args); 41 iterator PrependNewInst(iterator insertion_point, Opcode op,
42 std::initializer_list<Value> args = {});
43
44 /// Adds a new immediate predecessor to the basic block.
45 void AddImmediatePredecessor(IR::Block* immediate_predecessor);
40 46
41 /// Gets the starting location of this basic block. 47 /// Gets the starting location of this basic block.
42 [[nodiscard]] u32 LocationBegin() const noexcept; 48 [[nodiscard]] u32 LocationBegin() const noexcept;
@@ -44,9 +50,12 @@ public:
44 [[nodiscard]] u32 LocationEnd() const noexcept; 50 [[nodiscard]] u32 LocationEnd() const noexcept;
45 51
46 /// Gets a mutable reference to the instruction list for this basic block. 52 /// Gets a mutable reference to the instruction list for this basic block.
47 InstructionList& Instructions() noexcept; 53 [[nodiscard]] InstructionList& Instructions() noexcept;
48 /// Gets an immutable reference to the instruction list for this basic block. 54 /// Gets an immutable reference to the instruction list for this basic block.
49 const InstructionList& Instructions() const noexcept; 55 [[nodiscard]] const InstructionList& Instructions() const noexcept;
56
57 /// Gets an immutable span to the immediate predecessors.
58 [[nodiscard]] std::span<IR::Block* const> ImmediatePredecessors() const noexcept;
50 59
51 [[nodiscard]] bool empty() const { 60 [[nodiscard]] bool empty() const {
52 return instructions.empty(); 61 return instructions.empty();
@@ -115,13 +124,16 @@ private:
115 /// End location of this block 124 /// End location of this block
116 u32 location_end; 125 u32 location_end;
117 126
118 /// List of instructions in this block. 127 /// List of instructions in this block
119 InstructionList instructions; 128 InstructionList instructions;
120 129
121 /// Memory pool for instruction list 130 /// Memory pool for instruction list
122 boost::fast_pool_allocator<Inst, boost::default_user_allocator_malloc_free, 131 boost::fast_pool_allocator<Inst, boost::default_user_allocator_malloc_free,
123 boost::details::pool::null_mutex> 132 boost::details::pool::null_mutex>
124 instruction_alloc_pool; 133 instruction_alloc_pool;
134
135 /// Block immediate predecessors
136 std::vector<IR::Block*> imm_predecessors;
125}; 137};
126 138
127[[nodiscard]] std::string DumpBlock(const Block& block); 139[[nodiscard]] std::string DumpBlock(const Block& block);