[AArch64][GlobalISel] Add fp128 and i128 fptosi/fptoui handling. (#95528)
Any fp128 need to end up as libcall, as will f32->i128 and f64->i128.
f16 are a bit special as the maximum range of the result fits in a i17,
so can be shrank to an i64. Vector with i128/fp128 types are scalarized.
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 223d1ea..430fcae 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -1123,15 +1123,13 @@
case TargetOpcode::G_FPTOSI:
case TargetOpcode::G_FPTOUI: {
// FIXME: Support other types
- unsigned FromSize = MRI.getType(MI.getOperand(1).getReg()).getSizeInBits();
+ Type *FromTy =
+ getFloatTypeForLLT(Ctx, MRI.getType(MI.getOperand(1).getReg()));
unsigned ToSize = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
- if ((ToSize != 32 && ToSize != 64) || (FromSize != 32 && FromSize != 64))
+ if ((ToSize != 32 && ToSize != 64 && ToSize != 128) || !FromTy)
return UnableToLegalize;
LegalizeResult Status = conversionLibcall(
- MI, MIRBuilder,
- ToSize == 32 ? Type::getInt32Ty(Ctx) : Type::getInt64Ty(Ctx),
- FromSize == 64 ? Type::getDoubleTy(Ctx) : Type::getFloatTy(Ctx),
- LocObserver);
+ MI, MIRBuilder, Type::getIntNTy(Ctx, ToSize), FromTy, LocObserver);
if (Status != Legalized)
return Status;
break;