summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-08 18:50:10 -0400
committerGravatar ameerj2021-07-22 21:51:30 -0400
commit941c6dc740ed368edbbc00913ace73dddecd43ba (patch)
tree8747fc4328791cf32e793d85dc5eaca9d9cded0a /src/shader_recompiler/backend
parentglasm: Use BitField instead of C bitfields (diff)
downloadyuzu-941c6dc740ed368edbbc00913ace73dddecd43ba.tar.gz
yuzu-941c6dc740ed368edbbc00913ace73dddecd43ba.tar.xz
yuzu-941c6dc740ed368edbbc00913ace73dddecd43ba.zip
glasm: Implement BFI, BFE
Along with implementations of common instructions along the way
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_instructions.h66
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp146
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp40
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_select.cpp50
4 files changed, 164 insertions, 138 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
index 30cc6c2eb..13f47b253 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
@@ -208,8 +208,8 @@ void EmitSelectU8(EmitContext& ctx, std::string_view cond, std::string_view true
208 std::string_view false_value); 208 std::string_view false_value);
209void EmitSelectU16(EmitContext& ctx, std::string_view cond, std::string_view true_value, 209void EmitSelectU16(EmitContext& ctx, std::string_view cond, std::string_view true_value,
210 std::string_view false_value); 210 std::string_view false_value);
211void EmitSelectU32(EmitContext& ctx, std::string_view cond, std::string_view true_value, 211void EmitSelectU32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
212 std::string_view false_value); 212 std::string_view true_value, std::string_view false_value);
213void EmitSelectU64(EmitContext& ctx, std::string_view cond, std::string_view true_value, 213void EmitSelectU64(EmitContext& ctx, std::string_view cond, std::string_view true_value,
214 std::string_view false_value); 214 std::string_view false_value);
215void EmitSelectF16(EmitContext& ctx, std::string_view cond, std::string_view true_value, 215void EmitSelectF16(EmitContext& ctx, std::string_view cond, std::string_view true_value,
@@ -332,14 +332,14 @@ void EmitFPIsNan16(EmitContext& ctx, std::string_view value);
332void EmitFPIsNan32(EmitContext& ctx, std::string_view value); 332void EmitFPIsNan32(EmitContext& ctx, std::string_view value);
333void EmitFPIsNan64(EmitContext& ctx, std::string_view value); 333void EmitFPIsNan64(EmitContext& ctx, std::string_view value);
334void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); 334void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
335void EmitIAdd64(EmitContext& ctx, std::string_view a, std::string_view b); 335void EmitIAdd64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
336void EmitISub32(EmitContext& ctx, std::string_view a, std::string_view b); 336void EmitISub32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
337void EmitISub64(EmitContext& ctx, std::string_view a, std::string_view b); 337void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
338void EmitIMul32(EmitContext& ctx, std::string_view a, std::string_view b); 338void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
339void EmitINeg32(EmitContext& ctx, std::string_view value); 339void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
340void EmitINeg64(EmitContext& ctx, std::string_view value); 340void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value);
341void EmitIAbs32(EmitContext& ctx, std::string_view value); 341void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
342void EmitIAbs64(EmitContext& ctx, std::string_view value); 342void EmitIAbs64(EmitContext& ctx, IR::Inst& inst, std::string_view value);
343void EmitShiftLeftLogical32(EmitContext& ctx, std::string_view base, std::string_view shift); 343void EmitShiftLeftLogical32(EmitContext& ctx, std::string_view base, std::string_view shift);
344void EmitShiftLeftLogical64(EmitContext& ctx, std::string_view base, std::string_view shift); 344void EmitShiftLeftLogical64(EmitContext& ctx, std::string_view base, std::string_view shift);
345void EmitShiftRightLogical32(EmitContext& ctx, std::string_view base, std::string_view shift); 345void EmitShiftRightLogical32(EmitContext& ctx, std::string_view base, std::string_view shift);
@@ -349,35 +349,39 @@ void EmitShiftRightArithmetic64(EmitContext& ctx, std::string_view base, std::st
349void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); 349void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
350void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); 350void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
351void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b); 351void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
352void EmitBitFieldInsert(EmitContext& ctx, std::string_view base, std::string_view insert, 352void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
353 std::string_view offset, std::string_view count); 353 std::string_view insert, std::string_view offset, std::string_view count);
354void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 354void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
355 std::string_view offset, std::string_view count); 355 std::string_view offset, std::string_view count);
356void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 356void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
357 std::string_view offset, std::string_view count); 357 std::string_view offset, std::string_view count);
358void EmitBitReverse32(EmitContext& ctx, std::string_view value); 358void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
359void EmitBitCount32(EmitContext& ctx, std::string_view value); 359void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
360void EmitBitwiseNot32(EmitContext& ctx, std::string_view value); 360void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
361void EmitFindSMsb32(EmitContext& ctx, std::string_view value); 361void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
362void EmitFindUMsb32(EmitContext& ctx, std::string_view value); 362void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, std::string_view value);
363void EmitSMin32(EmitContext& ctx, std::string_view a, std::string_view b); 363void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
364void EmitUMin32(EmitContext& ctx, std::string_view a, std::string_view b); 364void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
365void EmitSMax32(EmitContext& ctx, std::string_view a, std::string_view b); 365void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
366void EmitUMax32(EmitContext& ctx, std::string_view a, std::string_view b); 366void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b);
367void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 367void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
368 std::string_view max); 368 std::string_view max);
369void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 369void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
370 std::string_view max); 370 std::string_view max);
371void EmitSLessThan(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 371void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs);
372void EmitULessThan(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 372void EmitULessThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs);
373void EmitIEqual(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 373void EmitIEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs);
374void EmitSLessThanEqual(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 374void EmitSLessThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs,
375void EmitULessThanEqual(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 375 std::string_view rhs);
376void EmitSGreaterThan(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 376void EmitULessThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs,
377void EmitUGreaterThan(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 377 std::string_view rhs);
378void EmitINotEqual(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 378void EmitSGreaterThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs);
379void EmitSGreaterThanEqual(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 379void EmitUGreaterThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs);
380void EmitUGreaterThanEqual(EmitContext& ctx, std::string_view lhs, std::string_view rhs); 380void EmitINotEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs);
381void EmitSGreaterThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs,
382 std::string_view rhs);
383void EmitUGreaterThanEqual(EmitContext& ctx, IR::Inst& inst, std::string_view lhs,
384 std::string_view rhs);
381void EmitSharedAtomicIAdd32(EmitContext& ctx, std::string_view pointer_offset, 385void EmitSharedAtomicIAdd32(EmitContext& ctx, std::string_view pointer_offset,
382 std::string_view value); 386 std::string_view value);
383void EmitSharedAtomicSMin32(EmitContext& ctx, std::string_view pointer_offset, 387void EmitSharedAtomicSMin32(EmitContext& ctx, std::string_view pointer_offset,
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
index e228fa072..d4e519a2a 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
@@ -12,42 +12,46 @@ namespace Shader::Backend::GLASM {
12 12
13void EmitIAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 13void EmitIAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
14 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 14 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
15 throw NotImplementedException("GLASM instruction"); 15 ctx.Add("ADD {},{},{};", inst, a, b);
16} 16}
17 17
18void EmitIAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 18void EmitIAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
19 [[maybe_unused]] std::string_view b) { 19 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
20 throw NotImplementedException("GLASM instruction"); 20 throw NotImplementedException("GLASM instruction");
21} 21}
22 22
23void EmitISub32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 23void EmitISub32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
24 [[maybe_unused]] std::string_view b) { 24 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
25 throw NotImplementedException("GLASM instruction"); 25 ctx.Add("SUB {},{},{};", inst, a, b);
26} 26}
27 27
28void EmitISub64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 28void EmitISub64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
29 [[maybe_unused]] std::string_view b) { 29 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
30 throw NotImplementedException("GLASM instruction"); 30 throw NotImplementedException("GLASM instruction");
31} 31}
32 32
33void EmitIMul32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 33void EmitIMul32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
34 [[maybe_unused]] std::string_view b) { 34 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
35 throw NotImplementedException("GLASM instruction"); 35 throw NotImplementedException("GLASM instruction");
36} 36}
37 37
38void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 38void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
39 [[maybe_unused]] std::string_view value) {
39 throw NotImplementedException("GLASM instruction"); 40 throw NotImplementedException("GLASM instruction");
40} 41}
41 42
42void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 43void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
44 [[maybe_unused]] std::string_view value) {
43 throw NotImplementedException("GLASM instruction"); 45 throw NotImplementedException("GLASM instruction");
44} 46}
45 47
46void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 48void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
49 [[maybe_unused]] std::string_view value) {
47 throw NotImplementedException("GLASM instruction"); 50 throw NotImplementedException("GLASM instruction");
48} 51}
49 52
50void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 53void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
54 [[maybe_unused]] std::string_view value) {
51 throw NotImplementedException("GLASM instruction"); 55 throw NotImplementedException("GLASM instruction");
52} 56}
53 57
@@ -94,7 +98,7 @@ void EmitBitwiseAnd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In
94 98
95void EmitBitwiseOr32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 99void EmitBitwiseOr32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
96 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 100 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
97 throw NotImplementedException("GLASM instruction"); 101 ctx.Add("OR {},{},{};", inst, a, b);
98} 102}
99 103
100void EmitBitwiseXor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 104void EmitBitwiseXor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
@@ -102,64 +106,66 @@ void EmitBitwiseXor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In
102 throw NotImplementedException("GLASM instruction"); 106 throw NotImplementedException("GLASM instruction");
103} 107}
104 108
105void EmitBitFieldInsert([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view base, 109void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
106 [[maybe_unused]] std::string_view insert, 110 std::string_view insert, std::string_view offset, std::string_view count) {
107 [[maybe_unused]] std::string_view offset, 111 ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset);
108 [[maybe_unused]] std::string_view count) { 112 ctx.Add("BFI.U {},RC,{},{};", inst, insert, base);
109 throw NotImplementedException("GLASM instruction");
110} 113}
111 114
112void EmitBitFieldSExtract([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 115void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
113 [[maybe_unused]] std::string_view base, 116 std::string_view offset, std::string_view count) {
114 [[maybe_unused]] std::string_view offset, 117 ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset);
115 [[maybe_unused]] std::string_view count) { 118 ctx.Add("BFE.S {},RC,{};", inst, base);
116 throw NotImplementedException("GLASM instruction");
117} 119}
118 120
119void EmitBitFieldUExtract([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 121void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
120 [[maybe_unused]] std::string_view base, 122 std::string_view offset, std::string_view count) {
121 [[maybe_unused]] std::string_view offset, 123 ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset);
122 [[maybe_unused]] std::string_view count) { 124 ctx.Add("BFE.U {},RC,{};", inst, base);
123 throw NotImplementedException("GLASM instruction");
124} 125}
125 126
126void EmitBitReverse32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 127void EmitBitReverse32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
127 throw NotImplementedException("GLASM instruction"); 128 [[maybe_unused]] std::string_view value) {
129 ctx.Add("BFR {},{};", inst, value);
128} 130}
129 131
130void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 132void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
133 [[maybe_unused]] std::string_view value) {
131 throw NotImplementedException("GLASM instruction"); 134 throw NotImplementedException("GLASM instruction");
132} 135}
133 136
134void EmitBitwiseNot32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 137void EmitBitwiseNot32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
138 [[maybe_unused]] std::string_view value) {
135 throw NotImplementedException("GLASM instruction"); 139 throw NotImplementedException("GLASM instruction");
136} 140}
137 141
138void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 142void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
143 [[maybe_unused]] std::string_view value) {
139 throw NotImplementedException("GLASM instruction"); 144 throw NotImplementedException("GLASM instruction");
140} 145}
141 146
142void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view value) { 147void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
148 [[maybe_unused]] std::string_view value) {
143 throw NotImplementedException("GLASM instruction"); 149 throw NotImplementedException("GLASM instruction");
144} 150}
145 151
146void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 152void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
147 [[maybe_unused]] std::string_view b) { 153 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
148 throw NotImplementedException("GLASM instruction"); 154 throw NotImplementedException("GLASM instruction");
149} 155}
150 156
151void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 157void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
152 [[maybe_unused]] std::string_view b) { 158 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
153 throw NotImplementedException("GLASM instruction"); 159 throw NotImplementedException("GLASM instruction");
154} 160}
155 161
156void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 162void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
157 [[maybe_unused]] std::string_view b) { 163 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
158 throw NotImplementedException("GLASM instruction"); 164 throw NotImplementedException("GLASM instruction");
159} 165}
160 166
161void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view a, 167void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
162 [[maybe_unused]] std::string_view b) { 168 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) {
163 throw NotImplementedException("GLASM instruction"); 169 throw NotImplementedException("GLASM instruction");
164} 170}
165 171
@@ -175,54 +181,60 @@ void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst&
175 throw NotImplementedException("GLASM instruction"); 181 throw NotImplementedException("GLASM instruction");
176} 182}
177 183
178void EmitSLessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 184void EmitSLessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
179 [[maybe_unused]] std::string_view rhs) { 185 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) {
180 throw NotImplementedException("GLASM instruction"); 186 ctx.Add("SLT.S {},{},{};", inst, lhs, rhs);
181} 187}
182 188
183void EmitULessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 189void EmitULessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
184 [[maybe_unused]] std::string_view rhs) { 190 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) {
185 throw NotImplementedException("GLASM instruction"); 191 ctx.Add("SLT.U {},{},{};", inst, lhs, rhs);
186} 192}
187 193
188void EmitIEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 194void EmitIEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
189 [[maybe_unused]] std::string_view rhs) { 195 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) {
190 throw NotImplementedException("GLASM instruction"); 196 ctx.Add("SEQ {},{},{};", inst, lhs, rhs);
191} 197}
192 198
193void EmitSLessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 199void EmitSLessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
200 [[maybe_unused]] std::string_view lhs,
194 [[maybe_unused]] std::string_view rhs) { 201 [[maybe_unused]] std::string_view rhs) {
195 throw NotImplementedException("GLASM instruction"); 202 ctx.Add("SLE.S {},{},{};", inst, lhs, rhs);
196} 203}
197 204
198void EmitULessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 205void EmitULessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
206 [[maybe_unused]] std::string_view lhs,
199 [[maybe_unused]] std::string_view rhs) { 207 [[maybe_unused]] std::string_view rhs) {
200 throw NotImplementedException("GLASM instruction"); 208 ctx.Add("SLE.U {},{},{};", inst, lhs, rhs);
201} 209}
202 210
203void EmitSGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 211void EmitSGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
212 [[maybe_unused]] std::string_view lhs,
204 [[maybe_unused]] std::string_view rhs) { 213 [[maybe_unused]] std::string_view rhs) {
205 throw NotImplementedException("GLASM instruction"); 214 ctx.Add("SGT.S {},{},{};", inst, lhs, rhs);
206} 215}
207 216
208void EmitUGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 217void EmitUGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
218 [[maybe_unused]] std::string_view lhs,
209 [[maybe_unused]] std::string_view rhs) { 219 [[maybe_unused]] std::string_view rhs) {
210 throw NotImplementedException("GLASM instruction"); 220 ctx.Add("SGT.U {},{},{};", inst, lhs, rhs);
211} 221}
212 222
213void EmitINotEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 223void EmitINotEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
214 [[maybe_unused]] std::string_view rhs) { 224 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) {
215 throw NotImplementedException("GLASM instruction"); 225 throw NotImplementedException("GLASM instruction");
216} 226}
217 227
218void EmitSGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 228void EmitSGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
229 [[maybe_unused]] std::string_view lhs,
219 [[maybe_unused]] std::string_view rhs) { 230 [[maybe_unused]] std::string_view rhs) {
220 throw NotImplementedException("GLASM instruction"); 231 ctx.Add("SGE.S {},{},{};", inst, lhs, rhs);
221} 232}
222 233
223void EmitUGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] std::string_view lhs, 234void EmitUGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
235 [[maybe_unused]] std::string_view lhs,
224 [[maybe_unused]] std::string_view rhs) { 236 [[maybe_unused]] std::string_view rhs) {
225 throw NotImplementedException("GLASM instruction"); 237 ctx.Add("SGE.U {},{},{};", inst, lhs, rhs);
226} 238}
227 239
228} // namespace Shader::Backend::GLASM 240} // namespace Shader::Backend::GLASM
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 1337f4ae8..32eb87837 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp
@@ -413,46 +413,6 @@ void EmitCompositeInsertF64x4(EmitContext& ctx, std::string_view composite, std:
413 NotImplemented(); 413 NotImplemented();
414} 414}
415 415
416void EmitSelectU1(EmitContext& ctx, std::string_view cond, std::string_view true_value,
417 std::string_view false_value) {
418 NotImplemented();
419}
420
421void EmitSelectU8(EmitContext& ctx, std::string_view cond, std::string_view true_value,
422 std::string_view false_value) {
423 NotImplemented();
424}
425
426void EmitSelectU16(EmitContext& ctx, std::string_view cond, std::string_view true_value,
427 std::string_view false_value) {
428 NotImplemented();
429}
430
431void EmitSelectU32(EmitContext& ctx, std::string_view cond, std::string_view true_value,
432 std::string_view false_value) {
433 NotImplemented();
434}
435
436void EmitSelectU64(EmitContext& ctx, std::string_view cond, std::string_view true_value,
437 std::string_view false_value) {
438 NotImplemented();
439}
440
441void EmitSelectF16(EmitContext& ctx, std::string_view cond, std::string_view true_value,
442 std::string_view false_value) {
443 NotImplemented();
444}
445
446void EmitSelectF32(EmitContext& ctx, std::string_view cond, std::string_view true_value,
447 std::string_view false_value) {
448 NotImplemented();
449}
450
451void EmitSelectF64(EmitContext& ctx, std::string_view cond, std::string_view true_value,
452 std::string_view false_value) {
453 NotImplemented();
454}
455
456void EmitPackUint2x32(EmitContext& ctx, std::string_view value) { 416void EmitPackUint2x32(EmitContext& ctx, std::string_view value) {
457 NotImplemented(); 417 NotImplemented();
458} 418}
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_select.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_select.cpp
index e69de29bb..636cbe8a0 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_select.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_select.cpp
@@ -0,0 +1,50 @@
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 <string_view>
6
7#include "shader_recompiler/backend/glasm/emit_context.h"
8#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
9#include "shader_recompiler/frontend/ir/value.h"
10
11namespace Shader::Backend::GLASM {
12
13void EmitSelectU1(EmitContext&, std::string_view, std::string_view, std::string_view) {
14 throw NotImplementedException("GLASM instruction");
15}
16
17void EmitSelectU8(EmitContext&, std::string_view, std::string_view, std::string_view) {
18 throw NotImplementedException("GLASM instruction");
19}
20
21void EmitSelectU16(EmitContext&, std::string_view, std::string_view, std::string_view) {
22 throw NotImplementedException("GLASM instruction");
23}
24
25void EmitSelectU32(EmitContext& ctx, IR::Inst& inst, std::string_view cond,
26 std::string_view true_value, std::string_view false_value) {
27 ctx.Add("MOV.U.CC RC,{};", cond);
28 ctx.Add("IF NE.x;");
29 ctx.Add("MOV.U {},{};", inst, true_value);
30 ctx.Add("ELSE;");
31 ctx.Add("MOV.U {},{};", inst, false_value);
32 ctx.Add("ENDIF;");
33}
34
35void EmitSelectU64(EmitContext&, std::string_view, std::string_view, std::string_view) {
36 throw NotImplementedException("GLASM instruction");
37}
38
39void EmitSelectF16(EmitContext&, std::string_view, std::string_view, std::string_view) {
40 throw NotImplementedException("GLASM instruction");
41}
42
43void EmitSelectF32(EmitContext&, std::string_view, std::string_view, std::string_view) {
44 throw NotImplementedException("GLASM instruction");
45}
46
47void EmitSelectF64(EmitContext&, std::string_view, std::string_view, std::string_view) {
48 throw NotImplementedException("GLASM instruction");
49}
50} // namespace Shader::Backend::GLASM