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