Allow custom expansion of ConstantVec nodes. PPC will use this in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25774 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2006-01-29 06:34:16 +00:00
parent ec4a0c7c6b
commit 8ca05e0c30

View File

@@ -530,30 +530,43 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
} }
break; break;
} }
case ISD::ConstantVec: { case ISD::ConstantVec:
switch (TLI.getOperationAction(ISD::ConstantVec, Node->getValueType(0))) {
default: assert(0 && "This action is not supported yet!");
case TargetLowering::Custom:
Tmp3 = TLI.LowerOperation(Result, DAG);
if (Tmp3.Val) {
Result = Tmp3;
break;
}
// FALLTHROUGH
case TargetLowering::Expand:
// We assume that vector constants are not legal, and will be immediately // We assume that vector constants are not legal, and will be immediately
// spilled to the constant pool. // spilled to the constant pool.
// //
// FIXME: Allow custom lowering to TargetConstantVec's.
//
// Create a ConstantPacked, and put it in the constant pool. // Create a ConstantPacked, and put it in the constant pool.
std::vector<Constant*> CV;
MVT::ValueType VT = Node->getValueType(0); MVT::ValueType VT = Node->getValueType(0);
for (unsigned I = 0, E = Node->getNumOperands(); I < E; ++I) { const Type *OpNTy =
SDOperand OpN = Node->getOperand(I); MVT::getTypeForValueType(Node->getOperand(0).getValueType());
const Type* OpNTy = MVT::getTypeForValueType(OpN.getValueType()); std::vector<Constant*> CV;
if (MVT::isFloatingPoint(VT)) if (MVT::isFloatingPoint(VT)) {
CV.push_back(ConstantFP::get(OpNTy, for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
cast<ConstantFPSDNode>(OpN)->getValue())); double V = cast<ConstantFPSDNode>(Node->getOperand(i))->getValue();
else CV.push_back(ConstantFP::get(OpNTy, V));
CV.push_back(ConstantUInt::get(OpNTy, }
cast<ConstantSDNode>(OpN)->getValue())); } else {
for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
uint64_t V = cast<ConstantSDNode>(Node->getOperand(i))->getValue();
CV.push_back(ConstantUInt::get(OpNTy, V));
}
} }
Constant *CP = ConstantPacked::get(CV); Constant *CP = ConstantPacked::get(CV);
SDOperand CPIdx = DAG.getConstantPool(CP, TLI.getPointerTy()); SDOperand CPIdx = DAG.getConstantPool(CP, TLI.getPointerTy());
Result = DAG.getLoad(VT, DAG.getEntryNode(), CPIdx, DAG.getSrcValue(NULL)); Result = DAG.getLoad(VT, DAG.getEntryNode(), CPIdx,
DAG.getSrcValue(NULL));
break; break;
} }
break;
case ISD::TokenFactor: case ISD::TokenFactor:
if (Node->getNumOperands() == 2) { if (Node->getNumOperands() == 2) {
Tmp1 = LegalizeOp(Node->getOperand(0)); Tmp1 = LegalizeOp(Node->getOperand(0));