From 13269335a55395f2914c81ddb2401524abb4fa5e Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Tue, 26 Aug 2008 22:34:28 +0000 Subject: [PATCH] Add support for fptosi of constants in fast isel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55393 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/FastISel.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 80ccc52365c..b0369b32e0a 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -355,9 +355,35 @@ FastISel::SelectInstructions(BasicBlock::iterator Begin, ValueMap[I] = ResultReg; break; - } else - // TODO: Materialize constant and convert to FP. - return I; + } else { + // Materialize constant and convert to FP. + // TODO: Attempt constant folding? + ConstantInt* CI = cast(I->getOperand(0)); + MVT SrcVT = MVT::getMVT(CI->getType()); + MVT DstVT = MVT::getMVT(I->getType()); + + if (SrcVT == MVT::Other || !SrcVT.isSimple() || + DstVT == MVT::Other || !DstVT.isSimple() || + !TLI.isTypeLegal(SrcVT) || !TLI.isTypeLegal(DstVT)) + // Unhandled type. Halt "fast" selection and bail. + return I; + + unsigned ResultReg1 = FastEmit_i(SrcVT.getSimpleVT(), + SrcVT.getSimpleVT(), + ISD::Constant, CI->getZExtValue()); + if (!ResultReg1) + return I; + + unsigned ResultReg2 = FastEmit_r(SrcVT.getSimpleVT(), + DstVT.getSimpleVT(), + ISD::SINT_TO_FP, + ResultReg1); + if (!ResultReg2) + return I; + + ValueMap[I] = ResultReg2; + break; + } default: // Unhandled instruction. Halt "fast" selection and bail. -- 2.11.0