| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* Rewriters *| |
| 4 | |* *| |
| 5 | |* Automatically generated file, do not edit! *| |
| 6 | |* From: ArithCanonicalization.td *| |
| 7 | |* *| |
| 8 | \*===----------------------------------------------------------------------===*/ |
| 9 | |
| 10 | |
| 11 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization1( |
| 12 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 13 | ::llvm::StringRef failureStr) { |
| 14 | if (!((::llvm::isa<::mlir::IntegerAttr>(Val: attr)))) { |
| 15 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 16 | diag << failureStr << ": arbitrary integer attribute" ; |
| 17 | }); |
| 18 | } |
| 19 | return ::mlir::success(); |
| 20 | } |
| 21 | |
| 22 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization2( |
| 23 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 24 | ::llvm::StringRef failureStr) { |
| 25 | if (!((true))) { |
| 26 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 27 | diag << failureStr << ": any attribute" ; |
| 28 | }); |
| 29 | } |
| 30 | return ::mlir::success(); |
| 31 | } |
| 32 | |
| 33 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization3( |
| 34 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 35 | ::llvm::StringRef failureStr) { |
| 36 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::sge)))) { |
| 37 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 38 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::sge" ; |
| 39 | }); |
| 40 | } |
| 41 | return ::mlir::success(); |
| 42 | } |
| 43 | |
| 44 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization4( |
| 45 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 46 | ::llvm::StringRef failureStr) { |
| 47 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::sgt)))) { |
| 48 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 49 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::sgt" ; |
| 50 | }); |
| 51 | } |
| 52 | return ::mlir::success(); |
| 53 | } |
| 54 | |
| 55 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization5( |
| 56 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 57 | ::llvm::StringRef failureStr) { |
| 58 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::sle)))) { |
| 59 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 60 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::sle" ; |
| 61 | }); |
| 62 | } |
| 63 | return ::mlir::success(); |
| 64 | } |
| 65 | |
| 66 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization6( |
| 67 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 68 | ::llvm::StringRef failureStr) { |
| 69 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::slt)))) { |
| 70 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 71 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::slt" ; |
| 72 | }); |
| 73 | } |
| 74 | return ::mlir::success(); |
| 75 | } |
| 76 | |
| 77 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization7( |
| 78 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 79 | ::llvm::StringRef failureStr) { |
| 80 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::uge)))) { |
| 81 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 82 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::uge" ; |
| 83 | }); |
| 84 | } |
| 85 | return ::mlir::success(); |
| 86 | } |
| 87 | |
| 88 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization8( |
| 89 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 90 | ::llvm::StringRef failureStr) { |
| 91 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::ugt)))) { |
| 92 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 93 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::ugt" ; |
| 94 | }); |
| 95 | } |
| 96 | return ::mlir::success(); |
| 97 | } |
| 98 | |
| 99 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization9( |
| 100 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 101 | ::llvm::StringRef failureStr) { |
| 102 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::ule)))) { |
| 103 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 104 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::ule" ; |
| 105 | }); |
| 106 | } |
| 107 | return ::mlir::success(); |
| 108 | } |
| 109 | |
| 110 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization10( |
| 111 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 112 | ::llvm::StringRef failureStr) { |
| 113 | if (!((attr == ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::ult)))) { |
| 114 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 115 | diag << failureStr << ": constant attribute ::mlir::arith::CmpIPredicate::ult" ; |
| 116 | }); |
| 117 | } |
| 118 | return ::mlir::success(); |
| 119 | } |
| 120 | |
| 121 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization11( |
| 122 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 123 | ::llvm::StringRef failureStr) { |
| 124 | if (!((attr == rewriter.getIntegerAttr(type: rewriter.getIntegerType(width: 1), value: 0)))) { |
| 125 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 126 | diag << failureStr << ": constant attribute 0" ; |
| 127 | }); |
| 128 | } |
| 129 | return ::mlir::success(); |
| 130 | } |
| 131 | |
| 132 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization12( |
| 133 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 134 | ::llvm::StringRef failureStr) { |
| 135 | if (!((attr == rewriter.getIntegerAttr(type: rewriter.getIntegerType(width: 1), value: 1)))) { |
| 136 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 137 | diag << failureStr << ": constant attribute 1" ; |
| 138 | }); |
| 139 | } |
| 140 | return ::mlir::success(); |
| 141 | } |
| 142 | |
| 143 | static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_ArithCanonicalization13( |
| 144 | ::mlir::PatternRewriter &rewriter, ::mlir::Operation *op, ::mlir::Attribute attr, |
| 145 | ::llvm::StringRef failureStr) { |
| 146 | if (!((::llvm::isa<::mlir::TypedAttr>(Val: attr)))) { |
| 147 | return rewriter.notifyMatchFailure(op, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 148 | diag << failureStr << ": TypedAttr instance" ; |
| 149 | }); |
| 150 | } |
| 151 | return ::mlir::success(); |
| 152 | } |
| 153 | static ::llvm::LogicalResult static_dag_matcher_0(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &x) { |
| 154 | (void)tblgen_ops; |
| 155 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::NegFOp>(Val: op0); (void)castedOp1; |
| 156 | if (!(castedOp1)){ |
| 157 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 158 | diag << "castedOp1 is not ::mlir::arith::NegFOp type" ; |
| 159 | }); |
| 160 | } |
| 161 | x = castedOp1.getODSOperands(index: 0); |
| 162 | { |
| 163 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getFastmath(); |
| 164 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::FastMathFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::FastMathFlags::none); |
| 165 | } |
| 166 | return ::mlir::success(); |
| 167 | } |
| 168 | |
| 169 | static ::llvm::LogicalResult static_dag_matcher_1(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &y) { |
| 170 | (void)tblgen_ops; |
| 171 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::NegFOp>(Val: op0); (void)castedOp1; |
| 172 | if (!(castedOp1)){ |
| 173 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 174 | diag << "castedOp1 is not ::mlir::arith::NegFOp type" ; |
| 175 | }); |
| 176 | } |
| 177 | y = castedOp1.getODSOperands(index: 0); |
| 178 | { |
| 179 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getFastmath(); |
| 180 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::FastMathFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::FastMathFlags::none); |
| 181 | } |
| 182 | return ::mlir::success(); |
| 183 | } |
| 184 | |
| 185 | static ::llvm::LogicalResult static_dag_matcher_2(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Attribute &c0) { |
| 186 | (void)tblgen_ops; |
| 187 | ::mlir::Attribute arg1_0; |
| 188 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op0->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg1_0)))))){ |
| 189 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 190 | diag << "::mlir::success(::mlir::matchPattern(op0->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure" ; |
| 191 | }); |
| 192 | } |
| 193 | c0 = arg1_0; |
| 194 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization1(rewriter, op: op0, attr: arg1_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'arbitrary integer attribute'" ))) { |
| 195 | return ::mlir::failure(); |
| 196 | } |
| 197 | return ::mlir::success(); |
| 198 | } |
| 199 | |
| 200 | static ::llvm::LogicalResult static_dag_matcher_3(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::arith::IntegerOverflowFlagsAttr &ovf1, ::mlir::Attribute &c0, ::mlir::Operation::operand_range &x) { |
| 201 | (void)tblgen_ops; |
| 202 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::AddIOp>(Val: op0); (void)castedOp1; |
| 203 | if (!(castedOp1)){ |
| 204 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 205 | diag << "castedOp1 is not ::mlir::arith::AddIOp type" ; |
| 206 | }); |
| 207 | } |
| 208 | x = castedOp1.getODSOperands(index: 0); |
| 209 | { |
| 210 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 211 | if (!(op2)){ |
| 212 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 213 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 214 | }); |
| 215 | } |
| 216 | if(::mlir::failed(Result: static_dag_matcher_2(rewriter, op0: op2, tblgen_ops, c0))) { |
| 217 | return ::mlir::failure(); |
| 218 | } |
| 219 | tblgen_ops.push_back(Elt: op2); |
| 220 | } |
| 221 | { |
| 222 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getOverflowFlags(); |
| 223 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 224 | ovf1 = tblgen_attr; |
| 225 | } |
| 226 | return ::mlir::success(); |
| 227 | } |
| 228 | |
| 229 | static ::llvm::LogicalResult static_dag_matcher_4(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Attribute &c1) { |
| 230 | (void)tblgen_ops; |
| 231 | ::mlir::Attribute arg1_0; |
| 232 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op0->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg1_0)))))){ |
| 233 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 234 | diag << "::mlir::success(::mlir::matchPattern(op0->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure" ; |
| 235 | }); |
| 236 | } |
| 237 | c1 = arg1_0; |
| 238 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization1(rewriter, op: op0, attr: arg1_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'arbitrary integer attribute'" ))) { |
| 239 | return ::mlir::failure(); |
| 240 | } |
| 241 | return ::mlir::success(); |
| 242 | } |
| 243 | |
| 244 | static ::llvm::LogicalResult static_dag_matcher_5(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Attribute &c0) { |
| 245 | (void)tblgen_ops; |
| 246 | ::mlir::Attribute arg1_0; |
| 247 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op0->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg1_0)))))){ |
| 248 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 249 | diag << "::mlir::success(::mlir::matchPattern(op0->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure" ; |
| 250 | }); |
| 251 | } |
| 252 | c0 = arg1_0; |
| 253 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization2(rewriter, op: op0, attr: arg1_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'any attribute'" ))) { |
| 254 | return ::mlir::failure(); |
| 255 | } |
| 256 | return ::mlir::success(); |
| 257 | } |
| 258 | |
| 259 | static ::llvm::LogicalResult static_dag_matcher_6(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::arith::IntegerOverflowFlagsAttr &ovf1, ::mlir::Operation::operand_range &x, ::mlir::Attribute &c0) { |
| 260 | (void)tblgen_ops; |
| 261 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp1; |
| 262 | if (!(castedOp1)){ |
| 263 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 264 | diag << "castedOp1 is not ::mlir::arith::SubIOp type" ; |
| 265 | }); |
| 266 | } |
| 267 | { |
| 268 | auto *op2 = (*castedOp1.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 269 | if (!(op2)){ |
| 270 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 271 | diag << "There's no operation that defines operand 0 of castedOp1" ; |
| 272 | }); |
| 273 | } |
| 274 | if(::mlir::failed(Result: static_dag_matcher_2(rewriter, op0: op2, tblgen_ops, c0))) { |
| 275 | return ::mlir::failure(); |
| 276 | } |
| 277 | tblgen_ops.push_back(Elt: op2); |
| 278 | } |
| 279 | x = castedOp1.getODSOperands(index: 1); |
| 280 | { |
| 281 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getOverflowFlags(); |
| 282 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 283 | ovf1 = tblgen_attr; |
| 284 | } |
| 285 | return ::mlir::success(); |
| 286 | } |
| 287 | |
| 288 | static ::llvm::LogicalResult static_dag_matcher_7(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::arith::IntegerOverflowFlagsAttr &ovf1, ::mlir::Attribute &c0, ::mlir::Operation::operand_range &x) { |
| 289 | (void)tblgen_ops; |
| 290 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp1; |
| 291 | if (!(castedOp1)){ |
| 292 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 293 | diag << "castedOp1 is not ::mlir::arith::SubIOp type" ; |
| 294 | }); |
| 295 | } |
| 296 | x = castedOp1.getODSOperands(index: 0); |
| 297 | { |
| 298 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 299 | if (!(op2)){ |
| 300 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 301 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 302 | }); |
| 303 | } |
| 304 | if(::mlir::failed(Result: static_dag_matcher_2(rewriter, op0: op2, tblgen_ops, c0))) { |
| 305 | return ::mlir::failure(); |
| 306 | } |
| 307 | tblgen_ops.push_back(Elt: op2); |
| 308 | } |
| 309 | { |
| 310 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getOverflowFlags(); |
| 311 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 312 | ovf1 = tblgen_attr; |
| 313 | } |
| 314 | return ::mlir::success(); |
| 315 | } |
| 316 | |
| 317 | static ::llvm::LogicalResult static_dag_matcher_8(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &x) { |
| 318 | (void)tblgen_ops; |
| 319 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtSIOp>(Val: op0); (void)castedOp1; |
| 320 | if (!(castedOp1)){ |
| 321 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 322 | diag << "castedOp1 is not ::mlir::arith::ExtSIOp type" ; |
| 323 | }); |
| 324 | } |
| 325 | x = castedOp1.getODSOperands(index: 0); |
| 326 | return ::mlir::success(); |
| 327 | } |
| 328 | |
| 329 | static ::llvm::LogicalResult static_dag_matcher_9(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &y) { |
| 330 | (void)tblgen_ops; |
| 331 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtSIOp>(Val: op0); (void)castedOp1; |
| 332 | if (!(castedOp1)){ |
| 333 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 334 | diag << "castedOp1 is not ::mlir::arith::ExtSIOp type" ; |
| 335 | }); |
| 336 | } |
| 337 | y = castedOp1.getODSOperands(index: 0); |
| 338 | return ::mlir::success(); |
| 339 | } |
| 340 | |
| 341 | static ::llvm::LogicalResult static_dag_matcher_10(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::UnitAttr &nneg1, ::mlir::Operation::operand_range &x) { |
| 342 | (void)tblgen_ops; |
| 343 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtUIOp>(Val: op0); (void)castedOp1; |
| 344 | if (!(castedOp1)){ |
| 345 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 346 | diag << "castedOp1 is not ::mlir::arith::ExtUIOp type" ; |
| 347 | }); |
| 348 | } |
| 349 | x = castedOp1.getODSOperands(index: 0); |
| 350 | { |
| 351 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getNonNeg(); |
| 352 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 353 | nneg1 = tblgen_attr; |
| 354 | } |
| 355 | return ::mlir::success(); |
| 356 | } |
| 357 | |
| 358 | static ::llvm::LogicalResult static_dag_matcher_11(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::UnitAttr &nneg2, ::mlir::Operation::operand_range &y) { |
| 359 | (void)tblgen_ops; |
| 360 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtUIOp>(Val: op0); (void)castedOp1; |
| 361 | if (!(castedOp1)){ |
| 362 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 363 | diag << "castedOp1 is not ::mlir::arith::ExtUIOp type" ; |
| 364 | }); |
| 365 | } |
| 366 | y = castedOp1.getODSOperands(index: 0); |
| 367 | { |
| 368 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getNonNeg(); |
| 369 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 370 | nneg2 = tblgen_attr; |
| 371 | } |
| 372 | return ::mlir::success(); |
| 373 | } |
| 374 | |
| 375 | static ::llvm::LogicalResult static_dag_matcher_12(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::UnitAttr &nneg, ::mlir::Operation::operand_range &x) { |
| 376 | (void)tblgen_ops; |
| 377 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtUIOp>(Val: op0); (void)castedOp1; |
| 378 | if (!(castedOp1)){ |
| 379 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 380 | diag << "castedOp1 is not ::mlir::arith::ExtUIOp type" ; |
| 381 | }); |
| 382 | } |
| 383 | x = castedOp1.getODSOperands(index: 0); |
| 384 | { |
| 385 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getNonNeg(); |
| 386 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 387 | nneg = tblgen_attr; |
| 388 | } |
| 389 | return ::mlir::success(); |
| 390 | } |
| 391 | |
| 392 | static ::llvm::LogicalResult static_dag_matcher_13(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 393 | (void)tblgen_ops; |
| 394 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 395 | if (!(castedOp1)){ |
| 396 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 397 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 398 | }); |
| 399 | } |
| 400 | { |
| 401 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 402 | if (!(tblgen_attr)){ |
| 403 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 404 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 405 | }); |
| 406 | } |
| 407 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization3(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::sge'" ))) { |
| 408 | return ::mlir::failure(); |
| 409 | } |
| 410 | } |
| 411 | a = castedOp1.getODSOperands(index: 0); |
| 412 | b = castedOp1.getODSOperands(index: 1); |
| 413 | return ::mlir::success(); |
| 414 | } |
| 415 | |
| 416 | static ::llvm::LogicalResult static_dag_matcher_14(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 417 | (void)tblgen_ops; |
| 418 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 419 | if (!(castedOp1)){ |
| 420 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 421 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 422 | }); |
| 423 | } |
| 424 | { |
| 425 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 426 | if (!(tblgen_attr)){ |
| 427 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 428 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 429 | }); |
| 430 | } |
| 431 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization4(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::sgt'" ))) { |
| 432 | return ::mlir::failure(); |
| 433 | } |
| 434 | } |
| 435 | a = castedOp1.getODSOperands(index: 0); |
| 436 | b = castedOp1.getODSOperands(index: 1); |
| 437 | return ::mlir::success(); |
| 438 | } |
| 439 | |
| 440 | static ::llvm::LogicalResult static_dag_matcher_15(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 441 | (void)tblgen_ops; |
| 442 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 443 | if (!(castedOp1)){ |
| 444 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 445 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 446 | }); |
| 447 | } |
| 448 | { |
| 449 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 450 | if (!(tblgen_attr)){ |
| 451 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 452 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 453 | }); |
| 454 | } |
| 455 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization5(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::sle'" ))) { |
| 456 | return ::mlir::failure(); |
| 457 | } |
| 458 | } |
| 459 | a = castedOp1.getODSOperands(index: 0); |
| 460 | b = castedOp1.getODSOperands(index: 1); |
| 461 | return ::mlir::success(); |
| 462 | } |
| 463 | |
| 464 | static ::llvm::LogicalResult static_dag_matcher_16(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 465 | (void)tblgen_ops; |
| 466 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 467 | if (!(castedOp1)){ |
| 468 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 469 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 470 | }); |
| 471 | } |
| 472 | { |
| 473 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 474 | if (!(tblgen_attr)){ |
| 475 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 476 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 477 | }); |
| 478 | } |
| 479 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization6(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::slt'" ))) { |
| 480 | return ::mlir::failure(); |
| 481 | } |
| 482 | } |
| 483 | a = castedOp1.getODSOperands(index: 0); |
| 484 | b = castedOp1.getODSOperands(index: 1); |
| 485 | return ::mlir::success(); |
| 486 | } |
| 487 | |
| 488 | static ::llvm::LogicalResult static_dag_matcher_17(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 489 | (void)tblgen_ops; |
| 490 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 491 | if (!(castedOp1)){ |
| 492 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 493 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 494 | }); |
| 495 | } |
| 496 | { |
| 497 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 498 | if (!(tblgen_attr)){ |
| 499 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 500 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 501 | }); |
| 502 | } |
| 503 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization7(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::uge'" ))) { |
| 504 | return ::mlir::failure(); |
| 505 | } |
| 506 | } |
| 507 | a = castedOp1.getODSOperands(index: 0); |
| 508 | b = castedOp1.getODSOperands(index: 1); |
| 509 | return ::mlir::success(); |
| 510 | } |
| 511 | |
| 512 | static ::llvm::LogicalResult static_dag_matcher_18(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 513 | (void)tblgen_ops; |
| 514 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 515 | if (!(castedOp1)){ |
| 516 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 517 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 518 | }); |
| 519 | } |
| 520 | { |
| 521 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 522 | if (!(tblgen_attr)){ |
| 523 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 524 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 525 | }); |
| 526 | } |
| 527 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization8(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::ugt'" ))) { |
| 528 | return ::mlir::failure(); |
| 529 | } |
| 530 | } |
| 531 | a = castedOp1.getODSOperands(index: 0); |
| 532 | b = castedOp1.getODSOperands(index: 1); |
| 533 | return ::mlir::success(); |
| 534 | } |
| 535 | |
| 536 | static ::llvm::LogicalResult static_dag_matcher_19(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 537 | (void)tblgen_ops; |
| 538 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 539 | if (!(castedOp1)){ |
| 540 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 541 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 542 | }); |
| 543 | } |
| 544 | { |
| 545 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 546 | if (!(tblgen_attr)){ |
| 547 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 548 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 549 | }); |
| 550 | } |
| 551 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization9(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::ule'" ))) { |
| 552 | return ::mlir::failure(); |
| 553 | } |
| 554 | } |
| 555 | a = castedOp1.getODSOperands(index: 0); |
| 556 | b = castedOp1.getODSOperands(index: 1); |
| 557 | return ::mlir::success(); |
| 558 | } |
| 559 | |
| 560 | static ::llvm::LogicalResult static_dag_matcher_20(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops, ::mlir::Operation::operand_range &b, ::mlir::Operation::operand_range &a) { |
| 561 | (void)tblgen_ops; |
| 562 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp1; |
| 563 | if (!(castedOp1)){ |
| 564 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 565 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 566 | }); |
| 567 | } |
| 568 | { |
| 569 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 570 | if (!(tblgen_attr)){ |
| 571 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 572 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 573 | }); |
| 574 | } |
| 575 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization10(rewriter, op: castedOp1, attr: tblgen_attr, failureStr: "op 'arith.cmpi' attribute 'predicate' failed to satisfy constraint: 'constant attribute ::mlir::arith::CmpIPredicate::ult'" ))) { |
| 576 | return ::mlir::failure(); |
| 577 | } |
| 578 | } |
| 579 | a = castedOp1.getODSOperands(index: 0); |
| 580 | b = castedOp1.getODSOperands(index: 1); |
| 581 | return ::mlir::success(); |
| 582 | } |
| 583 | |
| 584 | static ::llvm::LogicalResult static_dag_matcher_21(::mlir::PatternRewriter &rewriter, ::mlir::Operation *op0, ::llvm::SmallVector<::mlir::Operation *, 4> &tblgen_ops) { |
| 585 | (void)tblgen_ops; |
| 586 | ::mlir::Attribute arg1_0; |
| 587 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op0->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg1_0)))))){ |
| 588 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 589 | diag << "::mlir::success(::mlir::matchPattern(op0->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure" ; |
| 590 | }); |
| 591 | } |
| 592 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization12(rewriter, op: op0, attr: arg1_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'constant attribute 1'" ))) { |
| 593 | return ::mlir::failure(); |
| 594 | } |
| 595 | return ::mlir::success(); |
| 596 | } |
| 597 | |
| 598 | /* Generated from: |
| 599 | ArithCanonicalization.td:569 |
| 600 | */ |
| 601 | struct AddFOfNegFLhs : public ::mlir::RewritePattern { |
| 602 | AddFOfNegFLhs(::mlir::MLIRContext *context) |
| 603 | : ::mlir::RewritePattern("arith.addf" , 2, context, {"arith.subf" }) {} |
| 604 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 605 | ::mlir::PatternRewriter &rewriter) const override { |
| 606 | // Variables for capturing values and attributes used while creating ops |
| 607 | ::mlir::arith::RoundingModeAttr rm; |
| 608 | ::mlir::arith::FastMathFlagsAttr fmf; |
| 609 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 610 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 611 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 612 | |
| 613 | // Match |
| 614 | tblgen_ops.push_back(Elt: op0); |
| 615 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddFOp>(Val: op0); (void)castedOp0; |
| 616 | { |
| 617 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 618 | if (!(op1)){ |
| 619 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 620 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 621 | }); |
| 622 | } |
| 623 | if(::mlir::failed(Result: static_dag_matcher_0(rewriter, op0: op1, tblgen_ops, x))) { |
| 624 | return ::mlir::failure(); |
| 625 | } |
| 626 | tblgen_ops.push_back(Elt: op1); |
| 627 | } |
| 628 | y = castedOp0.getODSOperands(index: 1); |
| 629 | { |
| 630 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFastmath(); |
| 631 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::FastMathFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::FastMathFlags::none); |
| 632 | fmf = tblgen_attr; |
| 633 | } |
| 634 | { |
| 635 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRoundingmode(); |
| 636 | rm = tblgen_attr; |
| 637 | } |
| 638 | |
| 639 | // Rewrite |
| 640 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 641 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 642 | ::mlir::arith::SubFOp tblgen_SubFOp_0; |
| 643 | { |
| 644 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 645 | ::mlir::arith::SubFOp::Properties tblgen_props; (void)tblgen_props; |
| 646 | tblgen_values.push_back(Elt: (*y.begin())); |
| 647 | tblgen_values.push_back(Elt: (*x.begin())); |
| 648 | tblgen_props.fastmath = ::llvm::dyn_cast_if_present<decltype(tblgen_props.fastmath)>(Val&: fmf); |
| 649 | tblgen_props.roundingmode = ::llvm::dyn_cast_if_present<decltype(tblgen_props.roundingmode)>(Val&: rm); |
| 650 | tblgen_SubFOp_0 = ::mlir::arith::SubFOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 651 | } |
| 652 | |
| 653 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubFOp_0.getODSResults(index: 0) }) { |
| 654 | tblgen_repl_values.push_back(Elt: v); |
| 655 | } |
| 656 | |
| 657 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 658 | return ::mlir::success(); |
| 659 | } |
| 660 | }; |
| 661 | |
| 662 | /* Generated from: |
| 663 | ArithCanonicalization.td:573 |
| 664 | */ |
| 665 | struct AddFOfNegFRhs : public ::mlir::RewritePattern { |
| 666 | AddFOfNegFRhs(::mlir::MLIRContext *context) |
| 667 | : ::mlir::RewritePattern("arith.addf" , 2, context, {"arith.subf" }) {} |
| 668 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 669 | ::mlir::PatternRewriter &rewriter) const override { |
| 670 | // Variables for capturing values and attributes used while creating ops |
| 671 | ::mlir::arith::RoundingModeAttr rm; |
| 672 | ::mlir::arith::FastMathFlagsAttr fmf; |
| 673 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 674 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 675 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 676 | |
| 677 | // Match |
| 678 | tblgen_ops.push_back(Elt: op0); |
| 679 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddFOp>(Val: op0); (void)castedOp0; |
| 680 | x = castedOp0.getODSOperands(index: 0); |
| 681 | { |
| 682 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 683 | if (!(op1)){ |
| 684 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 685 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 686 | }); |
| 687 | } |
| 688 | if(::mlir::failed(Result: static_dag_matcher_1(rewriter, op0: op1, tblgen_ops, y))) { |
| 689 | return ::mlir::failure(); |
| 690 | } |
| 691 | tblgen_ops.push_back(Elt: op1); |
| 692 | } |
| 693 | { |
| 694 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFastmath(); |
| 695 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::FastMathFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::FastMathFlags::none); |
| 696 | fmf = tblgen_attr; |
| 697 | } |
| 698 | { |
| 699 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRoundingmode(); |
| 700 | rm = tblgen_attr; |
| 701 | } |
| 702 | |
| 703 | // Rewrite |
| 704 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 705 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 706 | ::mlir::arith::SubFOp tblgen_SubFOp_0; |
| 707 | { |
| 708 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 709 | ::mlir::arith::SubFOp::Properties tblgen_props; (void)tblgen_props; |
| 710 | tblgen_values.push_back(Elt: (*x.begin())); |
| 711 | tblgen_values.push_back(Elt: (*y.begin())); |
| 712 | tblgen_props.fastmath = ::llvm::dyn_cast_if_present<decltype(tblgen_props.fastmath)>(Val&: fmf); |
| 713 | tblgen_props.roundingmode = ::llvm::dyn_cast_if_present<decltype(tblgen_props.roundingmode)>(Val&: rm); |
| 714 | tblgen_SubFOp_0 = ::mlir::arith::SubFOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 715 | } |
| 716 | |
| 717 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubFOp_0.getODSResults(index: 0) }) { |
| 718 | tblgen_repl_values.push_back(Elt: v); |
| 719 | } |
| 720 | |
| 721 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 722 | return ::mlir::success(); |
| 723 | } |
| 724 | }; |
| 725 | |
| 726 | /* Generated from: |
| 727 | ArithCanonicalization.td:93 |
| 728 | */ |
| 729 | struct AddIAddConstant : public ::mlir::RewritePattern { |
| 730 | AddIAddConstant(::mlir::MLIRContext *context) |
| 731 | : ::mlir::RewritePattern("arith.addi" , 2, context, {"arith.addi" , "arith.constant" }) {} |
| 732 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 733 | ::mlir::PatternRewriter &rewriter) const override { |
| 734 | // Variables for capturing values and attributes used while creating ops |
| 735 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 736 | ::mlir::Attribute c1; |
| 737 | ::mlir::Attribute c0; |
| 738 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 739 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 740 | ::mlir::arith::AddIOp res; |
| 741 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 742 | |
| 743 | // Match |
| 744 | tblgen_ops.push_back(Elt: op0); |
| 745 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddIOp>(Val: op0); (void)castedOp0; |
| 746 | res = castedOp0; |
| 747 | { |
| 748 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 749 | if (!(op1)){ |
| 750 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 751 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 752 | }); |
| 753 | } |
| 754 | if(::mlir::failed(Result: static_dag_matcher_3(rewriter, op0: op1, tblgen_ops, ovf1, c0, x))) { |
| 755 | return ::mlir::failure(); |
| 756 | } |
| 757 | tblgen_ops.push_back(Elt: op1); |
| 758 | } |
| 759 | { |
| 760 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 761 | if (!(op1)){ |
| 762 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 763 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 764 | }); |
| 765 | } |
| 766 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 767 | return ::mlir::failure(); |
| 768 | } |
| 769 | tblgen_ops.push_back(Elt: op1); |
| 770 | } |
| 771 | { |
| 772 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 773 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 774 | ovf2 = tblgen_attr; |
| 775 | } |
| 776 | |
| 777 | // Rewrite |
| 778 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 779 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 780 | auto nativeVar_0 = addIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 781 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 782 | { |
| 783 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 784 | /*value=*/value: nativeVar_0 |
| 785 | ); |
| 786 | } |
| 787 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c0, rhs: c1, signedOp: &APInt::sadd_ov, unsignedOp: &APInt::uadd_ov); (void)nativeVar_2; |
| 788 | ::mlir::arith::AddIOp tblgen_AddIOp_3; |
| 789 | { |
| 790 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 791 | ::mlir::arith::AddIOp::Properties tblgen_props; (void)tblgen_props; |
| 792 | tblgen_values.push_back(Elt: (*x.begin())); |
| 793 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 794 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 795 | tblgen_AddIOp_3 = ::mlir::arith::AddIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 796 | } |
| 797 | |
| 798 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AddIOp_3.getODSResults(index: 0) }) { |
| 799 | tblgen_repl_values.push_back(Elt: v); |
| 800 | } |
| 801 | |
| 802 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 803 | return ::mlir::success(); |
| 804 | } |
| 805 | }; |
| 806 | |
| 807 | /* Generated from: |
| 808 | ArithCanonicalization.td:130 |
| 809 | */ |
| 810 | struct AddIMulNegativeOneLhs : public ::mlir::RewritePattern { |
| 811 | AddIMulNegativeOneLhs(::mlir::MLIRContext *context) |
| 812 | : ::mlir::RewritePattern("arith.addi" , 2, context, {"arith.subi" }) {} |
| 813 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 814 | ::mlir::PatternRewriter &rewriter) const override { |
| 815 | // Variables for capturing values and attributes used while creating ops |
| 816 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 817 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 818 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 819 | ::mlir::Attribute c0; |
| 820 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 821 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 822 | |
| 823 | // Match |
| 824 | tblgen_ops.push_back(Elt: op0); |
| 825 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddIOp>(Val: op0); (void)castedOp0; |
| 826 | { |
| 827 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 828 | if (!(op1)){ |
| 829 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 830 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 831 | }); |
| 832 | } |
| 833 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::MulIOp>(Val: op1); (void)castedOp1; |
| 834 | if (!(castedOp1)){ |
| 835 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 836 | diag << "castedOp1 is not ::mlir::arith::MulIOp type" ; |
| 837 | }); |
| 838 | } |
| 839 | x = castedOp1.getODSOperands(index: 0); |
| 840 | { |
| 841 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 842 | if (!(op2)){ |
| 843 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 844 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 845 | }); |
| 846 | } |
| 847 | if(::mlir::failed(Result: static_dag_matcher_5(rewriter, op0: op2, tblgen_ops, c0))) { |
| 848 | return ::mlir::failure(); |
| 849 | } |
| 850 | tblgen_ops.push_back(Elt: op2); |
| 851 | } |
| 852 | { |
| 853 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getOverflowFlags(); |
| 854 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 855 | ovf1 = tblgen_attr; |
| 856 | } |
| 857 | tblgen_ops.push_back(Elt: op1); |
| 858 | } |
| 859 | y = castedOp0.getODSOperands(index: 1); |
| 860 | { |
| 861 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 862 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 863 | ovf2 = tblgen_attr; |
| 864 | } |
| 865 | if (!(((succeeded(Result: getIntOrSplatIntValue(attr: c0)))) && ((getIntOrSplatIntValue(attr: c0)->isAllOnes())))){ |
| 866 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 867 | diag << "entities 'c0' failed to satisfy constraint: ''" ; |
| 868 | }); |
| 869 | } |
| 870 | |
| 871 | // Rewrite |
| 872 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 873 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 874 | ::mlir::arith::SubIOp tblgen_SubIOp_0; |
| 875 | { |
| 876 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 877 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 878 | tblgen_values.push_back(Elt: (*y.begin())); |
| 879 | tblgen_values.push_back(Elt: (*x.begin())); |
| 880 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val: ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none)); |
| 881 | tblgen_SubIOp_0 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 882 | } |
| 883 | |
| 884 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_0.getODSResults(index: 0) }) { |
| 885 | tblgen_repl_values.push_back(Elt: v); |
| 886 | } |
| 887 | |
| 888 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 889 | return ::mlir::success(); |
| 890 | } |
| 891 | }; |
| 892 | |
| 893 | /* Generated from: |
| 894 | ArithCanonicalization.td:122 |
| 895 | */ |
| 896 | struct AddIMulNegativeOneRhs : public ::mlir::RewritePattern { |
| 897 | AddIMulNegativeOneRhs(::mlir::MLIRContext *context) |
| 898 | : ::mlir::RewritePattern("arith.addi" , 2, context, {"arith.subi" }) {} |
| 899 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 900 | ::mlir::PatternRewriter &rewriter) const override { |
| 901 | // Variables for capturing values and attributes used while creating ops |
| 902 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 903 | ::mlir::Attribute c0; |
| 904 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 905 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 906 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 907 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 908 | |
| 909 | // Match |
| 910 | tblgen_ops.push_back(Elt: op0); |
| 911 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddIOp>(Val: op0); (void)castedOp0; |
| 912 | x = castedOp0.getODSOperands(index: 0); |
| 913 | { |
| 914 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 915 | if (!(op1)){ |
| 916 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 917 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 918 | }); |
| 919 | } |
| 920 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::MulIOp>(Val: op1); (void)castedOp1; |
| 921 | if (!(castedOp1)){ |
| 922 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 923 | diag << "castedOp1 is not ::mlir::arith::MulIOp type" ; |
| 924 | }); |
| 925 | } |
| 926 | y = castedOp1.getODSOperands(index: 0); |
| 927 | { |
| 928 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 929 | if (!(op2)){ |
| 930 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 931 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 932 | }); |
| 933 | } |
| 934 | if(::mlir::failed(Result: static_dag_matcher_5(rewriter, op0: op2, tblgen_ops, c0))) { |
| 935 | return ::mlir::failure(); |
| 936 | } |
| 937 | tblgen_ops.push_back(Elt: op2); |
| 938 | } |
| 939 | { |
| 940 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getOverflowFlags(); |
| 941 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 942 | ovf1 = tblgen_attr; |
| 943 | } |
| 944 | tblgen_ops.push_back(Elt: op1); |
| 945 | } |
| 946 | { |
| 947 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 948 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 949 | ovf2 = tblgen_attr; |
| 950 | } |
| 951 | if (!(((succeeded(Result: getIntOrSplatIntValue(attr: c0)))) && ((getIntOrSplatIntValue(attr: c0)->isAllOnes())))){ |
| 952 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 953 | diag << "entities 'c0' failed to satisfy constraint: ''" ; |
| 954 | }); |
| 955 | } |
| 956 | |
| 957 | // Rewrite |
| 958 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 959 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 960 | ::mlir::arith::SubIOp tblgen_SubIOp_0; |
| 961 | { |
| 962 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 963 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 964 | tblgen_values.push_back(Elt: (*x.begin())); |
| 965 | tblgen_values.push_back(Elt: (*y.begin())); |
| 966 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val: ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none)); |
| 967 | tblgen_SubIOp_0 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 968 | } |
| 969 | |
| 970 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_0.getODSResults(index: 0) }) { |
| 971 | tblgen_repl_values.push_back(Elt: v); |
| 972 | } |
| 973 | |
| 974 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 975 | return ::mlir::success(); |
| 976 | } |
| 977 | }; |
| 978 | |
| 979 | /* Generated from: |
| 980 | ArithCanonicalization.td:109 |
| 981 | */ |
| 982 | struct AddISubConstantLHS : public ::mlir::RewritePattern { |
| 983 | AddISubConstantLHS(::mlir::MLIRContext *context) |
| 984 | : ::mlir::RewritePattern("arith.addi" , 2, context, {"arith.constant" , "arith.subi" }) {} |
| 985 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 986 | ::mlir::PatternRewriter &rewriter) const override { |
| 987 | // Variables for capturing values and attributes used while creating ops |
| 988 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 989 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 990 | ::mlir::Attribute c1; |
| 991 | ::mlir::Attribute c0; |
| 992 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 993 | ::mlir::arith::AddIOp res; |
| 994 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 995 | |
| 996 | // Match |
| 997 | tblgen_ops.push_back(Elt: op0); |
| 998 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddIOp>(Val: op0); (void)castedOp0; |
| 999 | res = castedOp0; |
| 1000 | { |
| 1001 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1002 | if (!(op1)){ |
| 1003 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1004 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1005 | }); |
| 1006 | } |
| 1007 | if(::mlir::failed(Result: static_dag_matcher_6(rewriter, op0: op1, tblgen_ops, ovf1, x, c0))) { |
| 1008 | return ::mlir::failure(); |
| 1009 | } |
| 1010 | tblgen_ops.push_back(Elt: op1); |
| 1011 | } |
| 1012 | { |
| 1013 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1014 | if (!(op1)){ |
| 1015 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1016 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1017 | }); |
| 1018 | } |
| 1019 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 1020 | return ::mlir::failure(); |
| 1021 | } |
| 1022 | tblgen_ops.push_back(Elt: op1); |
| 1023 | } |
| 1024 | { |
| 1025 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 1026 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 1027 | ovf2 = tblgen_attr; |
| 1028 | } |
| 1029 | |
| 1030 | // Rewrite |
| 1031 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 1032 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1033 | auto nativeVar_0 = addIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 1034 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 1035 | { |
| 1036 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 1037 | /*value=*/value: nativeVar_0 |
| 1038 | ); |
| 1039 | } |
| 1040 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c0, rhs: c1, signedOp: &APInt::sadd_ov, unsignedOp: &APInt::uadd_ov); (void)nativeVar_2; |
| 1041 | ::mlir::arith::SubIOp tblgen_SubIOp_3; |
| 1042 | { |
| 1043 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1044 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 1045 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 1046 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1047 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 1048 | tblgen_SubIOp_3 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 1049 | } |
| 1050 | |
| 1051 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_3.getODSResults(index: 0) }) { |
| 1052 | tblgen_repl_values.push_back(Elt: v); |
| 1053 | } |
| 1054 | |
| 1055 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1056 | return ::mlir::success(); |
| 1057 | } |
| 1058 | }; |
| 1059 | |
| 1060 | /* Generated from: |
| 1061 | ArithCanonicalization.td:101 |
| 1062 | */ |
| 1063 | struct AddISubConstantRHS : public ::mlir::RewritePattern { |
| 1064 | AddISubConstantRHS(::mlir::MLIRContext *context) |
| 1065 | : ::mlir::RewritePattern("arith.addi" , 2, context, {"arith.addi" , "arith.constant" }) {} |
| 1066 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1067 | ::mlir::PatternRewriter &rewriter) const override { |
| 1068 | // Variables for capturing values and attributes used while creating ops |
| 1069 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 1070 | ::mlir::Attribute c1; |
| 1071 | ::mlir::Attribute c0; |
| 1072 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1073 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 1074 | ::mlir::arith::AddIOp res; |
| 1075 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1076 | |
| 1077 | // Match |
| 1078 | tblgen_ops.push_back(Elt: op0); |
| 1079 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddIOp>(Val: op0); (void)castedOp0; |
| 1080 | res = castedOp0; |
| 1081 | { |
| 1082 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1083 | if (!(op1)){ |
| 1084 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1085 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1086 | }); |
| 1087 | } |
| 1088 | if(::mlir::failed(Result: static_dag_matcher_7(rewriter, op0: op1, tblgen_ops, ovf1, c0, x))) { |
| 1089 | return ::mlir::failure(); |
| 1090 | } |
| 1091 | tblgen_ops.push_back(Elt: op1); |
| 1092 | } |
| 1093 | { |
| 1094 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1095 | if (!(op1)){ |
| 1096 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1097 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1098 | }); |
| 1099 | } |
| 1100 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 1101 | return ::mlir::failure(); |
| 1102 | } |
| 1103 | tblgen_ops.push_back(Elt: op1); |
| 1104 | } |
| 1105 | { |
| 1106 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 1107 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 1108 | ovf2 = tblgen_attr; |
| 1109 | } |
| 1110 | |
| 1111 | // Rewrite |
| 1112 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 1113 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1114 | auto nativeVar_0 = subIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c1, rhs: c0); (void)nativeVar_0; |
| 1115 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 1116 | { |
| 1117 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 1118 | /*value=*/value: nativeVar_0 |
| 1119 | ); |
| 1120 | } |
| 1121 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c1, rhs: c0, signedOp: &APInt::ssub_ov, unsignedOp: &APInt::usub_ov); (void)nativeVar_2; |
| 1122 | ::mlir::arith::AddIOp tblgen_AddIOp_3; |
| 1123 | { |
| 1124 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1125 | ::mlir::arith::AddIOp::Properties tblgen_props; (void)tblgen_props; |
| 1126 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1127 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 1128 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 1129 | tblgen_AddIOp_3 = ::mlir::arith::AddIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 1130 | } |
| 1131 | |
| 1132 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AddIOp_3.getODSResults(index: 0) }) { |
| 1133 | tblgen_repl_values.push_back(Elt: v); |
| 1134 | } |
| 1135 | |
| 1136 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1137 | return ::mlir::success(); |
| 1138 | } |
| 1139 | }; |
| 1140 | |
| 1141 | /* Generated from: |
| 1142 | ArithCanonicalization.td:153 |
| 1143 | */ |
| 1144 | struct AddUIExtendedToAddI : public ::mlir::RewritePattern { |
| 1145 | AddUIExtendedToAddI(::mlir::MLIRContext *context) |
| 1146 | : ::mlir::RewritePattern("arith.addui_extended" , 1, context, {"arith.addi" }) {} |
| 1147 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1148 | ::mlir::PatternRewriter &rewriter) const override { |
| 1149 | // Variables for capturing values and attributes used while creating ops |
| 1150 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1151 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 1152 | ::mlir::arith::AddUIExtendedOp res; |
| 1153 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1154 | |
| 1155 | // Match |
| 1156 | tblgen_ops.push_back(Elt: op0); |
| 1157 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AddUIExtendedOp>(Val: op0); (void)castedOp0; |
| 1158 | res = castedOp0; |
| 1159 | x = castedOp0.getODSOperands(index: 0); |
| 1160 | y = castedOp0.getODSOperands(index: 1); |
| 1161 | if (!(((*res.getODSResults(index: 1).begin()).getUses().empty()))){ |
| 1162 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1163 | diag << "entities 'res__1' failed to satisfy constraint: ''" ; |
| 1164 | }); |
| 1165 | } |
| 1166 | |
| 1167 | // Rewrite |
| 1168 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc()}); (void)odsLoc; |
| 1169 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1170 | ::mlir::arith::AddIOp tblgen_AddIOp_0; |
| 1171 | { |
| 1172 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1173 | ::mlir::arith::AddIOp::Properties tblgen_props; (void)tblgen_props; |
| 1174 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1175 | tblgen_values.push_back(Elt: (*y.begin())); |
| 1176 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val: ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none)); |
| 1177 | tblgen_AddIOp_0 = ::mlir::arith::AddIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 1178 | } |
| 1179 | |
| 1180 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AddIOp_0.getODSResults(index: 0) }) { |
| 1181 | tblgen_repl_values.push_back(Elt: v); |
| 1182 | } |
| 1183 | |
| 1184 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ x }) { |
| 1185 | tblgen_repl_values.push_back(Elt: v); |
| 1186 | } |
| 1187 | |
| 1188 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1189 | return ::mlir::success(); |
| 1190 | } |
| 1191 | }; |
| 1192 | |
| 1193 | /* Generated from: |
| 1194 | ArithCanonicalization.td:428 |
| 1195 | */ |
| 1196 | struct AndIAndIConstant : public ::mlir::RewritePattern { |
| 1197 | AndIAndIConstant(::mlir::MLIRContext *context) |
| 1198 | : ::mlir::RewritePattern("arith.andi" , 2, context, {"arith.andi" , "arith.constant" }) {} |
| 1199 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1200 | ::mlir::PatternRewriter &rewriter) const override { |
| 1201 | // Variables for capturing values and attributes used while creating ops |
| 1202 | ::mlir::Attribute c1; |
| 1203 | ::mlir::Attribute c0; |
| 1204 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1205 | ::mlir::arith::AndIOp res; |
| 1206 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1207 | |
| 1208 | // Match |
| 1209 | tblgen_ops.push_back(Elt: op0); |
| 1210 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AndIOp>(Val: op0); (void)castedOp0; |
| 1211 | res = castedOp0; |
| 1212 | { |
| 1213 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1214 | if (!(op1)){ |
| 1215 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1216 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1217 | }); |
| 1218 | } |
| 1219 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::AndIOp>(Val: op1); (void)castedOp1; |
| 1220 | if (!(castedOp1)){ |
| 1221 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1222 | diag << "castedOp1 is not ::mlir::arith::AndIOp type" ; |
| 1223 | }); |
| 1224 | } |
| 1225 | x = castedOp1.getODSOperands(index: 0); |
| 1226 | { |
| 1227 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1228 | if (!(op2)){ |
| 1229 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1230 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 1231 | }); |
| 1232 | } |
| 1233 | if(::mlir::failed(Result: static_dag_matcher_2(rewriter, op0: op2, tblgen_ops, c0))) { |
| 1234 | return ::mlir::failure(); |
| 1235 | } |
| 1236 | tblgen_ops.push_back(Elt: op2); |
| 1237 | } |
| 1238 | tblgen_ops.push_back(Elt: op1); |
| 1239 | } |
| 1240 | { |
| 1241 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1242 | if (!(op1)){ |
| 1243 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1244 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1245 | }); |
| 1246 | } |
| 1247 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 1248 | return ::mlir::failure(); |
| 1249 | } |
| 1250 | tblgen_ops.push_back(Elt: op1); |
| 1251 | } |
| 1252 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c0).getType()))){ |
| 1253 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1254 | diag << "entities 'res, c0' failed to satisfy constraint: ''" ; |
| 1255 | }); |
| 1256 | } |
| 1257 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c1).getType()))){ |
| 1258 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1259 | diag << "entities 'res, c1' failed to satisfy constraint: ''" ; |
| 1260 | }); |
| 1261 | } |
| 1262 | |
| 1263 | // Rewrite |
| 1264 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 1265 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1266 | auto nativeVar_0 = andIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 1267 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 1268 | { |
| 1269 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 1270 | /*value=*/value: nativeVar_0 |
| 1271 | ); |
| 1272 | } |
| 1273 | ::mlir::arith::AndIOp tblgen_AndIOp_2; |
| 1274 | { |
| 1275 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1276 | ::mlir::arith::AndIOp::Properties tblgen_props; (void)tblgen_props; |
| 1277 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1278 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 1279 | tblgen_AndIOp_2 = ::mlir::arith::AndIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 1280 | } |
| 1281 | |
| 1282 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AndIOp_2.getODSResults(index: 0) }) { |
| 1283 | tblgen_repl_values.push_back(Elt: v); |
| 1284 | } |
| 1285 | |
| 1286 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1287 | return ::mlir::success(); |
| 1288 | } |
| 1289 | }; |
| 1290 | |
| 1291 | /* Generated from: |
| 1292 | ArithCanonicalization.td:446 |
| 1293 | */ |
| 1294 | struct AndOfExtSI : public ::mlir::RewritePattern { |
| 1295 | AndOfExtSI(::mlir::MLIRContext *context) |
| 1296 | : ::mlir::RewritePattern("arith.andi" , 3, context, {"arith.andi" , "arith.extsi" }) {} |
| 1297 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1298 | ::mlir::PatternRewriter &rewriter) const override { |
| 1299 | // Variables for capturing values and attributes used while creating ops |
| 1300 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 1301 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1302 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1303 | |
| 1304 | // Match |
| 1305 | tblgen_ops.push_back(Elt: op0); |
| 1306 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AndIOp>(Val: op0); (void)castedOp0; |
| 1307 | { |
| 1308 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1309 | if (!(op1)){ |
| 1310 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1311 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1312 | }); |
| 1313 | } |
| 1314 | if(::mlir::failed(Result: static_dag_matcher_8(rewriter, op0: op1, tblgen_ops, x))) { |
| 1315 | return ::mlir::failure(); |
| 1316 | } |
| 1317 | tblgen_ops.push_back(Elt: op1); |
| 1318 | } |
| 1319 | { |
| 1320 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1321 | if (!(op1)){ |
| 1322 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1323 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1324 | }); |
| 1325 | } |
| 1326 | if(::mlir::failed(Result: static_dag_matcher_9(rewriter, op0: op1, tblgen_ops, y))) { |
| 1327 | return ::mlir::failure(); |
| 1328 | } |
| 1329 | tblgen_ops.push_back(Elt: op1); |
| 1330 | } |
| 1331 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 1332 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1333 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 1334 | }); |
| 1335 | } |
| 1336 | |
| 1337 | // Rewrite |
| 1338 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 1339 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1340 | ::mlir::arith::AndIOp tblgen_AndIOp_0; |
| 1341 | { |
| 1342 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1343 | ::mlir::arith::AndIOp::Properties tblgen_props; (void)tblgen_props; |
| 1344 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1345 | tblgen_values.push_back(Elt: (*y.begin())); |
| 1346 | tblgen_AndIOp_0 = ::mlir::arith::AndIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 1347 | } |
| 1348 | ::mlir::arith::ExtSIOp tblgen_ExtSIOp_1; |
| 1349 | { |
| 1350 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1351 | ::mlir::arith::ExtSIOp::Properties tblgen_props; (void)tblgen_props; |
| 1352 | tblgen_values.push_back(Elt: (*tblgen_AndIOp_0.getODSResults(index: 0).begin())); |
| 1353 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1354 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1355 | tblgen_types.push_back(Elt: v.getType()); |
| 1356 | } |
| 1357 | tblgen_ExtSIOp_1 = ::mlir::arith::ExtSIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1358 | } |
| 1359 | |
| 1360 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtSIOp_1.getODSResults(index: 0) }) { |
| 1361 | tblgen_repl_values.push_back(Elt: v); |
| 1362 | } |
| 1363 | |
| 1364 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1365 | return ::mlir::success(); |
| 1366 | } |
| 1367 | }; |
| 1368 | |
| 1369 | /* Generated from: |
| 1370 | ArithCanonicalization.td:439 |
| 1371 | */ |
| 1372 | struct AndOfExtUI : public ::mlir::RewritePattern { |
| 1373 | AndOfExtUI(::mlir::MLIRContext *context) |
| 1374 | : ::mlir::RewritePattern("arith.andi" , 3, context, {"arith.andi" , "arith.extui" }) {} |
| 1375 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1376 | ::mlir::PatternRewriter &rewriter) const override { |
| 1377 | // Variables for capturing values and attributes used while creating ops |
| 1378 | ::mlir::UnitAttr nneg2; |
| 1379 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 1380 | ::mlir::UnitAttr nneg1; |
| 1381 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1382 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1383 | |
| 1384 | // Match |
| 1385 | tblgen_ops.push_back(Elt: op0); |
| 1386 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::AndIOp>(Val: op0); (void)castedOp0; |
| 1387 | { |
| 1388 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1389 | if (!(op1)){ |
| 1390 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1391 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1392 | }); |
| 1393 | } |
| 1394 | if(::mlir::failed(Result: static_dag_matcher_10(rewriter, op0: op1, tblgen_ops, nneg1, x))) { |
| 1395 | return ::mlir::failure(); |
| 1396 | } |
| 1397 | tblgen_ops.push_back(Elt: op1); |
| 1398 | } |
| 1399 | { |
| 1400 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1401 | if (!(op1)){ |
| 1402 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1403 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1404 | }); |
| 1405 | } |
| 1406 | if(::mlir::failed(Result: static_dag_matcher_11(rewriter, op0: op1, tblgen_ops, nneg2, y))) { |
| 1407 | return ::mlir::failure(); |
| 1408 | } |
| 1409 | tblgen_ops.push_back(Elt: op1); |
| 1410 | } |
| 1411 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 1412 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1413 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 1414 | }); |
| 1415 | } |
| 1416 | |
| 1417 | // Rewrite |
| 1418 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 1419 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1420 | ::mlir::arith::AndIOp tblgen_AndIOp_0; |
| 1421 | { |
| 1422 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1423 | ::mlir::arith::AndIOp::Properties tblgen_props; (void)tblgen_props; |
| 1424 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1425 | tblgen_values.push_back(Elt: (*y.begin())); |
| 1426 | tblgen_AndIOp_0 = ::mlir::arith::AndIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 1427 | } |
| 1428 | auto nativeVar_1 = nneg1 ? nneg1 : nneg2; (void)nativeVar_1; |
| 1429 | ::mlir::arith::ExtUIOp tblgen_ExtUIOp_2; |
| 1430 | { |
| 1431 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1432 | ::mlir::arith::ExtUIOp::Properties tblgen_props; (void)tblgen_props; |
| 1433 | tblgen_values.push_back(Elt: (*tblgen_AndIOp_0.getODSResults(index: 0).begin())); |
| 1434 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nativeVar_1); |
| 1435 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1436 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1437 | tblgen_types.push_back(Elt: v.getType()); |
| 1438 | } |
| 1439 | tblgen_ExtUIOp_2 = ::mlir::arith::ExtUIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1440 | } |
| 1441 | |
| 1442 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtUIOp_2.getODSResults(index: 0) }) { |
| 1443 | tblgen_repl_values.push_back(Elt: v); |
| 1444 | } |
| 1445 | |
| 1446 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1447 | return ::mlir::success(); |
| 1448 | } |
| 1449 | }; |
| 1450 | |
| 1451 | /* Generated from: |
| 1452 | ArithCanonicalization.td:411 |
| 1453 | */ |
| 1454 | struct BitcastOfBitcast : public ::mlir::RewritePattern { |
| 1455 | BitcastOfBitcast(::mlir::MLIRContext *context) |
| 1456 | : ::mlir::RewritePattern("arith.bitcast" , 2, context, {"arith.bitcast" }) {} |
| 1457 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1458 | ::mlir::PatternRewriter &rewriter) const override { |
| 1459 | // Variables for capturing values and attributes used while creating ops |
| 1460 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1461 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1462 | |
| 1463 | // Match |
| 1464 | tblgen_ops.push_back(Elt: op0); |
| 1465 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::BitcastOp>(Val: op0); (void)castedOp0; |
| 1466 | { |
| 1467 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1468 | if (!(op1)){ |
| 1469 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1470 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1471 | }); |
| 1472 | } |
| 1473 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::BitcastOp>(Val: op1); (void)castedOp1; |
| 1474 | if (!(castedOp1)){ |
| 1475 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1476 | diag << "castedOp1 is not ::mlir::arith::BitcastOp type" ; |
| 1477 | }); |
| 1478 | } |
| 1479 | x = castedOp1.getODSOperands(index: 0); |
| 1480 | tblgen_ops.push_back(Elt: op1); |
| 1481 | } |
| 1482 | |
| 1483 | // Rewrite |
| 1484 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 1485 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1486 | ::mlir::arith::BitcastOp tblgen_BitcastOp_0; |
| 1487 | { |
| 1488 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1489 | ::mlir::arith::BitcastOp::Properties tblgen_props; (void)tblgen_props; |
| 1490 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1491 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1492 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1493 | tblgen_types.push_back(Elt: v.getType()); |
| 1494 | } |
| 1495 | tblgen_BitcastOp_0 = ::mlir::arith::BitcastOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1496 | } |
| 1497 | |
| 1498 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_BitcastOp_0.getODSResults(index: 0) }) { |
| 1499 | tblgen_repl_values.push_back(Elt: v); |
| 1500 | } |
| 1501 | |
| 1502 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1503 | return ::mlir::success(); |
| 1504 | } |
| 1505 | }; |
| 1506 | |
| 1507 | /* Generated from: |
| 1508 | ArithCanonicalization.td:310 |
| 1509 | */ |
| 1510 | struct CmpIExtSI : public ::mlir::RewritePattern { |
| 1511 | CmpIExtSI(::mlir::MLIRContext *context) |
| 1512 | : ::mlir::RewritePattern("arith.cmpi" , 3, context, {"arith.cmpi" }) {} |
| 1513 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1514 | ::mlir::PatternRewriter &rewriter) const override { |
| 1515 | // Variables for capturing values and attributes used while creating ops |
| 1516 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 1517 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 1518 | ::mlir::arith::CmpIPredicateAttr pred; |
| 1519 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1520 | |
| 1521 | // Match |
| 1522 | tblgen_ops.push_back(Elt: op0); |
| 1523 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp0; |
| 1524 | { |
| 1525 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPredicate(); |
| 1526 | if (!(tblgen_attr)){ |
| 1527 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1528 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 1529 | }); |
| 1530 | } |
| 1531 | pred = tblgen_attr; |
| 1532 | } |
| 1533 | { |
| 1534 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1535 | if (!(op1)){ |
| 1536 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1537 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1538 | }); |
| 1539 | } |
| 1540 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtSIOp>(Val: op1); (void)castedOp1; |
| 1541 | if (!(castedOp1)){ |
| 1542 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1543 | diag << "castedOp1 is not ::mlir::arith::ExtSIOp type" ; |
| 1544 | }); |
| 1545 | } |
| 1546 | a = castedOp1.getODSOperands(index: 0); |
| 1547 | tblgen_ops.push_back(Elt: op1); |
| 1548 | } |
| 1549 | { |
| 1550 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1551 | if (!(op1)){ |
| 1552 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1553 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1554 | }); |
| 1555 | } |
| 1556 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtSIOp>(Val: op1); (void)castedOp1; |
| 1557 | if (!(castedOp1)){ |
| 1558 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1559 | diag << "castedOp1 is not ::mlir::arith::ExtSIOp type" ; |
| 1560 | }); |
| 1561 | } |
| 1562 | b = castedOp1.getODSOperands(index: 0); |
| 1563 | tblgen_ops.push_back(Elt: op1); |
| 1564 | } |
| 1565 | if (!(((*a.begin()).getType() == (*b.begin()).getType()))){ |
| 1566 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1567 | diag << "entities 'a, b' failed to satisfy constraint: ''" ; |
| 1568 | }); |
| 1569 | } |
| 1570 | if (!((pred.getValue() == arith::CmpIPredicate::eq || pred.getValue() == arith::CmpIPredicate::ne))){ |
| 1571 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1572 | diag << "entities 'pred' failed to satisfy constraint: ''" ; |
| 1573 | }); |
| 1574 | } |
| 1575 | |
| 1576 | // Rewrite |
| 1577 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 1578 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1579 | ::mlir::arith::CmpIOp tblgen_CmpIOp_0; |
| 1580 | { |
| 1581 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1582 | ::mlir::arith::CmpIOp::Properties tblgen_props; (void)tblgen_props; |
| 1583 | tblgen_props.predicate = ::llvm::dyn_cast_if_present<decltype(tblgen_props.predicate)>(Val&: pred); |
| 1584 | tblgen_values.push_back(Elt: (*a.begin())); |
| 1585 | tblgen_values.push_back(Elt: (*b.begin())); |
| 1586 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1587 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1588 | tblgen_types.push_back(Elt: v.getType()); |
| 1589 | } |
| 1590 | tblgen_CmpIOp_0 = ::mlir::arith::CmpIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1591 | } |
| 1592 | |
| 1593 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CmpIOp_0.getODSResults(index: 0) }) { |
| 1594 | tblgen_repl_values.push_back(Elt: v); |
| 1595 | } |
| 1596 | |
| 1597 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1598 | return ::mlir::success(); |
| 1599 | } |
| 1600 | }; |
| 1601 | |
| 1602 | /* Generated from: |
| 1603 | ArithCanonicalization.td:318 |
| 1604 | */ |
| 1605 | struct CmpIExtUI : public ::mlir::RewritePattern { |
| 1606 | CmpIExtUI(::mlir::MLIRContext *context) |
| 1607 | : ::mlir::RewritePattern("arith.cmpi" , 3, context, {"arith.cmpi" }) {} |
| 1608 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1609 | ::mlir::PatternRewriter &rewriter) const override { |
| 1610 | // Variables for capturing values and attributes used while creating ops |
| 1611 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 1612 | ::mlir::UnitAttr nneg2; |
| 1613 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 1614 | ::mlir::UnitAttr nneg1; |
| 1615 | ::mlir::arith::CmpIPredicateAttr pred; |
| 1616 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1617 | |
| 1618 | // Match |
| 1619 | tblgen_ops.push_back(Elt: op0); |
| 1620 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op0); (void)castedOp0; |
| 1621 | { |
| 1622 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getPredicate(); |
| 1623 | if (!(tblgen_attr)){ |
| 1624 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1625 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 1626 | }); |
| 1627 | } |
| 1628 | pred = tblgen_attr; |
| 1629 | } |
| 1630 | { |
| 1631 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1632 | if (!(op1)){ |
| 1633 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1634 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1635 | }); |
| 1636 | } |
| 1637 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtUIOp>(Val: op1); (void)castedOp1; |
| 1638 | if (!(castedOp1)){ |
| 1639 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1640 | diag << "castedOp1 is not ::mlir::arith::ExtUIOp type" ; |
| 1641 | }); |
| 1642 | } |
| 1643 | a = castedOp1.getODSOperands(index: 0); |
| 1644 | { |
| 1645 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getNonNeg(); |
| 1646 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 1647 | nneg1 = tblgen_attr; |
| 1648 | } |
| 1649 | tblgen_ops.push_back(Elt: op1); |
| 1650 | } |
| 1651 | { |
| 1652 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1653 | if (!(op1)){ |
| 1654 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1655 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1656 | }); |
| 1657 | } |
| 1658 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtUIOp>(Val: op1); (void)castedOp1; |
| 1659 | if (!(castedOp1)){ |
| 1660 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1661 | diag << "castedOp1 is not ::mlir::arith::ExtUIOp type" ; |
| 1662 | }); |
| 1663 | } |
| 1664 | b = castedOp1.getODSOperands(index: 0); |
| 1665 | { |
| 1666 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getNonNeg(); |
| 1667 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 1668 | nneg2 = tblgen_attr; |
| 1669 | } |
| 1670 | tblgen_ops.push_back(Elt: op1); |
| 1671 | } |
| 1672 | if (!(((*a.begin()).getType() == (*b.begin()).getType()))){ |
| 1673 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1674 | diag << "entities 'a, b' failed to satisfy constraint: ''" ; |
| 1675 | }); |
| 1676 | } |
| 1677 | if (!((pred.getValue() == arith::CmpIPredicate::eq || pred.getValue() == arith::CmpIPredicate::ne))){ |
| 1678 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1679 | diag << "entities 'pred' failed to satisfy constraint: ''" ; |
| 1680 | }); |
| 1681 | } |
| 1682 | |
| 1683 | // Rewrite |
| 1684 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 1685 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1686 | ::mlir::arith::CmpIOp tblgen_CmpIOp_0; |
| 1687 | { |
| 1688 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1689 | ::mlir::arith::CmpIOp::Properties tblgen_props; (void)tblgen_props; |
| 1690 | tblgen_props.predicate = ::llvm::dyn_cast_if_present<decltype(tblgen_props.predicate)>(Val&: pred); |
| 1691 | tblgen_values.push_back(Elt: (*a.begin())); |
| 1692 | tblgen_values.push_back(Elt: (*b.begin())); |
| 1693 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1694 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1695 | tblgen_types.push_back(Elt: v.getType()); |
| 1696 | } |
| 1697 | tblgen_CmpIOp_0 = ::mlir::arith::CmpIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1698 | } |
| 1699 | |
| 1700 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CmpIOp_0.getODSResults(index: 0) }) { |
| 1701 | tblgen_repl_values.push_back(Elt: v); |
| 1702 | } |
| 1703 | |
| 1704 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1705 | return ::mlir::success(); |
| 1706 | } |
| 1707 | }; |
| 1708 | |
| 1709 | /* Generated from: |
| 1710 | ArithCanonicalization.td:615 |
| 1711 | */ |
| 1712 | struct DivFOfNegF : public ::mlir::RewritePattern { |
| 1713 | DivFOfNegF(::mlir::MLIRContext *context) |
| 1714 | : ::mlir::RewritePattern("arith.divf" , 3, context, {"arith.divf" }) {} |
| 1715 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1716 | ::mlir::PatternRewriter &rewriter) const override { |
| 1717 | // Variables for capturing values and attributes used while creating ops |
| 1718 | ::mlir::arith::RoundingModeAttr rm; |
| 1719 | ::mlir::arith::FastMathFlagsAttr fmf; |
| 1720 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 1721 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1722 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1723 | |
| 1724 | // Match |
| 1725 | tblgen_ops.push_back(Elt: op0); |
| 1726 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::DivFOp>(Val: op0); (void)castedOp0; |
| 1727 | { |
| 1728 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1729 | if (!(op1)){ |
| 1730 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1731 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1732 | }); |
| 1733 | } |
| 1734 | if(::mlir::failed(Result: static_dag_matcher_0(rewriter, op0: op1, tblgen_ops, x))) { |
| 1735 | return ::mlir::failure(); |
| 1736 | } |
| 1737 | tblgen_ops.push_back(Elt: op1); |
| 1738 | } |
| 1739 | { |
| 1740 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1741 | if (!(op1)){ |
| 1742 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1743 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1744 | }); |
| 1745 | } |
| 1746 | if(::mlir::failed(Result: static_dag_matcher_1(rewriter, op0: op1, tblgen_ops, y))) { |
| 1747 | return ::mlir::failure(); |
| 1748 | } |
| 1749 | tblgen_ops.push_back(Elt: op1); |
| 1750 | } |
| 1751 | { |
| 1752 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFastmath(); |
| 1753 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::FastMathFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::FastMathFlags::none); |
| 1754 | fmf = tblgen_attr; |
| 1755 | } |
| 1756 | { |
| 1757 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRoundingmode(); |
| 1758 | rm = tblgen_attr; |
| 1759 | } |
| 1760 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 1761 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1762 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 1763 | }); |
| 1764 | } |
| 1765 | if (!((rm == nullptr))){ |
| 1766 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1767 | diag << "entities 'rm' failed to satisfy constraint: 'default rounding mode'" ; |
| 1768 | }); |
| 1769 | } |
| 1770 | |
| 1771 | // Rewrite |
| 1772 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 1773 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1774 | ::mlir::arith::DivFOp tblgen_DivFOp_0; |
| 1775 | { |
| 1776 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1777 | ::mlir::arith::DivFOp::Properties tblgen_props; (void)tblgen_props; |
| 1778 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1779 | tblgen_values.push_back(Elt: (*y.begin())); |
| 1780 | tblgen_props.fastmath = ::llvm::dyn_cast_if_present<decltype(tblgen_props.fastmath)>(Val&: fmf); |
| 1781 | tblgen_props.roundingmode = ::llvm::dyn_cast_if_present<decltype(tblgen_props.roundingmode)>(Val&: rm); |
| 1782 | tblgen_DivFOp_0 = ::mlir::arith::DivFOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 1783 | } |
| 1784 | |
| 1785 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_DivFOp_0.getODSResults(index: 0) }) { |
| 1786 | tblgen_repl_values.push_back(Elt: v); |
| 1787 | } |
| 1788 | |
| 1789 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1790 | return ::mlir::success(); |
| 1791 | } |
| 1792 | }; |
| 1793 | |
| 1794 | /* Generated from: |
| 1795 | ArithCanonicalization.td:419 |
| 1796 | */ |
| 1797 | struct ExtSIOfExtUI : public ::mlir::RewritePattern { |
| 1798 | ExtSIOfExtUI(::mlir::MLIRContext *context) |
| 1799 | : ::mlir::RewritePattern("arith.extsi" , 2, context, {"arith.extui" }) {} |
| 1800 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1801 | ::mlir::PatternRewriter &rewriter) const override { |
| 1802 | // Variables for capturing values and attributes used while creating ops |
| 1803 | ::mlir::UnitAttr nneg; |
| 1804 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1805 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1806 | |
| 1807 | // Match |
| 1808 | tblgen_ops.push_back(Elt: op0); |
| 1809 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::ExtSIOp>(Val: op0); (void)castedOp0; |
| 1810 | { |
| 1811 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1812 | if (!(op1)){ |
| 1813 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1814 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1815 | }); |
| 1816 | } |
| 1817 | if(::mlir::failed(Result: static_dag_matcher_12(rewriter, op0: op1, tblgen_ops, nneg, x))) { |
| 1818 | return ::mlir::failure(); |
| 1819 | } |
| 1820 | tblgen_ops.push_back(Elt: op1); |
| 1821 | } |
| 1822 | |
| 1823 | // Rewrite |
| 1824 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 1825 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1826 | ::mlir::arith::ExtUIOp tblgen_ExtUIOp_0; |
| 1827 | { |
| 1828 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1829 | ::mlir::arith::ExtUIOp::Properties tblgen_props; (void)tblgen_props; |
| 1830 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1831 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nneg); |
| 1832 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1833 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1834 | tblgen_types.push_back(Elt: v.getType()); |
| 1835 | } |
| 1836 | tblgen_ExtUIOp_0 = ::mlir::arith::ExtUIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1837 | } |
| 1838 | |
| 1839 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtUIOp_0.getODSResults(index: 0) }) { |
| 1840 | tblgen_repl_values.push_back(Elt: v); |
| 1841 | } |
| 1842 | |
| 1843 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1844 | return ::mlir::success(); |
| 1845 | } |
| 1846 | }; |
| 1847 | |
| 1848 | /* Generated from: |
| 1849 | ArithCanonicalization.td:393 |
| 1850 | */ |
| 1851 | struct IndexCastOfExtSI : public ::mlir::RewritePattern { |
| 1852 | IndexCastOfExtSI(::mlir::MLIRContext *context) |
| 1853 | : ::mlir::RewritePattern("arith.index_cast" , 2, context, {"arith.index_cast" }) {} |
| 1854 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1855 | ::mlir::PatternRewriter &rewriter) const override { |
| 1856 | // Variables for capturing values and attributes used while creating ops |
| 1857 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1858 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1859 | |
| 1860 | // Match |
| 1861 | tblgen_ops.push_back(Elt: op0); |
| 1862 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::IndexCastOp>(Val: op0); (void)castedOp0; |
| 1863 | { |
| 1864 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1865 | if (!(op1)){ |
| 1866 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1867 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1868 | }); |
| 1869 | } |
| 1870 | if(::mlir::failed(Result: static_dag_matcher_8(rewriter, op0: op1, tblgen_ops, x))) { |
| 1871 | return ::mlir::failure(); |
| 1872 | } |
| 1873 | tblgen_ops.push_back(Elt: op1); |
| 1874 | } |
| 1875 | |
| 1876 | // Rewrite |
| 1877 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 1878 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1879 | ::mlir::arith::IndexCastOp tblgen_IndexCastOp_0; |
| 1880 | { |
| 1881 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1882 | ::mlir::arith::IndexCastOp::Properties tblgen_props; (void)tblgen_props; |
| 1883 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1884 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1885 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1886 | tblgen_types.push_back(Elt: v.getType()); |
| 1887 | } |
| 1888 | tblgen_IndexCastOp_0 = ::mlir::arith::IndexCastOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1889 | } |
| 1890 | |
| 1891 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_IndexCastOp_0.getODSResults(index: 0) }) { |
| 1892 | tblgen_repl_values.push_back(Elt: v); |
| 1893 | } |
| 1894 | |
| 1895 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1896 | return ::mlir::success(); |
| 1897 | } |
| 1898 | }; |
| 1899 | |
| 1900 | /* Generated from: |
| 1901 | ArithCanonicalization.td:401 |
| 1902 | */ |
| 1903 | struct IndexCastUIOfExtUI : public ::mlir::RewritePattern { |
| 1904 | IndexCastUIOfExtUI(::mlir::MLIRContext *context) |
| 1905 | : ::mlir::RewritePattern("arith.index_castui" , 2, context, {"arith.index_castui" }) {} |
| 1906 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1907 | ::mlir::PatternRewriter &rewriter) const override { |
| 1908 | // Variables for capturing values and attributes used while creating ops |
| 1909 | ::mlir::UnitAttr nneg2; |
| 1910 | ::mlir::UnitAttr nneg1; |
| 1911 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1912 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1913 | |
| 1914 | // Match |
| 1915 | tblgen_ops.push_back(Elt: op0); |
| 1916 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::IndexCastUIOp>(Val: op0); (void)castedOp0; |
| 1917 | { |
| 1918 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1919 | if (!(op1)){ |
| 1920 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1921 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1922 | }); |
| 1923 | } |
| 1924 | if(::mlir::failed(Result: static_dag_matcher_10(rewriter, op0: op1, tblgen_ops, nneg1, x))) { |
| 1925 | return ::mlir::failure(); |
| 1926 | } |
| 1927 | tblgen_ops.push_back(Elt: op1); |
| 1928 | } |
| 1929 | { |
| 1930 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getNonNeg(); |
| 1931 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 1932 | nneg2 = tblgen_attr; |
| 1933 | } |
| 1934 | |
| 1935 | // Rewrite |
| 1936 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 1937 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 1938 | ::mlir::arith::IndexCastUIOp tblgen_IndexCastUIOp_0; |
| 1939 | { |
| 1940 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 1941 | ::mlir::arith::IndexCastUIOp::Properties tblgen_props; (void)tblgen_props; |
| 1942 | tblgen_values.push_back(Elt: (*x.begin())); |
| 1943 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nneg1); |
| 1944 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 1945 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 1946 | tblgen_types.push_back(Elt: v.getType()); |
| 1947 | } |
| 1948 | tblgen_IndexCastUIOp_0 = ::mlir::arith::IndexCastUIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 1949 | } |
| 1950 | |
| 1951 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_IndexCastUIOp_0.getODSResults(index: 0) }) { |
| 1952 | tblgen_repl_values.push_back(Elt: v); |
| 1953 | } |
| 1954 | |
| 1955 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 1956 | return ::mlir::success(); |
| 1957 | } |
| 1958 | }; |
| 1959 | |
| 1960 | /* Generated from: |
| 1961 | ArithCanonicalization.td:602 |
| 1962 | */ |
| 1963 | struct MulFOfNegF : public ::mlir::RewritePattern { |
| 1964 | MulFOfNegF(::mlir::MLIRContext *context) |
| 1965 | : ::mlir::RewritePattern("arith.mulf" , 3, context, {"arith.mulf" }) {} |
| 1966 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 1967 | ::mlir::PatternRewriter &rewriter) const override { |
| 1968 | // Variables for capturing values and attributes used while creating ops |
| 1969 | ::mlir::arith::RoundingModeAttr rm; |
| 1970 | ::mlir::arith::FastMathFlagsAttr fmf; |
| 1971 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 1972 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 1973 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 1974 | |
| 1975 | // Match |
| 1976 | tblgen_ops.push_back(Elt: op0); |
| 1977 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::MulFOp>(Val: op0); (void)castedOp0; |
| 1978 | { |
| 1979 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 1980 | if (!(op1)){ |
| 1981 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1982 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 1983 | }); |
| 1984 | } |
| 1985 | if(::mlir::failed(Result: static_dag_matcher_0(rewriter, op0: op1, tblgen_ops, x))) { |
| 1986 | return ::mlir::failure(); |
| 1987 | } |
| 1988 | tblgen_ops.push_back(Elt: op1); |
| 1989 | } |
| 1990 | { |
| 1991 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 1992 | if (!(op1)){ |
| 1993 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 1994 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 1995 | }); |
| 1996 | } |
| 1997 | if(::mlir::failed(Result: static_dag_matcher_1(rewriter, op0: op1, tblgen_ops, y))) { |
| 1998 | return ::mlir::failure(); |
| 1999 | } |
| 2000 | tblgen_ops.push_back(Elt: op1); |
| 2001 | } |
| 2002 | { |
| 2003 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFastmath(); |
| 2004 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::FastMathFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::FastMathFlags::none); |
| 2005 | fmf = tblgen_attr; |
| 2006 | } |
| 2007 | { |
| 2008 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRoundingmode(); |
| 2009 | rm = tblgen_attr; |
| 2010 | } |
| 2011 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 2012 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2013 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 2014 | }); |
| 2015 | } |
| 2016 | if (!((rm == nullptr))){ |
| 2017 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2018 | diag << "entities 'rm' failed to satisfy constraint: 'default rounding mode'" ; |
| 2019 | }); |
| 2020 | } |
| 2021 | |
| 2022 | // Rewrite |
| 2023 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 2024 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2025 | ::mlir::arith::MulFOp tblgen_MulFOp_0; |
| 2026 | { |
| 2027 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2028 | ::mlir::arith::MulFOp::Properties tblgen_props; (void)tblgen_props; |
| 2029 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2030 | tblgen_values.push_back(Elt: (*y.begin())); |
| 2031 | tblgen_props.fastmath = ::llvm::dyn_cast_if_present<decltype(tblgen_props.fastmath)>(Val&: fmf); |
| 2032 | tblgen_props.roundingmode = ::llvm::dyn_cast_if_present<decltype(tblgen_props.roundingmode)>(Val&: rm); |
| 2033 | tblgen_MulFOp_0 = ::mlir::arith::MulFOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2034 | } |
| 2035 | |
| 2036 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MulFOp_0.getODSResults(index: 0) }) { |
| 2037 | tblgen_repl_values.push_back(Elt: v); |
| 2038 | } |
| 2039 | |
| 2040 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2041 | return ::mlir::success(); |
| 2042 | } |
| 2043 | }; |
| 2044 | |
| 2045 | /* Generated from: |
| 2046 | ArithCanonicalization.td:138 |
| 2047 | */ |
| 2048 | struct MulIMulIConstant : public ::mlir::RewritePattern { |
| 2049 | MulIMulIConstant(::mlir::MLIRContext *context) |
| 2050 | : ::mlir::RewritePattern("arith.muli" , 2, context, {"arith.constant" , "arith.muli" }) {} |
| 2051 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2052 | ::mlir::PatternRewriter &rewriter) const override { |
| 2053 | // Variables for capturing values and attributes used while creating ops |
| 2054 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 2055 | ::mlir::Attribute c1; |
| 2056 | ::mlir::Attribute c0; |
| 2057 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2058 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 2059 | ::mlir::arith::MulIOp res; |
| 2060 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2061 | |
| 2062 | // Match |
| 2063 | tblgen_ops.push_back(Elt: op0); |
| 2064 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::MulIOp>(Val: op0); (void)castedOp0; |
| 2065 | res = castedOp0; |
| 2066 | { |
| 2067 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2068 | if (!(op1)){ |
| 2069 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2070 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2071 | }); |
| 2072 | } |
| 2073 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::MulIOp>(Val: op1); (void)castedOp1; |
| 2074 | if (!(castedOp1)){ |
| 2075 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2076 | diag << "castedOp1 is not ::mlir::arith::MulIOp type" ; |
| 2077 | }); |
| 2078 | } |
| 2079 | x = castedOp1.getODSOperands(index: 0); |
| 2080 | { |
| 2081 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2082 | if (!(op2)){ |
| 2083 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2084 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 2085 | }); |
| 2086 | } |
| 2087 | if(::mlir::failed(Result: static_dag_matcher_2(rewriter, op0: op2, tblgen_ops, c0))) { |
| 2088 | return ::mlir::failure(); |
| 2089 | } |
| 2090 | tblgen_ops.push_back(Elt: op2); |
| 2091 | } |
| 2092 | { |
| 2093 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getOverflowFlags(); |
| 2094 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 2095 | ovf1 = tblgen_attr; |
| 2096 | } |
| 2097 | tblgen_ops.push_back(Elt: op1); |
| 2098 | } |
| 2099 | { |
| 2100 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2101 | if (!(op1)){ |
| 2102 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2103 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 2104 | }); |
| 2105 | } |
| 2106 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 2107 | return ::mlir::failure(); |
| 2108 | } |
| 2109 | tblgen_ops.push_back(Elt: op1); |
| 2110 | } |
| 2111 | { |
| 2112 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 2113 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 2114 | ovf2 = tblgen_attr; |
| 2115 | } |
| 2116 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c0).getType()))){ |
| 2117 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2118 | diag << "entities 'res, c0' failed to satisfy constraint: ''" ; |
| 2119 | }); |
| 2120 | } |
| 2121 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c1).getType()))){ |
| 2122 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2123 | diag << "entities 'res, c1' failed to satisfy constraint: ''" ; |
| 2124 | }); |
| 2125 | } |
| 2126 | |
| 2127 | // Rewrite |
| 2128 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2129 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2130 | auto nativeVar_0 = mulIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 2131 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 2132 | { |
| 2133 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 2134 | /*value=*/value: nativeVar_0 |
| 2135 | ); |
| 2136 | } |
| 2137 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c0, rhs: c1, signedOp: &APInt::smul_ov, unsignedOp: &APInt::umul_ov); (void)nativeVar_2; |
| 2138 | ::mlir::arith::MulIOp tblgen_MulIOp_3; |
| 2139 | { |
| 2140 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2141 | ::mlir::arith::MulIOp::Properties tblgen_props; (void)tblgen_props; |
| 2142 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2143 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 2144 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 2145 | tblgen_MulIOp_3 = ::mlir::arith::MulIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2146 | } |
| 2147 | |
| 2148 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MulIOp_3.getODSResults(index: 0) }) { |
| 2149 | tblgen_repl_values.push_back(Elt: v); |
| 2150 | } |
| 2151 | |
| 2152 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2153 | return ::mlir::success(); |
| 2154 | } |
| 2155 | }; |
| 2156 | |
| 2157 | /* Generated from: |
| 2158 | ArithCanonicalization.td:247 |
| 2159 | */ |
| 2160 | struct MulSIExtendedRHSOne : public ::mlir::RewritePattern { |
| 2161 | MulSIExtendedRHSOne(::mlir::MLIRContext *context) |
| 2162 | : ::mlir::RewritePattern("arith.mulsi_extended" , 1, context, {"arith.cmpi" , "arith.constant" , "arith.extsi" }) {} |
| 2163 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2164 | ::mlir::PatternRewriter &rewriter) const override { |
| 2165 | // Variables for capturing values and attributes used while creating ops |
| 2166 | ::mlir::Attribute c1; |
| 2167 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2168 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2169 | |
| 2170 | // Match |
| 2171 | tblgen_ops.push_back(Elt: op0); |
| 2172 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::MulSIExtendedOp>(Val: op0); (void)castedOp0; |
| 2173 | x = castedOp0.getODSOperands(index: 0); |
| 2174 | { |
| 2175 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2176 | if (!(op1)){ |
| 2177 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2178 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 2179 | }); |
| 2180 | } |
| 2181 | ::mlir::Attribute arg1_0; |
| 2182 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op1->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg1_0)))))){ |
| 2183 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2184 | diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure" ; |
| 2185 | }); |
| 2186 | } |
| 2187 | c1 = arg1_0; |
| 2188 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization2(rewriter, op: op1, attr: arg1_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'any attribute'" ))) { |
| 2189 | return ::mlir::failure(); |
| 2190 | } |
| 2191 | tblgen_ops.push_back(Elt: op1); |
| 2192 | } |
| 2193 | if (!(((succeeded(Result: getIntOrSplatIntValue(attr: c1)))) && ((getIntOrSplatIntValue(attr: c1)->isStrictlyPositive())) && ((*getIntOrSplatIntValue(attr: c1) == 1)))){ |
| 2194 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2195 | diag << "entities 'c1' failed to satisfy constraint: ''" ; |
| 2196 | }); |
| 2197 | } |
| 2198 | |
| 2199 | // Rewrite |
| 2200 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc()}); (void)odsLoc; |
| 2201 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2202 | |
| 2203 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ x }) { |
| 2204 | tblgen_repl_values.push_back(Elt: v); |
| 2205 | } |
| 2206 | auto nativeVar_0 = rewriter.getZeroAttr(type: (*x.begin()).getType()); (void)nativeVar_0; |
| 2207 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 2208 | { |
| 2209 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 2210 | /*value=*/value: nativeVar_0 |
| 2211 | ); |
| 2212 | } |
| 2213 | ::mlir::arith::CmpIOp tblgen_CmpIOp_2; |
| 2214 | { |
| 2215 | ::mlir::Value tblgen_value_0 = (*x.begin()); |
| 2216 | ::mlir::Value tblgen_value_1 = (*tblgen_ConstantOp_1.getODSResults(index: 0).begin()); |
| 2217 | tblgen_CmpIOp_2 = ::mlir::arith::CmpIOp::create(builder&: rewriter, location: odsLoc, |
| 2218 | predicate: ::mlir::arith::CmpIPredicateAttr::get(context: rewriter.getContext(), val: ::mlir::arith::CmpIPredicate::slt), |
| 2219 | /*lhs=*/lhs: tblgen_value_0, |
| 2220 | /*rhs=*/rhs: tblgen_value_1 |
| 2221 | ); |
| 2222 | } |
| 2223 | ::mlir::arith::ExtSIOp tblgen_ExtSIOp_3; |
| 2224 | { |
| 2225 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2226 | ::mlir::arith::ExtSIOp::Properties tblgen_props; (void)tblgen_props; |
| 2227 | tblgen_values.push_back(Elt: (*tblgen_CmpIOp_2.getODSResults(index: 0).begin())); |
| 2228 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 2229 | for (auto v: castedOp0.getODSResults(index: 1)) { |
| 2230 | tblgen_types.push_back(Elt: v.getType()); |
| 2231 | } |
| 2232 | tblgen_ExtSIOp_3 = ::mlir::arith::ExtSIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 2233 | } |
| 2234 | |
| 2235 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtSIOp_3.getODSResults(index: 0) }) { |
| 2236 | tblgen_repl_values.push_back(Elt: v); |
| 2237 | } |
| 2238 | |
| 2239 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2240 | return ::mlir::success(); |
| 2241 | } |
| 2242 | }; |
| 2243 | |
| 2244 | /* Generated from: |
| 2245 | ArithCanonicalization.td:234 |
| 2246 | */ |
| 2247 | struct MulSIExtendedToMulI : public ::mlir::RewritePattern { |
| 2248 | MulSIExtendedToMulI(::mlir::MLIRContext *context) |
| 2249 | : ::mlir::RewritePattern("arith.mulsi_extended" , 1, context, {"arith.muli" }) {} |
| 2250 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2251 | ::mlir::PatternRewriter &rewriter) const override { |
| 2252 | // Variables for capturing values and attributes used while creating ops |
| 2253 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2254 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 2255 | ::mlir::arith::MulSIExtendedOp res; |
| 2256 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2257 | |
| 2258 | // Match |
| 2259 | tblgen_ops.push_back(Elt: op0); |
| 2260 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::MulSIExtendedOp>(Val: op0); (void)castedOp0; |
| 2261 | res = castedOp0; |
| 2262 | x = castedOp0.getODSOperands(index: 0); |
| 2263 | y = castedOp0.getODSOperands(index: 1); |
| 2264 | if (!(((*res.getODSResults(index: 1).begin()).getUses().empty()))){ |
| 2265 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2266 | diag << "entities 'res__1' failed to satisfy constraint: ''" ; |
| 2267 | }); |
| 2268 | } |
| 2269 | |
| 2270 | // Rewrite |
| 2271 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc()}); (void)odsLoc; |
| 2272 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2273 | ::mlir::arith::MulIOp tblgen_MulIOp_0; |
| 2274 | { |
| 2275 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2276 | ::mlir::arith::MulIOp::Properties tblgen_props; (void)tblgen_props; |
| 2277 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2278 | tblgen_values.push_back(Elt: (*y.begin())); |
| 2279 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val: ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none)); |
| 2280 | tblgen_MulIOp_0 = ::mlir::arith::MulIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2281 | } |
| 2282 | |
| 2283 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MulIOp_0.getODSResults(index: 0) }) { |
| 2284 | tblgen_repl_values.push_back(Elt: v); |
| 2285 | } |
| 2286 | |
| 2287 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ x }) { |
| 2288 | tblgen_repl_values.push_back(Elt: v); |
| 2289 | } |
| 2290 | |
| 2291 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2292 | return ::mlir::success(); |
| 2293 | } |
| 2294 | }; |
| 2295 | |
| 2296 | /* Generated from: |
| 2297 | ArithCanonicalization.td:262 |
| 2298 | */ |
| 2299 | struct MulUIExtendedToMulI : public ::mlir::RewritePattern { |
| 2300 | MulUIExtendedToMulI(::mlir::MLIRContext *context) |
| 2301 | : ::mlir::RewritePattern("arith.mului_extended" , 1, context, {"arith.muli" }) {} |
| 2302 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2303 | ::mlir::PatternRewriter &rewriter) const override { |
| 2304 | // Variables for capturing values and attributes used while creating ops |
| 2305 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2306 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 2307 | ::mlir::arith::MulUIExtendedOp res; |
| 2308 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2309 | |
| 2310 | // Match |
| 2311 | tblgen_ops.push_back(Elt: op0); |
| 2312 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::MulUIExtendedOp>(Val: op0); (void)castedOp0; |
| 2313 | res = castedOp0; |
| 2314 | x = castedOp0.getODSOperands(index: 0); |
| 2315 | y = castedOp0.getODSOperands(index: 1); |
| 2316 | if (!(((*res.getODSResults(index: 1).begin()).getUses().empty()))){ |
| 2317 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2318 | diag << "entities 'res__1' failed to satisfy constraint: ''" ; |
| 2319 | }); |
| 2320 | } |
| 2321 | |
| 2322 | // Rewrite |
| 2323 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc()}); (void)odsLoc; |
| 2324 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2325 | ::mlir::arith::MulIOp tblgen_MulIOp_0; |
| 2326 | { |
| 2327 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2328 | ::mlir::arith::MulIOp::Properties tblgen_props; (void)tblgen_props; |
| 2329 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2330 | tblgen_values.push_back(Elt: (*y.begin())); |
| 2331 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val: ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none)); |
| 2332 | tblgen_MulIOp_0 = ::mlir::arith::MulIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2333 | } |
| 2334 | |
| 2335 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MulIOp_0.getODSResults(index: 0) }) { |
| 2336 | tblgen_repl_values.push_back(Elt: v); |
| 2337 | } |
| 2338 | |
| 2339 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ x }) { |
| 2340 | tblgen_repl_values.push_back(Elt: v); |
| 2341 | } |
| 2342 | |
| 2343 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2344 | return ::mlir::success(); |
| 2345 | } |
| 2346 | }; |
| 2347 | |
| 2348 | /* Generated from: |
| 2349 | ArithCanonicalization.td:456 |
| 2350 | */ |
| 2351 | struct OrIOrIConstant : public ::mlir::RewritePattern { |
| 2352 | OrIOrIConstant(::mlir::MLIRContext *context) |
| 2353 | : ::mlir::RewritePattern("arith.ori" , 2, context, {"arith.constant" , "arith.ori" }) {} |
| 2354 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2355 | ::mlir::PatternRewriter &rewriter) const override { |
| 2356 | // Variables for capturing values and attributes used while creating ops |
| 2357 | ::mlir::Attribute c1; |
| 2358 | ::mlir::Attribute c0; |
| 2359 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2360 | ::mlir::arith::OrIOp res; |
| 2361 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2362 | |
| 2363 | // Match |
| 2364 | tblgen_ops.push_back(Elt: op0); |
| 2365 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::OrIOp>(Val: op0); (void)castedOp0; |
| 2366 | res = castedOp0; |
| 2367 | { |
| 2368 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2369 | if (!(op1)){ |
| 2370 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2371 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2372 | }); |
| 2373 | } |
| 2374 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::OrIOp>(Val: op1); (void)castedOp1; |
| 2375 | if (!(castedOp1)){ |
| 2376 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2377 | diag << "castedOp1 is not ::mlir::arith::OrIOp type" ; |
| 2378 | }); |
| 2379 | } |
| 2380 | x = castedOp1.getODSOperands(index: 0); |
| 2381 | { |
| 2382 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2383 | if (!(op2)){ |
| 2384 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2385 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 2386 | }); |
| 2387 | } |
| 2388 | if(::mlir::failed(Result: static_dag_matcher_2(rewriter, op0: op2, tblgen_ops, c0))) { |
| 2389 | return ::mlir::failure(); |
| 2390 | } |
| 2391 | tblgen_ops.push_back(Elt: op2); |
| 2392 | } |
| 2393 | tblgen_ops.push_back(Elt: op1); |
| 2394 | } |
| 2395 | { |
| 2396 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2397 | if (!(op1)){ |
| 2398 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2399 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 2400 | }); |
| 2401 | } |
| 2402 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 2403 | return ::mlir::failure(); |
| 2404 | } |
| 2405 | tblgen_ops.push_back(Elt: op1); |
| 2406 | } |
| 2407 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c0).getType()))){ |
| 2408 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2409 | diag << "entities 'res, c0' failed to satisfy constraint: ''" ; |
| 2410 | }); |
| 2411 | } |
| 2412 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c1).getType()))){ |
| 2413 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2414 | diag << "entities 'res, c1' failed to satisfy constraint: ''" ; |
| 2415 | }); |
| 2416 | } |
| 2417 | |
| 2418 | // Rewrite |
| 2419 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2420 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2421 | auto nativeVar_0 = orIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 2422 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 2423 | { |
| 2424 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 2425 | /*value=*/value: nativeVar_0 |
| 2426 | ); |
| 2427 | } |
| 2428 | ::mlir::arith::OrIOp tblgen_OrIOp_2; |
| 2429 | { |
| 2430 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2431 | ::mlir::arith::OrIOp::Properties tblgen_props; (void)tblgen_props; |
| 2432 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2433 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 2434 | tblgen_OrIOp_2 = ::mlir::arith::OrIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2435 | } |
| 2436 | |
| 2437 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_OrIOp_2.getODSResults(index: 0) }) { |
| 2438 | tblgen_repl_values.push_back(Elt: v); |
| 2439 | } |
| 2440 | |
| 2441 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2442 | return ::mlir::success(); |
| 2443 | } |
| 2444 | }; |
| 2445 | |
| 2446 | /* Generated from: |
| 2447 | ArithCanonicalization.td:474 |
| 2448 | */ |
| 2449 | struct OrOfExtSI : public ::mlir::RewritePattern { |
| 2450 | OrOfExtSI(::mlir::MLIRContext *context) |
| 2451 | : ::mlir::RewritePattern("arith.ori" , 3, context, {"arith.extsi" , "arith.ori" }) {} |
| 2452 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2453 | ::mlir::PatternRewriter &rewriter) const override { |
| 2454 | // Variables for capturing values and attributes used while creating ops |
| 2455 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 2456 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2457 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2458 | |
| 2459 | // Match |
| 2460 | tblgen_ops.push_back(Elt: op0); |
| 2461 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::OrIOp>(Val: op0); (void)castedOp0; |
| 2462 | { |
| 2463 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2464 | if (!(op1)){ |
| 2465 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2466 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2467 | }); |
| 2468 | } |
| 2469 | if(::mlir::failed(Result: static_dag_matcher_8(rewriter, op0: op1, tblgen_ops, x))) { |
| 2470 | return ::mlir::failure(); |
| 2471 | } |
| 2472 | tblgen_ops.push_back(Elt: op1); |
| 2473 | } |
| 2474 | { |
| 2475 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2476 | if (!(op1)){ |
| 2477 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2478 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 2479 | }); |
| 2480 | } |
| 2481 | if(::mlir::failed(Result: static_dag_matcher_9(rewriter, op0: op1, tblgen_ops, y))) { |
| 2482 | return ::mlir::failure(); |
| 2483 | } |
| 2484 | tblgen_ops.push_back(Elt: op1); |
| 2485 | } |
| 2486 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 2487 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2488 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 2489 | }); |
| 2490 | } |
| 2491 | |
| 2492 | // Rewrite |
| 2493 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 2494 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2495 | ::mlir::arith::OrIOp tblgen_OrIOp_0; |
| 2496 | { |
| 2497 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2498 | ::mlir::arith::OrIOp::Properties tblgen_props; (void)tblgen_props; |
| 2499 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2500 | tblgen_values.push_back(Elt: (*y.begin())); |
| 2501 | tblgen_OrIOp_0 = ::mlir::arith::OrIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2502 | } |
| 2503 | ::mlir::arith::ExtSIOp tblgen_ExtSIOp_1; |
| 2504 | { |
| 2505 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2506 | ::mlir::arith::ExtSIOp::Properties tblgen_props; (void)tblgen_props; |
| 2507 | tblgen_values.push_back(Elt: (*tblgen_OrIOp_0.getODSResults(index: 0).begin())); |
| 2508 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 2509 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 2510 | tblgen_types.push_back(Elt: v.getType()); |
| 2511 | } |
| 2512 | tblgen_ExtSIOp_1 = ::mlir::arith::ExtSIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 2513 | } |
| 2514 | |
| 2515 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtSIOp_1.getODSResults(index: 0) }) { |
| 2516 | tblgen_repl_values.push_back(Elt: v); |
| 2517 | } |
| 2518 | |
| 2519 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2520 | return ::mlir::success(); |
| 2521 | } |
| 2522 | }; |
| 2523 | |
| 2524 | /* Generated from: |
| 2525 | ArithCanonicalization.td:467 |
| 2526 | */ |
| 2527 | struct OrOfExtUI : public ::mlir::RewritePattern { |
| 2528 | OrOfExtUI(::mlir::MLIRContext *context) |
| 2529 | : ::mlir::RewritePattern("arith.ori" , 3, context, {"arith.extui" , "arith.ori" }) {} |
| 2530 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2531 | ::mlir::PatternRewriter &rewriter) const override { |
| 2532 | // Variables for capturing values and attributes used while creating ops |
| 2533 | ::mlir::UnitAttr nneg2; |
| 2534 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 2535 | ::mlir::UnitAttr nneg1; |
| 2536 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2537 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2538 | |
| 2539 | // Match |
| 2540 | tblgen_ops.push_back(Elt: op0); |
| 2541 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::OrIOp>(Val: op0); (void)castedOp0; |
| 2542 | { |
| 2543 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2544 | if (!(op1)){ |
| 2545 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2546 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2547 | }); |
| 2548 | } |
| 2549 | if(::mlir::failed(Result: static_dag_matcher_10(rewriter, op0: op1, tblgen_ops, nneg1, x))) { |
| 2550 | return ::mlir::failure(); |
| 2551 | } |
| 2552 | tblgen_ops.push_back(Elt: op1); |
| 2553 | } |
| 2554 | { |
| 2555 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2556 | if (!(op1)){ |
| 2557 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2558 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 2559 | }); |
| 2560 | } |
| 2561 | if(::mlir::failed(Result: static_dag_matcher_11(rewriter, op0: op1, tblgen_ops, nneg2, y))) { |
| 2562 | return ::mlir::failure(); |
| 2563 | } |
| 2564 | tblgen_ops.push_back(Elt: op1); |
| 2565 | } |
| 2566 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 2567 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2568 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 2569 | }); |
| 2570 | } |
| 2571 | |
| 2572 | // Rewrite |
| 2573 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 2574 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2575 | ::mlir::arith::OrIOp tblgen_OrIOp_0; |
| 2576 | { |
| 2577 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2578 | ::mlir::arith::OrIOp::Properties tblgen_props; (void)tblgen_props; |
| 2579 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2580 | tblgen_values.push_back(Elt: (*y.begin())); |
| 2581 | tblgen_OrIOp_0 = ::mlir::arith::OrIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2582 | } |
| 2583 | auto nativeVar_1 = (nneg1 && nneg2) ? nneg1 : UnitAttr(); (void)nativeVar_1; |
| 2584 | ::mlir::arith::ExtUIOp tblgen_ExtUIOp_2; |
| 2585 | { |
| 2586 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2587 | ::mlir::arith::ExtUIOp::Properties tblgen_props; (void)tblgen_props; |
| 2588 | tblgen_values.push_back(Elt: (*tblgen_OrIOp_0.getODSResults(index: 0).begin())); |
| 2589 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nativeVar_1); |
| 2590 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 2591 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 2592 | tblgen_types.push_back(Elt: v.getType()); |
| 2593 | } |
| 2594 | tblgen_ExtUIOp_2 = ::mlir::arith::ExtUIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 2595 | } |
| 2596 | |
| 2597 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtUIOp_2.getODSResults(index: 0) }) { |
| 2598 | tblgen_repl_values.push_back(Elt: v); |
| 2599 | } |
| 2600 | |
| 2601 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2602 | return ::mlir::success(); |
| 2603 | } |
| 2604 | }; |
| 2605 | |
| 2606 | /* Generated from: |
| 2607 | ArithCanonicalization.td:341 |
| 2608 | */ |
| 2609 | struct RedundantSelectFalse : public ::mlir::RewritePattern { |
| 2610 | RedundantSelectFalse(::mlir::MLIRContext *context) |
| 2611 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.select" }) {} |
| 2612 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2613 | ::mlir::PatternRewriter &rewriter) const override { |
| 2614 | // Variables for capturing values and attributes used while creating ops |
| 2615 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 2616 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 2617 | ::mlir::Operation::operand_range c(op0->getOperands()); |
| 2618 | ::mlir::Operation::operand_range pred(op0->getOperands()); |
| 2619 | ::mlir::Operation::operand_range pred0(op0->getOperands()); |
| 2620 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2621 | |
| 2622 | // Match |
| 2623 | tblgen_ops.push_back(Elt: op0); |
| 2624 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 2625 | pred = castedOp0.getODSOperands(index: 0); |
| 2626 | a = castedOp0.getODSOperands(index: 1); |
| 2627 | { |
| 2628 | auto *op1 = (*castedOp0.getODSOperands(index: 2).begin()).getDefiningOp(); |
| 2629 | if (!(op1)){ |
| 2630 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2631 | diag << "There's no operation that defines operand 2 of castedOp0" ; |
| 2632 | }); |
| 2633 | } |
| 2634 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op1); (void)castedOp1; |
| 2635 | if (!(castedOp1)){ |
| 2636 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2637 | diag << "castedOp1 is not ::mlir::arith::SelectOp type" ; |
| 2638 | }); |
| 2639 | } |
| 2640 | pred0 = castedOp1.getODSOperands(index: 0); |
| 2641 | b = castedOp1.getODSOperands(index: 1); |
| 2642 | c = castedOp1.getODSOperands(index: 2); |
| 2643 | tblgen_ops.push_back(Elt: op1); |
| 2644 | } |
| 2645 | if (!(*pred.begin() == *pred0.begin())){ |
| 2646 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2647 | diag << "Operands 'pred' and 'pred0' must be equal" ; |
| 2648 | }); |
| 2649 | } |
| 2650 | |
| 2651 | // Rewrite |
| 2652 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2653 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2654 | ::mlir::arith::SelectOp tblgen_SelectOp_0; |
| 2655 | { |
| 2656 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2657 | ::mlir::arith::SelectOp::Properties tblgen_props; (void)tblgen_props; |
| 2658 | tblgen_values.push_back(Elt: (*pred.begin())); |
| 2659 | tblgen_values.push_back(Elt: (*a.begin())); |
| 2660 | tblgen_values.push_back(Elt: (*c.begin())); |
| 2661 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 2662 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 2663 | tblgen_types.push_back(Elt: v.getType()); |
| 2664 | } |
| 2665 | tblgen_SelectOp_0 = ::mlir::arith::SelectOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 2666 | } |
| 2667 | |
| 2668 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SelectOp_0.getODSResults(index: 0) }) { |
| 2669 | tblgen_repl_values.push_back(Elt: v); |
| 2670 | } |
| 2671 | |
| 2672 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2673 | return ::mlir::success(); |
| 2674 | } |
| 2675 | }; |
| 2676 | |
| 2677 | /* Generated from: |
| 2678 | ArithCanonicalization.td:336 |
| 2679 | */ |
| 2680 | struct RedundantSelectTrue : public ::mlir::RewritePattern { |
| 2681 | RedundantSelectTrue(::mlir::MLIRContext *context) |
| 2682 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.select" }) {} |
| 2683 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2684 | ::mlir::PatternRewriter &rewriter) const override { |
| 2685 | // Variables for capturing values and attributes used while creating ops |
| 2686 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 2687 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 2688 | ::mlir::Operation::operand_range c(op0->getOperands()); |
| 2689 | ::mlir::Operation::operand_range pred(op0->getOperands()); |
| 2690 | ::mlir::Operation::operand_range pred0(op0->getOperands()); |
| 2691 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2692 | |
| 2693 | // Match |
| 2694 | tblgen_ops.push_back(Elt: op0); |
| 2695 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 2696 | pred = castedOp0.getODSOperands(index: 0); |
| 2697 | { |
| 2698 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 2699 | if (!(op1)){ |
| 2700 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2701 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 2702 | }); |
| 2703 | } |
| 2704 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op1); (void)castedOp1; |
| 2705 | if (!(castedOp1)){ |
| 2706 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2707 | diag << "castedOp1 is not ::mlir::arith::SelectOp type" ; |
| 2708 | }); |
| 2709 | } |
| 2710 | pred0 = castedOp1.getODSOperands(index: 0); |
| 2711 | a = castedOp1.getODSOperands(index: 1); |
| 2712 | b = castedOp1.getODSOperands(index: 2); |
| 2713 | tblgen_ops.push_back(Elt: op1); |
| 2714 | } |
| 2715 | c = castedOp0.getODSOperands(index: 2); |
| 2716 | if (!(*pred.begin() == *pred0.begin())){ |
| 2717 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2718 | diag << "Operands 'pred' and 'pred0' must be equal" ; |
| 2719 | }); |
| 2720 | } |
| 2721 | |
| 2722 | // Rewrite |
| 2723 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2724 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2725 | ::mlir::arith::SelectOp tblgen_SelectOp_0; |
| 2726 | { |
| 2727 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2728 | ::mlir::arith::SelectOp::Properties tblgen_props; (void)tblgen_props; |
| 2729 | tblgen_values.push_back(Elt: (*pred.begin())); |
| 2730 | tblgen_values.push_back(Elt: (*a.begin())); |
| 2731 | tblgen_values.push_back(Elt: (*c.begin())); |
| 2732 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 2733 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 2734 | tblgen_types.push_back(Elt: v.getType()); |
| 2735 | } |
| 2736 | tblgen_SelectOp_0 = ::mlir::arith::SelectOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 2737 | } |
| 2738 | |
| 2739 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SelectOp_0.getODSResults(index: 0) }) { |
| 2740 | tblgen_repl_values.push_back(Elt: v); |
| 2741 | } |
| 2742 | |
| 2743 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2744 | return ::mlir::success(); |
| 2745 | } |
| 2746 | }; |
| 2747 | |
| 2748 | /* Generated from: |
| 2749 | ArithCanonicalization.td:541 |
| 2750 | */ |
| 2751 | struct SIToFPOfExtSI : public ::mlir::RewritePattern { |
| 2752 | SIToFPOfExtSI(::mlir::MLIRContext *context) |
| 2753 | : ::mlir::RewritePattern("arith.sitofp" , 2, context, {"arith.sitofp" }) {} |
| 2754 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2755 | ::mlir::PatternRewriter &rewriter) const override { |
| 2756 | // Variables for capturing values and attributes used while creating ops |
| 2757 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2758 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2759 | |
| 2760 | // Match |
| 2761 | tblgen_ops.push_back(Elt: op0); |
| 2762 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SIToFPOp>(Val: op0); (void)castedOp0; |
| 2763 | { |
| 2764 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2765 | if (!(op1)){ |
| 2766 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2767 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2768 | }); |
| 2769 | } |
| 2770 | if(::mlir::failed(Result: static_dag_matcher_8(rewriter, op0: op1, tblgen_ops, x))) { |
| 2771 | return ::mlir::failure(); |
| 2772 | } |
| 2773 | tblgen_ops.push_back(Elt: op1); |
| 2774 | } |
| 2775 | |
| 2776 | // Rewrite |
| 2777 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2778 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2779 | ::mlir::arith::SIToFPOp tblgen_SIToFPOp_0; |
| 2780 | { |
| 2781 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2782 | ::mlir::arith::SIToFPOp::Properties tblgen_props; (void)tblgen_props; |
| 2783 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2784 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 2785 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 2786 | tblgen_types.push_back(Elt: v.getType()); |
| 2787 | } |
| 2788 | tblgen_SIToFPOp_0 = ::mlir::arith::SIToFPOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 2789 | } |
| 2790 | |
| 2791 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SIToFPOp_0.getODSResults(index: 0) }) { |
| 2792 | tblgen_repl_values.push_back(Elt: v); |
| 2793 | } |
| 2794 | |
| 2795 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2796 | return ::mlir::success(); |
| 2797 | } |
| 2798 | }; |
| 2799 | |
| 2800 | /* Generated from: |
| 2801 | ArithCanonicalization.td:546 |
| 2802 | */ |
| 2803 | struct SIToFPOfExtUI : public ::mlir::RewritePattern { |
| 2804 | SIToFPOfExtUI(::mlir::MLIRContext *context) |
| 2805 | : ::mlir::RewritePattern("arith.sitofp" , 2, context, {"arith.uitofp" }) {} |
| 2806 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2807 | ::mlir::PatternRewriter &rewriter) const override { |
| 2808 | // Variables for capturing values and attributes used while creating ops |
| 2809 | ::mlir::UnitAttr nneg; |
| 2810 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 2811 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2812 | |
| 2813 | // Match |
| 2814 | tblgen_ops.push_back(Elt: op0); |
| 2815 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SIToFPOp>(Val: op0); (void)castedOp0; |
| 2816 | { |
| 2817 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2818 | if (!(op1)){ |
| 2819 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2820 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2821 | }); |
| 2822 | } |
| 2823 | if(::mlir::failed(Result: static_dag_matcher_12(rewriter, op0: op1, tblgen_ops, nneg, x))) { |
| 2824 | return ::mlir::failure(); |
| 2825 | } |
| 2826 | tblgen_ops.push_back(Elt: op1); |
| 2827 | } |
| 2828 | |
| 2829 | // Rewrite |
| 2830 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2831 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2832 | ::mlir::arith::UIToFPOp tblgen_UIToFPOp_0; |
| 2833 | { |
| 2834 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2835 | ::mlir::arith::UIToFPOp::Properties tblgen_props; (void)tblgen_props; |
| 2836 | tblgen_values.push_back(Elt: (*x.begin())); |
| 2837 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nneg); |
| 2838 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 2839 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 2840 | tblgen_types.push_back(Elt: v.getType()); |
| 2841 | } |
| 2842 | tblgen_UIToFPOp_0 = ::mlir::arith::UIToFPOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 2843 | } |
| 2844 | |
| 2845 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_UIToFPOp_0.getODSResults(index: 0) }) { |
| 2846 | tblgen_repl_values.push_back(Elt: v); |
| 2847 | } |
| 2848 | |
| 2849 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2850 | return ::mlir::success(); |
| 2851 | } |
| 2852 | }; |
| 2853 | |
| 2854 | /* Generated from: |
| 2855 | ArithCanonicalization.td:372 |
| 2856 | */ |
| 2857 | struct SelectCmpISgeToMaxSI : public ::mlir::RewritePattern { |
| 2858 | SelectCmpISgeToMaxSI(::mlir::MLIRContext *context) |
| 2859 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxsi" }) {} |
| 2860 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2861 | ::mlir::PatternRewriter &rewriter) const override { |
| 2862 | // Variables for capturing values and attributes used while creating ops |
| 2863 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 2864 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 2865 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 2866 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 2867 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2868 | |
| 2869 | // Match |
| 2870 | tblgen_ops.push_back(Elt: op0); |
| 2871 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 2872 | { |
| 2873 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2874 | if (!(op1)){ |
| 2875 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2876 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2877 | }); |
| 2878 | } |
| 2879 | if(::mlir::failed(Result: static_dag_matcher_13(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 2880 | return ::mlir::failure(); |
| 2881 | } |
| 2882 | tblgen_ops.push_back(Elt: op1); |
| 2883 | } |
| 2884 | a0 = castedOp0.getODSOperands(index: 1); |
| 2885 | b0 = castedOp0.getODSOperands(index: 2); |
| 2886 | if (!(*b.begin() == *b0.begin())){ |
| 2887 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2888 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 2889 | }); |
| 2890 | } |
| 2891 | if (!(*a.begin() == *a0.begin())){ |
| 2892 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2893 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 2894 | }); |
| 2895 | } |
| 2896 | |
| 2897 | // Rewrite |
| 2898 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2899 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2900 | ::mlir::arith::MaxSIOp tblgen_MaxSIOp_0; |
| 2901 | { |
| 2902 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2903 | ::mlir::arith::MaxSIOp::Properties tblgen_props; (void)tblgen_props; |
| 2904 | tblgen_values.push_back(Elt: (*a.begin())); |
| 2905 | tblgen_values.push_back(Elt: (*b.begin())); |
| 2906 | tblgen_MaxSIOp_0 = ::mlir::arith::MaxSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2907 | } |
| 2908 | |
| 2909 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxSIOp_0.getODSResults(index: 0) }) { |
| 2910 | tblgen_repl_values.push_back(Elt: v); |
| 2911 | } |
| 2912 | |
| 2913 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2914 | return ::mlir::success(); |
| 2915 | } |
| 2916 | }; |
| 2917 | |
| 2918 | /* Generated from: |
| 2919 | ArithCanonicalization.td:382 |
| 2920 | */ |
| 2921 | struct SelectCmpISgeToMinSI : public ::mlir::RewritePattern { |
| 2922 | SelectCmpISgeToMinSI(::mlir::MLIRContext *context) |
| 2923 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minsi" }) {} |
| 2924 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2925 | ::mlir::PatternRewriter &rewriter) const override { |
| 2926 | // Variables for capturing values and attributes used while creating ops |
| 2927 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 2928 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 2929 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 2930 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 2931 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2932 | |
| 2933 | // Match |
| 2934 | tblgen_ops.push_back(Elt: op0); |
| 2935 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 2936 | { |
| 2937 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 2938 | if (!(op1)){ |
| 2939 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2940 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 2941 | }); |
| 2942 | } |
| 2943 | if(::mlir::failed(Result: static_dag_matcher_13(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 2944 | return ::mlir::failure(); |
| 2945 | } |
| 2946 | tblgen_ops.push_back(Elt: op1); |
| 2947 | } |
| 2948 | b0 = castedOp0.getODSOperands(index: 1); |
| 2949 | a0 = castedOp0.getODSOperands(index: 2); |
| 2950 | if (!(*b.begin() == *b0.begin())){ |
| 2951 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2952 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 2953 | }); |
| 2954 | } |
| 2955 | if (!(*a.begin() == *a0.begin())){ |
| 2956 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 2957 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 2958 | }); |
| 2959 | } |
| 2960 | |
| 2961 | // Rewrite |
| 2962 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 2963 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 2964 | ::mlir::arith::MinSIOp tblgen_MinSIOp_0; |
| 2965 | { |
| 2966 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 2967 | ::mlir::arith::MinSIOp::Properties tblgen_props; (void)tblgen_props; |
| 2968 | tblgen_values.push_back(Elt: (*a.begin())); |
| 2969 | tblgen_values.push_back(Elt: (*b.begin())); |
| 2970 | tblgen_MinSIOp_0 = ::mlir::arith::MinSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 2971 | } |
| 2972 | |
| 2973 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinSIOp_0.getODSResults(index: 0) }) { |
| 2974 | tblgen_repl_values.push_back(Elt: v); |
| 2975 | } |
| 2976 | |
| 2977 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 2978 | return ::mlir::success(); |
| 2979 | } |
| 2980 | }; |
| 2981 | |
| 2982 | /* Generated from: |
| 2983 | ArithCanonicalization.td:371 |
| 2984 | */ |
| 2985 | struct SelectCmpISgtToMaxSI : public ::mlir::RewritePattern { |
| 2986 | SelectCmpISgtToMaxSI(::mlir::MLIRContext *context) |
| 2987 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxsi" }) {} |
| 2988 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 2989 | ::mlir::PatternRewriter &rewriter) const override { |
| 2990 | // Variables for capturing values and attributes used while creating ops |
| 2991 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 2992 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 2993 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 2994 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 2995 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 2996 | |
| 2997 | // Match |
| 2998 | tblgen_ops.push_back(Elt: op0); |
| 2999 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3000 | { |
| 3001 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3002 | if (!(op1)){ |
| 3003 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3004 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3005 | }); |
| 3006 | } |
| 3007 | if(::mlir::failed(Result: static_dag_matcher_14(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3008 | return ::mlir::failure(); |
| 3009 | } |
| 3010 | tblgen_ops.push_back(Elt: op1); |
| 3011 | } |
| 3012 | a0 = castedOp0.getODSOperands(index: 1); |
| 3013 | b0 = castedOp0.getODSOperands(index: 2); |
| 3014 | if (!(*b.begin() == *b0.begin())){ |
| 3015 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3016 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3017 | }); |
| 3018 | } |
| 3019 | if (!(*a.begin() == *a0.begin())){ |
| 3020 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3021 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3022 | }); |
| 3023 | } |
| 3024 | |
| 3025 | // Rewrite |
| 3026 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3027 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3028 | ::mlir::arith::MaxSIOp tblgen_MaxSIOp_0; |
| 3029 | { |
| 3030 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3031 | ::mlir::arith::MaxSIOp::Properties tblgen_props; (void)tblgen_props; |
| 3032 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3033 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3034 | tblgen_MaxSIOp_0 = ::mlir::arith::MaxSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3035 | } |
| 3036 | |
| 3037 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxSIOp_0.getODSResults(index: 0) }) { |
| 3038 | tblgen_repl_values.push_back(Elt: v); |
| 3039 | } |
| 3040 | |
| 3041 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3042 | return ::mlir::success(); |
| 3043 | } |
| 3044 | }; |
| 3045 | |
| 3046 | /* Generated from: |
| 3047 | ArithCanonicalization.td:381 |
| 3048 | */ |
| 3049 | struct SelectCmpISgtToMinSI : public ::mlir::RewritePattern { |
| 3050 | SelectCmpISgtToMinSI(::mlir::MLIRContext *context) |
| 3051 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minsi" }) {} |
| 3052 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3053 | ::mlir::PatternRewriter &rewriter) const override { |
| 3054 | // Variables for capturing values and attributes used while creating ops |
| 3055 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3056 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3057 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3058 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3059 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3060 | |
| 3061 | // Match |
| 3062 | tblgen_ops.push_back(Elt: op0); |
| 3063 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3064 | { |
| 3065 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3066 | if (!(op1)){ |
| 3067 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3068 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3069 | }); |
| 3070 | } |
| 3071 | if(::mlir::failed(Result: static_dag_matcher_14(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3072 | return ::mlir::failure(); |
| 3073 | } |
| 3074 | tblgen_ops.push_back(Elt: op1); |
| 3075 | } |
| 3076 | b0 = castedOp0.getODSOperands(index: 1); |
| 3077 | a0 = castedOp0.getODSOperands(index: 2); |
| 3078 | if (!(*b.begin() == *b0.begin())){ |
| 3079 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3080 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3081 | }); |
| 3082 | } |
| 3083 | if (!(*a.begin() == *a0.begin())){ |
| 3084 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3085 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3086 | }); |
| 3087 | } |
| 3088 | |
| 3089 | // Rewrite |
| 3090 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3091 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3092 | ::mlir::arith::MinSIOp tblgen_MinSIOp_0; |
| 3093 | { |
| 3094 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3095 | ::mlir::arith::MinSIOp::Properties tblgen_props; (void)tblgen_props; |
| 3096 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3097 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3098 | tblgen_MinSIOp_0 = ::mlir::arith::MinSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3099 | } |
| 3100 | |
| 3101 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinSIOp_0.getODSResults(index: 0) }) { |
| 3102 | tblgen_repl_values.push_back(Elt: v); |
| 3103 | } |
| 3104 | |
| 3105 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3106 | return ::mlir::success(); |
| 3107 | } |
| 3108 | }; |
| 3109 | |
| 3110 | /* Generated from: |
| 3111 | ArithCanonicalization.td:380 |
| 3112 | */ |
| 3113 | struct SelectCmpISleToMaxSI : public ::mlir::RewritePattern { |
| 3114 | SelectCmpISleToMaxSI(::mlir::MLIRContext *context) |
| 3115 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxsi" }) {} |
| 3116 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3117 | ::mlir::PatternRewriter &rewriter) const override { |
| 3118 | // Variables for capturing values and attributes used while creating ops |
| 3119 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3120 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3121 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3122 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3123 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3124 | |
| 3125 | // Match |
| 3126 | tblgen_ops.push_back(Elt: op0); |
| 3127 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3128 | { |
| 3129 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3130 | if (!(op1)){ |
| 3131 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3132 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3133 | }); |
| 3134 | } |
| 3135 | if(::mlir::failed(Result: static_dag_matcher_15(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3136 | return ::mlir::failure(); |
| 3137 | } |
| 3138 | tblgen_ops.push_back(Elt: op1); |
| 3139 | } |
| 3140 | b0 = castedOp0.getODSOperands(index: 1); |
| 3141 | a0 = castedOp0.getODSOperands(index: 2); |
| 3142 | if (!(*b.begin() == *b0.begin())){ |
| 3143 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3144 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3145 | }); |
| 3146 | } |
| 3147 | if (!(*a.begin() == *a0.begin())){ |
| 3148 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3149 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3150 | }); |
| 3151 | } |
| 3152 | |
| 3153 | // Rewrite |
| 3154 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3155 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3156 | ::mlir::arith::MaxSIOp tblgen_MaxSIOp_0; |
| 3157 | { |
| 3158 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3159 | ::mlir::arith::MaxSIOp::Properties tblgen_props; (void)tblgen_props; |
| 3160 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3161 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3162 | tblgen_MaxSIOp_0 = ::mlir::arith::MaxSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3163 | } |
| 3164 | |
| 3165 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxSIOp_0.getODSResults(index: 0) }) { |
| 3166 | tblgen_repl_values.push_back(Elt: v); |
| 3167 | } |
| 3168 | |
| 3169 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3170 | return ::mlir::success(); |
| 3171 | } |
| 3172 | }; |
| 3173 | |
| 3174 | /* Generated from: |
| 3175 | ArithCanonicalization.td:370 |
| 3176 | */ |
| 3177 | struct SelectCmpISleToMinSI : public ::mlir::RewritePattern { |
| 3178 | SelectCmpISleToMinSI(::mlir::MLIRContext *context) |
| 3179 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minsi" }) {} |
| 3180 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3181 | ::mlir::PatternRewriter &rewriter) const override { |
| 3182 | // Variables for capturing values and attributes used while creating ops |
| 3183 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3184 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3185 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3186 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3187 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3188 | |
| 3189 | // Match |
| 3190 | tblgen_ops.push_back(Elt: op0); |
| 3191 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3192 | { |
| 3193 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3194 | if (!(op1)){ |
| 3195 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3196 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3197 | }); |
| 3198 | } |
| 3199 | if(::mlir::failed(Result: static_dag_matcher_15(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3200 | return ::mlir::failure(); |
| 3201 | } |
| 3202 | tblgen_ops.push_back(Elt: op1); |
| 3203 | } |
| 3204 | a0 = castedOp0.getODSOperands(index: 1); |
| 3205 | b0 = castedOp0.getODSOperands(index: 2); |
| 3206 | if (!(*b.begin() == *b0.begin())){ |
| 3207 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3208 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3209 | }); |
| 3210 | } |
| 3211 | if (!(*a.begin() == *a0.begin())){ |
| 3212 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3213 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3214 | }); |
| 3215 | } |
| 3216 | |
| 3217 | // Rewrite |
| 3218 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3219 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3220 | ::mlir::arith::MinSIOp tblgen_MinSIOp_0; |
| 3221 | { |
| 3222 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3223 | ::mlir::arith::MinSIOp::Properties tblgen_props; (void)tblgen_props; |
| 3224 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3225 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3226 | tblgen_MinSIOp_0 = ::mlir::arith::MinSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3227 | } |
| 3228 | |
| 3229 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinSIOp_0.getODSResults(index: 0) }) { |
| 3230 | tblgen_repl_values.push_back(Elt: v); |
| 3231 | } |
| 3232 | |
| 3233 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3234 | return ::mlir::success(); |
| 3235 | } |
| 3236 | }; |
| 3237 | |
| 3238 | /* Generated from: |
| 3239 | ArithCanonicalization.td:379 |
| 3240 | */ |
| 3241 | struct SelectCmpISltToMaxSI : public ::mlir::RewritePattern { |
| 3242 | SelectCmpISltToMaxSI(::mlir::MLIRContext *context) |
| 3243 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxsi" }) {} |
| 3244 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3245 | ::mlir::PatternRewriter &rewriter) const override { |
| 3246 | // Variables for capturing values and attributes used while creating ops |
| 3247 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3248 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3249 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3250 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3251 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3252 | |
| 3253 | // Match |
| 3254 | tblgen_ops.push_back(Elt: op0); |
| 3255 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3256 | { |
| 3257 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3258 | if (!(op1)){ |
| 3259 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3260 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3261 | }); |
| 3262 | } |
| 3263 | if(::mlir::failed(Result: static_dag_matcher_16(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3264 | return ::mlir::failure(); |
| 3265 | } |
| 3266 | tblgen_ops.push_back(Elt: op1); |
| 3267 | } |
| 3268 | b0 = castedOp0.getODSOperands(index: 1); |
| 3269 | a0 = castedOp0.getODSOperands(index: 2); |
| 3270 | if (!(*b.begin() == *b0.begin())){ |
| 3271 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3272 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3273 | }); |
| 3274 | } |
| 3275 | if (!(*a.begin() == *a0.begin())){ |
| 3276 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3277 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3278 | }); |
| 3279 | } |
| 3280 | |
| 3281 | // Rewrite |
| 3282 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3283 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3284 | ::mlir::arith::MaxSIOp tblgen_MaxSIOp_0; |
| 3285 | { |
| 3286 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3287 | ::mlir::arith::MaxSIOp::Properties tblgen_props; (void)tblgen_props; |
| 3288 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3289 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3290 | tblgen_MaxSIOp_0 = ::mlir::arith::MaxSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3291 | } |
| 3292 | |
| 3293 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxSIOp_0.getODSResults(index: 0) }) { |
| 3294 | tblgen_repl_values.push_back(Elt: v); |
| 3295 | } |
| 3296 | |
| 3297 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3298 | return ::mlir::success(); |
| 3299 | } |
| 3300 | }; |
| 3301 | |
| 3302 | /* Generated from: |
| 3303 | ArithCanonicalization.td:369 |
| 3304 | */ |
| 3305 | struct SelectCmpISltToMinSI : public ::mlir::RewritePattern { |
| 3306 | SelectCmpISltToMinSI(::mlir::MLIRContext *context) |
| 3307 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minsi" }) {} |
| 3308 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3309 | ::mlir::PatternRewriter &rewriter) const override { |
| 3310 | // Variables for capturing values and attributes used while creating ops |
| 3311 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3312 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3313 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3314 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3315 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3316 | |
| 3317 | // Match |
| 3318 | tblgen_ops.push_back(Elt: op0); |
| 3319 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3320 | { |
| 3321 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3322 | if (!(op1)){ |
| 3323 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3324 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3325 | }); |
| 3326 | } |
| 3327 | if(::mlir::failed(Result: static_dag_matcher_16(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3328 | return ::mlir::failure(); |
| 3329 | } |
| 3330 | tblgen_ops.push_back(Elt: op1); |
| 3331 | } |
| 3332 | a0 = castedOp0.getODSOperands(index: 1); |
| 3333 | b0 = castedOp0.getODSOperands(index: 2); |
| 3334 | if (!(*b.begin() == *b0.begin())){ |
| 3335 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3336 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3337 | }); |
| 3338 | } |
| 3339 | if (!(*a.begin() == *a0.begin())){ |
| 3340 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3341 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3342 | }); |
| 3343 | } |
| 3344 | |
| 3345 | // Rewrite |
| 3346 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3347 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3348 | ::mlir::arith::MinSIOp tblgen_MinSIOp_0; |
| 3349 | { |
| 3350 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3351 | ::mlir::arith::MinSIOp::Properties tblgen_props; (void)tblgen_props; |
| 3352 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3353 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3354 | tblgen_MinSIOp_0 = ::mlir::arith::MinSIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3355 | } |
| 3356 | |
| 3357 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinSIOp_0.getODSResults(index: 0) }) { |
| 3358 | tblgen_repl_values.push_back(Elt: v); |
| 3359 | } |
| 3360 | |
| 3361 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3362 | return ::mlir::success(); |
| 3363 | } |
| 3364 | }; |
| 3365 | |
| 3366 | /* Generated from: |
| 3367 | ArithCanonicalization.td:376 |
| 3368 | */ |
| 3369 | struct SelectCmpIUgeToMaxUI : public ::mlir::RewritePattern { |
| 3370 | SelectCmpIUgeToMaxUI(::mlir::MLIRContext *context) |
| 3371 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxui" }) {} |
| 3372 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3373 | ::mlir::PatternRewriter &rewriter) const override { |
| 3374 | // Variables for capturing values and attributes used while creating ops |
| 3375 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3376 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3377 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3378 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3379 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3380 | |
| 3381 | // Match |
| 3382 | tblgen_ops.push_back(Elt: op0); |
| 3383 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3384 | { |
| 3385 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3386 | if (!(op1)){ |
| 3387 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3388 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3389 | }); |
| 3390 | } |
| 3391 | if(::mlir::failed(Result: static_dag_matcher_17(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3392 | return ::mlir::failure(); |
| 3393 | } |
| 3394 | tblgen_ops.push_back(Elt: op1); |
| 3395 | } |
| 3396 | a0 = castedOp0.getODSOperands(index: 1); |
| 3397 | b0 = castedOp0.getODSOperands(index: 2); |
| 3398 | if (!(*b.begin() == *b0.begin())){ |
| 3399 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3400 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3401 | }); |
| 3402 | } |
| 3403 | if (!(*a.begin() == *a0.begin())){ |
| 3404 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3405 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3406 | }); |
| 3407 | } |
| 3408 | |
| 3409 | // Rewrite |
| 3410 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3411 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3412 | ::mlir::arith::MaxUIOp tblgen_MaxUIOp_0; |
| 3413 | { |
| 3414 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3415 | ::mlir::arith::MaxUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3416 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3417 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3418 | tblgen_MaxUIOp_0 = ::mlir::arith::MaxUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3419 | } |
| 3420 | |
| 3421 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxUIOp_0.getODSResults(index: 0) }) { |
| 3422 | tblgen_repl_values.push_back(Elt: v); |
| 3423 | } |
| 3424 | |
| 3425 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3426 | return ::mlir::success(); |
| 3427 | } |
| 3428 | }; |
| 3429 | |
| 3430 | /* Generated from: |
| 3431 | ArithCanonicalization.td:386 |
| 3432 | */ |
| 3433 | struct SelectCmpIUgeToMinUI : public ::mlir::RewritePattern { |
| 3434 | SelectCmpIUgeToMinUI(::mlir::MLIRContext *context) |
| 3435 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minui" }) {} |
| 3436 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3437 | ::mlir::PatternRewriter &rewriter) const override { |
| 3438 | // Variables for capturing values and attributes used while creating ops |
| 3439 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3440 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3441 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3442 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3443 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3444 | |
| 3445 | // Match |
| 3446 | tblgen_ops.push_back(Elt: op0); |
| 3447 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3448 | { |
| 3449 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3450 | if (!(op1)){ |
| 3451 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3452 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3453 | }); |
| 3454 | } |
| 3455 | if(::mlir::failed(Result: static_dag_matcher_17(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3456 | return ::mlir::failure(); |
| 3457 | } |
| 3458 | tblgen_ops.push_back(Elt: op1); |
| 3459 | } |
| 3460 | b0 = castedOp0.getODSOperands(index: 1); |
| 3461 | a0 = castedOp0.getODSOperands(index: 2); |
| 3462 | if (!(*b.begin() == *b0.begin())){ |
| 3463 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3464 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3465 | }); |
| 3466 | } |
| 3467 | if (!(*a.begin() == *a0.begin())){ |
| 3468 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3469 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3470 | }); |
| 3471 | } |
| 3472 | |
| 3473 | // Rewrite |
| 3474 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3475 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3476 | ::mlir::arith::MinUIOp tblgen_MinUIOp_0; |
| 3477 | { |
| 3478 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3479 | ::mlir::arith::MinUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3480 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3481 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3482 | tblgen_MinUIOp_0 = ::mlir::arith::MinUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3483 | } |
| 3484 | |
| 3485 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinUIOp_0.getODSResults(index: 0) }) { |
| 3486 | tblgen_repl_values.push_back(Elt: v); |
| 3487 | } |
| 3488 | |
| 3489 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3490 | return ::mlir::success(); |
| 3491 | } |
| 3492 | }; |
| 3493 | |
| 3494 | /* Generated from: |
| 3495 | ArithCanonicalization.td:375 |
| 3496 | */ |
| 3497 | struct SelectCmpIUgtToMaxUI : public ::mlir::RewritePattern { |
| 3498 | SelectCmpIUgtToMaxUI(::mlir::MLIRContext *context) |
| 3499 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxui" }) {} |
| 3500 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3501 | ::mlir::PatternRewriter &rewriter) const override { |
| 3502 | // Variables for capturing values and attributes used while creating ops |
| 3503 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3504 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3505 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3506 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3507 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3508 | |
| 3509 | // Match |
| 3510 | tblgen_ops.push_back(Elt: op0); |
| 3511 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3512 | { |
| 3513 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3514 | if (!(op1)){ |
| 3515 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3516 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3517 | }); |
| 3518 | } |
| 3519 | if(::mlir::failed(Result: static_dag_matcher_18(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3520 | return ::mlir::failure(); |
| 3521 | } |
| 3522 | tblgen_ops.push_back(Elt: op1); |
| 3523 | } |
| 3524 | a0 = castedOp0.getODSOperands(index: 1); |
| 3525 | b0 = castedOp0.getODSOperands(index: 2); |
| 3526 | if (!(*b.begin() == *b0.begin())){ |
| 3527 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3528 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3529 | }); |
| 3530 | } |
| 3531 | if (!(*a.begin() == *a0.begin())){ |
| 3532 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3533 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3534 | }); |
| 3535 | } |
| 3536 | |
| 3537 | // Rewrite |
| 3538 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3539 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3540 | ::mlir::arith::MaxUIOp tblgen_MaxUIOp_0; |
| 3541 | { |
| 3542 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3543 | ::mlir::arith::MaxUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3544 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3545 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3546 | tblgen_MaxUIOp_0 = ::mlir::arith::MaxUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3547 | } |
| 3548 | |
| 3549 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxUIOp_0.getODSResults(index: 0) }) { |
| 3550 | tblgen_repl_values.push_back(Elt: v); |
| 3551 | } |
| 3552 | |
| 3553 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3554 | return ::mlir::success(); |
| 3555 | } |
| 3556 | }; |
| 3557 | |
| 3558 | /* Generated from: |
| 3559 | ArithCanonicalization.td:385 |
| 3560 | */ |
| 3561 | struct SelectCmpIUgtToMinUI : public ::mlir::RewritePattern { |
| 3562 | SelectCmpIUgtToMinUI(::mlir::MLIRContext *context) |
| 3563 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minui" }) {} |
| 3564 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3565 | ::mlir::PatternRewriter &rewriter) const override { |
| 3566 | // Variables for capturing values and attributes used while creating ops |
| 3567 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3568 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3569 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3570 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3571 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3572 | |
| 3573 | // Match |
| 3574 | tblgen_ops.push_back(Elt: op0); |
| 3575 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3576 | { |
| 3577 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3578 | if (!(op1)){ |
| 3579 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3580 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3581 | }); |
| 3582 | } |
| 3583 | if(::mlir::failed(Result: static_dag_matcher_18(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3584 | return ::mlir::failure(); |
| 3585 | } |
| 3586 | tblgen_ops.push_back(Elt: op1); |
| 3587 | } |
| 3588 | b0 = castedOp0.getODSOperands(index: 1); |
| 3589 | a0 = castedOp0.getODSOperands(index: 2); |
| 3590 | if (!(*b.begin() == *b0.begin())){ |
| 3591 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3592 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3593 | }); |
| 3594 | } |
| 3595 | if (!(*a.begin() == *a0.begin())){ |
| 3596 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3597 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3598 | }); |
| 3599 | } |
| 3600 | |
| 3601 | // Rewrite |
| 3602 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3603 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3604 | ::mlir::arith::MinUIOp tblgen_MinUIOp_0; |
| 3605 | { |
| 3606 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3607 | ::mlir::arith::MinUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3608 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3609 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3610 | tblgen_MinUIOp_0 = ::mlir::arith::MinUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3611 | } |
| 3612 | |
| 3613 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinUIOp_0.getODSResults(index: 0) }) { |
| 3614 | tblgen_repl_values.push_back(Elt: v); |
| 3615 | } |
| 3616 | |
| 3617 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3618 | return ::mlir::success(); |
| 3619 | } |
| 3620 | }; |
| 3621 | |
| 3622 | /* Generated from: |
| 3623 | ArithCanonicalization.td:384 |
| 3624 | */ |
| 3625 | struct SelectCmpIUleToMaxUI : public ::mlir::RewritePattern { |
| 3626 | SelectCmpIUleToMaxUI(::mlir::MLIRContext *context) |
| 3627 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxui" }) {} |
| 3628 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3629 | ::mlir::PatternRewriter &rewriter) const override { |
| 3630 | // Variables for capturing values and attributes used while creating ops |
| 3631 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3632 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3633 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3634 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3635 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3636 | |
| 3637 | // Match |
| 3638 | tblgen_ops.push_back(Elt: op0); |
| 3639 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3640 | { |
| 3641 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3642 | if (!(op1)){ |
| 3643 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3644 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3645 | }); |
| 3646 | } |
| 3647 | if(::mlir::failed(Result: static_dag_matcher_19(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3648 | return ::mlir::failure(); |
| 3649 | } |
| 3650 | tblgen_ops.push_back(Elt: op1); |
| 3651 | } |
| 3652 | b0 = castedOp0.getODSOperands(index: 1); |
| 3653 | a0 = castedOp0.getODSOperands(index: 2); |
| 3654 | if (!(*b.begin() == *b0.begin())){ |
| 3655 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3656 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3657 | }); |
| 3658 | } |
| 3659 | if (!(*a.begin() == *a0.begin())){ |
| 3660 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3661 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3662 | }); |
| 3663 | } |
| 3664 | |
| 3665 | // Rewrite |
| 3666 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3667 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3668 | ::mlir::arith::MaxUIOp tblgen_MaxUIOp_0; |
| 3669 | { |
| 3670 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3671 | ::mlir::arith::MaxUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3672 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3673 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3674 | tblgen_MaxUIOp_0 = ::mlir::arith::MaxUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3675 | } |
| 3676 | |
| 3677 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxUIOp_0.getODSResults(index: 0) }) { |
| 3678 | tblgen_repl_values.push_back(Elt: v); |
| 3679 | } |
| 3680 | |
| 3681 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3682 | return ::mlir::success(); |
| 3683 | } |
| 3684 | }; |
| 3685 | |
| 3686 | /* Generated from: |
| 3687 | ArithCanonicalization.td:374 |
| 3688 | */ |
| 3689 | struct SelectCmpIUleToMinUI : public ::mlir::RewritePattern { |
| 3690 | SelectCmpIUleToMinUI(::mlir::MLIRContext *context) |
| 3691 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minui" }) {} |
| 3692 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3693 | ::mlir::PatternRewriter &rewriter) const override { |
| 3694 | // Variables for capturing values and attributes used while creating ops |
| 3695 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3696 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3697 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3698 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3699 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3700 | |
| 3701 | // Match |
| 3702 | tblgen_ops.push_back(Elt: op0); |
| 3703 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3704 | { |
| 3705 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3706 | if (!(op1)){ |
| 3707 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3708 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3709 | }); |
| 3710 | } |
| 3711 | if(::mlir::failed(Result: static_dag_matcher_19(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3712 | return ::mlir::failure(); |
| 3713 | } |
| 3714 | tblgen_ops.push_back(Elt: op1); |
| 3715 | } |
| 3716 | a0 = castedOp0.getODSOperands(index: 1); |
| 3717 | b0 = castedOp0.getODSOperands(index: 2); |
| 3718 | if (!(*b.begin() == *b0.begin())){ |
| 3719 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3720 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3721 | }); |
| 3722 | } |
| 3723 | if (!(*a.begin() == *a0.begin())){ |
| 3724 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3725 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3726 | }); |
| 3727 | } |
| 3728 | |
| 3729 | // Rewrite |
| 3730 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3731 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3732 | ::mlir::arith::MinUIOp tblgen_MinUIOp_0; |
| 3733 | { |
| 3734 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3735 | ::mlir::arith::MinUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3736 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3737 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3738 | tblgen_MinUIOp_0 = ::mlir::arith::MinUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3739 | } |
| 3740 | |
| 3741 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinUIOp_0.getODSResults(index: 0) }) { |
| 3742 | tblgen_repl_values.push_back(Elt: v); |
| 3743 | } |
| 3744 | |
| 3745 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3746 | return ::mlir::success(); |
| 3747 | } |
| 3748 | }; |
| 3749 | |
| 3750 | /* Generated from: |
| 3751 | ArithCanonicalization.td:383 |
| 3752 | */ |
| 3753 | struct SelectCmpIUltToMaxUI : public ::mlir::RewritePattern { |
| 3754 | SelectCmpIUltToMaxUI(::mlir::MLIRContext *context) |
| 3755 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.maxui" }) {} |
| 3756 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3757 | ::mlir::PatternRewriter &rewriter) const override { |
| 3758 | // Variables for capturing values and attributes used while creating ops |
| 3759 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3760 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3761 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3762 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3763 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3764 | |
| 3765 | // Match |
| 3766 | tblgen_ops.push_back(Elt: op0); |
| 3767 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3768 | { |
| 3769 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3770 | if (!(op1)){ |
| 3771 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3772 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3773 | }); |
| 3774 | } |
| 3775 | if(::mlir::failed(Result: static_dag_matcher_20(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3776 | return ::mlir::failure(); |
| 3777 | } |
| 3778 | tblgen_ops.push_back(Elt: op1); |
| 3779 | } |
| 3780 | b0 = castedOp0.getODSOperands(index: 1); |
| 3781 | a0 = castedOp0.getODSOperands(index: 2); |
| 3782 | if (!(*b.begin() == *b0.begin())){ |
| 3783 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3784 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3785 | }); |
| 3786 | } |
| 3787 | if (!(*a.begin() == *a0.begin())){ |
| 3788 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3789 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3790 | }); |
| 3791 | } |
| 3792 | |
| 3793 | // Rewrite |
| 3794 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3795 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3796 | ::mlir::arith::MaxUIOp tblgen_MaxUIOp_0; |
| 3797 | { |
| 3798 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3799 | ::mlir::arith::MaxUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3800 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3801 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3802 | tblgen_MaxUIOp_0 = ::mlir::arith::MaxUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3803 | } |
| 3804 | |
| 3805 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MaxUIOp_0.getODSResults(index: 0) }) { |
| 3806 | tblgen_repl_values.push_back(Elt: v); |
| 3807 | } |
| 3808 | |
| 3809 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3810 | return ::mlir::success(); |
| 3811 | } |
| 3812 | }; |
| 3813 | |
| 3814 | /* Generated from: |
| 3815 | ArithCanonicalization.td:373 |
| 3816 | */ |
| 3817 | struct SelectCmpIUltToMinUI : public ::mlir::RewritePattern { |
| 3818 | SelectCmpIUltToMinUI(::mlir::MLIRContext *context) |
| 3819 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.minui" }) {} |
| 3820 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3821 | ::mlir::PatternRewriter &rewriter) const override { |
| 3822 | // Variables for capturing values and attributes used while creating ops |
| 3823 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3824 | ::mlir::Operation::operand_range b0(op0->getOperands()); |
| 3825 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3826 | ::mlir::Operation::operand_range a0(op0->getOperands()); |
| 3827 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3828 | |
| 3829 | // Match |
| 3830 | tblgen_ops.push_back(Elt: op0); |
| 3831 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3832 | { |
| 3833 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3834 | if (!(op1)){ |
| 3835 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3836 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3837 | }); |
| 3838 | } |
| 3839 | if(::mlir::failed(Result: static_dag_matcher_20(rewriter, op0: op1, tblgen_ops, b, a))) { |
| 3840 | return ::mlir::failure(); |
| 3841 | } |
| 3842 | tblgen_ops.push_back(Elt: op1); |
| 3843 | } |
| 3844 | a0 = castedOp0.getODSOperands(index: 1); |
| 3845 | b0 = castedOp0.getODSOperands(index: 2); |
| 3846 | if (!(*b.begin() == *b0.begin())){ |
| 3847 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3848 | diag << "Operands 'b' and 'b0' must be equal" ; |
| 3849 | }); |
| 3850 | } |
| 3851 | if (!(*a.begin() == *a0.begin())){ |
| 3852 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3853 | diag << "Operands 'a' and 'a0' must be equal" ; |
| 3854 | }); |
| 3855 | } |
| 3856 | |
| 3857 | // Rewrite |
| 3858 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 3859 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3860 | ::mlir::arith::MinUIOp tblgen_MinUIOp_0; |
| 3861 | { |
| 3862 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3863 | ::mlir::arith::MinUIOp::Properties tblgen_props; (void)tblgen_props; |
| 3864 | tblgen_values.push_back(Elt: (*a.begin())); |
| 3865 | tblgen_values.push_back(Elt: (*b.begin())); |
| 3866 | tblgen_MinUIOp_0 = ::mlir::arith::MinUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3867 | } |
| 3868 | |
| 3869 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_MinUIOp_0.getODSResults(index: 0) }) { |
| 3870 | tblgen_repl_values.push_back(Elt: v); |
| 3871 | } |
| 3872 | |
| 3873 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3874 | return ::mlir::success(); |
| 3875 | } |
| 3876 | }; |
| 3877 | |
| 3878 | /* Generated from: |
| 3879 | ArithCanonicalization.td:346 |
| 3880 | */ |
| 3881 | struct SelectI1ToNot : public ::mlir::RewritePattern { |
| 3882 | SelectI1ToNot(::mlir::MLIRContext *context) |
| 3883 | : ::mlir::RewritePattern("arith.select" , 1, context, {"arith.constant" , "arith.xori" }) {} |
| 3884 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3885 | ::mlir::PatternRewriter &rewriter) const override { |
| 3886 | // Variables for capturing values and attributes used while creating ops |
| 3887 | ::mlir::Operation::operand_range pred(op0->getOperands()); |
| 3888 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3889 | |
| 3890 | // Match |
| 3891 | tblgen_ops.push_back(Elt: op0); |
| 3892 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3893 | pred = castedOp0.getODSOperands(index: 0); |
| 3894 | { |
| 3895 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 3896 | if (!(op1)){ |
| 3897 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3898 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 3899 | }); |
| 3900 | } |
| 3901 | ::mlir::Attribute arg1_0; |
| 3902 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op1->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg1_0)))))){ |
| 3903 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3904 | diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure" ; |
| 3905 | }); |
| 3906 | } |
| 3907 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization11(rewriter, op: op1, attr: arg1_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'constant attribute 0'" ))) { |
| 3908 | return ::mlir::failure(); |
| 3909 | } |
| 3910 | tblgen_ops.push_back(Elt: op1); |
| 3911 | } |
| 3912 | { |
| 3913 | auto *op1 = (*castedOp0.getODSOperands(index: 2).begin()).getDefiningOp(); |
| 3914 | if (!(op1)){ |
| 3915 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3916 | diag << "There's no operation that defines operand 2 of castedOp0" ; |
| 3917 | }); |
| 3918 | } |
| 3919 | if(::mlir::failed(Result: static_dag_matcher_21(rewriter, op0: op1, tblgen_ops))) { |
| 3920 | return ::mlir::failure(); |
| 3921 | } |
| 3922 | tblgen_ops.push_back(Elt: op1); |
| 3923 | } |
| 3924 | |
| 3925 | // Rewrite |
| 3926 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc()}); (void)odsLoc; |
| 3927 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 3928 | ::mlir::arith::ConstantOp tblgen_ConstantOp_0; |
| 3929 | { |
| 3930 | tblgen_ConstantOp_0 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 3931 | value: rewriter.getIntegerAttr(type: rewriter.getIntegerType(width: 1), value: 1) |
| 3932 | ); |
| 3933 | } |
| 3934 | ::mlir::arith::XOrIOp tblgen_XOrIOp_1; |
| 3935 | { |
| 3936 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 3937 | ::mlir::arith::XOrIOp::Properties tblgen_props; (void)tblgen_props; |
| 3938 | tblgen_values.push_back(Elt: (*pred.begin())); |
| 3939 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_0.getODSResults(index: 0).begin())); |
| 3940 | tblgen_XOrIOp_1 = ::mlir::arith::XOrIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 3941 | } |
| 3942 | |
| 3943 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_XOrIOp_1.getODSResults(index: 0) }) { |
| 3944 | tblgen_repl_values.push_back(Elt: v); |
| 3945 | } |
| 3946 | |
| 3947 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 3948 | return ::mlir::success(); |
| 3949 | } |
| 3950 | }; |
| 3951 | |
| 3952 | /* Generated from: |
| 3953 | ArithCanonicalization.td:330 |
| 3954 | */ |
| 3955 | struct SelectNotCond : public ::mlir::RewritePattern { |
| 3956 | SelectNotCond(::mlir::MLIRContext *context) |
| 3957 | : ::mlir::RewritePattern("arith.select" , 2, context, {"arith.select" }) {} |
| 3958 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 3959 | ::mlir::PatternRewriter &rewriter) const override { |
| 3960 | // Variables for capturing values and attributes used while creating ops |
| 3961 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 3962 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 3963 | ::mlir::Attribute ones; |
| 3964 | ::mlir::Operation::operand_range pred(op0->getOperands()); |
| 3965 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 3966 | |
| 3967 | // Match |
| 3968 | tblgen_ops.push_back(Elt: op0); |
| 3969 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SelectOp>(Val: op0); (void)castedOp0; |
| 3970 | { |
| 3971 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 3972 | if (!(op1)){ |
| 3973 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3974 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 3975 | }); |
| 3976 | } |
| 3977 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::XOrIOp>(Val: op1); (void)castedOp1; |
| 3978 | if (!(castedOp1)){ |
| 3979 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3980 | diag << "castedOp1 is not ::mlir::arith::XOrIOp type" ; |
| 3981 | }); |
| 3982 | } |
| 3983 | pred = castedOp1.getODSOperands(index: 0); |
| 3984 | { |
| 3985 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 3986 | if (!(op2)){ |
| 3987 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3988 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 3989 | }); |
| 3990 | } |
| 3991 | ::mlir::Attribute arg2_0; |
| 3992 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op2->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg2_0)))))){ |
| 3993 | return rewriter.notifyMatchFailure(op: op2, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 3994 | diag << "::mlir::success(::mlir::matchPattern(op2->getResult(0), ::mlir::m_Constant(&arg2_0))) return ::mlir::failure" ; |
| 3995 | }); |
| 3996 | } |
| 3997 | ones = arg2_0; |
| 3998 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization1(rewriter, op: op2, attr: arg2_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'arbitrary integer attribute'" ))) { |
| 3999 | return ::mlir::failure(); |
| 4000 | } |
| 4001 | tblgen_ops.push_back(Elt: op2); |
| 4002 | } |
| 4003 | tblgen_ops.push_back(Elt: op1); |
| 4004 | } |
| 4005 | a = castedOp0.getODSOperands(index: 1); |
| 4006 | b = castedOp0.getODSOperands(index: 2); |
| 4007 | if (!(((succeeded(Result: getIntOrSplatIntValue(attr: ones)))) && ((getIntOrSplatIntValue(attr: ones)->isAllOnes())))){ |
| 4008 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4009 | diag << "entities 'ones' failed to satisfy constraint: ''" ; |
| 4010 | }); |
| 4011 | } |
| 4012 | |
| 4013 | // Rewrite |
| 4014 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4015 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4016 | ::mlir::arith::SelectOp tblgen_SelectOp_0; |
| 4017 | { |
| 4018 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4019 | ::mlir::arith::SelectOp::Properties tblgen_props; (void)tblgen_props; |
| 4020 | tblgen_values.push_back(Elt: (*pred.begin())); |
| 4021 | tblgen_values.push_back(Elt: (*b.begin())); |
| 4022 | tblgen_values.push_back(Elt: (*a.begin())); |
| 4023 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 4024 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 4025 | tblgen_types.push_back(Elt: v.getType()); |
| 4026 | } |
| 4027 | tblgen_SelectOp_0 = ::mlir::arith::SelectOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 4028 | } |
| 4029 | |
| 4030 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SelectOp_0.getODSResults(index: 0) }) { |
| 4031 | tblgen_repl_values.push_back(Elt: v); |
| 4032 | } |
| 4033 | |
| 4034 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4035 | return ::mlir::success(); |
| 4036 | } |
| 4037 | }; |
| 4038 | |
| 4039 | /* Generated from: |
| 4040 | ArithCanonicalization.td:589 |
| 4041 | */ |
| 4042 | struct SubFOfNegZero : public ::mlir::RewritePattern { |
| 4043 | SubFOfNegZero(::mlir::MLIRContext *context) |
| 4044 | : ::mlir::RewritePattern("arith.subf" , 1, context, {"arith.negf" }) {} |
| 4045 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4046 | ::mlir::PatternRewriter &rewriter) const override { |
| 4047 | // Variables for capturing values and attributes used while creating ops |
| 4048 | ::mlir::arith::RoundingModeAttr rm; |
| 4049 | ::mlir::arith::FastMathFlagsAttr fmf; |
| 4050 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4051 | ::mlir::Attribute c; |
| 4052 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4053 | |
| 4054 | // Match |
| 4055 | tblgen_ops.push_back(Elt: op0); |
| 4056 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubFOp>(Val: op0); (void)castedOp0; |
| 4057 | { |
| 4058 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4059 | if (!(op1)){ |
| 4060 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4061 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4062 | }); |
| 4063 | } |
| 4064 | ::mlir::Attribute arg1_0; |
| 4065 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op1->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg1_0)))))){ |
| 4066 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4067 | diag << "::mlir::success(::mlir::matchPattern(op1->getResult(0), ::mlir::m_Constant(&arg1_0))) return ::mlir::failure" ; |
| 4068 | }); |
| 4069 | } |
| 4070 | c = arg1_0; |
| 4071 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization2(rewriter, op: op1, attr: arg1_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'any attribute'" ))) { |
| 4072 | return ::mlir::failure(); |
| 4073 | } |
| 4074 | tblgen_ops.push_back(Elt: op1); |
| 4075 | } |
| 4076 | x = castedOp0.getODSOperands(index: 1); |
| 4077 | { |
| 4078 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFastmath(); |
| 4079 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::FastMathFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::FastMathFlags::none); |
| 4080 | fmf = tblgen_attr; |
| 4081 | } |
| 4082 | { |
| 4083 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRoundingmode(); |
| 4084 | rm = tblgen_attr; |
| 4085 | } |
| 4086 | if (!((m_NegZeroFloat().match(attr: c)))){ |
| 4087 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4088 | diag << "entities 'c' failed to satisfy constraint: 'is negative-zero float constant'" ; |
| 4089 | }); |
| 4090 | } |
| 4091 | if (!((rm == nullptr))){ |
| 4092 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4093 | diag << "entities 'rm' failed to satisfy constraint: 'default rounding mode'" ; |
| 4094 | }); |
| 4095 | } |
| 4096 | |
| 4097 | // Rewrite |
| 4098 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc()}); (void)odsLoc; |
| 4099 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4100 | ::mlir::arith::NegFOp tblgen_NegFOp_0; |
| 4101 | { |
| 4102 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4103 | ::mlir::arith::NegFOp::Properties tblgen_props; (void)tblgen_props; |
| 4104 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4105 | tblgen_props.fastmath = ::llvm::dyn_cast_if_present<decltype(tblgen_props.fastmath)>(Val&: fmf); |
| 4106 | tblgen_NegFOp_0 = ::mlir::arith::NegFOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4107 | } |
| 4108 | |
| 4109 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_NegFOp_0.getODSResults(index: 0) }) { |
| 4110 | tblgen_repl_values.push_back(Elt: v); |
| 4111 | } |
| 4112 | |
| 4113 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4114 | return ::mlir::success(); |
| 4115 | } |
| 4116 | }; |
| 4117 | |
| 4118 | /* Generated from: |
| 4119 | ArithCanonicalization.td:182 |
| 4120 | */ |
| 4121 | struct SubILHSAddConstant : public ::mlir::RewritePattern { |
| 4122 | SubILHSAddConstant(::mlir::MLIRContext *context) |
| 4123 | : ::mlir::RewritePattern("arith.subi" , 2, context, {"arith.constant" , "arith.subi" }) {} |
| 4124 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4125 | ::mlir::PatternRewriter &rewriter) const override { |
| 4126 | // Variables for capturing values and attributes used while creating ops |
| 4127 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 4128 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4129 | ::mlir::Attribute c0; |
| 4130 | ::mlir::Attribute c1; |
| 4131 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 4132 | ::mlir::arith::SubIOp res; |
| 4133 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4134 | |
| 4135 | // Match |
| 4136 | tblgen_ops.push_back(Elt: op0); |
| 4137 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp0; |
| 4138 | res = castedOp0; |
| 4139 | { |
| 4140 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4141 | if (!(op1)){ |
| 4142 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4143 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4144 | }); |
| 4145 | } |
| 4146 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 4147 | return ::mlir::failure(); |
| 4148 | } |
| 4149 | tblgen_ops.push_back(Elt: op1); |
| 4150 | } |
| 4151 | { |
| 4152 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 4153 | if (!(op1)){ |
| 4154 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4155 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 4156 | }); |
| 4157 | } |
| 4158 | if(::mlir::failed(Result: static_dag_matcher_3(rewriter, op0: op1, tblgen_ops, ovf1, c0, x))) { |
| 4159 | return ::mlir::failure(); |
| 4160 | } |
| 4161 | tblgen_ops.push_back(Elt: op1); |
| 4162 | } |
| 4163 | { |
| 4164 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4165 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4166 | ovf2 = tblgen_attr; |
| 4167 | } |
| 4168 | |
| 4169 | // Rewrite |
| 4170 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4171 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4172 | auto nativeVar_0 = subIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c1, rhs: c0); (void)nativeVar_0; |
| 4173 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 4174 | { |
| 4175 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 4176 | /*value=*/value: nativeVar_0 |
| 4177 | ); |
| 4178 | } |
| 4179 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c1, rhs: c0, signedOp: &APInt::ssub_ov, unsignedOp: &APInt::usub_ov); (void)nativeVar_2; |
| 4180 | ::mlir::arith::SubIOp tblgen_SubIOp_3; |
| 4181 | { |
| 4182 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4183 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 4184 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 4185 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4186 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 4187 | tblgen_SubIOp_3 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4188 | } |
| 4189 | |
| 4190 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_3.getODSResults(index: 0) }) { |
| 4191 | tblgen_repl_values.push_back(Elt: v); |
| 4192 | } |
| 4193 | |
| 4194 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4195 | return ::mlir::success(); |
| 4196 | } |
| 4197 | }; |
| 4198 | |
| 4199 | /* Generated from: |
| 4200 | ArithCanonicalization.td:214 |
| 4201 | */ |
| 4202 | struct SubILHSSubConstantLHS : public ::mlir::RewritePattern { |
| 4203 | SubILHSSubConstantLHS(::mlir::MLIRContext *context) |
| 4204 | : ::mlir::RewritePattern("arith.subi" , 2, context, {"arith.addi" , "arith.constant" }) {} |
| 4205 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4206 | ::mlir::PatternRewriter &rewriter) const override { |
| 4207 | // Variables for capturing values and attributes used while creating ops |
| 4208 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 4209 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4210 | ::mlir::Attribute c0; |
| 4211 | ::mlir::Attribute c1; |
| 4212 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 4213 | ::mlir::arith::SubIOp res; |
| 4214 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4215 | |
| 4216 | // Match |
| 4217 | tblgen_ops.push_back(Elt: op0); |
| 4218 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp0; |
| 4219 | res = castedOp0; |
| 4220 | { |
| 4221 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4222 | if (!(op1)){ |
| 4223 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4224 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4225 | }); |
| 4226 | } |
| 4227 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 4228 | return ::mlir::failure(); |
| 4229 | } |
| 4230 | tblgen_ops.push_back(Elt: op1); |
| 4231 | } |
| 4232 | { |
| 4233 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 4234 | if (!(op1)){ |
| 4235 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4236 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 4237 | }); |
| 4238 | } |
| 4239 | if(::mlir::failed(Result: static_dag_matcher_6(rewriter, op0: op1, tblgen_ops, ovf1, x, c0))) { |
| 4240 | return ::mlir::failure(); |
| 4241 | } |
| 4242 | tblgen_ops.push_back(Elt: op1); |
| 4243 | } |
| 4244 | { |
| 4245 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4246 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4247 | ovf2 = tblgen_attr; |
| 4248 | } |
| 4249 | |
| 4250 | // Rewrite |
| 4251 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4252 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4253 | auto nativeVar_0 = subIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c1, rhs: c0); (void)nativeVar_0; |
| 4254 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 4255 | { |
| 4256 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 4257 | /*value=*/value: nativeVar_0 |
| 4258 | ); |
| 4259 | } |
| 4260 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c1, rhs: c0, signedOp: &APInt::ssub_ov, unsignedOp: &APInt::usub_ov); (void)nativeVar_2; |
| 4261 | ::mlir::arith::AddIOp tblgen_AddIOp_3; |
| 4262 | { |
| 4263 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4264 | ::mlir::arith::AddIOp::Properties tblgen_props; (void)tblgen_props; |
| 4265 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4266 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 4267 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 4268 | tblgen_AddIOp_3 = ::mlir::arith::AddIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4269 | } |
| 4270 | |
| 4271 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AddIOp_3.getODSResults(index: 0) }) { |
| 4272 | tblgen_repl_values.push_back(Elt: v); |
| 4273 | } |
| 4274 | |
| 4275 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4276 | return ::mlir::success(); |
| 4277 | } |
| 4278 | }; |
| 4279 | |
| 4280 | /* Generated from: |
| 4281 | ArithCanonicalization.td:206 |
| 4282 | */ |
| 4283 | struct SubILHSSubConstantRHS : public ::mlir::RewritePattern { |
| 4284 | SubILHSSubConstantRHS(::mlir::MLIRContext *context) |
| 4285 | : ::mlir::RewritePattern("arith.subi" , 2, context, {"arith.constant" , "arith.subi" }) {} |
| 4286 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4287 | ::mlir::PatternRewriter &rewriter) const override { |
| 4288 | // Variables for capturing values and attributes used while creating ops |
| 4289 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 4290 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4291 | ::mlir::Attribute c0; |
| 4292 | ::mlir::Attribute c1; |
| 4293 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 4294 | ::mlir::arith::SubIOp res; |
| 4295 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4296 | |
| 4297 | // Match |
| 4298 | tblgen_ops.push_back(Elt: op0); |
| 4299 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp0; |
| 4300 | res = castedOp0; |
| 4301 | { |
| 4302 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4303 | if (!(op1)){ |
| 4304 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4305 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4306 | }); |
| 4307 | } |
| 4308 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 4309 | return ::mlir::failure(); |
| 4310 | } |
| 4311 | tblgen_ops.push_back(Elt: op1); |
| 4312 | } |
| 4313 | { |
| 4314 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 4315 | if (!(op1)){ |
| 4316 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4317 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 4318 | }); |
| 4319 | } |
| 4320 | if(::mlir::failed(Result: static_dag_matcher_7(rewriter, op0: op1, tblgen_ops, ovf1, c0, x))) { |
| 4321 | return ::mlir::failure(); |
| 4322 | } |
| 4323 | tblgen_ops.push_back(Elt: op1); |
| 4324 | } |
| 4325 | { |
| 4326 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4327 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4328 | ovf2 = tblgen_attr; |
| 4329 | } |
| 4330 | |
| 4331 | // Rewrite |
| 4332 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4333 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4334 | auto nativeVar_0 = addIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 4335 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 4336 | { |
| 4337 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 4338 | /*value=*/value: nativeVar_0 |
| 4339 | ); |
| 4340 | } |
| 4341 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c0, rhs: c1, signedOp: &APInt::sadd_ov, unsignedOp: &APInt::uadd_ov); (void)nativeVar_2; |
| 4342 | ::mlir::arith::SubIOp tblgen_SubIOp_3; |
| 4343 | { |
| 4344 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4345 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 4346 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 4347 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4348 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 4349 | tblgen_SubIOp_3 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4350 | } |
| 4351 | |
| 4352 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_3.getODSResults(index: 0) }) { |
| 4353 | tblgen_repl_values.push_back(Elt: v); |
| 4354 | } |
| 4355 | |
| 4356 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4357 | return ::mlir::success(); |
| 4358 | } |
| 4359 | }; |
| 4360 | |
| 4361 | /* Generated from: |
| 4362 | ArithCanonicalization.td:174 |
| 4363 | */ |
| 4364 | struct SubIRHSAddConstant : public ::mlir::RewritePattern { |
| 4365 | SubIRHSAddConstant(::mlir::MLIRContext *context) |
| 4366 | : ::mlir::RewritePattern("arith.subi" , 2, context, {"arith.addi" , "arith.constant" }) {} |
| 4367 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4368 | ::mlir::PatternRewriter &rewriter) const override { |
| 4369 | // Variables for capturing values and attributes used while creating ops |
| 4370 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 4371 | ::mlir::Attribute c1; |
| 4372 | ::mlir::Attribute c0; |
| 4373 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4374 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 4375 | ::mlir::arith::SubIOp res; |
| 4376 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4377 | |
| 4378 | // Match |
| 4379 | tblgen_ops.push_back(Elt: op0); |
| 4380 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp0; |
| 4381 | res = castedOp0; |
| 4382 | { |
| 4383 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4384 | if (!(op1)){ |
| 4385 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4386 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4387 | }); |
| 4388 | } |
| 4389 | if(::mlir::failed(Result: static_dag_matcher_3(rewriter, op0: op1, tblgen_ops, ovf1, c0, x))) { |
| 4390 | return ::mlir::failure(); |
| 4391 | } |
| 4392 | tblgen_ops.push_back(Elt: op1); |
| 4393 | } |
| 4394 | { |
| 4395 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 4396 | if (!(op1)){ |
| 4397 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4398 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 4399 | }); |
| 4400 | } |
| 4401 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 4402 | return ::mlir::failure(); |
| 4403 | } |
| 4404 | tblgen_ops.push_back(Elt: op1); |
| 4405 | } |
| 4406 | { |
| 4407 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4408 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4409 | ovf2 = tblgen_attr; |
| 4410 | } |
| 4411 | |
| 4412 | // Rewrite |
| 4413 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4414 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4415 | auto nativeVar_0 = subIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 4416 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 4417 | { |
| 4418 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 4419 | /*value=*/value: nativeVar_0 |
| 4420 | ); |
| 4421 | } |
| 4422 | ::mlir::arith::AddIOp tblgen_AddIOp_2; |
| 4423 | { |
| 4424 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4425 | ::mlir::arith::AddIOp::Properties tblgen_props; (void)tblgen_props; |
| 4426 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4427 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 4428 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val: ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none)); |
| 4429 | tblgen_AddIOp_2 = ::mlir::arith::AddIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4430 | } |
| 4431 | |
| 4432 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_AddIOp_2.getODSResults(index: 0) }) { |
| 4433 | tblgen_repl_values.push_back(Elt: v); |
| 4434 | } |
| 4435 | |
| 4436 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4437 | return ::mlir::success(); |
| 4438 | } |
| 4439 | }; |
| 4440 | |
| 4441 | /* Generated from: |
| 4442 | ArithCanonicalization.td:198 |
| 4443 | */ |
| 4444 | struct SubIRHSSubConstantLHS : public ::mlir::RewritePattern { |
| 4445 | SubIRHSSubConstantLHS(::mlir::MLIRContext *context) |
| 4446 | : ::mlir::RewritePattern("arith.subi" , 2, context, {"arith.constant" , "arith.subi" }) {} |
| 4447 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4448 | ::mlir::PatternRewriter &rewriter) const override { |
| 4449 | // Variables for capturing values and attributes used while creating ops |
| 4450 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 4451 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4452 | ::mlir::Attribute c1; |
| 4453 | ::mlir::Attribute c0; |
| 4454 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 4455 | ::mlir::arith::SubIOp res; |
| 4456 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4457 | |
| 4458 | // Match |
| 4459 | tblgen_ops.push_back(Elt: op0); |
| 4460 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp0; |
| 4461 | res = castedOp0; |
| 4462 | { |
| 4463 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4464 | if (!(op1)){ |
| 4465 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4466 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4467 | }); |
| 4468 | } |
| 4469 | if(::mlir::failed(Result: static_dag_matcher_6(rewriter, op0: op1, tblgen_ops, ovf1, x, c0))) { |
| 4470 | return ::mlir::failure(); |
| 4471 | } |
| 4472 | tblgen_ops.push_back(Elt: op1); |
| 4473 | } |
| 4474 | { |
| 4475 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 4476 | if (!(op1)){ |
| 4477 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4478 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 4479 | }); |
| 4480 | } |
| 4481 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 4482 | return ::mlir::failure(); |
| 4483 | } |
| 4484 | tblgen_ops.push_back(Elt: op1); |
| 4485 | } |
| 4486 | { |
| 4487 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4488 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4489 | ovf2 = tblgen_attr; |
| 4490 | } |
| 4491 | |
| 4492 | // Rewrite |
| 4493 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4494 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4495 | auto nativeVar_0 = subIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 4496 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 4497 | { |
| 4498 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 4499 | /*value=*/value: nativeVar_0 |
| 4500 | ); |
| 4501 | } |
| 4502 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c0, rhs: c1, signedOp: &APInt::ssub_ov, unsignedOp: &APInt::usub_ov); (void)nativeVar_2; |
| 4503 | ::mlir::arith::SubIOp tblgen_SubIOp_3; |
| 4504 | { |
| 4505 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4506 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 4507 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 4508 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4509 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 4510 | tblgen_SubIOp_3 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4511 | } |
| 4512 | |
| 4513 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_3.getODSResults(index: 0) }) { |
| 4514 | tblgen_repl_values.push_back(Elt: v); |
| 4515 | } |
| 4516 | |
| 4517 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4518 | return ::mlir::success(); |
| 4519 | } |
| 4520 | }; |
| 4521 | |
| 4522 | /* Generated from: |
| 4523 | ArithCanonicalization.td:190 |
| 4524 | */ |
| 4525 | struct SubIRHSSubConstantRHS : public ::mlir::RewritePattern { |
| 4526 | SubIRHSSubConstantRHS(::mlir::MLIRContext *context) |
| 4527 | : ::mlir::RewritePattern("arith.subi" , 2, context, {"arith.constant" , "arith.subi" }) {} |
| 4528 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4529 | ::mlir::PatternRewriter &rewriter) const override { |
| 4530 | // Variables for capturing values and attributes used while creating ops |
| 4531 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 4532 | ::mlir::Attribute c1; |
| 4533 | ::mlir::Attribute c0; |
| 4534 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4535 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 4536 | ::mlir::arith::SubIOp res; |
| 4537 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4538 | |
| 4539 | // Match |
| 4540 | tblgen_ops.push_back(Elt: op0); |
| 4541 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp0; |
| 4542 | res = castedOp0; |
| 4543 | { |
| 4544 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4545 | if (!(op1)){ |
| 4546 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4547 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4548 | }); |
| 4549 | } |
| 4550 | if(::mlir::failed(Result: static_dag_matcher_7(rewriter, op0: op1, tblgen_ops, ovf1, c0, x))) { |
| 4551 | return ::mlir::failure(); |
| 4552 | } |
| 4553 | tblgen_ops.push_back(Elt: op1); |
| 4554 | } |
| 4555 | { |
| 4556 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 4557 | if (!(op1)){ |
| 4558 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4559 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 4560 | }); |
| 4561 | } |
| 4562 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 4563 | return ::mlir::failure(); |
| 4564 | } |
| 4565 | tblgen_ops.push_back(Elt: op1); |
| 4566 | } |
| 4567 | { |
| 4568 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4569 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4570 | ovf2 = tblgen_attr; |
| 4571 | } |
| 4572 | |
| 4573 | // Rewrite |
| 4574 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4575 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4576 | auto nativeVar_0 = addIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 4577 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 4578 | { |
| 4579 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 4580 | /*value=*/value: nativeVar_0 |
| 4581 | ); |
| 4582 | } |
| 4583 | auto nativeVar_2 = mergeOverflowFlagsForReassociation(val1: ovf1, val2: ovf2, lhs: c0, rhs: c1, signedOp: &APInt::sadd_ov, unsignedOp: &APInt::uadd_ov); (void)nativeVar_2; |
| 4584 | ::mlir::arith::SubIOp tblgen_SubIOp_3; |
| 4585 | { |
| 4586 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4587 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 4588 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4589 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 4590 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 4591 | tblgen_SubIOp_3 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4592 | } |
| 4593 | |
| 4594 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_3.getODSResults(index: 0) }) { |
| 4595 | tblgen_repl_values.push_back(Elt: v); |
| 4596 | } |
| 4597 | |
| 4598 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4599 | return ::mlir::success(); |
| 4600 | } |
| 4601 | }; |
| 4602 | |
| 4603 | /* Generated from: |
| 4604 | ArithCanonicalization.td:222 |
| 4605 | */ |
| 4606 | struct SubISubILHSRHSLHS : public ::mlir::RewritePattern { |
| 4607 | SubISubILHSRHSLHS(::mlir::MLIRContext *context) |
| 4608 | : ::mlir::RewritePattern("arith.subi" , 2, context, {"arith.constant" , "arith.subi" }) {} |
| 4609 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4610 | ::mlir::PatternRewriter &rewriter) const override { |
| 4611 | // Variables for capturing values and attributes used while creating ops |
| 4612 | ::mlir::arith::IntegerOverflowFlagsAttr ovf1; |
| 4613 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4614 | ::mlir::Operation::operand_range x0(op0->getOperands()); |
| 4615 | ::mlir::arith::IntegerOverflowFlagsAttr ovf2; |
| 4616 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 4617 | ::mlir::arith::SubIOp res; |
| 4618 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4619 | |
| 4620 | // Match |
| 4621 | tblgen_ops.push_back(Elt: op0); |
| 4622 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op0); (void)castedOp0; |
| 4623 | res = castedOp0; |
| 4624 | { |
| 4625 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4626 | if (!(op1)){ |
| 4627 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4628 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4629 | }); |
| 4630 | } |
| 4631 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::SubIOp>(Val: op1); (void)castedOp1; |
| 4632 | if (!(castedOp1)){ |
| 4633 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4634 | diag << "castedOp1 is not ::mlir::arith::SubIOp type" ; |
| 4635 | }); |
| 4636 | } |
| 4637 | x = castedOp1.getODSOperands(index: 0); |
| 4638 | y = castedOp1.getODSOperands(index: 1); |
| 4639 | { |
| 4640 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getOverflowFlags(); |
| 4641 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4642 | ovf1 = tblgen_attr; |
| 4643 | } |
| 4644 | tblgen_ops.push_back(Elt: op1); |
| 4645 | } |
| 4646 | x0 = castedOp0.getODSOperands(index: 1); |
| 4647 | { |
| 4648 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4649 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4650 | ovf2 = tblgen_attr; |
| 4651 | } |
| 4652 | if (!(*x.begin() == *x0.begin())){ |
| 4653 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4654 | diag << "Operands 'x' and 'x0' must be equal" ; |
| 4655 | }); |
| 4656 | } |
| 4657 | if (!((!::llvm::isa<::mlir::ShapedType>(Val: (*y.begin()).getType()) || ::llvm::cast<::mlir::ShapedType>(Val: (*y.begin()).getType()).hasStaticShape()))){ |
| 4658 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4659 | diag << "entities 'y' failed to satisfy constraint: 'type is a scalar or has a static shape'" ; |
| 4660 | }); |
| 4661 | } |
| 4662 | |
| 4663 | // Rewrite |
| 4664 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4665 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4666 | auto nativeVar_0 = rewriter.getZeroAttr(type: (*y.begin()).getType()); (void)nativeVar_0; |
| 4667 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 4668 | { |
| 4669 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 4670 | /*value=*/value: nativeVar_0 |
| 4671 | ); |
| 4672 | } |
| 4673 | auto nativeVar_2 = mergeOverflowFlags(val1: ovf1, val2: ovf2); (void)nativeVar_2; |
| 4674 | ::mlir::arith::SubIOp tblgen_SubIOp_3; |
| 4675 | { |
| 4676 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4677 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 4678 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 4679 | tblgen_values.push_back(Elt: (*y.begin())); |
| 4680 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_2); |
| 4681 | tblgen_SubIOp_3 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4682 | } |
| 4683 | |
| 4684 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_3.getODSResults(index: 0) }) { |
| 4685 | tblgen_repl_values.push_back(Elt: v); |
| 4686 | } |
| 4687 | |
| 4688 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4689 | return ::mlir::success(); |
| 4690 | } |
| 4691 | }; |
| 4692 | |
| 4693 | /* Generated from: |
| 4694 | ArithCanonicalization.td:164 |
| 4695 | */ |
| 4696 | struct SubUIExtendedToSubI : public ::mlir::RewritePattern { |
| 4697 | SubUIExtendedToSubI(::mlir::MLIRContext *context) |
| 4698 | : ::mlir::RewritePattern("arith.subui_extended" , 1, context, {"arith.subi" }) {} |
| 4699 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4700 | ::mlir::PatternRewriter &rewriter) const override { |
| 4701 | // Variables for capturing values and attributes used while creating ops |
| 4702 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4703 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 4704 | ::mlir::arith::SubUIExtendedOp res; |
| 4705 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4706 | |
| 4707 | // Match |
| 4708 | tblgen_ops.push_back(Elt: op0); |
| 4709 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::SubUIExtendedOp>(Val: op0); (void)castedOp0; |
| 4710 | res = castedOp0; |
| 4711 | x = castedOp0.getODSOperands(index: 0); |
| 4712 | y = castedOp0.getODSOperands(index: 1); |
| 4713 | if (!(((*res.getODSResults(index: 1).begin()).getUses().empty()))){ |
| 4714 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4715 | diag << "entities 'res__1' failed to satisfy constraint: ''" ; |
| 4716 | }); |
| 4717 | } |
| 4718 | |
| 4719 | // Rewrite |
| 4720 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc()}); (void)odsLoc; |
| 4721 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4722 | ::mlir::arith::SubIOp tblgen_SubIOp_0; |
| 4723 | { |
| 4724 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4725 | ::mlir::arith::SubIOp::Properties tblgen_props; (void)tblgen_props; |
| 4726 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4727 | tblgen_values.push_back(Elt: (*y.begin())); |
| 4728 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val: ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none)); |
| 4729 | tblgen_SubIOp_0 = ::mlir::arith::SubIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 4730 | } |
| 4731 | |
| 4732 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SubIOp_0.getODSResults(index: 0) }) { |
| 4733 | tblgen_repl_values.push_back(Elt: v); |
| 4734 | } |
| 4735 | |
| 4736 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ x }) { |
| 4737 | tblgen_repl_values.push_back(Elt: v); |
| 4738 | } |
| 4739 | |
| 4740 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4741 | return ::mlir::success(); |
| 4742 | } |
| 4743 | }; |
| 4744 | |
| 4745 | /* Generated from: |
| 4746 | ArithCanonicalization.td:525 |
| 4747 | */ |
| 4748 | struct TruncFSIToFPToSIToFP : public ::mlir::RewritePattern { |
| 4749 | TruncFSIToFPToSIToFP(::mlir::MLIRContext *context) |
| 4750 | : ::mlir::RewritePattern("arith.truncf" , 2, context, {"arith.sitofp" }) {} |
| 4751 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4752 | ::mlir::PatternRewriter &rewriter) const override { |
| 4753 | // Variables for capturing values and attributes used while creating ops |
| 4754 | ::mlir::arith::FastMathFlagsAttr fmf; |
| 4755 | ::mlir::arith::RoundingModeAttr rmf; |
| 4756 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4757 | ::mlir::arith::SIToFPOp fp; |
| 4758 | ::mlir::arith::TruncFOp tr; |
| 4759 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4760 | |
| 4761 | // Match |
| 4762 | tblgen_ops.push_back(Elt: op0); |
| 4763 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::TruncFOp>(Val: op0); (void)castedOp0; |
| 4764 | tr = castedOp0; |
| 4765 | { |
| 4766 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4767 | if (!(op1)){ |
| 4768 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4769 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4770 | }); |
| 4771 | } |
| 4772 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::SIToFPOp>(Val: op1); (void)castedOp1; |
| 4773 | if (!(castedOp1)){ |
| 4774 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4775 | diag << "castedOp1 is not ::mlir::arith::SIToFPOp type" ; |
| 4776 | }); |
| 4777 | } |
| 4778 | fp = castedOp1; |
| 4779 | x = castedOp1.getODSOperands(index: 0); |
| 4780 | tblgen_ops.push_back(Elt: op1); |
| 4781 | } |
| 4782 | { |
| 4783 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRoundingmode(); |
| 4784 | rmf = tblgen_attr; |
| 4785 | } |
| 4786 | { |
| 4787 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFastmath(); |
| 4788 | fmf = tblgen_attr; |
| 4789 | } |
| 4790 | if (!((rmf == nullptr))){ |
| 4791 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4792 | diag << "entities 'rmf' failed to satisfy constraint: 'default rounding mode'" ; |
| 4793 | }); |
| 4794 | } |
| 4795 | |
| 4796 | // Rewrite |
| 4797 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4798 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4799 | ::mlir::arith::SIToFPOp tblgen_SIToFPOp_0; |
| 4800 | { |
| 4801 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4802 | ::mlir::arith::SIToFPOp::Properties tblgen_props; (void)tblgen_props; |
| 4803 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4804 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 4805 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 4806 | tblgen_types.push_back(Elt: v.getType()); |
| 4807 | } |
| 4808 | tblgen_SIToFPOp_0 = ::mlir::arith::SIToFPOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 4809 | } |
| 4810 | |
| 4811 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_SIToFPOp_0.getODSResults(index: 0) }) { |
| 4812 | tblgen_repl_values.push_back(Elt: v); |
| 4813 | } |
| 4814 | |
| 4815 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4816 | return ::mlir::success(); |
| 4817 | } |
| 4818 | }; |
| 4819 | |
| 4820 | /* Generated from: |
| 4821 | ArithCanonicalization.td:531 |
| 4822 | */ |
| 4823 | struct TruncFUIToFPToUIToFP : public ::mlir::RewritePattern { |
| 4824 | TruncFUIToFPToUIToFP(::mlir::MLIRContext *context) |
| 4825 | : ::mlir::RewritePattern("arith.truncf" , 2, context, {"arith.uitofp" }) {} |
| 4826 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4827 | ::mlir::PatternRewriter &rewriter) const override { |
| 4828 | // Variables for capturing values and attributes used while creating ops |
| 4829 | ::mlir::arith::FastMathFlagsAttr fmf; |
| 4830 | ::mlir::arith::RoundingModeAttr rmf; |
| 4831 | ::mlir::UnitAttr nneg; |
| 4832 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4833 | ::mlir::arith::UIToFPOp fp; |
| 4834 | ::mlir::arith::TruncFOp tr; |
| 4835 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4836 | |
| 4837 | // Match |
| 4838 | tblgen_ops.push_back(Elt: op0); |
| 4839 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::TruncFOp>(Val: op0); (void)castedOp0; |
| 4840 | tr = castedOp0; |
| 4841 | { |
| 4842 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4843 | if (!(op1)){ |
| 4844 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4845 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4846 | }); |
| 4847 | } |
| 4848 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::UIToFPOp>(Val: op1); (void)castedOp1; |
| 4849 | if (!(castedOp1)){ |
| 4850 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4851 | diag << "castedOp1 is not ::mlir::arith::UIToFPOp type" ; |
| 4852 | }); |
| 4853 | } |
| 4854 | fp = castedOp1; |
| 4855 | x = castedOp1.getODSOperands(index: 0); |
| 4856 | { |
| 4857 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getNonNeg(); |
| 4858 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 4859 | nneg = tblgen_attr; |
| 4860 | } |
| 4861 | tblgen_ops.push_back(Elt: op1); |
| 4862 | } |
| 4863 | { |
| 4864 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getRoundingmode(); |
| 4865 | rmf = tblgen_attr; |
| 4866 | } |
| 4867 | { |
| 4868 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getFastmath(); |
| 4869 | fmf = tblgen_attr; |
| 4870 | } |
| 4871 | if (!((rmf == nullptr))){ |
| 4872 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4873 | diag << "entities 'rmf' failed to satisfy constraint: 'default rounding mode'" ; |
| 4874 | }); |
| 4875 | } |
| 4876 | |
| 4877 | // Rewrite |
| 4878 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4879 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4880 | ::mlir::arith::UIToFPOp tblgen_UIToFPOp_0; |
| 4881 | { |
| 4882 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4883 | ::mlir::arith::UIToFPOp::Properties tblgen_props; (void)tblgen_props; |
| 4884 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4885 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nneg); |
| 4886 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 4887 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 4888 | tblgen_types.push_back(Elt: v.getType()); |
| 4889 | } |
| 4890 | tblgen_UIToFPOp_0 = ::mlir::arith::UIToFPOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 4891 | } |
| 4892 | |
| 4893 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_UIToFPOp_0.getODSResults(index: 0) }) { |
| 4894 | tblgen_repl_values.push_back(Elt: v); |
| 4895 | } |
| 4896 | |
| 4897 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4898 | return ::mlir::success(); |
| 4899 | } |
| 4900 | }; |
| 4901 | |
| 4902 | /* Generated from: |
| 4903 | ArithCanonicalization.td:495 |
| 4904 | */ |
| 4905 | struct TruncIExtSIToExtSI : public ::mlir::RewritePattern { |
| 4906 | TruncIExtSIToExtSI(::mlir::MLIRContext *context) |
| 4907 | : ::mlir::RewritePattern("arith.trunci" , 2, context, {"arith.extsi" }) {} |
| 4908 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4909 | ::mlir::PatternRewriter &rewriter) const override { |
| 4910 | // Variables for capturing values and attributes used while creating ops |
| 4911 | ::mlir::arith::IntegerOverflowFlagsAttr overflow; |
| 4912 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4913 | ::mlir::arith::ExtSIOp ext; |
| 4914 | ::mlir::arith::TruncIOp tr; |
| 4915 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4916 | |
| 4917 | // Match |
| 4918 | tblgen_ops.push_back(Elt: op0); |
| 4919 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::TruncIOp>(Val: op0); (void)castedOp0; |
| 4920 | tr = castedOp0; |
| 4921 | { |
| 4922 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 4923 | if (!(op1)){ |
| 4924 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4925 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 4926 | }); |
| 4927 | } |
| 4928 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtSIOp>(Val: op1); (void)castedOp1; |
| 4929 | if (!(castedOp1)){ |
| 4930 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4931 | diag << "castedOp1 is not ::mlir::arith::ExtSIOp type" ; |
| 4932 | }); |
| 4933 | } |
| 4934 | ext = castedOp1; |
| 4935 | x = castedOp1.getODSOperands(index: 0); |
| 4936 | tblgen_ops.push_back(Elt: op1); |
| 4937 | } |
| 4938 | { |
| 4939 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 4940 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 4941 | overflow = tblgen_attr; |
| 4942 | } |
| 4943 | if (!(((getScalarOrElementWidth(value: (*ext.getODSResults(index: 0).begin())) > getScalarOrElementWidth(value: (*tr.getODSResults(index: 0).begin())))) && ((getScalarOrElementWidth(value: (*tr.getODSResults(index: 0).begin())) > 0)))){ |
| 4944 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4945 | diag << "entities 'ext, tr' failed to satisfy constraint: ''" ; |
| 4946 | }); |
| 4947 | } |
| 4948 | if (!(((getScalarOrElementWidth(value: (*tr.getODSResults(index: 0).begin())) > getScalarOrElementWidth(value: (*x.begin())))) && ((getScalarOrElementWidth(value: (*x.begin())) > 0)))){ |
| 4949 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 4950 | diag << "entities 'tr, x' failed to satisfy constraint: ''" ; |
| 4951 | }); |
| 4952 | } |
| 4953 | |
| 4954 | // Rewrite |
| 4955 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 4956 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 4957 | ::mlir::arith::ExtSIOp tblgen_ExtSIOp_0; |
| 4958 | { |
| 4959 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 4960 | ::mlir::arith::ExtSIOp::Properties tblgen_props; (void)tblgen_props; |
| 4961 | tblgen_values.push_back(Elt: (*x.begin())); |
| 4962 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 4963 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 4964 | tblgen_types.push_back(Elt: v.getType()); |
| 4965 | } |
| 4966 | tblgen_ExtSIOp_0 = ::mlir::arith::ExtSIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 4967 | } |
| 4968 | |
| 4969 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtSIOp_0.getODSResults(index: 0) }) { |
| 4970 | tblgen_repl_values.push_back(Elt: v); |
| 4971 | } |
| 4972 | |
| 4973 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 4974 | return ::mlir::success(); |
| 4975 | } |
| 4976 | }; |
| 4977 | |
| 4978 | /* Generated from: |
| 4979 | ArithCanonicalization.td:502 |
| 4980 | */ |
| 4981 | struct TruncIExtUIToExtUI : public ::mlir::RewritePattern { |
| 4982 | TruncIExtUIToExtUI(::mlir::MLIRContext *context) |
| 4983 | : ::mlir::RewritePattern("arith.trunci" , 2, context, {"arith.extui" }) {} |
| 4984 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 4985 | ::mlir::PatternRewriter &rewriter) const override { |
| 4986 | // Variables for capturing values and attributes used while creating ops |
| 4987 | ::mlir::arith::IntegerOverflowFlagsAttr overflow; |
| 4988 | ::mlir::UnitAttr nneg; |
| 4989 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 4990 | ::mlir::arith::ExtUIOp ext; |
| 4991 | ::mlir::arith::TruncIOp tr; |
| 4992 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 4993 | |
| 4994 | // Match |
| 4995 | tblgen_ops.push_back(Elt: op0); |
| 4996 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::TruncIOp>(Val: op0); (void)castedOp0; |
| 4997 | tr = castedOp0; |
| 4998 | { |
| 4999 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 5000 | if (!(op1)){ |
| 5001 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5002 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 5003 | }); |
| 5004 | } |
| 5005 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ExtUIOp>(Val: op1); (void)castedOp1; |
| 5006 | if (!(castedOp1)){ |
| 5007 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5008 | diag << "castedOp1 is not ::mlir::arith::ExtUIOp type" ; |
| 5009 | }); |
| 5010 | } |
| 5011 | ext = castedOp1; |
| 5012 | x = castedOp1.getODSOperands(index: 0); |
| 5013 | { |
| 5014 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getNonNeg(); |
| 5015 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 5016 | nneg = tblgen_attr; |
| 5017 | } |
| 5018 | tblgen_ops.push_back(Elt: op1); |
| 5019 | } |
| 5020 | { |
| 5021 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 5022 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 5023 | overflow = tblgen_attr; |
| 5024 | } |
| 5025 | if (!(((getScalarOrElementWidth(value: (*ext.getODSResults(index: 0).begin())) > getScalarOrElementWidth(value: (*tr.getODSResults(index: 0).begin())))) && ((getScalarOrElementWidth(value: (*tr.getODSResults(index: 0).begin())) > 0)))){ |
| 5026 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5027 | diag << "entities 'ext, tr' failed to satisfy constraint: ''" ; |
| 5028 | }); |
| 5029 | } |
| 5030 | if (!(((getScalarOrElementWidth(value: (*tr.getODSResults(index: 0).begin())) > getScalarOrElementWidth(value: (*x.begin())))) && ((getScalarOrElementWidth(value: (*x.begin())) > 0)))){ |
| 5031 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5032 | diag << "entities 'tr, x' failed to satisfy constraint: ''" ; |
| 5033 | }); |
| 5034 | } |
| 5035 | |
| 5036 | // Rewrite |
| 5037 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 5038 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 5039 | ::mlir::arith::ExtUIOp tblgen_ExtUIOp_0; |
| 5040 | { |
| 5041 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5042 | ::mlir::arith::ExtUIOp::Properties tblgen_props; (void)tblgen_props; |
| 5043 | tblgen_values.push_back(Elt: (*x.begin())); |
| 5044 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nneg); |
| 5045 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 5046 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 5047 | tblgen_types.push_back(Elt: v.getType()); |
| 5048 | } |
| 5049 | tblgen_ExtUIOp_0 = ::mlir::arith::ExtUIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 5050 | } |
| 5051 | |
| 5052 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtUIOp_0.getODSResults(index: 0) }) { |
| 5053 | tblgen_repl_values.push_back(Elt: v); |
| 5054 | } |
| 5055 | |
| 5056 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 5057 | return ::mlir::success(); |
| 5058 | } |
| 5059 | }; |
| 5060 | |
| 5061 | /* Generated from: |
| 5062 | ArithCanonicalization.td:511 |
| 5063 | */ |
| 5064 | struct TruncIShrSIToTrunciShrUI : public ::mlir::RewritePattern { |
| 5065 | TruncIShrSIToTrunciShrUI(::mlir::MLIRContext *context) |
| 5066 | : ::mlir::RewritePattern("arith.trunci" , 2, context, {"arith.constant" , "arith.shrui" , "arith.trunci" }) {} |
| 5067 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 5068 | ::mlir::PatternRewriter &rewriter) const override { |
| 5069 | // Variables for capturing values and attributes used while creating ops |
| 5070 | ::mlir::arith::IntegerOverflowFlagsAttr overflow; |
| 5071 | ::mlir::UnitAttr exact; |
| 5072 | ::mlir::Attribute c0; |
| 5073 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 5074 | ::mlir::arith::TruncIOp tr; |
| 5075 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 5076 | |
| 5077 | // Match |
| 5078 | tblgen_ops.push_back(Elt: op0); |
| 5079 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::TruncIOp>(Val: op0); (void)castedOp0; |
| 5080 | tr = castedOp0; |
| 5081 | { |
| 5082 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 5083 | if (!(op1)){ |
| 5084 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5085 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 5086 | }); |
| 5087 | } |
| 5088 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::ShRSIOp>(Val: op1); (void)castedOp1; |
| 5089 | if (!(castedOp1)){ |
| 5090 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5091 | diag << "castedOp1 is not ::mlir::arith::ShRSIOp type" ; |
| 5092 | }); |
| 5093 | } |
| 5094 | x = castedOp1.getODSOperands(index: 0); |
| 5095 | { |
| 5096 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 5097 | if (!(op2)){ |
| 5098 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5099 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 5100 | }); |
| 5101 | } |
| 5102 | ::mlir::Attribute arg2_0; |
| 5103 | if (!(!::mlir::failed(Result: ::mlir::success(IsSuccess: ::mlir::matchPattern(value: op2->getResult(idx: 0), pattern: ::mlir::m_Constant(bind_value: &arg2_0)))))){ |
| 5104 | return rewriter.notifyMatchFailure(op: op2, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5105 | diag << "::mlir::success(::mlir::matchPattern(op2->getResult(0), ::mlir::m_Constant(&arg2_0))) return ::mlir::failure" ; |
| 5106 | }); |
| 5107 | } |
| 5108 | c0 = arg2_0; |
| 5109 | if(::mlir::failed(Result: __mlir_ods_local_attr_constraint_ArithCanonicalization13(rewriter, op: op2, attr: arg2_0, failureStr: "operand 0 of native code call '::mlir::success(::mlir::matchPattern($_self->getResult(0), ::mlir::m_Constant(&$0)))' failed to satisfy constraint: 'TypedAttr instance'" ))) { |
| 5110 | return ::mlir::failure(); |
| 5111 | } |
| 5112 | tblgen_ops.push_back(Elt: op2); |
| 5113 | } |
| 5114 | { |
| 5115 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getIsExact(); |
| 5116 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 5117 | exact = tblgen_attr; |
| 5118 | } |
| 5119 | tblgen_ops.push_back(Elt: op1); |
| 5120 | } |
| 5121 | { |
| 5122 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getOverflowFlags(); |
| 5123 | if (!tblgen_attr) tblgen_attr = ::mlir::arith::IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: ::mlir::arith::IntegerOverflowFlags::none); |
| 5124 | overflow = tblgen_attr; |
| 5125 | } |
| 5126 | if (!(((succeeded(Result: getIntOrSplatIntValue(attr: c0)))) && (((getScalarOrElementWidth(value: (*x.begin())) - getScalarOrElementWidth(value: (*tr.getODSResults(index: 0).begin()))) == *getIntOrSplatIntValue(attr: c0))))){ |
| 5127 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5128 | diag << "entities 'x, tr, c0' failed to satisfy constraint: ''" ; |
| 5129 | }); |
| 5130 | } |
| 5131 | |
| 5132 | // Rewrite |
| 5133 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 5134 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 5135 | auto nativeVar_0 = ::mlir::cast<TypedAttr>(Val&: c0); (void)nativeVar_0; |
| 5136 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 5137 | { |
| 5138 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 5139 | /*value=*/value: nativeVar_0 |
| 5140 | ); |
| 5141 | } |
| 5142 | ::mlir::arith::ShRUIOp tblgen_ShRUIOp_2; |
| 5143 | { |
| 5144 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5145 | ::mlir::arith::ShRUIOp::Properties tblgen_props; (void)tblgen_props; |
| 5146 | tblgen_values.push_back(Elt: (*x.begin())); |
| 5147 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 5148 | tblgen_props.isExact = ::llvm::dyn_cast_if_present<decltype(tblgen_props.isExact)>(Val&: exact); |
| 5149 | tblgen_ShRUIOp_2 = ::mlir::arith::ShRUIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 5150 | } |
| 5151 | auto nativeVar_3 = IntegerOverflowFlagsAttr::get(context: rewriter.getContext(), value: overflow.getValue() & ~IntegerOverflowFlags::nsw); (void)nativeVar_3; |
| 5152 | ::mlir::arith::TruncIOp tblgen_TruncIOp_4; |
| 5153 | { |
| 5154 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5155 | ::mlir::arith::TruncIOp::Properties tblgen_props; (void)tblgen_props; |
| 5156 | tblgen_values.push_back(Elt: (*tblgen_ShRUIOp_2.getODSResults(index: 0).begin())); |
| 5157 | tblgen_props.overflowFlags = ::llvm::dyn_cast_if_present<decltype(tblgen_props.overflowFlags)>(Val&: nativeVar_3); |
| 5158 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 5159 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 5160 | tblgen_types.push_back(Elt: v.getType()); |
| 5161 | } |
| 5162 | tblgen_TruncIOp_4 = ::mlir::arith::TruncIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 5163 | } |
| 5164 | |
| 5165 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_TruncIOp_4.getODSResults(index: 0) }) { |
| 5166 | tblgen_repl_values.push_back(Elt: v); |
| 5167 | } |
| 5168 | |
| 5169 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 5170 | return ::mlir::success(); |
| 5171 | } |
| 5172 | }; |
| 5173 | |
| 5174 | /* Generated from: |
| 5175 | ArithCanonicalization.td:555 |
| 5176 | */ |
| 5177 | struct UIToFPOfExtUI : public ::mlir::RewritePattern { |
| 5178 | UIToFPOfExtUI(::mlir::MLIRContext *context) |
| 5179 | : ::mlir::RewritePattern("arith.uitofp" , 2, context, {"arith.uitofp" }) {} |
| 5180 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 5181 | ::mlir::PatternRewriter &rewriter) const override { |
| 5182 | // Variables for capturing values and attributes used while creating ops |
| 5183 | ::mlir::UnitAttr nneg2; |
| 5184 | ::mlir::UnitAttr nneg1; |
| 5185 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 5186 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 5187 | |
| 5188 | // Match |
| 5189 | tblgen_ops.push_back(Elt: op0); |
| 5190 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::UIToFPOp>(Val: op0); (void)castedOp0; |
| 5191 | { |
| 5192 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 5193 | if (!(op1)){ |
| 5194 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5195 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 5196 | }); |
| 5197 | } |
| 5198 | if(::mlir::failed(Result: static_dag_matcher_10(rewriter, op0: op1, tblgen_ops, nneg1, x))) { |
| 5199 | return ::mlir::failure(); |
| 5200 | } |
| 5201 | tblgen_ops.push_back(Elt: op1); |
| 5202 | } |
| 5203 | { |
| 5204 | [[maybe_unused]] auto tblgen_attr = castedOp0.getProperties().getNonNeg(); |
| 5205 | if (!tblgen_attr) tblgen_attr = ((false) ? rewriter.getUnitAttr() : nullptr); |
| 5206 | nneg2 = tblgen_attr; |
| 5207 | } |
| 5208 | |
| 5209 | // Rewrite |
| 5210 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 5211 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 5212 | ::mlir::arith::UIToFPOp tblgen_UIToFPOp_0; |
| 5213 | { |
| 5214 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5215 | ::mlir::arith::UIToFPOp::Properties tblgen_props; (void)tblgen_props; |
| 5216 | tblgen_values.push_back(Elt: (*x.begin())); |
| 5217 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nneg1); |
| 5218 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 5219 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 5220 | tblgen_types.push_back(Elt: v.getType()); |
| 5221 | } |
| 5222 | tblgen_UIToFPOp_0 = ::mlir::arith::UIToFPOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 5223 | } |
| 5224 | |
| 5225 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_UIToFPOp_0.getODSResults(index: 0) }) { |
| 5226 | tblgen_repl_values.push_back(Elt: v); |
| 5227 | } |
| 5228 | |
| 5229 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 5230 | return ::mlir::success(); |
| 5231 | } |
| 5232 | }; |
| 5233 | |
| 5234 | /* Generated from: |
| 5235 | ArithCanonicalization.td:285 |
| 5236 | */ |
| 5237 | struct XOrINotCmpI : public ::mlir::RewritePattern { |
| 5238 | XOrINotCmpI(::mlir::MLIRContext *context) |
| 5239 | : ::mlir::RewritePattern("arith.xori" , 2, context, {"arith.cmpi" }) {} |
| 5240 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 5241 | ::mlir::PatternRewriter &rewriter) const override { |
| 5242 | // Variables for capturing values and attributes used while creating ops |
| 5243 | ::mlir::Operation::operand_range b(op0->getOperands()); |
| 5244 | ::mlir::Operation::operand_range a(op0->getOperands()); |
| 5245 | ::mlir::arith::CmpIPredicateAttr pred; |
| 5246 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 5247 | |
| 5248 | // Match |
| 5249 | tblgen_ops.push_back(Elt: op0); |
| 5250 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::XOrIOp>(Val: op0); (void)castedOp0; |
| 5251 | { |
| 5252 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 5253 | if (!(op1)){ |
| 5254 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5255 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 5256 | }); |
| 5257 | } |
| 5258 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::CmpIOp>(Val: op1); (void)castedOp1; |
| 5259 | if (!(castedOp1)){ |
| 5260 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5261 | diag << "castedOp1 is not ::mlir::arith::CmpIOp type" ; |
| 5262 | }); |
| 5263 | } |
| 5264 | { |
| 5265 | [[maybe_unused]] auto tblgen_attr = castedOp1.getProperties().getPredicate(); |
| 5266 | if (!(tblgen_attr)){ |
| 5267 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5268 | diag << "expected op 'arith.cmpi' to have attribute 'predicate' of type '::mlir::arith::CmpIPredicateAttr'" ; |
| 5269 | }); |
| 5270 | } |
| 5271 | pred = tblgen_attr; |
| 5272 | } |
| 5273 | a = castedOp1.getODSOperands(index: 0); |
| 5274 | b = castedOp1.getODSOperands(index: 1); |
| 5275 | tblgen_ops.push_back(Elt: op1); |
| 5276 | } |
| 5277 | { |
| 5278 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 5279 | if (!(op1)){ |
| 5280 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5281 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 5282 | }); |
| 5283 | } |
| 5284 | if(::mlir::failed(Result: static_dag_matcher_21(rewriter, op0: op1, tblgen_ops))) { |
| 5285 | return ::mlir::failure(); |
| 5286 | } |
| 5287 | tblgen_ops.push_back(Elt: op1); |
| 5288 | } |
| 5289 | |
| 5290 | // Rewrite |
| 5291 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 5292 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 5293 | auto nativeVar_0 = invertPredicate(pred); (void)nativeVar_0; |
| 5294 | ::mlir::arith::CmpIOp tblgen_CmpIOp_1; |
| 5295 | { |
| 5296 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5297 | ::mlir::arith::CmpIOp::Properties tblgen_props; (void)tblgen_props; |
| 5298 | tblgen_props.predicate = ::llvm::dyn_cast_if_present<decltype(tblgen_props.predicate)>(Val&: nativeVar_0); |
| 5299 | tblgen_values.push_back(Elt: (*a.begin())); |
| 5300 | tblgen_values.push_back(Elt: (*b.begin())); |
| 5301 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 5302 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 5303 | tblgen_types.push_back(Elt: v.getType()); |
| 5304 | } |
| 5305 | tblgen_CmpIOp_1 = ::mlir::arith::CmpIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 5306 | } |
| 5307 | |
| 5308 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_CmpIOp_1.getODSResults(index: 0) }) { |
| 5309 | tblgen_repl_values.push_back(Elt: v); |
| 5310 | } |
| 5311 | |
| 5312 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 5313 | return ::mlir::success(); |
| 5314 | } |
| 5315 | }; |
| 5316 | |
| 5317 | /* Generated from: |
| 5318 | ArithCanonicalization.td:301 |
| 5319 | */ |
| 5320 | struct XOrIOfExtSI : public ::mlir::RewritePattern { |
| 5321 | XOrIOfExtSI(::mlir::MLIRContext *context) |
| 5322 | : ::mlir::RewritePattern("arith.xori" , 3, context, {"arith.extsi" , "arith.xori" }) {} |
| 5323 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 5324 | ::mlir::PatternRewriter &rewriter) const override { |
| 5325 | // Variables for capturing values and attributes used while creating ops |
| 5326 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 5327 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 5328 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 5329 | |
| 5330 | // Match |
| 5331 | tblgen_ops.push_back(Elt: op0); |
| 5332 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::XOrIOp>(Val: op0); (void)castedOp0; |
| 5333 | { |
| 5334 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 5335 | if (!(op1)){ |
| 5336 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5337 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 5338 | }); |
| 5339 | } |
| 5340 | if(::mlir::failed(Result: static_dag_matcher_8(rewriter, op0: op1, tblgen_ops, x))) { |
| 5341 | return ::mlir::failure(); |
| 5342 | } |
| 5343 | tblgen_ops.push_back(Elt: op1); |
| 5344 | } |
| 5345 | { |
| 5346 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 5347 | if (!(op1)){ |
| 5348 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5349 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 5350 | }); |
| 5351 | } |
| 5352 | if(::mlir::failed(Result: static_dag_matcher_9(rewriter, op0: op1, tblgen_ops, y))) { |
| 5353 | return ::mlir::failure(); |
| 5354 | } |
| 5355 | tblgen_ops.push_back(Elt: op1); |
| 5356 | } |
| 5357 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 5358 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5359 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 5360 | }); |
| 5361 | } |
| 5362 | |
| 5363 | // Rewrite |
| 5364 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 5365 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 5366 | ::mlir::arith::XOrIOp tblgen_XOrIOp_0; |
| 5367 | { |
| 5368 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5369 | ::mlir::arith::XOrIOp::Properties tblgen_props; (void)tblgen_props; |
| 5370 | tblgen_values.push_back(Elt: (*x.begin())); |
| 5371 | tblgen_values.push_back(Elt: (*y.begin())); |
| 5372 | tblgen_XOrIOp_0 = ::mlir::arith::XOrIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 5373 | } |
| 5374 | ::mlir::arith::ExtSIOp tblgen_ExtSIOp_1; |
| 5375 | { |
| 5376 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5377 | ::mlir::arith::ExtSIOp::Properties tblgen_props; (void)tblgen_props; |
| 5378 | tblgen_values.push_back(Elt: (*tblgen_XOrIOp_0.getODSResults(index: 0).begin())); |
| 5379 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 5380 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 5381 | tblgen_types.push_back(Elt: v.getType()); |
| 5382 | } |
| 5383 | tblgen_ExtSIOp_1 = ::mlir::arith::ExtSIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 5384 | } |
| 5385 | |
| 5386 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtSIOp_1.getODSResults(index: 0) }) { |
| 5387 | tblgen_repl_values.push_back(Elt: v); |
| 5388 | } |
| 5389 | |
| 5390 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 5391 | return ::mlir::success(); |
| 5392 | } |
| 5393 | }; |
| 5394 | |
| 5395 | /* Generated from: |
| 5396 | ArithCanonicalization.td:294 |
| 5397 | */ |
| 5398 | struct XOrIOfExtUI : public ::mlir::RewritePattern { |
| 5399 | XOrIOfExtUI(::mlir::MLIRContext *context) |
| 5400 | : ::mlir::RewritePattern("arith.xori" , 3, context, {"arith.extui" , "arith.xori" }) {} |
| 5401 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 5402 | ::mlir::PatternRewriter &rewriter) const override { |
| 5403 | // Variables for capturing values and attributes used while creating ops |
| 5404 | ::mlir::UnitAttr nneg2; |
| 5405 | ::mlir::Operation::operand_range y(op0->getOperands()); |
| 5406 | ::mlir::UnitAttr nneg1; |
| 5407 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 5408 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 5409 | |
| 5410 | // Match |
| 5411 | tblgen_ops.push_back(Elt: op0); |
| 5412 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::XOrIOp>(Val: op0); (void)castedOp0; |
| 5413 | { |
| 5414 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 5415 | if (!(op1)){ |
| 5416 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5417 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 5418 | }); |
| 5419 | } |
| 5420 | if(::mlir::failed(Result: static_dag_matcher_10(rewriter, op0: op1, tblgen_ops, nneg1, x))) { |
| 5421 | return ::mlir::failure(); |
| 5422 | } |
| 5423 | tblgen_ops.push_back(Elt: op1); |
| 5424 | } |
| 5425 | { |
| 5426 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 5427 | if (!(op1)){ |
| 5428 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5429 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 5430 | }); |
| 5431 | } |
| 5432 | if(::mlir::failed(Result: static_dag_matcher_11(rewriter, op0: op1, tblgen_ops, nneg2, y))) { |
| 5433 | return ::mlir::failure(); |
| 5434 | } |
| 5435 | tblgen_ops.push_back(Elt: op1); |
| 5436 | } |
| 5437 | if (!(((*x.begin()).getType() == (*y.begin()).getType()))){ |
| 5438 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5439 | diag << "entities 'x, y' failed to satisfy constraint: ''" ; |
| 5440 | }); |
| 5441 | } |
| 5442 | |
| 5443 | // Rewrite |
| 5444 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc(), tblgen_ops[2]->getLoc()}); (void)odsLoc; |
| 5445 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 5446 | ::mlir::arith::XOrIOp tblgen_XOrIOp_0; |
| 5447 | { |
| 5448 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5449 | ::mlir::arith::XOrIOp::Properties tblgen_props; (void)tblgen_props; |
| 5450 | tblgen_values.push_back(Elt: (*x.begin())); |
| 5451 | tblgen_values.push_back(Elt: (*y.begin())); |
| 5452 | tblgen_XOrIOp_0 = ::mlir::arith::XOrIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 5453 | } |
| 5454 | auto nativeVar_1 = (nneg1 && nneg2) ? nneg1 : UnitAttr(); (void)nativeVar_1; |
| 5455 | ::mlir::arith::ExtUIOp tblgen_ExtUIOp_2; |
| 5456 | { |
| 5457 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5458 | ::mlir::arith::ExtUIOp::Properties tblgen_props; (void)tblgen_props; |
| 5459 | tblgen_values.push_back(Elt: (*tblgen_XOrIOp_0.getODSResults(index: 0).begin())); |
| 5460 | tblgen_props.nonNeg = ::llvm::dyn_cast_if_present<decltype(tblgen_props.nonNeg)>(Val&: nativeVar_1); |
| 5461 | ::llvm::SmallVector<::mlir::Type, 4> tblgen_types; (void)tblgen_types; |
| 5462 | for (auto v: castedOp0.getODSResults(index: 0)) { |
| 5463 | tblgen_types.push_back(Elt: v.getType()); |
| 5464 | } |
| 5465 | tblgen_ExtUIOp_2 = ::mlir::arith::ExtUIOp::create(builder&: rewriter, location: odsLoc, resultTypes: tblgen_types, operands: tblgen_values, properties: tblgen_props); |
| 5466 | } |
| 5467 | |
| 5468 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_ExtUIOp_2.getODSResults(index: 0) }) { |
| 5469 | tblgen_repl_values.push_back(Elt: v); |
| 5470 | } |
| 5471 | |
| 5472 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 5473 | return ::mlir::success(); |
| 5474 | } |
| 5475 | }; |
| 5476 | |
| 5477 | /* Generated from: |
| 5478 | ArithCanonicalization.td:275 |
| 5479 | */ |
| 5480 | struct XOrIXOrIConstant : public ::mlir::RewritePattern { |
| 5481 | XOrIXOrIConstant(::mlir::MLIRContext *context) |
| 5482 | : ::mlir::RewritePattern("arith.xori" , 2, context, {"arith.constant" , "arith.xori" }) {} |
| 5483 | ::llvm::LogicalResult matchAndRewrite(::mlir::Operation *op0, |
| 5484 | ::mlir::PatternRewriter &rewriter) const override { |
| 5485 | // Variables for capturing values and attributes used while creating ops |
| 5486 | ::mlir::Attribute c1; |
| 5487 | ::mlir::Attribute c0; |
| 5488 | ::mlir::Operation::operand_range x(op0->getOperands()); |
| 5489 | ::mlir::arith::XOrIOp res; |
| 5490 | ::llvm::SmallVector<::mlir::Operation *, 4> tblgen_ops; |
| 5491 | |
| 5492 | // Match |
| 5493 | tblgen_ops.push_back(Elt: op0); |
| 5494 | auto castedOp0 = ::llvm::dyn_cast<::mlir::arith::XOrIOp>(Val: op0); (void)castedOp0; |
| 5495 | res = castedOp0; |
| 5496 | { |
| 5497 | auto *op1 = (*castedOp0.getODSOperands(index: 0).begin()).getDefiningOp(); |
| 5498 | if (!(op1)){ |
| 5499 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5500 | diag << "There's no operation that defines operand 0 of castedOp0" ; |
| 5501 | }); |
| 5502 | } |
| 5503 | auto castedOp1 = ::llvm::dyn_cast<::mlir::arith::XOrIOp>(Val: op1); (void)castedOp1; |
| 5504 | if (!(castedOp1)){ |
| 5505 | return rewriter.notifyMatchFailure(op: op1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5506 | diag << "castedOp1 is not ::mlir::arith::XOrIOp type" ; |
| 5507 | }); |
| 5508 | } |
| 5509 | x = castedOp1.getODSOperands(index: 0); |
| 5510 | { |
| 5511 | auto *op2 = (*castedOp1.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 5512 | if (!(op2)){ |
| 5513 | return rewriter.notifyMatchFailure(op: castedOp1, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5514 | diag << "There's no operation that defines operand 1 of castedOp1" ; |
| 5515 | }); |
| 5516 | } |
| 5517 | if(::mlir::failed(Result: static_dag_matcher_2(rewriter, op0: op2, tblgen_ops, c0))) { |
| 5518 | return ::mlir::failure(); |
| 5519 | } |
| 5520 | tblgen_ops.push_back(Elt: op2); |
| 5521 | } |
| 5522 | tblgen_ops.push_back(Elt: op1); |
| 5523 | } |
| 5524 | { |
| 5525 | auto *op1 = (*castedOp0.getODSOperands(index: 1).begin()).getDefiningOp(); |
| 5526 | if (!(op1)){ |
| 5527 | return rewriter.notifyMatchFailure(op: castedOp0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5528 | diag << "There's no operation that defines operand 1 of castedOp0" ; |
| 5529 | }); |
| 5530 | } |
| 5531 | if(::mlir::failed(Result: static_dag_matcher_4(rewriter, op0: op1, tblgen_ops, c1))) { |
| 5532 | return ::mlir::failure(); |
| 5533 | } |
| 5534 | tblgen_ops.push_back(Elt: op1); |
| 5535 | } |
| 5536 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c0).getType()))){ |
| 5537 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5538 | diag << "entities 'res, c0' failed to satisfy constraint: ''" ; |
| 5539 | }); |
| 5540 | } |
| 5541 | if (!(((*res.getODSResults(index: 0).begin()).getType() == cast<IntegerAttr>(Val&: c1).getType()))){ |
| 5542 | return rewriter.notifyMatchFailure(op: op0, reasonCallback: [&](::mlir::Diagnostic &diag) { |
| 5543 | diag << "entities 'res, c1' failed to satisfy constraint: ''" ; |
| 5544 | }); |
| 5545 | } |
| 5546 | |
| 5547 | // Rewrite |
| 5548 | auto odsLoc = rewriter.getFusedLoc(locs: {tblgen_ops[0]->getLoc(), tblgen_ops[1]->getLoc()}); (void)odsLoc; |
| 5549 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_repl_values; |
| 5550 | auto nativeVar_0 = xorIntegerAttrs(builder&: rewriter, res: (*res.getODSResults(index: 0).begin()), lhs: c0, rhs: c1); (void)nativeVar_0; |
| 5551 | ::mlir::arith::ConstantOp tblgen_ConstantOp_1; |
| 5552 | { |
| 5553 | tblgen_ConstantOp_1 = ::mlir::arith::ConstantOp::create(builder&: rewriter, location: odsLoc, |
| 5554 | /*value=*/value: nativeVar_0 |
| 5555 | ); |
| 5556 | } |
| 5557 | ::mlir::arith::XOrIOp tblgen_XOrIOp_2; |
| 5558 | { |
| 5559 | ::llvm::SmallVector<::mlir::Value, 4> tblgen_values; (void)tblgen_values; |
| 5560 | ::mlir::arith::XOrIOp::Properties tblgen_props; (void)tblgen_props; |
| 5561 | tblgen_values.push_back(Elt: (*x.begin())); |
| 5562 | tblgen_values.push_back(Elt: (*tblgen_ConstantOp_1.getODSResults(index: 0).begin())); |
| 5563 | tblgen_XOrIOp_2 = ::mlir::arith::XOrIOp::create(builder&: rewriter, location: odsLoc, operands: tblgen_values, properties: tblgen_props); |
| 5564 | } |
| 5565 | |
| 5566 | for (auto v: ::llvm::SmallVector<::mlir::Value, 4>{ tblgen_XOrIOp_2.getODSResults(index: 0) }) { |
| 5567 | tblgen_repl_values.push_back(Elt: v); |
| 5568 | } |
| 5569 | |
| 5570 | rewriter.replaceOp(op: op0, newValues: tblgen_repl_values); |
| 5571 | return ::mlir::success(); |
| 5572 | } |
| 5573 | }; |
| 5574 | |
| 5575 | [[maybe_unused]] void populateWithGenerated(::mlir::RewritePatternSet &patterns) { |
| 5576 | patterns.add<AddFOfNegFLhs>(arg: patterns.getContext()); |
| 5577 | patterns.add<AddFOfNegFRhs>(arg: patterns.getContext()); |
| 5578 | patterns.add<AddIAddConstant>(arg: patterns.getContext()); |
| 5579 | patterns.add<AddIMulNegativeOneLhs>(arg: patterns.getContext()); |
| 5580 | patterns.add<AddIMulNegativeOneRhs>(arg: patterns.getContext()); |
| 5581 | patterns.add<AddISubConstantLHS>(arg: patterns.getContext()); |
| 5582 | patterns.add<AddISubConstantRHS>(arg: patterns.getContext()); |
| 5583 | patterns.add<AddUIExtendedToAddI>(arg: patterns.getContext()); |
| 5584 | patterns.add<AndIAndIConstant>(arg: patterns.getContext()); |
| 5585 | patterns.add<AndOfExtSI>(arg: patterns.getContext()); |
| 5586 | patterns.add<AndOfExtUI>(arg: patterns.getContext()); |
| 5587 | patterns.add<BitcastOfBitcast>(arg: patterns.getContext()); |
| 5588 | patterns.add<CmpIExtSI>(arg: patterns.getContext()); |
| 5589 | patterns.add<CmpIExtUI>(arg: patterns.getContext()); |
| 5590 | patterns.add<DivFOfNegF>(arg: patterns.getContext()); |
| 5591 | patterns.add<ExtSIOfExtUI>(arg: patterns.getContext()); |
| 5592 | patterns.add<IndexCastOfExtSI>(arg: patterns.getContext()); |
| 5593 | patterns.add<IndexCastUIOfExtUI>(arg: patterns.getContext()); |
| 5594 | patterns.add<MulFOfNegF>(arg: patterns.getContext()); |
| 5595 | patterns.add<MulIMulIConstant>(arg: patterns.getContext()); |
| 5596 | patterns.add<MulSIExtendedRHSOne>(arg: patterns.getContext()); |
| 5597 | patterns.add<MulSIExtendedToMulI>(arg: patterns.getContext()); |
| 5598 | patterns.add<MulUIExtendedToMulI>(arg: patterns.getContext()); |
| 5599 | patterns.add<OrIOrIConstant>(arg: patterns.getContext()); |
| 5600 | patterns.add<OrOfExtSI>(arg: patterns.getContext()); |
| 5601 | patterns.add<OrOfExtUI>(arg: patterns.getContext()); |
| 5602 | patterns.add<RedundantSelectFalse>(arg: patterns.getContext()); |
| 5603 | patterns.add<RedundantSelectTrue>(arg: patterns.getContext()); |
| 5604 | patterns.add<SIToFPOfExtSI>(arg: patterns.getContext()); |
| 5605 | patterns.add<SIToFPOfExtUI>(arg: patterns.getContext()); |
| 5606 | patterns.add<SelectCmpISgeToMaxSI>(arg: patterns.getContext()); |
| 5607 | patterns.add<SelectCmpISgeToMinSI>(arg: patterns.getContext()); |
| 5608 | patterns.add<SelectCmpISgtToMaxSI>(arg: patterns.getContext()); |
| 5609 | patterns.add<SelectCmpISgtToMinSI>(arg: patterns.getContext()); |
| 5610 | patterns.add<SelectCmpISleToMaxSI>(arg: patterns.getContext()); |
| 5611 | patterns.add<SelectCmpISleToMinSI>(arg: patterns.getContext()); |
| 5612 | patterns.add<SelectCmpISltToMaxSI>(arg: patterns.getContext()); |
| 5613 | patterns.add<SelectCmpISltToMinSI>(arg: patterns.getContext()); |
| 5614 | patterns.add<SelectCmpIUgeToMaxUI>(arg: patterns.getContext()); |
| 5615 | patterns.add<SelectCmpIUgeToMinUI>(arg: patterns.getContext()); |
| 5616 | patterns.add<SelectCmpIUgtToMaxUI>(arg: patterns.getContext()); |
| 5617 | patterns.add<SelectCmpIUgtToMinUI>(arg: patterns.getContext()); |
| 5618 | patterns.add<SelectCmpIUleToMaxUI>(arg: patterns.getContext()); |
| 5619 | patterns.add<SelectCmpIUleToMinUI>(arg: patterns.getContext()); |
| 5620 | patterns.add<SelectCmpIUltToMaxUI>(arg: patterns.getContext()); |
| 5621 | patterns.add<SelectCmpIUltToMinUI>(arg: patterns.getContext()); |
| 5622 | patterns.add<SelectI1ToNot>(arg: patterns.getContext()); |
| 5623 | patterns.add<SelectNotCond>(arg: patterns.getContext()); |
| 5624 | patterns.add<SubFOfNegZero>(arg: patterns.getContext()); |
| 5625 | patterns.add<SubILHSAddConstant>(arg: patterns.getContext()); |
| 5626 | patterns.add<SubILHSSubConstantLHS>(arg: patterns.getContext()); |
| 5627 | patterns.add<SubILHSSubConstantRHS>(arg: patterns.getContext()); |
| 5628 | patterns.add<SubIRHSAddConstant>(arg: patterns.getContext()); |
| 5629 | patterns.add<SubIRHSSubConstantLHS>(arg: patterns.getContext()); |
| 5630 | patterns.add<SubIRHSSubConstantRHS>(arg: patterns.getContext()); |
| 5631 | patterns.add<SubISubILHSRHSLHS>(arg: patterns.getContext()); |
| 5632 | patterns.add<SubUIExtendedToSubI>(arg: patterns.getContext()); |
| 5633 | patterns.add<TruncFSIToFPToSIToFP>(arg: patterns.getContext()); |
| 5634 | patterns.add<TruncFUIToFPToUIToFP>(arg: patterns.getContext()); |
| 5635 | patterns.add<TruncIExtSIToExtSI>(arg: patterns.getContext()); |
| 5636 | patterns.add<TruncIExtUIToExtUI>(arg: patterns.getContext()); |
| 5637 | patterns.add<TruncIShrSIToTrunciShrUI>(arg: patterns.getContext()); |
| 5638 | patterns.add<UIToFPOfExtUI>(arg: patterns.getContext()); |
| 5639 | patterns.add<XOrINotCmpI>(arg: patterns.getContext()); |
| 5640 | patterns.add<XOrIOfExtSI>(arg: patterns.getContext()); |
| 5641 | patterns.add<XOrIOfExtUI>(arg: patterns.getContext()); |
| 5642 | patterns.add<XOrIXOrIConstant>(arg: patterns.getContext()); |
| 5643 | } |
| 5644 | |