@@ -377,6 +377,12 @@ static inline bool isMergeBlock(Block &block) {
377
377
isa<spirv::MergeOp>(block.front ());
378
378
}
379
379
380
+ // ===----------------------------------------------------------------------===//
381
+ // TableGen'erated canonicalizers
382
+ // ===----------------------------------------------------------------------===//
383
+
384
+ #include " SPIRVCanonicalization.inc"
385
+
380
386
// ===----------------------------------------------------------------------===//
381
387
// Common parsers and printers
382
388
// ===----------------------------------------------------------------------===//
@@ -771,30 +777,6 @@ static LogicalResult verify(spirv::BitcastOp bitcastOp) {
771
777
return success ();
772
778
}
773
779
774
- namespace {
775
-
776
- // / Converts chained `spirv::BitcastOp` operations into one
777
- // / `spirv::BitcastOp` operation.
778
- struct ConvertChainedBitcast : public OpRewritePattern <spirv::BitcastOp> {
779
- using OpRewritePattern<spirv::BitcastOp>::OpRewritePattern;
780
-
781
- PatternMatchResult matchAndRewrite (spirv::BitcastOp bitcastOp,
782
- PatternRewriter &rewriter) const override {
783
- auto parentBitcastOp = dyn_cast_or_null<spirv::BitcastOp>(
784
- bitcastOp.operand ()->getDefiningOp ());
785
-
786
- if (!parentBitcastOp) {
787
- return matchFailure ();
788
- }
789
-
790
- rewriter.replaceOpWithNewOp <spirv::BitcastOp>(
791
- /* valuesToRemoveIfDead=*/ {parentBitcastOp.result ()}, bitcastOp,
792
- bitcastOp.result ()->getType (), parentBitcastOp.operand ());
793
- return matchSuccess ();
794
- }
795
- };
796
- } // end anonymous namespace
797
-
798
780
void spirv::BitcastOp::getCanonicalizationPatterns (
799
781
OwningRewritePatternList &results, MLIRContext *context) {
800
782
results.insert <ConvertChainedBitcast>(context);
@@ -1587,41 +1569,11 @@ static LogicalResult verify(spirv::LoadOp loadOp) {
1587
1569
// spv.LogicalNot
1588
1570
// ===----------------------------------------------------------------------===//
1589
1571
1590
- namespace {
1591
-
1592
- // / Converts `spirv::LogicalNotOp` to the given `NewOp` using the first and the
1593
- // / second operands from the given `ParentOp`.
1594
- template <typename NewOp, typename ParentOp>
1595
- struct ConvertLogicalNotOp : public OpRewritePattern <spirv::LogicalNotOp> {
1596
- using OpRewritePattern<spirv::LogicalNotOp>::OpRewritePattern;
1597
-
1598
- PatternMatchResult matchAndRewrite (spirv::LogicalNotOp logicalNotOp,
1599
- PatternRewriter &rewriter) const override {
1600
- auto parentOp =
1601
- dyn_cast_or_null<ParentOp>(logicalNotOp.operand ()->getDefiningOp ());
1602
-
1603
- if (!parentOp) {
1604
- return this ->matchFailure ();
1605
- }
1606
-
1607
- rewriter.replaceOpWithNewOp <NewOp>(
1608
- /* valuesToRemoveIfDead=*/ {parentOp.result ()}, logicalNotOp,
1609
- logicalNotOp.result ()->getType (), parentOp.operand1 (),
1610
- parentOp.operand2 ());
1611
-
1612
- return this ->matchSuccess ();
1613
- }
1614
- };
1615
- } // end anonymous namespace
1616
-
1617
1572
void spirv::LogicalNotOp::getCanonicalizationPatterns (
1618
1573
OwningRewritePatternList &results, MLIRContext *context) {
1619
- results.insert <
1620
- ConvertLogicalNotOp<spirv::INotEqualOp, spirv::IEqualOp>,
1621
- ConvertLogicalNotOp<spirv::IEqualOp, spirv::INotEqualOp>,
1622
- ConvertLogicalNotOp<spirv::LogicalNotEqualOp, spirv::LogicalEqualOp>,
1623
- ConvertLogicalNotOp<spirv::LogicalEqualOp, spirv::LogicalNotEqualOp>>(
1624
- context);
1574
+ results.insert <ConvertLogicalNotOfIEqual, ConvertLogicalNotOfINotEqual,
1575
+ ConvertLogicalNotOfLogicalEqual,
1576
+ ConvertLogicalNotOfLogicalNotEqual>(context);
1625
1577
}
1626
1578
1627
1579
// ===----------------------------------------------------------------------===//
0 commit comments