diff options
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 | |||
| 143 | void 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 | ||
| 156 | std::string EmitGLASM(const Profile&, IR::Program& program, Bindings&) { | 144 | std::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 | ||
| 186 | void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 187 | Alias(inst, value); | ||
| 188 | } | ||
| 189 | |||
| 190 | void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 191 | Alias(inst, value); | ||
| 192 | } | ||
| 193 | |||
| 194 | void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 195 | Alias(inst, value); | ||
| 196 | } | ||
| 197 | |||
| 198 | void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 199 | Alias(inst, value); | ||
| 200 | } | ||
| 201 | |||
| 202 | void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 203 | Alias(inst, value); | ||
| 204 | } | ||
| 205 | |||
| 206 | void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 207 | Alias(inst, value); | ||
| 208 | } | ||
| 209 | |||
| 210 | void 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 | |||
| 9 | namespace Shader::Backend::GLASM { | ||
| 10 | |||
| 11 | static 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 | |||
| 23 | void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 24 | Alias(inst, value); | ||
| 25 | } | ||
| 26 | |||
| 27 | void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 28 | Alias(inst, value); | ||
| 29 | } | ||
| 30 | |||
| 31 | void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 32 | Alias(inst, value); | ||
| 33 | } | ||
| 34 | |||
| 35 | void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 36 | Alias(inst, value); | ||
| 37 | } | ||
| 38 | |||
| 39 | void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 40 | Alias(inst, value); | ||
| 41 | } | ||
| 42 | |||
| 43 | void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 44 | Alias(inst, value); | ||
| 45 | } | ||
| 46 | |||
| 47 | void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||
| 48 | Alias(inst, value); | ||
| 49 | } | ||
| 50 | |||
| 51 | void EmitPackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { | ||
| 52 | throw NotImplementedException("GLASM instruction"); | ||
| 53 | } | ||
| 54 | |||
| 55 | void EmitUnpackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { | ||
| 56 | throw NotImplementedException("GLASM instruction"); | ||
| 57 | } | ||
| 58 | |||
| 59 | void EmitPackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { | ||
| 60 | throw NotImplementedException("GLASM instruction"); | ||
| 61 | } | ||
| 62 | |||
| 63 | void EmitUnpackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { | ||
| 64 | throw NotImplementedException("GLASM instruction"); | ||
| 65 | } | ||
| 66 | |||
| 67 | void EmitPackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value) { | ||
| 68 | ctx.Add("PK2H {}.x,{};", inst, value); | ||
| 69 | } | ||
| 70 | |||
| 71 | void 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); | |||
| 200 | void EmitUnpackUint2x32(EmitContext& ctx, Register value); | 200 | void EmitUnpackUint2x32(EmitContext& ctx, Register value); |
| 201 | void EmitPackFloat2x16(EmitContext& ctx, Register value); | 201 | void EmitPackFloat2x16(EmitContext& ctx, Register value); |
| 202 | void EmitUnpackFloat2x16(EmitContext& ctx, Register value); | 202 | void EmitUnpackFloat2x16(EmitContext& ctx, Register value); |
| 203 | void EmitPackHalf2x16(EmitContext& ctx, Register value); | 203 | void EmitPackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value); |
| 204 | void EmitUnpackHalf2x16(EmitContext& ctx, Register value); | 204 | void EmitUnpackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value); |
| 205 | void EmitPackDouble2x32(EmitContext& ctx, Register value); | 205 | void EmitPackDouble2x32(EmitContext& ctx, Register value); |
| 206 | void EmitUnpackDouble2x32(EmitContext& ctx, Register value); | 206 | void EmitUnpackDouble2x32(EmitContext& ctx, Register value); |
| 207 | void EmitGetZeroFromOp(EmitContext& ctx); | 207 | void 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 | ||
| 284 | void EmitPackUint2x32(EmitContext& ctx, Register value) { | ||
| 285 | NotImplemented(); | ||
| 286 | } | ||
| 287 | |||
| 288 | void EmitUnpackUint2x32(EmitContext& ctx, Register value) { | ||
| 289 | NotImplemented(); | ||
| 290 | } | ||
| 291 | |||
| 292 | void EmitPackFloat2x16(EmitContext& ctx, Register value) { | ||
| 293 | NotImplemented(); | ||
| 294 | } | ||
| 295 | |||
| 296 | void EmitUnpackFloat2x16(EmitContext& ctx, Register value) { | ||
| 297 | NotImplemented(); | ||
| 298 | } | ||
| 299 | |||
| 300 | void EmitPackHalf2x16(EmitContext& ctx, Register value) { | ||
| 301 | NotImplemented(); | ||
| 302 | } | ||
| 303 | |||
| 304 | void EmitUnpackHalf2x16(EmitContext& ctx, Register value) { | ||
| 305 | NotImplemented(); | ||
| 306 | } | ||
| 307 | |||
| 308 | void EmitPackDouble2x32(EmitContext& ctx, Register value) { | 284 | void EmitPackDouble2x32(EmitContext& ctx, Register value) { |
| 309 | NotImplemented(); | 285 | NotImplemented(); |
| 310 | } | 286 | } |