[llvm-commits] [llvm] r55393 - /llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
Owen Anderson
resistor at mac.com
Tue Aug 26 15:34:28 PDT 2008
Author: resistor
Date: Tue Aug 26 17:34:28 2008
New Revision: 55393
URL: http://llvm.org/viewvc/llvm-project?rev=55393&view=rev
Log:
Add support for fptosi of constants in fast isel.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=55393&r1=55392&r2=55393&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Aug 26 17:34:28 2008
@@ -355,9 +355,35 @@
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<ConstantInt>(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.
More information about the llvm-commits
mailing list