arithmetic.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/assert.h"
  5. #include "common/common_types.h"
  6. #include "video_core/engines/shader_bytecode.h"
  7. #include "video_core/shader/shader_ir.h"
  8. namespace VideoCommon::Shader {
  9. using Tegra::Shader::Instruction;
  10. using Tegra::Shader::OpCode;
  11. using Tegra::Shader::SubOp;
  12. u32 ShaderIR::DecodeArithmetic(BasicBlock& bb, u32 pc) {
  13. const Instruction instr = {program_code[pc]};
  14. const auto opcode = OpCode::Decode(instr);
  15. Node op_a = GetRegister(instr.gpr8);
  16. Node op_b = [&]() -> Node {
  17. if (instr.is_b_imm) {
  18. return GetImmediate19(instr);
  19. } else if (instr.is_b_gpr) {
  20. return GetRegister(instr.gpr20);
  21. } else {
  22. return GetConstBuffer(instr.cbuf34.index, instr.cbuf34.offset);
  23. }
  24. }();
  25. switch (opcode->get().GetId()) {
  26. case OpCode::Id::MOV_C:
  27. case OpCode::Id::MOV_R: {
  28. // MOV does not have neither 'abs' nor 'neg' bits.
  29. SetRegister(bb, instr.gpr0, op_b);
  30. break;
  31. }
  32. default:
  33. UNIMPLEMENTED_MSG("Unhandled arithmetic instruction: {}", opcode->get().GetName());
  34. }
  35. return pc;
  36. }
  37. } // namespace VideoCommon::Shader