@@ -1576,10 +1576,10 @@ m_Store(const ValueOpTy &ValueOp, const PointerOpTy &PointerOp) {
1576
1576
// Matchers for CastInst classes
1577
1577
//
1578
1578
1579
- template <typename Op_t, unsigned Opcode> struct CastClass_match {
1579
+ template <typename Op_t, unsigned Opcode> struct CastOperator_match {
1580
1580
Op_t Op;
1581
1581
1582
- CastClass_match (const Op_t &OpMatch) : Op(OpMatch) {}
1582
+ CastOperator_match (const Op_t &OpMatch) : Op(OpMatch) {}
1583
1583
1584
1584
template <typename OpTy> bool match (OpTy *V) {
1585
1585
if (auto *O = dyn_cast<Operator>(V))
@@ -1588,6 +1588,18 @@ template <typename Op_t, unsigned Opcode> struct CastClass_match {
1588
1588
}
1589
1589
};
1590
1590
1591
+ template <typename Op_t, unsigned Opcode> struct CastInst_match {
1592
+ Op_t Op;
1593
+
1594
+ CastInst_match (const Op_t &OpMatch) : Op(OpMatch) {}
1595
+
1596
+ template <typename OpTy> bool match (OpTy *V) {
1597
+ if (auto *I = dyn_cast<Instruction>(V))
1598
+ return I->getOpcode () == Opcode && Op.match (I->getOperand (0 ));
1599
+ return false ;
1600
+ }
1601
+ };
1602
+
1591
1603
template <typename Op_t> struct PtrToIntSameSize_match {
1592
1604
const DataLayout &DL;
1593
1605
Op_t Op;
@@ -1607,14 +1619,16 @@ template <typename Op_t> struct PtrToIntSameSize_match {
1607
1619
1608
1620
// / Matches BitCast.
1609
1621
template <typename OpTy>
1610
- inline CastClass_match<OpTy, Instruction::BitCast> m_BitCast (const OpTy &Op) {
1611
- return CastClass_match<OpTy, Instruction::BitCast>(Op);
1622
+ inline CastOperator_match<OpTy, Instruction::BitCast>
1623
+ m_BitCast (const OpTy &Op) {
1624
+ return CastOperator_match<OpTy, Instruction::BitCast>(Op);
1612
1625
}
1613
1626
1614
1627
// / Matches PtrToInt.
1615
1628
template <typename OpTy>
1616
- inline CastClass_match<OpTy, Instruction::PtrToInt> m_PtrToInt (const OpTy &Op) {
1617
- return CastClass_match<OpTy, Instruction::PtrToInt>(Op);
1629
+ inline CastOperator_match<OpTy, Instruction::PtrToInt>
1630
+ m_PtrToInt (const OpTy &Op) {
1631
+ return CastOperator_match<OpTy, Instruction::PtrToInt>(Op);
1618
1632
}
1619
1633
1620
1634
template <typename OpTy>
@@ -1625,90 +1639,92 @@ inline PtrToIntSameSize_match<OpTy> m_PtrToIntSameSize(const DataLayout &DL,
1625
1639
1626
1640
// / Matches IntToPtr.
1627
1641
template <typename OpTy>
1628
- inline CastClass_match<OpTy, Instruction::IntToPtr> m_IntToPtr (const OpTy &Op) {
1629
- return CastClass_match<OpTy, Instruction::IntToPtr>(Op);
1642
+ inline CastOperator_match<OpTy, Instruction::IntToPtr>
1643
+ m_IntToPtr (const OpTy &Op) {
1644
+ return CastOperator_match<OpTy, Instruction::IntToPtr>(Op);
1630
1645
}
1631
1646
1632
1647
// / Matches Trunc.
1633
1648
template <typename OpTy>
1634
- inline CastClass_match <OpTy, Instruction::Trunc> m_Trunc (const OpTy &Op) {
1635
- return CastClass_match <OpTy, Instruction::Trunc>(Op);
1649
+ inline CastOperator_match <OpTy, Instruction::Trunc> m_Trunc (const OpTy &Op) {
1650
+ return CastOperator_match <OpTy, Instruction::Trunc>(Op);
1636
1651
}
1637
1652
1638
1653
template <typename OpTy>
1639
- inline match_combine_or<CastClass_match <OpTy, Instruction::Trunc>, OpTy>
1654
+ inline match_combine_or<CastOperator_match <OpTy, Instruction::Trunc>, OpTy>
1640
1655
m_TruncOrSelf (const OpTy &Op) {
1641
1656
return m_CombineOr (m_Trunc (Op), Op);
1642
1657
}
1643
1658
1644
1659
// / Matches SExt.
1645
1660
template <typename OpTy>
1646
- inline CastClass_match <OpTy, Instruction::SExt> m_SExt (const OpTy &Op) {
1647
- return CastClass_match <OpTy, Instruction::SExt>(Op);
1661
+ inline CastInst_match <OpTy, Instruction::SExt> m_SExt (const OpTy &Op) {
1662
+ return CastInst_match <OpTy, Instruction::SExt>(Op);
1648
1663
}
1649
1664
1650
1665
// / Matches ZExt.
1651
1666
template <typename OpTy>
1652
- inline CastClass_match <OpTy, Instruction::ZExt> m_ZExt (const OpTy &Op) {
1653
- return CastClass_match <OpTy, Instruction::ZExt>(Op);
1667
+ inline CastInst_match <OpTy, Instruction::ZExt> m_ZExt (const OpTy &Op) {
1668
+ return CastInst_match <OpTy, Instruction::ZExt>(Op);
1654
1669
}
1655
1670
1656
1671
template <typename OpTy>
1657
- inline match_combine_or<CastClass_match <OpTy, Instruction::ZExt>, OpTy>
1672
+ inline match_combine_or<CastInst_match <OpTy, Instruction::ZExt>, OpTy>
1658
1673
m_ZExtOrSelf (const OpTy &Op) {
1659
1674
return m_CombineOr (m_ZExt (Op), Op);
1660
1675
}
1661
1676
1662
1677
template <typename OpTy>
1663
- inline match_combine_or<CastClass_match <OpTy, Instruction::SExt>, OpTy>
1678
+ inline match_combine_or<CastInst_match <OpTy, Instruction::SExt>, OpTy>
1664
1679
m_SExtOrSelf (const OpTy &Op) {
1665
1680
return m_CombineOr (m_SExt (Op), Op);
1666
1681
}
1667
1682
1668
1683
template <typename OpTy>
1669
- inline match_combine_or<CastClass_match <OpTy, Instruction::ZExt>,
1670
- CastClass_match <OpTy, Instruction::SExt>>
1684
+ inline match_combine_or<CastInst_match <OpTy, Instruction::ZExt>,
1685
+ CastInst_match <OpTy, Instruction::SExt>>
1671
1686
m_ZExtOrSExt (const OpTy &Op) {
1672
1687
return m_CombineOr (m_ZExt (Op), m_SExt (Op));
1673
1688
}
1674
1689
1675
1690
template <typename OpTy>
1676
1691
inline match_combine_or<
1677
- match_combine_or<CastClass_match <OpTy, Instruction::ZExt>,
1678
- CastClass_match <OpTy, Instruction::SExt>>,
1692
+ match_combine_or<CastInst_match <OpTy, Instruction::ZExt>,
1693
+ CastInst_match <OpTy, Instruction::SExt>>,
1679
1694
OpTy>
1680
1695
m_ZExtOrSExtOrSelf (const OpTy &Op) {
1681
1696
return m_CombineOr (m_ZExtOrSExt (Op), Op);
1682
1697
}
1683
1698
1684
1699
template <typename OpTy>
1685
- inline CastClass_match <OpTy, Instruction::UIToFP> m_UIToFP (const OpTy &Op) {
1686
- return CastClass_match <OpTy, Instruction::UIToFP>(Op);
1700
+ inline CastOperator_match <OpTy, Instruction::UIToFP> m_UIToFP (const OpTy &Op) {
1701
+ return CastOperator_match <OpTy, Instruction::UIToFP>(Op);
1687
1702
}
1688
1703
1689
1704
template <typename OpTy>
1690
- inline CastClass_match <OpTy, Instruction::SIToFP> m_SIToFP (const OpTy &Op) {
1691
- return CastClass_match <OpTy, Instruction::SIToFP>(Op);
1705
+ inline CastOperator_match <OpTy, Instruction::SIToFP> m_SIToFP (const OpTy &Op) {
1706
+ return CastOperator_match <OpTy, Instruction::SIToFP>(Op);
1692
1707
}
1693
1708
1694
1709
template <typename OpTy>
1695
- inline CastClass_match <OpTy, Instruction::FPToUI> m_FPToUI (const OpTy &Op) {
1696
- return CastClass_match <OpTy, Instruction::FPToUI>(Op);
1710
+ inline CastOperator_match <OpTy, Instruction::FPToUI> m_FPToUI (const OpTy &Op) {
1711
+ return CastOperator_match <OpTy, Instruction::FPToUI>(Op);
1697
1712
}
1698
1713
1699
1714
template <typename OpTy>
1700
- inline CastClass_match <OpTy, Instruction::FPToSI> m_FPToSI (const OpTy &Op) {
1701
- return CastClass_match <OpTy, Instruction::FPToSI>(Op);
1715
+ inline CastOperator_match <OpTy, Instruction::FPToSI> m_FPToSI (const OpTy &Op) {
1716
+ return CastOperator_match <OpTy, Instruction::FPToSI>(Op);
1702
1717
}
1703
1718
1704
1719
template <typename OpTy>
1705
- inline CastClass_match<OpTy, Instruction::FPTrunc> m_FPTrunc (const OpTy &Op) {
1706
- return CastClass_match<OpTy, Instruction::FPTrunc>(Op);
1720
+ inline CastOperator_match<OpTy, Instruction::FPTrunc>
1721
+ m_FPTrunc (const OpTy &Op) {
1722
+ return CastOperator_match<OpTy, Instruction::FPTrunc>(Op);
1707
1723
}
1708
1724
1709
1725
template <typename OpTy>
1710
- inline CastClass_match <OpTy, Instruction::FPExt> m_FPExt (const OpTy &Op) {
1711
- return CastClass_match <OpTy, Instruction::FPExt>(Op);
1726
+ inline CastOperator_match <OpTy, Instruction::FPExt> m_FPExt (const OpTy &Op) {
1727
+ return CastOperator_match <OpTy, Instruction::FPExt>(Op);
1712
1728
}
1713
1729
1714
1730
// ===----------------------------------------------------------------------===//
0 commit comments