aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/SelectionDAG/FastISel.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-25 21:32:34 +0000
committerOwen Anderson <resistor@mac.com>2008-08-25 21:32:34 +0000
commit0658ade677cfe44b6a154094a8a32ac390b329e1 (patch)
treecb079539da0c10cf20b1d6b2947af389ae13c041 /lib/CodeGen/SelectionDAG/FastISel.cpp
parent98cfaf8d6e92d785052ea6fa0e63dc10ac8e538c (diff)
downloadexternal_llvm-0658ade677cfe44b6a154094a8a32ac390b329e1.zip
external_llvm-0658ade677cfe44b6a154094a8a32ac390b329e1.tar.gz
external_llvm-0658ade677cfe44b6a154094a8a32ac390b329e1.tar.bz2
Expand bitcast support in fast isel to support bitcasts of non-constant values by emitting reg-reg copies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55340 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index c8c219d..c48a2f2 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -234,8 +234,36 @@ FastISel::SelectInstructions(BasicBlock::iterator Begin,
} else
// TODO: Support vector and fp constants.
return I;
+ } else if (!isa<Constant>(I->getOperand(0))) {
+ // Bitcasts of non-constant values become reg-reg copies.
+ MVT SrcVT = MVT::getMVT(I->getOperand(0)->getType());
+ MVT DstVT = MVT::getMVT(I->getOperand(0)->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;
+ if (!TLI.isConvertLegal(SrcVT, DstVT))
+ // Illegal conversion. Halt "fast" selection and bail.
+ return I:
+
+ // Otherwise, insert a register-to-register copy.
+ TargetRegisterClass* SrcClass = TLI.getRegClassFor(SrcVT);
+ TargetRegisterClass* DstClass = TLI.getRegClassFor(DstVT);
+ unsigned Op0 = ValueMap[I->getOperand(0)];
+ unsigned ResultReg = createResultReg(DstClass);
+
+ if (Op0 == 0)
+ // Unhandled operand. Halt "fast" selection and bail.
+ return false;
+
+ TII.copyRegToReg(*MBB, MBB->end(), ResultReg, Op0, DstClass, SrcClass);
+ ValueMap[I] = ResultReg;
+
+ break;
} else
- // TODO: Support non-constant bitcasts.
+ // Casting a non-integral constant?
return I;
default: