bfi.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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::DecodeBfi(NodeBlock& bb, u32 pc) {
  12. const Instruction instr = {program_code[pc]};
  13. const auto opcode = OpCode::Decode(instr);
  14. const auto [base, packed_shift] = [&]() -> std::tuple<Node, Node> {
  15. switch (opcode->get().GetId()) {
  16. case OpCode::Id::BFI_IMM_R:
  17. return {GetRegister(instr.gpr39), Immediate(instr.alu.GetSignedImm20_20())};
  18. default:
  19. UNREACHABLE();
  20. return {Immediate(0), Immediate(0)};
  21. }
  22. }();
  23. const Node insert = GetRegister(instr.gpr8);
  24. const Node offset = BitfieldExtract(packed_shift, 0, 8);
  25. const Node bits = BitfieldExtract(packed_shift, 8, 8);
  26. const Node value =
  27. Operation(OperationCode::UBitfieldInsert, PRECISE, base, insert, offset, bits);
  28. SetInternalFlagsFromInteger(bb, value, instr.generates_cc);
  29. SetRegister(bb, instr.gpr0, value);
  30. return pc;
  31. }
  32. } // namespace VideoCommon::Shader