emit_glasm_not_implemented.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <string_view>
  5. #include "shader_recompiler/backend/glasm/emit_context.h"
  6. #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
  7. #include "shader_recompiler/frontend/ir/program.h"
  8. #include "shader_recompiler/frontend/ir/value.h"
  9. #ifdef _MSC_VER
  10. #pragma warning(disable : 4100)
  11. #endif
  12. namespace Shader::Backend::GLASM {
  13. #define NotImplemented() throw NotImplementedException("GLASM instruction {}", __LINE__)
  14. void EmitPhi(EmitContext&, IR::Inst&) {}
  15. void EmitVoid(EmitContext&) {}
  16. void EmitReference(EmitContext&) {}
  17. void EmitPhiMove(EmitContext& ctx, const IR::Value& phi, const IR::Value& value) {
  18. if (phi == value) {
  19. return;
  20. }
  21. const Register phi_reg{ctx.reg_alloc.Consume(phi)};
  22. const Value eval_value{ctx.reg_alloc.Consume(value)};
  23. switch (phi.Inst()->Flags<IR::Type>()) {
  24. case IR::Type::U1:
  25. case IR::Type::U32:
  26. case IR::Type::F32:
  27. ctx.Add("MOV.S {}.x,{};", phi_reg, ScalarS32{eval_value});
  28. break;
  29. case IR::Type::U64:
  30. case IR::Type::F64:
  31. ctx.Add("MOV.U64 {}.x,{};", phi_reg, ScalarRegister{eval_value});
  32. break;
  33. default:
  34. throw NotImplementedException("Phi node type {}", phi.Type());
  35. }
  36. }
  37. void EmitJoin(EmitContext& ctx) {
  38. NotImplemented();
  39. }
  40. void EmitDemoteToHelperInvocation(EmitContext& ctx) {
  41. ctx.Add("KIL TR.x;");
  42. }
  43. void EmitBarrier(EmitContext& ctx) {
  44. ctx.Add("BAR;");
  45. }
  46. void EmitWorkgroupMemoryBarrier(EmitContext& ctx) {
  47. ctx.Add("MEMBAR.CTA;");
  48. }
  49. void EmitDeviceMemoryBarrier(EmitContext& ctx) {
  50. ctx.Add("MEMBAR;");
  51. }
  52. void EmitPrologue(EmitContext& ctx) {
  53. // TODO
  54. }
  55. void EmitEpilogue(EmitContext& ctx) {
  56. // TODO
  57. }
  58. void EmitEmitVertex(EmitContext& ctx, ScalarS32 stream) {
  59. if (stream.type == Type::U32 && stream.imm_u32 == 0) {
  60. ctx.Add("EMIT;");
  61. } else {
  62. ctx.Add("EMITS {};", stream);
  63. }
  64. }
  65. void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) {
  66. if (!stream.IsImmediate()) {
  67. // LOG_WARNING not immediate
  68. }
  69. ctx.reg_alloc.Consume(stream);
  70. ctx.Add("ENDPRIM;");
  71. }
  72. void EmitGetRegister(EmitContext& ctx) {
  73. NotImplemented();
  74. }
  75. void EmitSetRegister(EmitContext& ctx) {
  76. NotImplemented();
  77. }
  78. void EmitGetPred(EmitContext& ctx) {
  79. NotImplemented();
  80. }
  81. void EmitSetPred(EmitContext& ctx) {
  82. NotImplemented();
  83. }
  84. void EmitSetGotoVariable(EmitContext& ctx) {
  85. NotImplemented();
  86. }
  87. void EmitGetGotoVariable(EmitContext& ctx) {
  88. NotImplemented();
  89. }
  90. void EmitSetIndirectBranchVariable(EmitContext& ctx) {
  91. NotImplemented();
  92. }
  93. void EmitGetIndirectBranchVariable(EmitContext& ctx) {
  94. NotImplemented();
  95. }
  96. void EmitGetZFlag(EmitContext& ctx) {
  97. NotImplemented();
  98. }
  99. void EmitGetSFlag(EmitContext& ctx) {
  100. NotImplemented();
  101. }
  102. void EmitGetCFlag(EmitContext& ctx) {
  103. NotImplemented();
  104. }
  105. void EmitGetOFlag(EmitContext& ctx) {
  106. NotImplemented();
  107. }
  108. void EmitSetZFlag(EmitContext& ctx) {
  109. NotImplemented();
  110. }
  111. void EmitSetSFlag(EmitContext& ctx) {
  112. NotImplemented();
  113. }
  114. void EmitSetCFlag(EmitContext& ctx) {
  115. NotImplemented();
  116. }
  117. void EmitSetOFlag(EmitContext& ctx) {
  118. NotImplemented();
  119. }
  120. void EmitWorkgroupId(EmitContext& ctx, IR::Inst& inst) {
  121. ctx.Add("MOV.S {},invocation.groupid;", inst);
  122. }
  123. void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst) {
  124. ctx.Add("MOV.S {},invocation.localid;", inst);
  125. }
  126. void EmitInvocationId(EmitContext& ctx, IR::Inst& inst) {
  127. ctx.Add("MOV.S {}.x,primitive_invocation.x;", inst);
  128. }
  129. void EmitSampleId(EmitContext& ctx) {
  130. NotImplemented();
  131. }
  132. void EmitIsHelperInvocation(EmitContext& ctx) {
  133. NotImplemented();
  134. }
  135. void EmitYDirection(EmitContext& ctx) {
  136. NotImplemented();
  137. }
  138. void EmitUndefU1(EmitContext& ctx) {
  139. NotImplemented();
  140. }
  141. void EmitUndefU8(EmitContext& ctx) {
  142. NotImplemented();
  143. }
  144. void EmitUndefU16(EmitContext& ctx) {
  145. NotImplemented();
  146. }
  147. void EmitUndefU32(EmitContext& ctx) {
  148. NotImplemented();
  149. }
  150. void EmitUndefU64(EmitContext& ctx) {
  151. NotImplemented();
  152. }
  153. void EmitGetZeroFromOp(EmitContext& ctx) {
  154. NotImplemented();
  155. }
  156. void EmitGetSignFromOp(EmitContext& ctx) {
  157. NotImplemented();
  158. }
  159. void EmitGetCarryFromOp(EmitContext& ctx) {
  160. NotImplemented();
  161. }
  162. void EmitGetOverflowFromOp(EmitContext& ctx) {
  163. NotImplemented();
  164. }
  165. void EmitGetSparseFromOp(EmitContext& ctx) {
  166. NotImplemented();
  167. }
  168. void EmitGetInBoundsFromOp(EmitContext& ctx) {
  169. NotImplemented();
  170. }
  171. void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
  172. ctx.Add("OR.S {},{},{};", inst, a, b);
  173. }
  174. void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
  175. ctx.Add("AND.S {},{},{};", inst, a, b);
  176. }
  177. void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
  178. ctx.Add("XOR.S {},{},{};", inst, a, b);
  179. }
  180. void EmitLogicalNot(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
  181. ctx.Add("SEQ.S {},{},0;", inst, value);
  182. }
  183. } // namespace Shader::Backend::GLASM