[llvm-commits] [llvm] r55340 - /llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
Owen Anderson
resistor at mac.com
Mon Aug 25 14:32:34 PDT 2008
Author: resistor
Date: Mon Aug 25 16:32:34 2008
New Revision: 55340
URL: http://llvm.org/viewvc/llvm-project?rev=55340&view=rev
Log:
Expand bitcast support in fast isel to support bitcasts of non-constant values by emitting reg-reg copies.
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=55340&r1=55339&r2=55340&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Mon Aug 25 16:32:34 2008
@@ -234,8 +234,36 @@
} 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:
More information about the llvm-commits
mailing list