diff options
Diffstat (limited to 'src/shader_recompiler/backend')
6 files changed, 30 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h index cb7232704..4f8dd8e42 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h +++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h | |||
| @@ -304,6 +304,8 @@ void EmitIAdd64(EmitContext& ctx, IR::Inst& inst, Register a, Register b); | |||
| 304 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); | 304 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| 305 | void EmitISub64(EmitContext& ctx, IR::Inst& inst, Register a, Register b); | 305 | void EmitISub64(EmitContext& ctx, IR::Inst& inst, Register a, Register b); |
| 306 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); | 306 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| 307 | void EmitSDiv32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); | ||
| 308 | void EmitUDiv32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b); | ||
| 307 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); | 309 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
| 308 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, Register value); | 310 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, Register value); |
| 309 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); | 311 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp index f55c26b76..8aa494a4d 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp | |||
| @@ -90,6 +90,14 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) { | |||
| 90 | ctx.Add("MUL.S {}.x,{},{};", inst, a, b); | 90 | ctx.Add("MUL.S {}.x,{},{};", inst, a, b); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | void EmitSDiv32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) { | ||
| 94 | ctx.Add("DIV.S {}.x,{},{};", inst, a, b); | ||
| 95 | } | ||
| 96 | |||
| 97 | void EmitUDiv32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b) { | ||
| 98 | ctx.Add("DIV.U {}.x,{},{};", inst, a, b); | ||
| 99 | } | ||
| 100 | |||
| 93 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { | 101 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { |
| 94 | if (value.type != Type::Register && static_cast<s32>(value.imm_u32) < 0) { | 102 | if (value.type != Type::Register && static_cast<s32>(value.imm_u32) < 0) { |
| 95 | ctx.Add("MOV.S {},{};", inst, -static_cast<s32>(value.imm_u32)); | 103 | ctx.Add("MOV.S {},{};", inst, -static_cast<s32>(value.imm_u32)); |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h index 6cae0b84a..159e4b770 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h +++ b/src/shader_recompiler/backend/glsl/emit_glsl_instructions.h | |||
| @@ -363,6 +363,8 @@ void EmitIAdd64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin | |||
| 363 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | 363 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 364 | void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | 364 | void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 365 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | 365 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); |
| 366 | void EmitSDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | ||
| 367 | void EmitUDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); | ||
| 366 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 368 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| 367 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 369 | void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
| 368 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value); | 370 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value); |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp index 38419f88f..88c1d4c5e 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp | |||
| @@ -78,6 +78,14 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin | |||
| 78 | ctx.AddU32("{}=uint({}*{});", inst, a, b); | 78 | ctx.AddU32("{}=uint({}*{});", inst, a, b); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | void EmitSDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { | ||
| 82 | ctx.AddU32("{}=uint(int({})/int({}));", inst, a, b); | ||
| 83 | } | ||
| 84 | |||
| 85 | void EmitUDiv32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { | ||
| 86 | ctx.AddU32("{}={}/{};", inst, a, b); | ||
| 87 | } | ||
| 88 | |||
| 81 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { | 89 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { |
| 82 | ctx.AddU32("{}=uint(-({}));", inst, value); | 90 | ctx.AddU32("{}=uint(-({}));", inst, value); |
| 83 | } | 91 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 3d90b2286..44eda16ca 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
| @@ -284,6 +284,8 @@ Id EmitIAdd64(EmitContext& ctx, Id a, Id b); | |||
| 284 | Id EmitISub32(EmitContext& ctx, Id a, Id b); | 284 | Id EmitISub32(EmitContext& ctx, Id a, Id b); |
| 285 | Id EmitISub64(EmitContext& ctx, Id a, Id b); | 285 | Id EmitISub64(EmitContext& ctx, Id a, Id b); |
| 286 | Id EmitIMul32(EmitContext& ctx, Id a, Id b); | 286 | Id EmitIMul32(EmitContext& ctx, Id a, Id b); |
| 287 | Id EmitSDiv32(EmitContext& ctx, Id a, Id b); | ||
| 288 | Id EmitUDiv32(EmitContext& ctx, Id a, Id b); | ||
| 287 | Id EmitINeg32(EmitContext& ctx, Id value); | 289 | Id EmitINeg32(EmitContext& ctx, Id value); |
| 288 | Id EmitINeg64(EmitContext& ctx, Id value); | 290 | Id EmitINeg64(EmitContext& ctx, Id value); |
| 289 | Id EmitIAbs32(EmitContext& ctx, Id value); | 291 | Id EmitIAbs32(EmitContext& ctx, Id value); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp index 3501d7495..50277eec3 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp | |||
| @@ -72,6 +72,14 @@ Id EmitIMul32(EmitContext& ctx, Id a, Id b) { | |||
| 72 | return ctx.OpIMul(ctx.U32[1], a, b); | 72 | return ctx.OpIMul(ctx.U32[1], a, b); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | Id EmitSDiv32(EmitContext& ctx, Id a, Id b) { | ||
| 76 | return ctx.OpSDiv(ctx.U32[1], a, b); | ||
| 77 | } | ||
| 78 | |||
| 79 | Id EmitUDiv32(EmitContext& ctx, Id a, Id b) { | ||
| 80 | return ctx.OpUDiv(ctx.U32[1], a, b); | ||
| 81 | } | ||
| 82 | |||
| 75 | Id EmitINeg32(EmitContext& ctx, Id value) { | 83 | Id EmitINeg32(EmitContext& ctx, Id value) { |
| 76 | return ctx.OpSNegate(ctx.U32[1], value); | 84 | return ctx.OpSNegate(ctx.U32[1], value); |
| 77 | } | 85 | } |