diff options
| author | 2021-05-09 18:49:27 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:30 -0400 | |
| commit | 6705f56029d627941f56e36273fd4548a88e8b63 (patch) | |
| tree | 18373a6ee96dfaa7b26f52efb8c864fa7b289825 /src/shader_recompiler/backend | |
| parent | glasm: Reimplement bitwise ops and BFI/BFE (diff) | |
| download | yuzu-6705f56029d627941f56e36273fd4548a88e8b63.tar.gz yuzu-6705f56029d627941f56e36273fd4548a88e8b63.tar.xz yuzu-6705f56029d627941f56e36273fd4548a88e8b63.zip | |
emit_glasm: Implement more integer alu ops
Diffstat (limited to 'src/shader_recompiler/backend')
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_instructions.h | 22 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp | 66 |
2 files changed, 41 insertions, 47 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h index aef5f7663..b19899624 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h +++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h | |||
| @@ -302,15 +302,15 @@ void EmitIAdd64(EmitContext& ctx, Register a, Register b); | |||
| 302 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); | 302 | void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| 303 | void EmitISub64(EmitContext& ctx, Register a, Register b); | 303 | void EmitISub64(EmitContext& ctx, Register a, Register b); |
| 304 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); | 304 | void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| 305 | void EmitINeg32(EmitContext& ctx, ScalarS32 value); | 305 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
| 306 | void EmitINeg64(EmitContext& ctx, Register value); | 306 | void EmitINeg64(EmitContext& ctx, Register value); |
| 307 | void EmitIAbs32(EmitContext& ctx, ScalarS32 value); | 307 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
| 308 | void EmitIAbs64(EmitContext& ctx, Register value); | 308 | void EmitIAbs64(EmitContext& ctx, Register value); |
| 309 | void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift); | 309 | void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift); |
| 310 | void EmitShiftLeftLogical64(EmitContext& ctx, Register base, Register shift); | 310 | void EmitShiftLeftLogical64(EmitContext& ctx, Register base, Register shift); |
| 311 | void EmitShiftRightLogical32(EmitContext& ctx, ScalarU32 base, ScalarU32 shift); | 311 | void EmitShiftRightLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift); |
| 312 | void EmitShiftRightLogical64(EmitContext& ctx, Register base, Register shift); | 312 | void EmitShiftRightLogical64(EmitContext& ctx, Register base, Register shift); |
| 313 | void EmitShiftRightArithmetic32(EmitContext& ctx, ScalarS32 base, ScalarS32 shift); | 313 | void EmitShiftRightArithmetic32(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, ScalarS32 shift); |
| 314 | void EmitShiftRightArithmetic64(EmitContext& ctx, Register base, Register shift); | 314 | void EmitShiftRightArithmetic64(EmitContext& ctx, Register base, Register shift); |
| 315 | void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); | 315 | void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| 316 | void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); | 316 | void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| @@ -322,14 +322,14 @@ void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, Scal | |||
| 322 | void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 offset, | 322 | void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 offset, |
| 323 | ScalarU32 count); | 323 | ScalarU32 count); |
| 324 | void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); | 324 | void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
| 325 | void EmitBitCount32(EmitContext& ctx, ScalarS32 value); | 325 | void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
| 326 | void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); | 326 | void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
| 327 | void EmitFindSMsb32(EmitContext& ctx, ScalarS32 value); | 327 | void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); |
| 328 | void EmitFindUMsb32(EmitContext& ctx, ScalarU32 value); | 328 | void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value); |
| 329 | void EmitSMin32(EmitContext& ctx, ScalarS32 a, ScalarS32 b); | 329 | void EmitSMin32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| 330 | void EmitUMin32(EmitContext& ctx, ScalarU32 a, ScalarU32 b); | 330 | void EmitUMin32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b); |
| 331 | void EmitSMax32(EmitContext& ctx, ScalarS32 a, ScalarS32 b); | 331 | void EmitSMax32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); |
| 332 | void EmitUMax32(EmitContext& ctx, ScalarU32 a, ScalarU32 b); | 332 | void EmitUMax32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b); |
| 333 | void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max); | 333 | void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max); |
| 334 | void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max); | 334 | void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max); |
| 335 | void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs); | 335 | void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs); |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp index 2db05e62d..9d72af942 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp | |||
| @@ -30,16 +30,16 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) { | |||
| 30 | ctx.Add("MUL.S {}.x,{},{};", inst, a, b); | 30 | ctx.Add("MUL.S {}.x,{},{};", inst, a, b); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { | 33 | void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { |
| 34 | throw NotImplementedException("GLASM instruction"); | 34 | ctx.Add("MOV.S {},-{};", inst, value); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { | 37 | void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { |
| 38 | throw NotImplementedException("GLASM instruction"); | 38 | throw NotImplementedException("GLASM instruction"); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { | 41 | void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { |
| 42 | throw NotImplementedException("GLASM instruction"); | 42 | ctx.Add("ABS.S {},{};", inst, value); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { | 45 | void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { |
| @@ -55,9 +55,8 @@ void EmitShiftLeftLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] | |||
| 55 | throw NotImplementedException("GLASM instruction"); | 55 | throw NotImplementedException("GLASM instruction"); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | void EmitShiftRightLogical32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 base, | 58 | void EmitShiftRightLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift) { |
| 59 | [[maybe_unused]] ScalarU32 shift) { | 59 | ctx.Add("SHR.U {}.x,{},{};", inst, base, shift); |
| 60 | throw NotImplementedException("GLASM instruction"); | ||
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, | 62 | void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, |
| @@ -65,9 +64,8 @@ void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] | |||
| 65 | throw NotImplementedException("GLASM instruction"); | 64 | throw NotImplementedException("GLASM instruction"); |
| 66 | } | 65 | } |
| 67 | 66 | ||
| 68 | void EmitShiftRightArithmetic32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 base, | 67 | void EmitShiftRightArithmetic32(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, ScalarS32 shift) { |
| 69 | [[maybe_unused]] ScalarS32 shift) { | 68 | ctx.Add("SHR.S {}.x,{},{};", inst, base, shift); |
| 70 | throw NotImplementedException("GLASM instruction"); | ||
| 71 | } | 69 | } |
| 72 | 70 | ||
| 73 | void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, | 71 | void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, |
| @@ -109,52 +107,48 @@ void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { | |||
| 109 | ctx.Add("BFR {},{};", inst, value); | 107 | ctx.Add("BFR {},{};", inst, value); |
| 110 | } | 108 | } |
| 111 | 109 | ||
| 112 | void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { | 110 | void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { |
| 113 | throw NotImplementedException("GLASM instruction"); | 111 | ctx.Add("BTC {},{};", inst, value); |
| 114 | } | 112 | } |
| 115 | 113 | ||
| 116 | void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { | 114 | void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { |
| 117 | ctx.Add("NOT.S {},{};", inst, value); | 115 | ctx.Add("NOT.S {},{};", inst, value); |
| 118 | } | 116 | } |
| 119 | 117 | ||
| 120 | void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { | 118 | void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { |
| 121 | throw NotImplementedException("GLASM instruction"); | 119 | ctx.Add("BTFM.S {},{};", inst, value); |
| 122 | } | 120 | } |
| 123 | 121 | ||
| 124 | void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 value) { | 122 | void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value) { |
| 125 | throw NotImplementedException("GLASM instruction"); | 123 | ctx.Add("BTFM.U {},{};", inst, value); |
| 126 | } | 124 | } |
| 127 | 125 | ||
| 128 | void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a, | 126 | void EmitSMin32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) { |
| 129 | [[maybe_unused]] ScalarS32 b) { | 127 | ctx.Add("MIN.S {},{},{};", inst, a, b); |
| 130 | throw NotImplementedException("GLASM instruction"); | ||
| 131 | } | 128 | } |
| 132 | 129 | ||
| 133 | void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a, | 130 | void EmitUMin32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b) { |
| 134 | [[maybe_unused]] ScalarU32 b) { | 131 | ctx.Add("MIN.U {},{},{};", inst, a, b); |
| 135 | throw NotImplementedException("GLASM instruction"); | ||
| 136 | } | 132 | } |
| 137 | 133 | ||
| 138 | void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a, | 134 | void EmitSMax32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) { |
| 139 | [[maybe_unused]] ScalarS32 b) { | 135 | ctx.Add("MAX.S {},{},{};", inst, a, b); |
| 140 | throw NotImplementedException("GLASM instruction"); | ||
| 141 | } | 136 | } |
| 142 | 137 | ||
| 143 | void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a, | 138 | void EmitUMax32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b) { |
| 144 | [[maybe_unused]] ScalarU32 b) { | 139 | ctx.Add("MAX.U {},{},{};", inst, a, b); |
| 145 | throw NotImplementedException("GLASM instruction"); | ||
| 146 | } | 140 | } |
| 147 | 141 | ||
| 148 | void EmitSClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 142 | void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max) { |
| 149 | [[maybe_unused]] ScalarS32 value, [[maybe_unused]] ScalarS32 min, | 143 | const Register ret{ctx.reg_alloc.Define(inst)}; |
| 150 | [[maybe_unused]] ScalarS32 max) { | 144 | ctx.Add("MIN.S {}.x,{},{};", ret, max, value); |
| 151 | throw NotImplementedException("GLASM instruction"); | 145 | ctx.Add("MAX.S {}.x,{},{};", ret, ret, min); |
| 152 | } | 146 | } |
| 153 | 147 | ||
| 154 | void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 148 | void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max) { |
| 155 | [[maybe_unused]] ScalarU32 value, [[maybe_unused]] ScalarU32 min, | 149 | const Register ret{ctx.reg_alloc.Define(inst)}; |
| 156 | [[maybe_unused]] ScalarU32 max) { | 150 | ctx.Add("MIN.U {}.x,{},{};", ret, max, value); |
| 157 | throw NotImplementedException("GLASM instruction"); | 151 | ctx.Add("MAX.U {}.x,{},{};", ret, ret, min); |
| 158 | } | 152 | } |
| 159 | 153 | ||
| 160 | void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs) { | 154 | void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs) { |