summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp216
1 files changed, 93 insertions, 123 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
index 579806c38..7b88d6f02 100644
--- a/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
+++ b/src/shader_recompiler/backend/glasm/emit_glasm_integer.cpp
@@ -2,239 +2,209 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <string_view>
6
7#include "shader_recompiler/backend/glasm/emit_context.h" 5#include "shader_recompiler/backend/glasm/emit_context.h"
8#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h" 6#include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
9#include "shader_recompiler/frontend/ir/value.h" 7#include "shader_recompiler/frontend/ir/value.h"
10 8
11namespace Shader::Backend::GLASM { 9namespace Shader::Backend::GLASM {
12 10
13void EmitIAdd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 11void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
14 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 12 ctx.Add("ADD.S {}.x,{},{};", inst, a, b);
15 ctx.Add("ADD.U {},{},{};", inst, a, b);
16} 13}
17 14
18void EmitIAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 15void EmitIAdd64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register a,
19 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 16 [[maybe_unused]] Register b) {
20 throw NotImplementedException("GLASM instruction"); 17 throw NotImplementedException("GLASM instruction");
21} 18}
22 19
23void EmitISub32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 20void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
24 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 21 ctx.Add("SUB.S {}.x,{},{};", inst, a, b);
25 ctx.Add("SUB.U {},{},{};", inst, a, b);
26} 22}
27 23
28void EmitISub64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 24void EmitISub64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register a,
29 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 25 [[maybe_unused]] Register b) {
30 throw NotImplementedException("GLASM instruction"); 26 throw NotImplementedException("GLASM instruction");
31} 27}
32 28
33void EmitIMul32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 29void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
34 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 30 ctx.Add("MUL.S {}.x,{},{};", inst, a, b);
35 throw NotImplementedException("GLASM instruction");
36} 31}
37 32
38void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 33void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
39 [[maybe_unused]] std::string_view value) {
40 throw NotImplementedException("GLASM instruction"); 34 throw NotImplementedException("GLASM instruction");
41} 35}
42 36
43void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 37void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
44 [[maybe_unused]] std::string_view value) {
45 throw NotImplementedException("GLASM instruction"); 38 throw NotImplementedException("GLASM instruction");
46} 39}
47 40
48void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 41void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
49 [[maybe_unused]] std::string_view value) {
50 throw NotImplementedException("GLASM instruction"); 42 throw NotImplementedException("GLASM instruction");
51} 43}
52 44
53void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 45void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
54 [[maybe_unused]] std::string_view value) {
55 throw NotImplementedException("GLASM instruction"); 46 throw NotImplementedException("GLASM instruction");
56} 47}
57 48
58void EmitShiftLeftLogical32([[maybe_unused]] EmitContext& ctx, 49void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift) {
59 [[maybe_unused]] std::string_view base, 50 ctx.Add("SHL.U {}.x,{},{};", inst, base, shift);
60 [[maybe_unused]] std::string_view shift) {
61 throw NotImplementedException("GLASM instruction");
62} 51}
63 52
64void EmitShiftLeftLogical64([[maybe_unused]] EmitContext& ctx, 53void EmitShiftLeftLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
65 [[maybe_unused]] std::string_view base, 54 [[maybe_unused]] Register shift) {
66 [[maybe_unused]] std::string_view shift) {
67 throw NotImplementedException("GLASM instruction"); 55 throw NotImplementedException("GLASM instruction");
68} 56}
69 57
70void EmitShiftRightLogical32([[maybe_unused]] EmitContext& ctx, 58void EmitShiftRightLogical32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 base,
71 [[maybe_unused]] std::string_view base, 59 [[maybe_unused]] ScalarU32 shift) {
72 [[maybe_unused]] std::string_view shift) {
73 throw NotImplementedException("GLASM instruction"); 60 throw NotImplementedException("GLASM instruction");
74} 61}
75 62
76void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, 63void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
77 [[maybe_unused]] std::string_view base, 64 [[maybe_unused]] Register shift) {
78 [[maybe_unused]] std::string_view shift) {
79 throw NotImplementedException("GLASM instruction"); 65 throw NotImplementedException("GLASM instruction");
80} 66}
81 67
82void EmitShiftRightArithmetic32([[maybe_unused]] EmitContext& ctx, 68void EmitShiftRightArithmetic32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 base,
83 [[maybe_unused]] std::string_view base, 69 [[maybe_unused]] ScalarS32 shift) {
84 [[maybe_unused]] std::string_view shift) {
85 throw NotImplementedException("GLASM instruction"); 70 throw NotImplementedException("GLASM instruction");
86} 71}
87 72
88void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, 73void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
89 [[maybe_unused]] std::string_view base, 74 [[maybe_unused]] Register shift) {
90 [[maybe_unused]] std::string_view shift) {
91 throw NotImplementedException("GLASM instruction"); 75 throw NotImplementedException("GLASM instruction");
92} 76}
93 77
94void EmitBitwiseAnd32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 78void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
95 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 79 ctx.Add("AND.S {}.x,{},{};", inst, a, b);
96 ctx.Add("AND {},{},{};", inst, a, b);
97} 80}
98 81
99void EmitBitwiseOr32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 82void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
100 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 83 ctx.Add("OR.S {}.x,{},{};", inst, a, b);
101 ctx.Add("OR {},{},{};", inst, a, b);
102} 84}
103 85
104void EmitBitwiseXor32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 86void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
105 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 87 ctx.Add("XOR.S {}.x,{},{};", inst, a, b);
106 ctx.Add("XOR {},{},{};", inst, a, b);
107} 88}
108 89
109void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base, 90void EmitBitFieldInsert([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 base,
110 std::string_view insert, std::string_view offset, std::string_view count) { 91 [[maybe_unused]] ScalarS32 insert, [[maybe_unused]] ScalarS32 offset,
111 ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset); 92 [[maybe_unused]] ScalarS32 count) {
112 ctx.Add("BFI.U {},RC,{},{};", inst, insert, base); 93 throw NotImplementedException("GLASM instruction");
113} 94}
114 95
115void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 96void EmitBitFieldSExtract([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
116 std::string_view offset, std::string_view count) { 97 [[maybe_unused]] ScalarS32 base, [[maybe_unused]] ScalarS32 offset,
117 ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset); 98 [[maybe_unused]] ScalarS32 count) {
118 ctx.Add("BFE.S {},RC,{};", inst, base); 99 throw NotImplementedException("GLASM instruction");
119} 100}
120 101
121void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 102void EmitBitFieldUExtract([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
122 std::string_view offset, std::string_view count) { 103 [[maybe_unused]] ScalarU32 base, [[maybe_unused]] ScalarU32 offset,
123 ctx.Add("MOV.U RC.x,{};MOV.U RC.y,{};", count, offset); 104 [[maybe_unused]] ScalarU32 count) {
124 ctx.Add("BFE.U {},RC,{};", inst, base); 105 throw NotImplementedException("GLASM instruction");
125} 106}
126 107
127void EmitBitReverse32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 108void EmitBitReverse32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
128 [[maybe_unused]] std::string_view value) { 109 throw NotImplementedException("GLASM instruction");
129 ctx.Add("BFR {},{};", inst, value);
130} 110}
131 111
132void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 112void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
133 [[maybe_unused]] std::string_view value) {
134 throw NotImplementedException("GLASM instruction"); 113 throw NotImplementedException("GLASM instruction");
135} 114}
136 115
137void EmitBitwiseNot32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 116void EmitBitwiseNot32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
138 [[maybe_unused]] std::string_view value) { 117 throw NotImplementedException("GLASM instruction");
139 ctx.Add("NOT {},{};", inst, value);
140} 118}
141 119
142void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 120void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) {
143 [[maybe_unused]] std::string_view value) {
144 throw NotImplementedException("GLASM instruction"); 121 throw NotImplementedException("GLASM instruction");
145} 122}
146 123
147void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 124void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 value) {
148 [[maybe_unused]] std::string_view value) {
149 throw NotImplementedException("GLASM instruction"); 125 throw NotImplementedException("GLASM instruction");
150} 126}
151 127
152void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 128void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a,
153 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 129 [[maybe_unused]] ScalarS32 b) {
154 throw NotImplementedException("GLASM instruction"); 130 throw NotImplementedException("GLASM instruction");
155} 131}
156 132
157void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 133void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a,
158 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 134 [[maybe_unused]] ScalarU32 b) {
159 throw NotImplementedException("GLASM instruction"); 135 throw NotImplementedException("GLASM instruction");
160} 136}
161 137
162void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 138void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a,
163 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 139 [[maybe_unused]] ScalarS32 b) {
164 throw NotImplementedException("GLASM instruction"); 140 throw NotImplementedException("GLASM instruction");
165} 141}
166 142
167void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 143void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a,
168 [[maybe_unused]] std::string_view a, [[maybe_unused]] std::string_view b) { 144 [[maybe_unused]] ScalarU32 b) {
169 throw NotImplementedException("GLASM instruction"); 145 throw NotImplementedException("GLASM instruction");
170} 146}
171 147
172void EmitSClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 148void EmitSClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
173 [[maybe_unused]] std::string_view value, [[maybe_unused]] std::string_view min, 149 [[maybe_unused]] ScalarS32 value, [[maybe_unused]] ScalarS32 min,
174 [[maybe_unused]] std::string_view max) { 150 [[maybe_unused]] ScalarS32 max) {
175 throw NotImplementedException("GLASM instruction"); 151 throw NotImplementedException("GLASM instruction");
176} 152}
177 153
178void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 154void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
179 [[maybe_unused]] std::string_view value, [[maybe_unused]] std::string_view min, 155 [[maybe_unused]] ScalarU32 value, [[maybe_unused]] ScalarU32 min,
180 [[maybe_unused]] std::string_view max) { 156 [[maybe_unused]] ScalarU32 max) {
181 throw NotImplementedException("GLASM instruction"); 157 throw NotImplementedException("GLASM instruction");
182} 158}
183 159
184void EmitSLessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 160void EmitSLessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
185 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { 161 [[maybe_unused]] ScalarS32 rhs) {
186 ctx.Add("SLT.S {},{},{};", inst, lhs, rhs); 162 throw NotImplementedException("GLASM instruction");
187} 163}
188 164
189void EmitULessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 165void EmitULessThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
190 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { 166 [[maybe_unused]] ScalarU32 rhs) {
191 ctx.Add("SLT.U {},{},{};", inst, lhs, rhs); 167 throw NotImplementedException("GLASM instruction");
192} 168}
193 169
194void EmitIEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 170void EmitIEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
195 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { 171 [[maybe_unused]] ScalarS32 rhs) {
196 ctx.Add("SEQ {},{},{};", inst, lhs, rhs); 172 throw NotImplementedException("GLASM instruction");
197} 173}
198 174
199void EmitSLessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 175void EmitSLessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
200 [[maybe_unused]] std::string_view lhs, 176 [[maybe_unused]] ScalarS32 rhs) {
201 [[maybe_unused]] std::string_view rhs) { 177 throw NotImplementedException("GLASM instruction");
202 ctx.Add("SLE.S {},{},{};", inst, lhs, rhs);
203} 178}
204 179
205void EmitULessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 180void EmitULessThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
206 [[maybe_unused]] std::string_view lhs, 181 [[maybe_unused]] ScalarU32 rhs) {
207 [[maybe_unused]] std::string_view rhs) { 182 throw NotImplementedException("GLASM instruction");
208 ctx.Add("SLE.U {},{},{};", inst, lhs, rhs);
209} 183}
210 184
211void EmitSGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 185void EmitSGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
212 [[maybe_unused]] std::string_view lhs, 186 [[maybe_unused]] ScalarS32 rhs) {
213 [[maybe_unused]] std::string_view rhs) { 187 throw NotImplementedException("GLASM instruction");
214 ctx.Add("SGT.S {},{},{};", inst, lhs, rhs);
215} 188}
216 189
217void EmitUGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 190void EmitUGreaterThan([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
218 [[maybe_unused]] std::string_view lhs, 191 [[maybe_unused]] ScalarU32 rhs) {
219 [[maybe_unused]] std::string_view rhs) { 192 throw NotImplementedException("GLASM instruction");
220 ctx.Add("SGT.U {},{},{};", inst, lhs, rhs);
221} 193}
222 194
223void EmitINotEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 195void EmitINotEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
224 [[maybe_unused]] std::string_view lhs, [[maybe_unused]] std::string_view rhs) { 196 [[maybe_unused]] ScalarS32 rhs) {
225 ctx.Add("SNE.U {},{},{};", inst, lhs, rhs); 197 throw NotImplementedException("GLASM instruction");
226} 198}
227 199
228void EmitSGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 200void EmitSGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 lhs,
229 [[maybe_unused]] std::string_view lhs, 201 [[maybe_unused]] ScalarS32 rhs) {
230 [[maybe_unused]] std::string_view rhs) { 202 throw NotImplementedException("GLASM instruction");
231 ctx.Add("SGE.S {},{},{};", inst, lhs, rhs);
232} 203}
233 204
234void EmitUGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 205void EmitUGreaterThanEqual([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 lhs,
235 [[maybe_unused]] std::string_view lhs, 206 [[maybe_unused]] ScalarU32 rhs) {
236 [[maybe_unused]] std::string_view rhs) { 207 throw NotImplementedException("GLASM instruction");
237 ctx.Add("SGE.U {},{},{};", inst, lhs, rhs);
238} 208}
239 209
240} // namespace Shader::Backend::GLASM 210} // namespace Shader::Backend::GLASM