summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.cpp46
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.h6
-rw-r--r--src/shader_recompiler/frontend/ir/microinstruction.cpp6
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc18
-rw-r--r--src/shader_recompiler/frontend/ir/program.h2
5 files changed, 78 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
index 6d41442ee..d6a1d8ec2 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp
@@ -355,6 +355,52 @@ void IREmitter::WriteGlobal128(const U64& address, const IR::Value& vector) {
355 Inst(Opcode::WriteGlobal128, address, vector); 355 Inst(Opcode::WriteGlobal128, address, vector);
356} 356}
357 357
358U32 IREmitter::LoadLocal(const IR::U32& word_offset) {
359 return Inst<U32>(Opcode::LoadLocal, word_offset);
360}
361
362void IREmitter::WriteLocal(const IR::U32& word_offset, const IR::U32& value) {
363 Inst(Opcode::WriteLocal, word_offset, value);
364}
365
366Value IREmitter::LoadShared(int bit_size, bool is_signed, const IR::U32& offset) {
367 switch (bit_size) {
368 case 8:
369 return Inst(is_signed ? Opcode::LoadSharedS8 : Opcode::LoadSharedU8, offset);
370 case 16:
371 return Inst(is_signed ? Opcode::LoadSharedS16 : Opcode::LoadSharedU16, offset);
372 case 32:
373 return Inst(Opcode::LoadSharedU32, offset);
374 case 64:
375 return Inst(Opcode::LoadSharedU64, offset);
376 case 128:
377 return Inst(Opcode::LoadSharedU128, offset);
378 }
379 throw InvalidArgument("Invalid bit size {}", bit_size);
380}
381
382void IREmitter::WriteShared(int bit_size, const IR::U32& offset, const IR::Value& value) {
383 switch (bit_size) {
384 case 8:
385 Inst(Opcode::WriteSharedU8, offset, value);
386 break;
387 case 16:
388 Inst(Opcode::WriteSharedU16, offset, value);
389 break;
390 case 32:
391 Inst(Opcode::WriteSharedU32, offset, value);
392 break;
393 case 64:
394 Inst(Opcode::WriteSharedU64, offset, value);
395 break;
396 case 128:
397 Inst(Opcode::WriteSharedU128, offset, value);
398 break;
399 default:
400 throw InvalidArgument("Invalid bit size {}", bit_size);
401 }
402}
403
358U1 IREmitter::GetZeroFromOp(const Value& op) { 404U1 IREmitter::GetZeroFromOp(const Value& op) {
359 return Inst<U1>(Opcode::GetZeroFromOp, op); 405 return Inst<U1>(Opcode::GetZeroFromOp, op);
360} 406}
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h
index 8d50aa607..842c2bdaf 100644
--- a/src/shader_recompiler/frontend/ir/ir_emitter.h
+++ b/src/shader_recompiler/frontend/ir/ir_emitter.h
@@ -99,6 +99,12 @@ public:
99 void WriteGlobal64(const U64& address, const IR::Value& vector); 99 void WriteGlobal64(const U64& address, const IR::Value& vector);
100 void WriteGlobal128(const U64& address, const IR::Value& vector); 100 void WriteGlobal128(const U64& address, const IR::Value& vector);
101 101
102 [[nodiscard]] U32 LoadLocal(const U32& word_offset);
103 void WriteLocal(const U32& word_offset, const U32& value);
104
105 [[nodiscard]] Value LoadShared(int bit_size, bool is_signed, const U32& offset);
106 void WriteShared(int bit_size, const U32& offset, const Value& value);
107
102 [[nodiscard]] U1 GetZeroFromOp(const Value& op); 108 [[nodiscard]] U1 GetZeroFromOp(const Value& op);
103 [[nodiscard]] U1 GetSignFromOp(const Value& op); 109 [[nodiscard]] U1 GetSignFromOp(const Value& op);
104 [[nodiscard]] U1 GetCarryFromOp(const Value& op); 110 [[nodiscard]] U1 GetCarryFromOp(const Value& op);
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp
index be8eb4d4c..52a5e5034 100644
--- a/src/shader_recompiler/frontend/ir/microinstruction.cpp
+++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp
@@ -76,6 +76,12 @@ bool Inst::MayHaveSideEffects() const noexcept {
76 case Opcode::WriteStorage32: 76 case Opcode::WriteStorage32:
77 case Opcode::WriteStorage64: 77 case Opcode::WriteStorage64:
78 case Opcode::WriteStorage128: 78 case Opcode::WriteStorage128:
79 case Opcode::WriteLocal:
80 case Opcode::WriteSharedU8:
81 case Opcode::WriteSharedU16:
82 case Opcode::WriteSharedU32:
83 case Opcode::WriteSharedU64:
84 case Opcode::WriteSharedU128:
79 return true; 85 return true;
80 default: 86 default:
81 return false; 87 return false;
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc
index 5d7462d76..c75658328 100644
--- a/src/shader_recompiler/frontend/ir/opcodes.inc
+++ b/src/shader_recompiler/frontend/ir/opcodes.inc
@@ -89,6 +89,24 @@ OPCODE(WriteStorage32, Void, U32,
89OPCODE(WriteStorage64, Void, U32, U32, U32x2, ) 89OPCODE(WriteStorage64, Void, U32, U32, U32x2, )
90OPCODE(WriteStorage128, Void, U32, U32, U32x4, ) 90OPCODE(WriteStorage128, Void, U32, U32, U32x4, )
91 91
92// Local memory operations
93OPCODE(LoadLocal, U32, U32, )
94OPCODE(WriteLocal, Void, U32, U32, )
95
96// Shared memory operations
97OPCODE(LoadSharedU8, U32, U32, )
98OPCODE(LoadSharedS8, U32, U32, )
99OPCODE(LoadSharedU16, U32, U32, )
100OPCODE(LoadSharedS16, U32, U32, )
101OPCODE(LoadSharedU32, U32, U32, )
102OPCODE(LoadSharedU64, U32x2, U32, )
103OPCODE(LoadSharedU128, U32x4, U32, )
104OPCODE(WriteSharedU8, Void, U32, U32, )
105OPCODE(WriteSharedU16, Void, U32, U32, )
106OPCODE(WriteSharedU32, Void, U32, U32, )
107OPCODE(WriteSharedU64, Void, U32, U32x2, )
108OPCODE(WriteSharedU128, Void, U32, U32x4, )
109
92// Vector utility 110// Vector utility
93OPCODE(CompositeConstructU32x2, U32x2, U32, U32, ) 111OPCODE(CompositeConstructU32x2, U32x2, U32, U32, )
94OPCODE(CompositeConstructU32x3, U32x3, U32, U32, U32, ) 112OPCODE(CompositeConstructU32x3, U32x3, U32, U32, U32, )
diff --git a/src/shader_recompiler/frontend/ir/program.h b/src/shader_recompiler/frontend/ir/program.h
index 0162e919c..3a37b3ab9 100644
--- a/src/shader_recompiler/frontend/ir/program.h
+++ b/src/shader_recompiler/frontend/ir/program.h
@@ -21,6 +21,8 @@ struct Program {
21 Info info; 21 Info info;
22 Stage stage{}; 22 Stage stage{};
23 std::array<u32, 3> workgroup_size{}; 23 std::array<u32, 3> workgroup_size{};
24 u32 local_memory_size{};
25 u32 shared_memory_size{};
24}; 26};
25 27
26[[nodiscard]] std::string DumpProgram(const Program& program); 28[[nodiscard]] std::string DumpProgram(const Program& program);