summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm.cpp40
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp75
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_instructions.h4
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp24
4 files changed, 77 insertions, 66 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm.cpp b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
index 8981cf300..842ec157d 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm.cpp
@@ -139,18 +139,6 @@ void EmitInst(EmitContext& ctx, IR::Inst* inst) {
139 } 139 }
140 throw LogicError("Invalid opcode {}", inst->GetOpcode()); 140 throw LogicError("Invalid opcode {}", inst->GetOpcode());
141} 141}
142
143void Alias(IR::Inst& inst, const IR::Value& value) {
144 if (value.IsImmediate()) {
145 return;
146 }
147 IR::Inst* const value_inst{value.InstRecursive()};
148 if (inst.GetOpcode() == IR::Opcode::Identity) {
149 value_inst->DestructiveAddUsage(inst.UseCount());
150 value_inst->DestructiveRemoveUsage();
151 }
152 inst.SetDefinition(value_inst->Definition<Id>());
153}
154} // Anonymous namespace 142} // Anonymous namespace
155 143
156std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) { 144std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) {
@@ -183,32 +171,4 @@ std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) {
183 return ctx.code; 171 return ctx.code;
184} 172}
185 173
186void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) {
187 Alias(inst, value);
188}
189
190void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
191 Alias(inst, value);
192}
193
194void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
195 Alias(inst, value);
196}
197
198void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
199 Alias(inst, value);
200}
201
202void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
203 Alias(inst, value);
204}
205
206void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
207 Alias(inst, value);
208}
209
210void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
211 Alias(inst, value);
212}
213
214} // namespace Shader::Backend::GLASM 174} // namespace Shader::Backend::GLASM
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp
index e69de29bb..918d82375 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_bitwise_conversion.cpp
@@ -0,0 +1,75 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "shader_recompiler/backend/glasm/emit_context.h"
6#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
7#include "shader_recompiler/frontend/ir/value.h"
8
9namespace Shader::Backend::GLASM {
10
11static void Alias(IR::Inst& inst, const IR::Value& value) {
12 if (value.IsImmediate()) {
13 return;
14 }
15 IR::Inst* const value_inst{value.InstRecursive()};
16 if (inst.GetOpcode() == IR::Opcode::Identity) {
17 value_inst->DestructiveAddUsage(inst.UseCount());
18 value_inst->DestructiveRemoveUsage();
19 }
20 inst.SetDefinition(value_inst->Definition<Id>());
21}
22
23void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) {
24 Alias(inst, value);
25}
26
27void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
28 Alias(inst, value);
29}
30
31void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
32 Alias(inst, value);
33}
34
35void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
36 Alias(inst, value);
37}
38
39void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
40 Alias(inst, value);
41}
42
43void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
44 Alias(inst, value);
45}
46
47void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
48 Alias(inst, value);
49}
50
51void EmitPackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
52 throw NotImplementedException("GLASM instruction");
53}
54
55void EmitUnpackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
56 throw NotImplementedException("GLASM instruction");
57}
58
59void EmitPackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
60 throw NotImplementedException("GLASM instruction");
61}
62
63void EmitUnpackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
64 throw NotImplementedException("GLASM instruction");
65}
66
67void EmitPackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value) {
68 ctx.Add("PK2H {}.x,{};", inst, value);
69}
70
71void EmitUnpackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value) {
72 ctx.Add("UP2H {}.xy,{}.x;", inst, value);
73}
74
75} // namespace Shader::Backend::GLASM
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
index 42de6716a..cb1067dc9 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
@@ -200,8 +200,8 @@ void EmitPackUint2x32(EmitContext& ctx, Register value);
200void EmitUnpackUint2x32(EmitContext& ctx, Register value); 200void EmitUnpackUint2x32(EmitContext& ctx, Register value);
201void EmitPackFloat2x16(EmitContext& ctx, Register value); 201void EmitPackFloat2x16(EmitContext& ctx, Register value);
202void EmitUnpackFloat2x16(EmitContext& ctx, Register value); 202void EmitUnpackFloat2x16(EmitContext& ctx, Register value);
203void EmitPackHalf2x16(EmitContext& ctx, Register value); 203void EmitPackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value);
204void EmitUnpackHalf2x16(EmitContext& ctx, Register value); 204void EmitUnpackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value);
205void EmitPackDouble2x32(EmitContext& ctx, Register value); 205void EmitPackDouble2x32(EmitContext& ctx, Register value);
206void EmitUnpackDouble2x32(EmitContext& ctx, Register value); 206void EmitUnpackDouble2x32(EmitContext& ctx, Register value);
207void EmitGetZeroFromOp(EmitContext& ctx); 207void EmitGetZeroFromOp(EmitContext& ctx);
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
index 5729b27a7..03464524e 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
@@ -281,30 +281,6 @@ void EmitSelectF64(EmitContext& ctx, ScalarS32 cond, Register true_value, Regist
281 NotImplemented(); 281 NotImplemented();
282} 282}
283 283
284void EmitPackUint2x32(EmitContext& ctx, Register value) {
285 NotImplemented();
286}
287
288void EmitUnpackUint2x32(EmitContext& ctx, Register value) {
289 NotImplemented();
290}
291
292void EmitPackFloat2x16(EmitContext& ctx, Register value) {
293 NotImplemented();
294}
295
296void EmitUnpackFloat2x16(EmitContext& ctx, Register value) {
297 NotImplemented();
298}
299
300void EmitPackHalf2x16(EmitContext& ctx, Register value) {
301 NotImplemented();
302}
303
304void EmitUnpackHalf2x16(EmitContext& ctx, Register value) {
305 NotImplemented();
306}
307
308void EmitPackDouble2x32(EmitContext& ctx, Register value) { 284void EmitPackDouble2x32(EmitContext& ctx, Register value) {
309 NotImplemented(); 285 NotImplemented();
310} 286}