Fixed JIT error with Conjugate/Inverse

These need to be compiler intrinsics since faux types aren't supported with self.
This commit is contained in:
Boondorl 2025-05-28 15:36:20 -04:00 committed by Ricardo Luís Vaz Silva
commit e7d0991798
8 changed files with 54 additions and 39 deletions

View file

@ -9063,7 +9063,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
else if (Self->IsQuaternion())
{
// Reuse vector built-ins for quaternion
if (MethodName == NAME_Length || MethodName == NAME_LengthSquared || MethodName == NAME_Unit)
if (MethodName == NAME_Length || MethodName == NAME_LengthSquared || MethodName == NAME_Unit || MethodName == NAME_Conjugate || MethodName == NAME_Inverse)
{
if (ArgList.Size() > 0)
{
@ -10361,6 +10361,9 @@ FxExpression *FxVectorBuiltin::Resolve(FCompileContext &ctx)
ValueType = TypeFloat64;
break;
case NAME_Conjugate:
case NAME_Inverse:
assert(Self->IsQuaternion());
case NAME_Unit:
ValueType = Self->ValueType;
break;
@ -10413,6 +10416,18 @@ ExpEmit FxVectorBuiltin::Emit(VMFunctionBuilder *build)
build->Emit(vecSize == 2 ? OP_DIVVF2_RR : vecSize == 3 ? OP_DIVVF3_RR : OP_DIVVF4_RR, to.RegNum, op.RegNum, len.RegNum);
len.Free(build);
}
else if (Function == NAME_Conjugate)
{
build->Emit(OP_CONJQ, to.RegNum, op.RegNum);
}
else if (Function == NAME_Inverse)
{
ExpEmit len(build, REGT_FLOAT);
build->Emit(OP_DOTV4_RR, len.RegNum, op.RegNum, op.RegNum);
build->Emit(OP_CONJQ, to.RegNum, op.RegNum);
build->Emit(OP_DIVVF4_RR, to.RegNum, to.RegNum, len.RegNum);
len.Free(build);
}
else if (Function == NAME_Angle)
{
build->Emit(OP_ATAN2, to.RegNum, op.RegNum + 1, op.RegNum);