diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -3601,6 +3601,19 @@ llvm_unreachable("Not Implemented"); } + /// Create target specific constant pool and set the new alignment in + /// \p NewAlign + virtual SDValue getConstantPool(const Constant *C, SelectionDAG &DAG, + Align &NewAlign, EVT VT, + MaybeAlign Align = None, int Offset = 0, + bool isTarget = false, + unsigned TargetFlags = 0) const { + SDValue CPIdx = + DAG.getConstantPool(C, VT, Align, Offset, isTarget, TargetFlags); + NewAlign = cast(CPIdx)->getAlign(); + return CPIdx; + } + /// Return the newly negated expression if the cost is not expensive and /// set the cost in \p Cost to indicate that if it is cheaper or neutral to /// do the negation. diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -328,9 +328,9 @@ } } - SDValue CPIdx = - DAG.getConstantPool(LLVMC, TLI.getPointerTy(DAG.getDataLayout())); - Align Alignment = cast(CPIdx)->getAlign(); + Align Alignment; + SDValue CPIdx = TLI.getConstantPool(LLVMC, DAG, Alignment, + TLI.getPointerTy(DAG.getDataLayout())); if (Extend) { SDValue Result = DAG.getExtLoad( ISD::EXTLOAD, dl, OrigVT, DAG.getEntryNode(), CPIdx, @@ -347,10 +347,10 @@ /// Expands the Constant node to a load from the constant pool. SDValue SelectionDAGLegalize::ExpandConstant(ConstantSDNode *CP) { SDLoc dl(CP); + Align Alignment; EVT VT = CP->getValueType(0); - SDValue CPIdx = DAG.getConstantPool(CP->getConstantIntValue(), + SDValue CPIdx = TLI.getConstantPool(CP->getConstantIntValue(), DAG, Alignment, TLI.getPointerTy(DAG.getDataLayout())); - Align Alignment = cast(CPIdx)->getAlign(); SDValue Result = DAG.getLoad( VT, dl, DAG.getEntryNode(), CPIdx, MachinePointerInfo::getConstantPool(DAG.getMachineFunction()), Alignment); @@ -2010,10 +2010,10 @@ CV.push_back(UndefValue::get(OpNTy)); } } + Align Alignment; Constant *CP = ConstantVector::get(CV); - SDValue CPIdx = - DAG.getConstantPool(CP, TLI.getPointerTy(DAG.getDataLayout())); - Align Alignment = cast(CPIdx)->getAlign(); + SDValue CPIdx = TLI.getConstantPool(CP, DAG, Alignment, + TLI.getPointerTy(DAG.getDataLayout())); return DAG.getLoad( VT, dl, DAG.getEntryNode(), CPIdx, MachinePointerInfo::getConstantPool(DAG.getMachineFunction()), @@ -2557,9 +2557,9 @@ Constant *FudgeFactor = ConstantInt::get( Type::getInt64Ty(*DAG.getContext()), FF); - SDValue CPIdx = - DAG.getConstantPool(FudgeFactor, TLI.getPointerTy(DAG.getDataLayout())); - Align Alignment = cast(CPIdx)->getAlign(); + Align Alignment; + SDValue CPIdx = TLI.getConstantPool(FudgeFactor, DAG, Alignment, + TLI.getPointerTy(DAG.getDataLayout())); CPIdx = DAG.getNode(ISD::ADD, dl, CPIdx.getValueType(), CPIdx, CstOffset); Alignment = commonAlignment(Alignment, 4); SDValue FudgeInReg;