summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-08 08:08:56 +0000
committerChris Lattner <sabre@nondot.org>2005-01-08 08:08:56 +0000
commit2a6db3c351426828450bcbad50f9851144793e55 (patch)
tree7ac8390eeef2ba5a72cc1dc356a6dadd83f2589d /llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
parent6209f1d29434b4805a38acf66fc92433fd4683db (diff)
downloadbcm5719-llvm-2a6db3c351426828450bcbad50f9851144793e55.tar.gz
bcm5719-llvm-2a6db3c351426828450bcbad50f9851144793e55.zip
Add support for FP->INT conversions and back.
llvm-svn: 19369
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 167d2f7e359..820a4fb310a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -434,24 +434,33 @@ void SelectionDAGLowering::visitCast(User &I) {
if (N.getValueType() == DestTy) {
setValue(&I, N); // noop cast.
- return;
- } else if (isInteger(SrcTy) && isInteger(DestTy)) {
- if (DestTy < SrcTy) // Truncating cast?
- setValue(&I, DAG.getNode(ISD::TRUNCATE, DestTy, N));
- else if (I.getOperand(0)->getType()->isSigned())
- setValue(&I, DAG.getNode(ISD::SIGN_EXTEND, DestTy, N));
- else
- setValue(&I, DAG.getNode(ISD::ZERO_EXTEND, DestTy, N));
- return;
- } else if (isFloatingPoint(SrcTy) && isFloatingPoint(DestTy)) {
- if (DestTy < SrcTy) // Rounding cast?
- setValue(&I, DAG.getNode(ISD::FP_ROUND, DestTy, N));
- else
- setValue(&I, DAG.getNode(ISD::FP_EXTEND, DestTy, N));
+ } else if (isInteger(SrcTy)) {
+ if (isInteger(DestTy)) { // Int -> Int cast
+ if (DestTy < SrcTy) // Truncating cast?
+ setValue(&I, DAG.getNode(ISD::TRUNCATE, DestTy, N));
+ else if (I.getOperand(0)->getType()->isSigned())
+ setValue(&I, DAG.getNode(ISD::SIGN_EXTEND, DestTy, N));
+ else
+ setValue(&I, DAG.getNode(ISD::ZERO_EXTEND, DestTy, N));
+ } else { // Int -> FP cast
+ if (I.getOperand(0)->getType()->isSigned())
+ setValue(&I, DAG.getNode(ISD::SINT_TO_FP, DestTy, N));
+ else
+ setValue(&I, DAG.getNode(ISD::UINT_TO_FP, DestTy, N));
+ }
} else {
- // F->I or I->F
- // FIXME: implement integer/fp conversions!
- assert(0 && "This CAST is not yet implemented!\n");
+ assert(isFloatingPoint(SrcTy) && "Unknown value type!");
+ if (isFloatingPoint(DestTy)) { // FP -> FP cast
+ if (DestTy < SrcTy) // Rounding cast?
+ setValue(&I, DAG.getNode(ISD::FP_ROUND, DestTy, N));
+ else
+ setValue(&I, DAG.getNode(ISD::FP_EXTEND, DestTy, N));
+ } else { // FP -> Int cast.
+ if (I.getType()->isSigned())
+ setValue(&I, DAG.getNode(ISD::FP_TO_SINT, DestTy, N));
+ else
+ setValue(&I, DAG.getNode(ISD::FP_TO_UINT, DestTy, N));
+ }
}
}
OpenPOWER on IntegriCloud