shader: implement RDNA2 subrev borrow

This commit is contained in:
nmzik
2026-08-15 04:47:25 +02:00
parent 9c316e6988
commit 4a7bc55afa
8 changed files with 128 additions and 21 deletions
@@ -741,6 +741,23 @@ bool LowerVectorAddCarry(const Decoder::Instruction& decoded, BasicBlock& block,
return true;
}
bool LowerVectorSubrevBorrowCarry(const Decoder::Instruction& decoded, BasicBlock& block,
std::string* error) {
Instruction inst;
inst.pc = decoded.pc;
inst.op = Opcode::ISubBorrowCarryU32;
inst.src_count = 3;
if (!LowerRegisterOperand(decoded.dst, inst.dst, error) ||
!LowerRegisterOperand(decoded.dst2, inst.dst2, error) ||
!LowerSourceOperand(decoded.src1, inst.src[0], error) ||
!LowerSourceOperand(decoded.src0, inst.src[1], error) ||
!LowerSourceOperand(decoded.src2, inst.src[2], error)) {
return false;
}
block.instructions.push_back(inst);
return true;
}
bool LowerVectorCarryOut(const Decoder::Instruction& decoded, BasicBlock& block,
std::string* error) {
Instruction inst;
@@ -1124,6 +1141,8 @@ bool LowerDecodedInstruction(const Decoder::Instruction& inst, BasicBlock& block
case Decoder::Opcode::VMovreldB32: return LowerVectorMoveRelDestination(inst, block, error);
case Decoder::Opcode::VMovrelsB32: return LowerVectorMoveRelSource(inst, block, error);
case Decoder::Opcode::VAddcU32: return LowerVectorAddCarry(inst, block, error);
case Decoder::Opcode::VSubrevCoCiU32:
return LowerVectorSubrevBorrowCarry(inst, block, error);
case Decoder::Opcode::VMadU64U32: return LowerVectorMadU64U32(inst, block, error);
case Decoder::Opcode::VMacF32: return LowerVectorMacF32(inst, block, error);
case Decoder::Opcode::VPkFmacF16: return LowerVectorPkFmacF16(inst, block, error);
@@ -22,6 +22,7 @@ IR_OPCODE(Permlanex16B32, General, Lane)
IR_OPCODE(AbsI32, General, SimpleInteger)
IR_OPCODE(IAddU32, General, SimpleInteger)
IR_OPCODE(IAddCarryU32, General, State)
IR_OPCODE(ISubBorrowCarryU32, General, State)
IR_OPCODE(ISubBorrowU32, General, State)
IR_OPCODE(ScalarAddCarryU32, General, State)
IR_OPCODE(ScalarSubBorrowU32, General, State)