emit_glasm_bitwise_conversion.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "shader_recompiler/backend/glasm/emit_context.h"
  5. #include "shader_recompiler/backend/glasm/emit_glasm_instructions.h"
  6. #include "shader_recompiler/frontend/ir/value.h"
  7. namespace Shader::Backend::GLASM {
  8. static void Alias(IR::Inst& inst, const IR::Value& value) {
  9. if (value.IsImmediate()) {
  10. return;
  11. }
  12. IR::Inst* const value_inst{value.InstRecursive()};
  13. if (inst.GetOpcode() == IR::Opcode::Identity) {
  14. value_inst->DestructiveAddUsage(inst.UseCount());
  15. value_inst->DestructiveRemoveUsage();
  16. }
  17. inst.SetDefinition(value_inst->Definition<Id>());
  18. }
  19. void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) {
  20. Alias(inst, value);
  21. }
  22. void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
  23. Alias(inst, value);
  24. }
  25. void EmitBitCastU32F32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
  26. Alias(inst, value);
  27. }
  28. void EmitBitCastU64F64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
  29. Alias(inst, value);
  30. }
  31. void EmitBitCastF16U16(EmitContext&, IR::Inst& inst, const IR::Value& value) {
  32. Alias(inst, value);
  33. }
  34. void EmitBitCastF32U32(EmitContext&, IR::Inst& inst, const IR::Value& value) {
  35. Alias(inst, value);
  36. }
  37. void EmitBitCastF64U64(EmitContext&, IR::Inst& inst, const IR::Value& value) {
  38. Alias(inst, value);
  39. }
  40. void EmitPackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
  41. throw NotImplementedException("GLASM instruction");
  42. }
  43. void EmitUnpackUint2x32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
  44. throw NotImplementedException("GLASM instruction");
  45. }
  46. void EmitPackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
  47. throw NotImplementedException("GLASM instruction");
  48. }
  49. void EmitUnpackFloat2x16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
  50. throw NotImplementedException("GLASM instruction");
  51. }
  52. void EmitPackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value) {
  53. ctx.Add("PK2H {}.x,{};", inst, value);
  54. }
  55. void EmitUnpackHalf2x16(EmitContext& ctx, IR::Inst& inst, Register value) {
  56. ctx.Add("UP2H {}.xy,{}.x;", inst, value);
  57. }
  58. } // namespace Shader::Backend::GLASM