DXIL Debugger support for Integer division and remainder instructions

Operation::UDiv
Operation::SDiv
Operation::URem
Operation::SRem

Remainder implemented using % which keeps the remainder having the same sign as the dividend
This commit is contained in:
Jake Turner
2024-10-16 10:16:37 +01:00
parent 8074aa4a89
commit 62a737c713
2 changed files with 32 additions and 8 deletions
+32 -4
View File
@@ -2561,6 +2561,10 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
case Operation::Add:
case Operation::Sub:
case Operation::Mul:
case Operation::UDiv:
case Operation::SDiv:
case Operation::URem:
case Operation::SRem:
{
RDCASSERTEQUAL(inst.args[0]->type->type, Type::TypeKind::Scalar);
RDCASSERTEQUAL(inst.args[0]->type->scalarType, Type::Int);
@@ -2594,6 +2598,34 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, a.type);
}
else if(opCode == Operation::UDiv)
{
#undef _IMPL
#define _IMPL(I, S, U) comp<U>(result, c) = comp<U>(a, c) / comp<U>(b, c)
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, a.type);
}
else if(opCode == Operation::SDiv)
{
#undef _IMPL
#define _IMPL(I, S, U) comp<S>(result, c) = comp<S>(a, c) / comp<S>(b, c)
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, a.type);
}
else if(opCode == Operation::URem)
{
#undef _IMPL
#define _IMPL(I, S, U) comp<U>(result, c) = comp<U>(a, c) % comp<U>(b, c)
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, a.type);
}
else if(opCode == Operation::SRem)
{
#undef _IMPL
#define _IMPL(I, S, U) comp<S>(result, c) = comp<S>(a, c) % comp<S>(b, c)
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, a.type);
}
else
{
RDCERR("Unhandled opCode %s", ToStr(opCode).c_str());
@@ -3017,10 +3049,6 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
case Operation::PtrToI:
case Operation::IToPtr:
case Operation::AddrSpaceCast:
case Operation::UDiv:
case Operation::SDiv:
case Operation::URem:
case Operation::SRem:
case Operation::ExtractElement:
case Operation::InsertElement:
case Operation::ShuffleVector:
@@ -1773,10 +1773,6 @@ rdcstr Program::GetDebugStatus()
case Operation::PtrToI:
case Operation::IToPtr:
case Operation::AddrSpaceCast:
case Operation::UDiv:
case Operation::SDiv:
case Operation::URem:
case Operation::SRem:
case Operation::ExtractElement:
case Operation::InsertElement:
case Operation::ShuffleVector: