emit_glasm_not_implemented.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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.InstRecursive()->Arg(0).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. NotImplemented();
  45. }
  46. void EmitWorkgroupMemoryBarrier(EmitContext& ctx) {
  47. NotImplemented();
  48. }
  49. void EmitDeviceMemoryBarrier(EmitContext& ctx) {
  50. NotImplemented();
  51. }
  52. void EmitPrologue(EmitContext& ctx) {
  53. // TODO
  54. }
  55. void EmitEpilogue(EmitContext& ctx) {
  56. // TODO
  57. }
  58. void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) {
  59. NotImplemented();
  60. }
  61. void EmitEndPrimitive(EmitContext& ctx, const IR::Value& stream) {
  62. NotImplemented();
  63. }
  64. void EmitGetRegister(EmitContext& ctx) {
  65. NotImplemented();
  66. }
  67. void EmitSetRegister(EmitContext& ctx) {
  68. NotImplemented();
  69. }
  70. void EmitGetPred(EmitContext& ctx) {
  71. NotImplemented();
  72. }
  73. void EmitSetPred(EmitContext& ctx) {
  74. NotImplemented();
  75. }
  76. void EmitSetGotoVariable(EmitContext& ctx) {
  77. NotImplemented();
  78. }
  79. void EmitGetGotoVariable(EmitContext& ctx) {
  80. NotImplemented();
  81. }
  82. void EmitSetIndirectBranchVariable(EmitContext& ctx) {
  83. NotImplemented();
  84. }
  85. void EmitGetIndirectBranchVariable(EmitContext& ctx) {
  86. NotImplemented();
  87. }
  88. void EmitGetZFlag(EmitContext& ctx) {
  89. NotImplemented();
  90. }
  91. void EmitGetSFlag(EmitContext& ctx) {
  92. NotImplemented();
  93. }
  94. void EmitGetCFlag(EmitContext& ctx) {
  95. NotImplemented();
  96. }
  97. void EmitGetOFlag(EmitContext& ctx) {
  98. NotImplemented();
  99. }
  100. void EmitSetZFlag(EmitContext& ctx) {
  101. NotImplemented();
  102. }
  103. void EmitSetSFlag(EmitContext& ctx) {
  104. NotImplemented();
  105. }
  106. void EmitSetCFlag(EmitContext& ctx) {
  107. NotImplemented();
  108. }
  109. void EmitSetOFlag(EmitContext& ctx) {
  110. NotImplemented();
  111. }
  112. void EmitWorkgroupId(EmitContext& ctx) {
  113. NotImplemented();
  114. }
  115. void EmitLocalInvocationId(EmitContext& ctx, IR::Inst& inst) {
  116. ctx.Add("MOV.S {},invocation.localid;", inst);
  117. }
  118. void EmitInvocationId(EmitContext& ctx) {
  119. NotImplemented();
  120. }
  121. void EmitSampleId(EmitContext& ctx) {
  122. NotImplemented();
  123. }
  124. void EmitIsHelperInvocation(EmitContext& ctx) {
  125. NotImplemented();
  126. }
  127. void EmitYDirection(EmitContext& ctx) {
  128. NotImplemented();
  129. }
  130. void EmitUndefU1(EmitContext& ctx) {
  131. NotImplemented();
  132. }
  133. void EmitUndefU8(EmitContext& ctx) {
  134. NotImplemented();
  135. }
  136. void EmitUndefU16(EmitContext& ctx) {
  137. NotImplemented();
  138. }
  139. void EmitUndefU32(EmitContext& ctx) {
  140. NotImplemented();
  141. }
  142. void EmitUndefU64(EmitContext& ctx) {
  143. NotImplemented();
  144. }
  145. void EmitGetZeroFromOp(EmitContext& ctx) {
  146. NotImplemented();
  147. }
  148. void EmitGetSignFromOp(EmitContext& ctx) {
  149. NotImplemented();
  150. }
  151. void EmitGetCarryFromOp(EmitContext& ctx) {
  152. NotImplemented();
  153. }
  154. void EmitGetOverflowFromOp(EmitContext& ctx) {
  155. NotImplemented();
  156. }
  157. void EmitGetSparseFromOp(EmitContext& ctx) {
  158. NotImplemented();
  159. }
  160. void EmitGetInBoundsFromOp(EmitContext& ctx) {
  161. NotImplemented();
  162. }
  163. void EmitLogicalOr(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
  164. ctx.Add("OR.S {},{},{};", inst, a, b);
  165. }
  166. void EmitLogicalAnd(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
  167. ctx.Add("AND.S {},{},{};", inst, a, b);
  168. }
  169. void EmitLogicalXor(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
  170. ctx.Add("XOR.S {},{},{};", inst, a, b);
  171. }
  172. void EmitLogicalNot(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
  173. ctx.Add("SEQ.S {},{},0;", inst, value);
  174. }
  175. } // namespace Shader::Backend::GLASM