summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2018-01-30 09:15:17 +0000
committerDiana Picus <diana.picus@linaro.org>2018-01-30 09:15:17 +0000
commit517531e5a59e436abc462bb84a4e656cfd6d2f69 (patch)
tree01b5aeda505f600cd103ae0a4a979badba1e537e /llvm/lib
parentc4ccfb5d932909e64511bcfdc995ab20a80b2a89 (diff)
downloadbcm5719-llvm-517531e5a59e436abc462bb84a4e656cfd6d2f69.tar.gz
bcm5719-llvm-517531e5a59e436abc462bb84a4e656cfd6d2f69.zip
[ARM GlobalISel] Legalize G_SITOFP and G_UITOFP
Legal if we have hardware support, libcall otherwise. Also add supporting code to the legalizer helper for libcalls. llvm-svn: 323730
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp19
-rw-r--r--llvm/lib/Target/ARM/ARMLegalizerInfo.cpp11
2 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index 4fcb6a639d8..773e51c6e34 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -154,6 +154,10 @@ static RTLIB::Libcall getConvRTLibDesc(unsigned Opcode, Type *ToType,
return RTLIB::getFPTOSINT(FromMVT, ToMVT);
case TargetOpcode::G_FPTOUI:
return RTLIB::getFPTOUINT(FromMVT, ToMVT);
+ case TargetOpcode::G_SITOFP:
+ return RTLIB::getSINTTOFP(FromMVT, ToMVT);
+ case TargetOpcode::G_UITOFP:
+ return RTLIB::getUINTTOFP(FromMVT, ToMVT);
}
llvm_unreachable("Unsupported libcall function");
}
@@ -238,6 +242,21 @@ LegalizerHelper::libcall(MachineInstr &MI) {
return Status;
break;
}
+ case TargetOpcode::G_SITOFP:
+ case TargetOpcode::G_UITOFP: {
+ // FIXME: Support other types
+ unsigned FromSize = MRI.getType(MI.getOperand(1).getReg()).getSizeInBits();
+ unsigned ToSize = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
+ if (FromSize != 32 || (ToSize != 32 && ToSize != 64))
+ return UnableToLegalize;
+ LegalizeResult Status = conversionLibcall(
+ MI, MIRBuilder,
+ ToSize == 64 ? Type::getDoubleTy(Ctx) : Type::getFloatTy(Ctx),
+ Type::getInt32Ty(Ctx));
+ if (Status != Legalized)
+ return Status;
+ break;
+ }
}
MI.eraseFromParent();
diff --git a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
index 4082d4e68ab..2d09bcae3d8 100644
--- a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
@@ -192,6 +192,12 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
for (auto Ty : {s32, s64})
setAction({Op, 1, Ty}, Legal);
}
+
+ for (unsigned Op : {G_SITOFP, G_UITOFP}) {
+ setAction({Op, 1, s32}, Legal);
+ for (auto Ty : {s32, s64})
+ setAction({Op, Ty}, Legal);
+ }
} else {
for (unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV})
for (auto Ty : {s32, s64})
@@ -218,6 +224,11 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
setAction({Op, 1, s64}, Libcall);
}
+ for (unsigned Op : {G_SITOFP, G_UITOFP}) {
+ for (auto Ty : {s32, s64})
+ setAction({Op, Ty}, Libcall);
+ }
+
if (AEABI(ST))
setFCmpLibcallsAEABI();
else
OpenPOWER on IntegriCloud