11
11
//
12
12
// ===----------------------------------------------------------------------===//
13
13
14
+ #include " VECustomDAG.h"
14
15
#include " VEISelLowering.h"
15
16
#include " MCTargetDesc/VEMCExpr.h"
16
17
#include " VEInstrBuilder.h"
@@ -1640,28 +1641,28 @@ static SDValue getSplatValue(SDNode *N) {
1640
1641
1641
1642
SDValue VETargetLowering::lowerBUILD_VECTOR (SDValue Op,
1642
1643
SelectionDAG &DAG) const {
1643
- SDLoc DL ( Op);
1644
+ VECustomDAG CDAG (DAG, Op);
1644
1645
unsigned NumEls = Op.getValueType ().getVectorNumElements ();
1645
1646
MVT ElemVT = Op.getSimpleValueType ().getVectorElementType ();
1646
1647
1647
1648
// If there is just one element, expand to INSERT_VECTOR_ELT.
1648
1649
unsigned UniqueIdx;
1649
1650
if (getUniqueInsertion (Op.getNode (), UniqueIdx)) {
1650
- SDValue AccuV = DAG .getUNDEF (Op.getValueType ());
1651
+ SDValue AccuV = CDAG .getUNDEF (Op.getValueType ());
1651
1652
auto ElemV = Op->getOperand (UniqueIdx);
1652
- SDValue IdxV = DAG .getConstant (UniqueIdx, DL , MVT::i64 );
1653
- return DAG .getNode (ISD::INSERT_VECTOR_ELT, DL, Op.getValueType (), AccuV ,
1654
- ElemV, IdxV);
1653
+ SDValue IdxV = CDAG .getConstant (UniqueIdx, MVT::i64 );
1654
+ return CDAG .getNode (ISD::INSERT_VECTOR_ELT, Op.getValueType (),
1655
+ {AccuV, ElemV, IdxV} );
1655
1656
}
1656
1657
1657
1658
// Else emit a broadcast.
1658
1659
if (SDValue ScalarV = getSplatValue (Op.getNode ())) {
1659
1660
// lower to VEC_BROADCAST
1660
1661
MVT LegalResVT = MVT::getVectorVT (ElemVT, 256 );
1661
1662
1662
- auto AVL = DAG .getConstant (NumEls, DL , MVT::i32 );
1663
- return DAG .getNode (VEISD::VEC_BROADCAST, DL, LegalResVT, Op. getOperand ( 0 ) ,
1664
- AVL);
1663
+ auto AVL = CDAG .getConstant (NumEls, MVT::i32 );
1664
+ return CDAG .getNode (VEISD::VEC_BROADCAST, LegalResVT,
1665
+ {Op. getOperand ( 0 ), AVL} );
1665
1666
}
1666
1667
1667
1668
// Expand
@@ -2691,7 +2692,7 @@ SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const {
2691
2692
const bool FromVP = ISD::isVPOpcode (Opcode);
2692
2693
2693
2694
// The representative and legalized vector type of this operation.
2694
- SDLoc DL ( Op);
2695
+ VECustomDAG CDAG (DAG, Op);
2695
2696
MVT MaskVT = MVT::v256i1; // TODO: packed mode.
2696
2697
EVT OpVecVT = Op.getValueType ();
2697
2698
EVT LegalVecVT = getTypeToTransformTo (*DAG.getContext (), OpVecVT);
@@ -2708,10 +2709,10 @@ SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const {
2708
2709
2709
2710
} else {
2710
2711
// Materialize the VL parameter.
2711
- AVL = DAG .getConstant (OpVecVT.getVectorNumElements (), DL , MVT::i32 );
2712
- SDValue ConstTrue = DAG .getConstant (1 , DL , MVT::i32 );
2713
- Mask = DAG .getNode (VEISD::VEC_BROADCAST, DL , MaskVT,
2714
- ConstTrue); // emit a VEISD::VEC_BROADCAST here.
2712
+ AVL = CDAG .getConstant (OpVecVT.getVectorNumElements (), MVT::i32 );
2713
+ SDValue ConstTrue = CDAG .getConstant (1 , MVT::i32 );
2714
+ Mask = CDAG .getNode (VEISD::VEC_BROADCAST, MaskVT,
2715
+ ConstTrue); // emit a VEISD::VEC_BROADCAST here.
2715
2716
}
2716
2717
2717
2718
// Categories we are interested in.
@@ -2727,13 +2728,13 @@ SDValue VETargetLowering::lowerToVVP(SDValue Op, SelectionDAG &DAG) const {
2727
2728
2728
2729
if (IsBinaryOp) {
2729
2730
assert (LegalVecVT.isSimple ());
2730
- return DAG .getNode (VVPOpcode, DL, LegalVecVT, Op-> getOperand ( 0 ) ,
2731
- Op->getOperand (1 ), Mask, AVL);
2731
+ return CDAG .getNode (VVPOpcode, LegalVecVT,
2732
+ { Op->getOperand (0 ), Op-> getOperand ( 1 ), Mask, AVL} );
2732
2733
} else if (VVPOpcode == VEISD::VVP_SELECT) {
2733
2734
auto Mask = Op->getOperand (0 );
2734
2735
auto OnTrue = Op->getOperand (1 );
2735
2736
auto OnFalse = Op->getOperand (2 );
2736
- return DAG .getNode (VVPOpcode, DL, LegalVecVT, OnTrue, OnFalse, Mask, AVL);
2737
+ return CDAG .getNode (VVPOpcode, LegalVecVT, { OnTrue, OnFalse, Mask, AVL} );
2737
2738
}
2738
2739
llvm_unreachable (" lowerToVVP called for unexpected SDNode." );
2739
2740
}
0 commit comments