diff options
| author | Diana Picus <diana.picus@linaro.org> | 2018-01-10 10:01:49 +0000 |
|---|---|---|
| committer | Diana Picus <diana.picus@linaro.org> | 2018-01-10 10:01:49 +0000 |
| commit | 8f14886630c530c61510fb8497c6a59e4adbe181 (patch) | |
| tree | a06cee718d6058843650721b0e72c31150a4382b /llvm/lib | |
| parent | 9222b91e24dfefd596b01f51c3e46c247e0115b3 (diff) | |
| download | bcm5719-llvm-8f14886630c530c61510fb8497c6a59e4adbe181.tar.gz bcm5719-llvm-8f14886630c530c61510fb8497c6a59e4adbe181.zip | |
[ARM GlobalISel] Legalize s32/s64 G_FCONSTANT
Legal for hard float.
Change to G_CONSTANT for soft float (but preserve the binary
representation).
llvm-svn: 322164
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMLegalizerInfo.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp index fe526fef97e..b3bfd2a53ad 100644 --- a/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp +++ b/llvm/lib/Target/ARM/ARMLegalizerInfo.cpp @@ -161,7 +161,7 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) { setAction({G_ICMP, 1, Ty}, Legal); if (!ST.useSoftFloat() && ST.hasVFP2()) { - for (unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV}) + for (unsigned BinOp : {G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FCONSTANT}) for (auto Ty : {s32, s64}) setAction({BinOp, Ty}, Legal); @@ -183,6 +183,10 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) { for (auto Ty : {s32, s64}) setAction({BinOp, Ty}, Libcall); + for (auto Ty : {s32, s64}) { + setAction({G_FCONSTANT, Ty}, Custom); + } + setAction({G_FCMP, s1}, Legal); setAction({G_FCMP, 1, s32}, Custom); setAction({G_FCMP, 1, s64}, Custom); @@ -313,6 +317,7 @@ bool ARMLegalizerInfo::legalizeCustom(MachineInstr &MI, using namespace TargetOpcode; MIRBuilder.setInstr(MI); + LLVMContext &Ctx = MIRBuilder.getMF().getFunction().getContext(); switch (MI.getOpcode()) { default: @@ -329,7 +334,6 @@ bool ARMLegalizerInfo::legalizeCustom(MachineInstr &MI, // Our divmod libcalls return a struct containing the quotient and the // remainder. We need to create a virtual register for it. - auto &Ctx = MIRBuilder.getMF().getFunction().getContext(); Type *ArgTy = Type::getInt32Ty(Ctx); StructType *RetTy = StructType::get(Ctx, {ArgTy, ArgTy}, /* Packed */ true); auto RetVal = MRI.createGenericVirtualRegister( @@ -370,7 +374,6 @@ bool ARMLegalizerInfo::legalizeCustom(MachineInstr &MI, return true; } - auto &Ctx = MIRBuilder.getMF().getFunction().getContext(); assert((OpSize == 32 || OpSize == 64) && "Unsupported operand size"); auto *ArgTy = OpSize == 32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx); auto *RetTy = Type::getInt32Ty(Ctx); @@ -415,6 +418,14 @@ bool ARMLegalizerInfo::legalizeCustom(MachineInstr &MI, } break; } + case G_FCONSTANT: { + // Convert to integer constants, while preserving the binary representation. + auto AsInteger = + MI.getOperand(1).getFPImm()->getValueAPF().bitcastToAPInt(); + MIRBuilder.buildConstant(MI.getOperand(0).getReg(), + *ConstantInt::get(Ctx, AsInteger)); + break; + } } MI.eraseFromParent(); |

