summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-09 18:49:27 -0400
committerGravatar ameerj2021-07-22 21:51:30 -0400
commit6705f56029d627941f56e36273fd4548a88e8b63 (patch)
tree18373a6ee96dfaa7b26f52efb8c864fa7b289825 /src
parentglasm: Reimplement bitwise ops and BFI/BFE (diff)
downloadyuzu-6705f56029d627941f56e36273fd4548a88e8b63.tar.gz
yuzu-6705f56029d627941f56e36273fd4548a88e8b63.tar.xz
yuzu-6705f56029d627941f56e36273fd4548a88e8b63.zip
emit_glasm: Implement more integer alu ops
Diffstat (limited to 'src')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_instructions.h22
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp66
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);
302void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); 302void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
303void EmitISub64(EmitContext& ctx, Register a, Register b); 303void EmitISub64(EmitContext& ctx, Register a, Register b);
304void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); 304void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
305void EmitINeg32(EmitContext& ctx, ScalarS32 value); 305void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
306void EmitINeg64(EmitContext& ctx, Register value); 306void EmitINeg64(EmitContext& ctx, Register value);
307void EmitIAbs32(EmitContext& ctx, ScalarS32 value); 307void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
308void EmitIAbs64(EmitContext& ctx, Register value); 308void EmitIAbs64(EmitContext& ctx, Register value);
309void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift); 309void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift);
310void EmitShiftLeftLogical64(EmitContext& ctx, Register base, Register shift); 310void EmitShiftLeftLogical64(EmitContext& ctx, Register base, Register shift);
311void EmitShiftRightLogical32(EmitContext& ctx, ScalarU32 base, ScalarU32 shift); 311void EmitShiftRightLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift);
312void EmitShiftRightLogical64(EmitContext& ctx, Register base, Register shift); 312void EmitShiftRightLogical64(EmitContext& ctx, Register base, Register shift);
313void EmitShiftRightArithmetic32(EmitContext& ctx, ScalarS32 base, ScalarS32 shift); 313void EmitShiftRightArithmetic32(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, ScalarS32 shift);
314void EmitShiftRightArithmetic64(EmitContext& ctx, Register base, Register shift); 314void EmitShiftRightArithmetic64(EmitContext& ctx, Register base, Register shift);
315void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); 315void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
316void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); 316void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
@@ -322,14 +322,14 @@ void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, Scal
322void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 offset, 322void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 offset,
323 ScalarU32 count); 323 ScalarU32 count);
324void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); 324void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
325void EmitBitCount32(EmitContext& ctx, ScalarS32 value); 325void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
326void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); 326void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
327void EmitFindSMsb32(EmitContext& ctx, ScalarS32 value); 327void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
328void EmitFindUMsb32(EmitContext& ctx, ScalarU32 value); 328void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value);
329void EmitSMin32(EmitContext& ctx, ScalarS32 a, ScalarS32 b); 329void EmitSMin32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
330void EmitUMin32(EmitContext& ctx, ScalarU32 a, ScalarU32 b); 330void EmitUMin32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b);
331void EmitSMax32(EmitContext& ctx, ScalarS32 a, ScalarS32 b); 331void EmitSMax32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
332void EmitUMax32(EmitContext& ctx, ScalarU32 a, ScalarU32 b); 332void EmitUMax32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b);
333void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max); 333void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max);
334void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max); 334void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max);
335void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs); 335void 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
33void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { 33void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
34 throw NotImplementedException("GLASM instruction"); 34 ctx.Add("MOV.S {},-{};", inst, value);
35} 35}
36 36
37void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { 37void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
38 throw NotImplementedException("GLASM instruction"); 38 throw NotImplementedException("GLASM instruction");
39} 39}
40 40
41void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { 41void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
42 throw NotImplementedException("GLASM instruction"); 42 ctx.Add("ABS.S {},{};", inst, value);
43} 43}
44 44
45void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { 45void 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
58void EmitShiftRightLogical32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 base, 58void 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
63void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, 62void 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
68void EmitShiftRightArithmetic32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 base, 67void 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
73void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, 71void 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
112void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { 110void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
113 throw NotImplementedException("GLASM instruction"); 111 ctx.Add("BTC {},{};", inst, value);
114} 112}
115 113
116void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { 114void 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
120void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { 118void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
121 throw NotImplementedException("GLASM instruction"); 119 ctx.Add("BTFM.S {},{};", inst, value);
122} 120}
123 121
124void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 value) { 122void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value) {
125 throw NotImplementedException("GLASM instruction"); 123 ctx.Add("BTFM.U {},{};", inst, value);
126} 124}
127 125
128void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a, 126void 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
133void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a, 130void 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
138void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a, 134void 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
143void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a, 138void 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
148void EmitSClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 142void 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
154void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 148void 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
160void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs) { 154void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs) {