arithmetic_immediate.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. u32 ShaderIR::DecodeArithmeticImmediate(BasicBlock& bb, u32 pc) {
  12. const Instruction instr = {program_code[pc]};
  13. const auto opcode = OpCode::Decode(instr);
  14. switch (opcode->get().GetId()) {
  15. case OpCode::Id::MOV32_IMM: {
  16. SetRegister(bb, instr.gpr0, GetImmediate32(instr));
  17. break;
  18. }
  19. case OpCode::Id::FMUL32_IMM: {
  20. UNIMPLEMENTED_IF_MSG(instr.op_32.generates_cc,
  21. "Condition codes generation in FMUL32 is not implemented");
  22. Node value =
  23. Operation(OperationCode::FMul, PRECISE, GetRegister(instr.gpr8), GetImmediate32(instr));
  24. value = GetSaturatedFloat(value, instr.fmul32.saturate);
  25. SetRegister(bb, instr.gpr0, value);
  26. break;
  27. }
  28. default:
  29. UNIMPLEMENTED_MSG("Unhandled arithmetic immediate instruction: {}",
  30. opcode->get().GetName());
  31. }
  32. return pc;
  33. }
  34. } // namespace VideoCommon::Shader