summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-26 22:34:28 +0000
committerOwen Anderson <resistor@mac.com>2008-08-26 22:34:28 +0000
commit655c1dc63d0cf94c522c9fc9357b2817a7fd4d0c (patch)
tree6dc473dd9aa3e6c3fd777d5e4ab3e880915626c9 /llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
parentaf665820e48c84128621c08585938a64c20e5dbe (diff)
downloadbcm5719-llvm-655c1dc63d0cf94c522c9fc9357b2817a7fd4d0c.tar.gz
bcm5719-llvm-655c1dc63d0cf94c522c9fc9357b2817a7fd4d0c.zip
Add support for fptosi of constants in fast isel.
llvm-svn: 55393
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FastISel.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 80ccc52365c..b0369b32e0a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/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<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.
OpenPOWER on IntegriCloud