@@ -688,7 +688,7 @@ inline api_pred_ty<is_lowbit_mask_or_zero> m_LowBitMaskOrZero(const APInt *&V) {
688
688
}
689
689
690
690
struct icmp_pred_with_threshold {
691
- ICmpInst::Predicate Pred;
691
+ CmpPredicate Pred;
692
692
const APInt *Thr;
693
693
bool isValue (const APInt &C) { return ICmpInst::compare (C, *Thr, Pred); }
694
694
};
@@ -1557,16 +1557,16 @@ template <typename T> inline Exact_match<T> m_Exact(const T &SubPattern) {
1557
1557
// Matchers for CmpInst classes
1558
1558
//
1559
1559
1560
- template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
1560
+ template <typename LHS_t, typename RHS_t, typename Class,
1561
1561
bool Commutable = false >
1562
1562
struct CmpClass_match {
1563
- PredicateTy *Predicate;
1563
+ CmpPredicate *Predicate;
1564
1564
LHS_t L;
1565
1565
RHS_t R;
1566
1566
1567
1567
// The evaluation order is always stable, regardless of Commutability.
1568
1568
// The LHS is always matched first.
1569
- CmpClass_match (PredicateTy &Pred, const LHS_t &LHS, const RHS_t &RHS)
1569
+ CmpClass_match (CmpPredicate &Pred, const LHS_t &LHS, const RHS_t &RHS)
1570
1570
: Predicate(&Pred), L(LHS), R(RHS) {}
1571
1571
CmpClass_match (const LHS_t &LHS, const RHS_t &RHS)
1572
1572
: Predicate(nullptr ), L(LHS), R(RHS) {}
@@ -1575,12 +1575,13 @@ struct CmpClass_match {
1575
1575
if (auto *I = dyn_cast<Class>(V)) {
1576
1576
if (L.match (I->getOperand (0 )) && R.match (I->getOperand (1 ))) {
1577
1577
if (Predicate)
1578
- *Predicate = I-> getPredicate ( );
1578
+ *Predicate = CmpPredicate::get (I );
1579
1579
return true ;
1580
- } else if (Commutable && L.match (I->getOperand (1 )) &&
1581
- R.match (I->getOperand (0 ))) {
1580
+ }
1581
+ if (Commutable && L.match (I->getOperand (1 )) &&
1582
+ R.match (I->getOperand (0 ))) {
1582
1583
if (Predicate)
1583
- *Predicate = I-> getSwappedPredicate ( );
1584
+ *Predicate = CmpPredicate::getSwapped (I );
1584
1585
return true ;
1585
1586
}
1586
1587
}
@@ -1589,60 +1590,58 @@ struct CmpClass_match {
1589
1590
};
1590
1591
1591
1592
template <typename LHS, typename RHS>
1592
- inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1593
- m_Cmp (CmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1594
- return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate >(Pred, L, R);
1593
+ inline CmpClass_match<LHS, RHS, CmpInst> m_Cmp (CmpPredicate &Pred, const LHS &L,
1594
+ const RHS &R) {
1595
+ return CmpClass_match<LHS, RHS, CmpInst>(Pred, L, R);
1595
1596
}
1596
1597
1597
1598
template <typename LHS, typename RHS>
1598
- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1599
- m_ICmp (ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1600
- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate >(Pred, L, R);
1599
+ inline CmpClass_match<LHS, RHS, ICmpInst> m_ICmp (CmpPredicate &Pred,
1600
+ const LHS &L, const RHS &R) {
1601
+ return CmpClass_match<LHS, RHS, ICmpInst>(Pred, L, R);
1601
1602
}
1602
1603
1603
1604
template <typename LHS, typename RHS>
1604
- inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1605
- m_FCmp (FCmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
1606
- return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate >(Pred, L, R);
1605
+ inline CmpClass_match<LHS, RHS, FCmpInst> m_FCmp (CmpPredicate &Pred,
1606
+ const LHS &L, const RHS &R) {
1607
+ return CmpClass_match<LHS, RHS, FCmpInst>(Pred, L, R);
1607
1608
}
1608
1609
1609
1610
template <typename LHS, typename RHS>
1610
- inline CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1611
- m_Cmp (const LHS &L, const RHS &R) {
1612
- return CmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(L, R);
1611
+ inline CmpClass_match<LHS, RHS, CmpInst> m_Cmp (const LHS &L, const RHS &R) {
1612
+ return CmpClass_match<LHS, RHS, CmpInst>(L, R);
1613
1613
}
1614
1614
1615
1615
template <typename LHS, typename RHS>
1616
- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1617
- m_ICmp (const LHS &L, const RHS &R) {
1618
- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(L, R);
1616
+ inline CmpClass_match<LHS, RHS, ICmpInst> m_ICmp (const LHS &L, const RHS &R) {
1617
+ return CmpClass_match<LHS, RHS, ICmpInst>(L, R);
1619
1618
}
1620
1619
1621
1620
template <typename LHS, typename RHS>
1622
- inline CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1623
- m_FCmp (const LHS &L, const RHS &R) {
1624
- return CmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(L, R);
1621
+ inline CmpClass_match<LHS, RHS, FCmpInst> m_FCmp (const LHS &L, const RHS &R) {
1622
+ return CmpClass_match<LHS, RHS, FCmpInst>(L, R);
1625
1623
}
1626
1624
1627
1625
// Same as CmpClass, but instead of saving Pred as out output variable, match a
1628
1626
// specific input pred for equality.
1629
- template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
1627
+ template <typename LHS_t, typename RHS_t, typename Class,
1630
1628
bool Commutable = false >
1631
1629
struct SpecificCmpClass_match {
1632
- const PredicateTy Predicate;
1630
+ const CmpPredicate Predicate;
1633
1631
LHS_t L;
1634
1632
RHS_t R;
1635
1633
1636
- SpecificCmpClass_match (PredicateTy Pred, const LHS_t &LHS, const RHS_t &RHS)
1634
+ SpecificCmpClass_match (CmpPredicate Pred, const LHS_t &LHS, const RHS_t &RHS)
1637
1635
: Predicate(Pred), L(LHS), R(RHS) {}
1638
1636
1639
1637
template <typename OpTy> bool match (OpTy *V) {
1640
1638
if (auto *I = dyn_cast<Class>(V)) {
1641
- if (I-> getPredicate () == Predicate && L. match (I-> getOperand ( 0 ) ) &&
1642
- R.match (I->getOperand (1 )))
1639
+ if (CmpPredicate::getMatching ( CmpPredicate::get (I), Predicate ) &&
1640
+ L. match (I-> getOperand ( 0 )) && R.match (I->getOperand (1 )))
1643
1641
return true ;
1644
1642
if constexpr (Commutable) {
1645
- if (I->getPredicate () == Class::getSwappedPredicate (Predicate) &&
1643
+ if (CmpPredicate::getMatching (CmpPredicate::get (I),
1644
+ CmpPredicate::getSwapped (Predicate)) &&
1646
1645
L.match (I->getOperand (1 )) && R.match (I->getOperand (0 )))
1647
1646
return true ;
1648
1647
}
@@ -1653,31 +1652,27 @@ struct SpecificCmpClass_match {
1653
1652
};
1654
1653
1655
1654
template <typename LHS, typename RHS>
1656
- inline SpecificCmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>
1657
- m_SpecificCmp (CmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1658
- return SpecificCmpClass_match<LHS, RHS, CmpInst, CmpInst::Predicate>(
1659
- MatchPred, L, R);
1655
+ inline SpecificCmpClass_match<LHS, RHS, CmpInst>
1656
+ m_SpecificCmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1657
+ return SpecificCmpClass_match<LHS, RHS, CmpInst>(MatchPred, L, R);
1660
1658
}
1661
1659
1662
1660
template <typename LHS, typename RHS>
1663
- inline SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>
1664
- m_SpecificICmp (ICmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1665
- return SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>(
1666
- MatchPred, L, R);
1661
+ inline SpecificCmpClass_match<LHS, RHS, ICmpInst>
1662
+ m_SpecificICmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1663
+ return SpecificCmpClass_match<LHS, RHS, ICmpInst>(MatchPred, L, R);
1667
1664
}
1668
1665
1669
1666
template <typename LHS, typename RHS>
1670
- inline SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >
1671
- m_c_SpecificICmp (ICmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1672
- return SpecificCmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(
1673
- MatchPred, L, R);
1667
+ inline SpecificCmpClass_match<LHS, RHS, ICmpInst, true >
1668
+ m_c_SpecificICmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1669
+ return SpecificCmpClass_match<LHS, RHS, ICmpInst, true >(MatchPred, L, R);
1674
1670
}
1675
1671
1676
1672
template <typename LHS, typename RHS>
1677
- inline SpecificCmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>
1678
- m_SpecificFCmp (FCmpInst::Predicate MatchPred, const LHS &L, const RHS &R) {
1679
- return SpecificCmpClass_match<LHS, RHS, FCmpInst, FCmpInst::Predicate>(
1680
- MatchPred, L, R);
1673
+ inline SpecificCmpClass_match<LHS, RHS, FCmpInst>
1674
+ m_SpecificFCmp (CmpPredicate MatchPred, const LHS &L, const RHS &R) {
1675
+ return SpecificCmpClass_match<LHS, RHS, FCmpInst>(MatchPred, L, R);
1681
1676
}
1682
1677
1683
1678
// ===----------------------------------------------------------------------===//
@@ -2468,7 +2463,7 @@ struct UAddWithOverflow_match {
2468
2463
2469
2464
template <typename OpTy> bool match (OpTy *V) {
2470
2465
Value *ICmpLHS, *ICmpRHS;
2471
- ICmpInst::Predicate Pred;
2466
+ CmpPredicate Pred;
2472
2467
if (!m_ICmp (Pred, m_Value (ICmpLHS), m_Value (ICmpRHS)).match (V))
2473
2468
return false ;
2474
2469
@@ -2738,16 +2733,15 @@ inline AnyBinaryOp_match<LHS, RHS, true> m_c_BinOp(const LHS &L, const RHS &R) {
2738
2733
// / Matches an ICmp with a predicate over LHS and RHS in either order.
2739
2734
// / Swaps the predicate if operands are commuted.
2740
2735
template <typename LHS, typename RHS>
2741
- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >
2742
- m_c_ICmp (ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
2743
- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(Pred, L,
2744
- R);
2736
+ inline CmpClass_match<LHS, RHS, ICmpInst, true >
2737
+ m_c_ICmp (CmpPredicate &Pred, const LHS &L, const RHS &R) {
2738
+ return CmpClass_match<LHS, RHS, ICmpInst, true >(Pred, L, R);
2745
2739
}
2746
2740
2747
2741
template <typename LHS, typename RHS>
2748
- inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >
2749
- m_c_ICmp ( const LHS &L, const RHS &R) {
2750
- return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true >(L, R);
2742
+ inline CmpClass_match<LHS, RHS, ICmpInst, true > m_c_ICmp ( const LHS &L,
2743
+ const RHS &R) {
2744
+ return CmpClass_match<LHS, RHS, ICmpInst, true >(L, R);
2751
2745
}
2752
2746
2753
2747
// / Matches a specific opcode with LHS and RHS in either order.
0 commit comments