diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-29 06:34:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-29 06:34:16 +0000 |
commit | 8ca05e0c302e15d6365afd2a0ea5fe15c9e85758 (patch) | |
tree | 2ea0d2c626f16f52e021430f4e0bf0fbaa88d358 | |
parent | ec4a0c7c6bd689572d8f432950867e6ee9d777f4 (diff) |
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
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 89d764cc6c..fb5329a5c0 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -530,30 +530,43 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { } break; } - case ISD::ConstantVec: { - // We assume that vector constants are not legal, and will be immediately - // spilled to the constant pool. - // - // FIXME: Allow custom lowering to TargetConstantVec's. - // - // Create a ConstantPacked, and put it in the constant pool. - std::vector<Constant*> CV; - MVT::ValueType VT = Node->getValueType(0); - for (unsigned I = 0, E = Node->getNumOperands(); I < E; ++I) { - SDOperand OpN = Node->getOperand(I); - const Type* OpNTy = MVT::getTypeForValueType(OpN.getValueType()); - if (MVT::isFloatingPoint(VT)) - CV.push_back(ConstantFP::get(OpNTy, - cast<ConstantFPSDNode>(OpN)->getValue())); - else - CV.push_back(ConstantUInt::get(OpNTy, - cast<ConstantSDNode>(OpN)->getValue())); + 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 + // spilled to the constant pool. + // + // Create a ConstantPacked, and put it in the constant pool. + MVT::ValueType VT = Node->getValueType(0); + const Type *OpNTy = + 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; - } case ISD::TokenFactor: if (Node->getNumOperands() == 2) { Tmp1 = LegalizeOp(Node->getOperand(0)); |