Bug Summary

File:mlir/include/mlir/IR/Attributes.h
Warning:line 64, column 33
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ArithmeticOps.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -D MLIR_CUDA_CONVERSIONS_ENABLED=1 -D MLIR_ROCM_CONVERSIONS_ENABLED=1 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/mlir/lib/Dialect/Arithmetic/IR -I /build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/mlir/lib/Dialect/Arithmetic/IR -I include -I /build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/llvm/include -I /build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/mlir/include -I tools/mlir/include -D _FORTIFY_SOURCE=2 -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/= -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/= -O3 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/= -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-01-25-232935-20746-1 -x c++ /build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp

/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp

1//===- ArithmeticOps.cpp - MLIR Arithmetic dialect ops implementation -----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include <utility>
10
11#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
12#include "mlir/Dialect/CommonFolders.h"
13#include "mlir/IR/Builders.h"
14#include "mlir/IR/Matchers.h"
15#include "mlir/IR/OpImplementation.h"
16#include "mlir/IR/PatternMatch.h"
17#include "mlir/IR/TypeUtilities.h"
18
19#include "llvm/ADT/APSInt.h"
20
21using namespace mlir;
22using namespace mlir::arith;
23
24//===----------------------------------------------------------------------===//
25// Pattern helpers
26//===----------------------------------------------------------------------===//
27
28static IntegerAttr addIntegerAttrs(PatternRewriter &builder, Value res,
29 Attribute lhs, Attribute rhs) {
30 return builder.getIntegerAttr(res.getType(),
31 lhs.cast<IntegerAttr>().getInt() +
32 rhs.cast<IntegerAttr>().getInt());
33}
34
35static IntegerAttr subIntegerAttrs(PatternRewriter &builder, Value res,
36 Attribute lhs, Attribute rhs) {
37 return builder.getIntegerAttr(res.getType(),
38 lhs.cast<IntegerAttr>().getInt() -
39 rhs.cast<IntegerAttr>().getInt());
40}
41
42/// Invert an integer comparison predicate.
43arith::CmpIPredicate arith::invertPredicate(arith::CmpIPredicate pred) {
44 switch (pred) {
45 case arith::CmpIPredicate::eq:
46 return arith::CmpIPredicate::ne;
47 case arith::CmpIPredicate::ne:
48 return arith::CmpIPredicate::eq;
49 case arith::CmpIPredicate::slt:
50 return arith::CmpIPredicate::sge;
51 case arith::CmpIPredicate::sle:
52 return arith::CmpIPredicate::sgt;
53 case arith::CmpIPredicate::sgt:
54 return arith::CmpIPredicate::sle;
55 case arith::CmpIPredicate::sge:
56 return arith::CmpIPredicate::slt;
57 case arith::CmpIPredicate::ult:
58 return arith::CmpIPredicate::uge;
59 case arith::CmpIPredicate::ule:
60 return arith::CmpIPredicate::ugt;
61 case arith::CmpIPredicate::ugt:
62 return arith::CmpIPredicate::ule;
63 case arith::CmpIPredicate::uge:
64 return arith::CmpIPredicate::ult;
65 }
66 llvm_unreachable("unknown cmpi predicate kind")::llvm::llvm_unreachable_internal("unknown cmpi predicate kind"
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 66)
;
67}
68
69static arith::CmpIPredicateAttr invertPredicate(arith::CmpIPredicateAttr pred) {
70 return arith::CmpIPredicateAttr::get(pred.getContext(),
71 invertPredicate(pred.getValue()));
72}
73
74//===----------------------------------------------------------------------===//
75// TableGen'd canonicalization patterns
76//===----------------------------------------------------------------------===//
77
78namespace {
79#include "ArithmeticCanonicalization.inc"
80} // namespace
81
82//===----------------------------------------------------------------------===//
83// ConstantOp
84//===----------------------------------------------------------------------===//
85
86void arith::ConstantOp::getAsmResultNames(
87 function_ref<void(Value, StringRef)> setNameFn) {
88 auto type = getType();
89 if (auto intCst = getValue().dyn_cast<IntegerAttr>()) {
90 auto intType = type.dyn_cast<IntegerType>();
91
92 // Sugar i1 constants with 'true' and 'false'.
93 if (intType && intType.getWidth() == 1)
94 return setNameFn(getResult(), (intCst.getInt() ? "true" : "false"));
95
96 // Otherwise, build a compex name with the value and type.
97 SmallString<32> specialNameBuffer;
98 llvm::raw_svector_ostream specialName(specialNameBuffer);
99 specialName << 'c' << intCst.getInt();
100 if (intType)
101 specialName << '_' << type;
102 setNameFn(getResult(), specialName.str());
103 } else {
104 setNameFn(getResult(), "cst");
105 }
106}
107
108/// TODO: disallow arith.constant to return anything other than signless integer
109/// or float like.
110static LogicalResult verify(arith::ConstantOp op) {
111 auto type = op.getType();
112 // The value's type must match the return type.
113 if (op.getValue().getType() != type) {
114 return op.emitOpError() << "value type " << op.getValue().getType()
115 << " must match return type: " << type;
116 }
117 // Integer values must be signless.
118 if (type.isa<IntegerType>() && !type.cast<IntegerType>().isSignless())
119 return op.emitOpError("integer return type must be signless");
120 // Any float or elements attribute are acceptable.
121 if (!op.getValue().isa<IntegerAttr, FloatAttr, ElementsAttr>()) {
122 return op.emitOpError(
123 "value must be an integer, float, or elements attribute");
124 }
125 return success();
126}
127
128bool arith::ConstantOp::isBuildableWith(Attribute value, Type type) {
129 // The value's type must be the same as the provided type.
130 if (value.getType() != type)
131 return false;
132 // Integer values must be signless.
133 if (type.isa<IntegerType>() && !type.cast<IntegerType>().isSignless())
134 return false;
135 // Integer, float, and element attributes are buildable.
136 return value.isa<IntegerAttr, FloatAttr, ElementsAttr>();
137}
138
139OpFoldResult arith::ConstantOp::fold(ArrayRef<Attribute> operands) {
140 return getValue();
141}
142
143void arith::ConstantIntOp::build(OpBuilder &builder, OperationState &result,
144 int64_t value, unsigned width) {
145 auto type = builder.getIntegerType(width);
146 arith::ConstantOp::build(builder, result, type,
147 builder.getIntegerAttr(type, value));
148}
149
150void arith::ConstantIntOp::build(OpBuilder &builder, OperationState &result,
151 int64_t value, Type type) {
152 assert(type.isSignlessInteger() &&(static_cast <bool> (type.isSignlessInteger() &&
"ConstantIntOp can only have signless integer type values") ?
void (0) : __assert_fail ("type.isSignlessInteger() && \"ConstantIntOp can only have signless integer type values\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 153, __extension__
__PRETTY_FUNCTION__))
153 "ConstantIntOp can only have signless integer type values")(static_cast <bool> (type.isSignlessInteger() &&
"ConstantIntOp can only have signless integer type values") ?
void (0) : __assert_fail ("type.isSignlessInteger() && \"ConstantIntOp can only have signless integer type values\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 153, __extension__
__PRETTY_FUNCTION__))
;
154 arith::ConstantOp::build(builder, result, type,
155 builder.getIntegerAttr(type, value));
156}
157
158bool arith::ConstantIntOp::classof(Operation *op) {
159 if (auto constOp = dyn_cast_or_null<arith::ConstantOp>(op))
160 return constOp.getType().isSignlessInteger();
161 return false;
162}
163
164void arith::ConstantFloatOp::build(OpBuilder &builder, OperationState &result,
165 const APFloat &value, FloatType type) {
166 arith::ConstantOp::build(builder, result, type,
167 builder.getFloatAttr(type, value));
168}
169
170bool arith::ConstantFloatOp::classof(Operation *op) {
171 if (auto constOp = dyn_cast_or_null<arith::ConstantOp>(op))
172 return constOp.getType().isa<FloatType>();
173 return false;
174}
175
176void arith::ConstantIndexOp::build(OpBuilder &builder, OperationState &result,
177 int64_t value) {
178 arith::ConstantOp::build(builder, result, builder.getIndexType(),
179 builder.getIndexAttr(value));
180}
181
182bool arith::ConstantIndexOp::classof(Operation *op) {
183 if (auto constOp = dyn_cast_or_null<arith::ConstantOp>(op))
184 return constOp.getType().isIndex();
185 return false;
186}
187
188//===----------------------------------------------------------------------===//
189// AddIOp
190//===----------------------------------------------------------------------===//
191
192OpFoldResult arith::AddIOp::fold(ArrayRef<Attribute> operands) {
193 // addi(x, 0) -> x
194 if (matchPattern(getRhs(), m_Zero()))
195 return getLhs();
196
197 // add(sub(a, b), b) -> a
198 if (auto sub = getLhs().getDefiningOp<SubIOp>())
199 if (getRhs() == sub.getRhs())
200 return sub.getLhs();
201
202 // add(b, sub(a, b)) -> a
203 if (auto sub = getRhs().getDefiningOp<SubIOp>())
204 if (getLhs() == sub.getRhs())
205 return sub.getLhs();
206
207 return constFoldBinaryOp<IntegerAttr>(
208 operands, [](APInt a, const APInt &b) { return std::move(a) + b; });
209}
210
211void arith::AddIOp::getCanonicalizationPatterns(
212 OwningRewritePatternList &patterns, MLIRContext *context) {
213 patterns.insert<AddIAddConstant, AddISubConstantRHS, AddISubConstantLHS>(
214 context);
215}
216
217//===----------------------------------------------------------------------===//
218// SubIOp
219//===----------------------------------------------------------------------===//
220
221OpFoldResult arith::SubIOp::fold(ArrayRef<Attribute> operands) {
222 // subi(x,x) -> 0
223 if (getOperand(0) == getOperand(1))
224 return Builder(getContext()).getZeroAttr(getType());
225 // subi(x,0) -> x
226 if (matchPattern(getRhs(), m_Zero()))
227 return getLhs();
228
229 return constFoldBinaryOp<IntegerAttr>(
230 operands, [](APInt a, const APInt &b) { return std::move(a) - b; });
231}
232
233void arith::SubIOp::getCanonicalizationPatterns(
234 OwningRewritePatternList &patterns, MLIRContext *context) {
235 patterns.insert<SubIRHSAddConstant, SubILHSAddConstant, SubIRHSSubConstantRHS,
236 SubIRHSSubConstantLHS, SubILHSSubConstantRHS,
237 SubILHSSubConstantLHS>(context);
238}
239
240//===----------------------------------------------------------------------===//
241// MulIOp
242//===----------------------------------------------------------------------===//
243
244OpFoldResult arith::MulIOp::fold(ArrayRef<Attribute> operands) {
245 // muli(x, 0) -> 0
246 if (matchPattern(getRhs(), m_Zero()))
247 return getRhs();
248 // muli(x, 1) -> x
249 if (matchPattern(getRhs(), m_One()))
250 return getOperand(0);
251 // TODO: Handle the overflow case.
252
253 // default folder
254 return constFoldBinaryOp<IntegerAttr>(
255 operands, [](const APInt &a, const APInt &b) { return a * b; });
256}
257
258//===----------------------------------------------------------------------===//
259// DivUIOp
260//===----------------------------------------------------------------------===//
261
262OpFoldResult arith::DivUIOp::fold(ArrayRef<Attribute> operands) {
263 // Don't fold if it would require a division by zero.
264 bool div0 = false;
265 auto result =
266 constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
267 if (div0 || !b) {
268 div0 = true;
269 return a;
270 }
271 return a.udiv(b);
272 });
273
274 // Fold out division by one. Assumes all tensors of all ones are splats.
275 if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
276 if (rhs.getValue() == 1)
277 return getLhs();
278 } else if (auto rhs = operands[1].dyn_cast_or_null<SplatElementsAttr>()) {
279 if (rhs.getSplatValue<IntegerAttr>().getValue() == 1)
280 return getLhs();
281 }
282
283 return div0 ? Attribute() : result;
284}
285
286//===----------------------------------------------------------------------===//
287// DivSIOp
288//===----------------------------------------------------------------------===//
289
290OpFoldResult arith::DivSIOp::fold(ArrayRef<Attribute> operands) {
291 // Don't fold if it would overflow or if it requires a division by zero.
292 bool overflowOrDiv0 = false;
293 auto result =
294 constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
295 if (overflowOrDiv0 || !b) {
296 overflowOrDiv0 = true;
297 return a;
298 }
299 return a.sdiv_ov(b, overflowOrDiv0);
300 });
301
302 // Fold out division by one. Assumes all tensors of all ones are splats.
303 if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
304 if (rhs.getValue() == 1)
305 return getLhs();
306 } else if (auto rhs = operands[1].dyn_cast_or_null<SplatElementsAttr>()) {
307 if (rhs.getSplatValue<IntegerAttr>().getValue() == 1)
308 return getLhs();
309 }
310
311 return overflowOrDiv0 ? Attribute() : result;
312}
313
314//===----------------------------------------------------------------------===//
315// Ceil and floor division folding helpers
316//===----------------------------------------------------------------------===//
317
318static APInt signedCeilNonnegInputs(const APInt &a, const APInt &b,
319 bool &overflow) {
320 // Returns (a-1)/b + 1
321 APInt one(a.getBitWidth(), 1, true); // Signed value 1.
322 APInt val = a.ssub_ov(one, overflow).sdiv_ov(b, overflow);
323 return val.sadd_ov(one, overflow);
324}
325
326//===----------------------------------------------------------------------===//
327// CeilDivUIOp
328//===----------------------------------------------------------------------===//
329
330OpFoldResult arith::CeilDivUIOp::fold(ArrayRef<Attribute> operands) {
331 bool overflowOrDiv0 = false;
332 auto result =
333 constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
334 if (overflowOrDiv0 || !b) {
335 overflowOrDiv0 = true;
336 return a;
337 }
338 APInt quotient = a.udiv(b);
339 if (!a.urem(b))
340 return quotient;
341 APInt one(a.getBitWidth(), 1, true);
342 return quotient.uadd_ov(one, overflowOrDiv0);
343 });
344 // Fold out ceil division by one. Assumes all tensors of all ones are
345 // splats.
346 if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
347 if (rhs.getValue() == 1)
348 return getLhs();
349 } else if (auto rhs = operands[1].dyn_cast_or_null<SplatElementsAttr>()) {
350 if (rhs.getSplatValue<IntegerAttr>().getValue() == 1)
351 return getLhs();
352 }
353
354 return overflowOrDiv0 ? Attribute() : result;
355}
356
357//===----------------------------------------------------------------------===//
358// CeilDivSIOp
359//===----------------------------------------------------------------------===//
360
361OpFoldResult arith::CeilDivSIOp::fold(ArrayRef<Attribute> operands) {
362 // Don't fold if it would overflow or if it requires a division by zero.
363 bool overflowOrDiv0 = false;
364 auto result =
365 constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
366 if (overflowOrDiv0 || !b) {
367 overflowOrDiv0 = true;
368 return a;
369 }
370 if (!a)
371 return a;
372 // After this point we know that neither a or b are zero.
373 unsigned bits = a.getBitWidth();
374 APInt zero = APInt::getZero(bits);
375 bool aGtZero = a.sgt(zero);
376 bool bGtZero = b.sgt(zero);
377 if (aGtZero && bGtZero) {
378 // Both positive, return ceil(a, b).
379 return signedCeilNonnegInputs(a, b, overflowOrDiv0);
380 }
381 if (!aGtZero && !bGtZero) {
382 // Both negative, return ceil(-a, -b).
383 APInt posA = zero.ssub_ov(a, overflowOrDiv0);
384 APInt posB = zero.ssub_ov(b, overflowOrDiv0);
385 return signedCeilNonnegInputs(posA, posB, overflowOrDiv0);
386 }
387 if (!aGtZero && bGtZero) {
388 // A is negative, b is positive, return - ( -a / b).
389 APInt posA = zero.ssub_ov(a, overflowOrDiv0);
390 APInt div = posA.sdiv_ov(b, overflowOrDiv0);
391 return zero.ssub_ov(div, overflowOrDiv0);
392 }
393 // A is positive, b is negative, return - (a / -b).
394 APInt posB = zero.ssub_ov(b, overflowOrDiv0);
395 APInt div = a.sdiv_ov(posB, overflowOrDiv0);
396 return zero.ssub_ov(div, overflowOrDiv0);
397 });
398
399 // Fold out ceil division by one. Assumes all tensors of all ones are
400 // splats.
401 if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
402 if (rhs.getValue() == 1)
403 return getLhs();
404 } else if (auto rhs = operands[1].dyn_cast_or_null<SplatElementsAttr>()) {
405 if (rhs.getSplatValue<IntegerAttr>().getValue() == 1)
406 return getLhs();
407 }
408
409 return overflowOrDiv0 ? Attribute() : result;
410}
411
412//===----------------------------------------------------------------------===//
413// FloorDivSIOp
414//===----------------------------------------------------------------------===//
415
416OpFoldResult arith::FloorDivSIOp::fold(ArrayRef<Attribute> operands) {
417 // Don't fold if it would overflow or if it requires a division by zero.
418 bool overflowOrDiv0 = false;
419 auto result =
420 constFoldBinaryOp<IntegerAttr>(operands, [&](APInt a, const APInt &b) {
421 if (overflowOrDiv0 || !b) {
422 overflowOrDiv0 = true;
423 return a;
424 }
425 if (!a)
426 return a;
427 // After this point we know that neither a or b are zero.
428 unsigned bits = a.getBitWidth();
429 APInt zero = APInt::getZero(bits);
430 bool aGtZero = a.sgt(zero);
431 bool bGtZero = b.sgt(zero);
432 if (aGtZero && bGtZero) {
433 // Both positive, return a / b.
434 return a.sdiv_ov(b, overflowOrDiv0);
435 }
436 if (!aGtZero && !bGtZero) {
437 // Both negative, return -a / -b.
438 APInt posA = zero.ssub_ov(a, overflowOrDiv0);
439 APInt posB = zero.ssub_ov(b, overflowOrDiv0);
440 return posA.sdiv_ov(posB, overflowOrDiv0);
441 }
442 if (!aGtZero && bGtZero) {
443 // A is negative, b is positive, return - ceil(-a, b).
444 APInt posA = zero.ssub_ov(a, overflowOrDiv0);
445 APInt ceil = signedCeilNonnegInputs(posA, b, overflowOrDiv0);
446 return zero.ssub_ov(ceil, overflowOrDiv0);
447 }
448 // A is positive, b is negative, return - ceil(a, -b).
449 APInt posB = zero.ssub_ov(b, overflowOrDiv0);
450 APInt ceil = signedCeilNonnegInputs(a, posB, overflowOrDiv0);
451 return zero.ssub_ov(ceil, overflowOrDiv0);
452 });
453
454 // Fold out floor division by one. Assumes all tensors of all ones are
455 // splats.
456 if (auto rhs = operands[1].dyn_cast_or_null<IntegerAttr>()) {
457 if (rhs.getValue() == 1)
458 return getLhs();
459 } else if (auto rhs = operands[1].dyn_cast_or_null<SplatElementsAttr>()) {
460 if (rhs.getSplatValue<IntegerAttr>().getValue() == 1)
461 return getLhs();
462 }
463
464 return overflowOrDiv0 ? Attribute() : result;
465}
466
467//===----------------------------------------------------------------------===//
468// RemUIOp
469//===----------------------------------------------------------------------===//
470
471OpFoldResult arith::RemUIOp::fold(ArrayRef<Attribute> operands) {
472 auto rhs = operands.back().dyn_cast_or_null<IntegerAttr>();
473 if (!rhs)
474 return {};
475 auto rhsValue = rhs.getValue();
476
477 // x % 1 = 0
478 if (rhsValue.isOneValue())
479 return IntegerAttr::get(rhs.getType(), APInt(rhsValue.getBitWidth(), 0));
480
481 // Don't fold if it requires division by zero.
482 if (rhsValue.isNullValue())
483 return {};
484
485 auto lhs = operands.front().dyn_cast_or_null<IntegerAttr>();
486 if (!lhs)
487 return {};
488 return IntegerAttr::get(lhs.getType(), lhs.getValue().urem(rhsValue));
489}
490
491//===----------------------------------------------------------------------===//
492// RemSIOp
493//===----------------------------------------------------------------------===//
494
495OpFoldResult arith::RemSIOp::fold(ArrayRef<Attribute> operands) {
496 auto rhs = operands.back().dyn_cast_or_null<IntegerAttr>();
497 if (!rhs)
498 return {};
499 auto rhsValue = rhs.getValue();
500
501 // x % 1 = 0
502 if (rhsValue.isOneValue())
503 return IntegerAttr::get(rhs.getType(), APInt(rhsValue.getBitWidth(), 0));
504
505 // Don't fold if it requires division by zero.
506 if (rhsValue.isNullValue())
507 return {};
508
509 auto lhs = operands.front().dyn_cast_or_null<IntegerAttr>();
510 if (!lhs)
511 return {};
512 return IntegerAttr::get(lhs.getType(), lhs.getValue().srem(rhsValue));
513}
514
515//===----------------------------------------------------------------------===//
516// AndIOp
517//===----------------------------------------------------------------------===//
518
519OpFoldResult arith::AndIOp::fold(ArrayRef<Attribute> operands) {
520 /// and(x, 0) -> 0
521 if (matchPattern(getRhs(), m_Zero()))
522 return getRhs();
523 /// and(x, allOnes) -> x
524 APInt intValue;
525 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isAllOnes())
526 return getLhs();
527
528 return constFoldBinaryOp<IntegerAttr>(
529 operands, [](APInt a, const APInt &b) { return std::move(a) & b; });
530}
531
532//===----------------------------------------------------------------------===//
533// OrIOp
534//===----------------------------------------------------------------------===//
535
536OpFoldResult arith::OrIOp::fold(ArrayRef<Attribute> operands) {
537 /// or(x, 0) -> x
538 if (matchPattern(getRhs(), m_Zero()))
539 return getLhs();
540 /// or(x, <all ones>) -> <all ones>
541 if (auto rhsAttr = operands[1].dyn_cast_or_null<IntegerAttr>())
542 if (rhsAttr.getValue().isAllOnes())
543 return rhsAttr;
544
545 return constFoldBinaryOp<IntegerAttr>(
546 operands, [](APInt a, const APInt &b) { return std::move(a) | b; });
547}
548
549//===----------------------------------------------------------------------===//
550// XOrIOp
551//===----------------------------------------------------------------------===//
552
553OpFoldResult arith::XOrIOp::fold(ArrayRef<Attribute> operands) {
554 /// xor(x, 0) -> x
555 if (matchPattern(getRhs(), m_Zero()))
556 return getLhs();
557 /// xor(x, x) -> 0
558 if (getLhs() == getRhs())
559 return Builder(getContext()).getZeroAttr(getType());
560 /// xor(xor(x, a), a) -> x
561 if (arith::XOrIOp prev = getLhs().getDefiningOp<arith::XOrIOp>())
562 if (prev.getRhs() == getRhs())
563 return prev.getLhs();
564
565 return constFoldBinaryOp<IntegerAttr>(
566 operands, [](APInt a, const APInt &b) { return std::move(a) ^ b; });
567}
568
569void arith::XOrIOp::getCanonicalizationPatterns(
570 OwningRewritePatternList &patterns, MLIRContext *context) {
571 patterns.insert<XOrINotCmpI>(context);
572}
573
574//===----------------------------------------------------------------------===//
575// AddFOp
576//===----------------------------------------------------------------------===//
577
578OpFoldResult arith::AddFOp::fold(ArrayRef<Attribute> operands) {
579 return constFoldBinaryOp<FloatAttr>(
580 operands, [](const APFloat &a, const APFloat &b) { return a + b; });
581}
582
583//===----------------------------------------------------------------------===//
584// SubFOp
585//===----------------------------------------------------------------------===//
586
587OpFoldResult arith::SubFOp::fold(ArrayRef<Attribute> operands) {
588 return constFoldBinaryOp<FloatAttr>(
589 operands, [](const APFloat &a, const APFloat &b) { return a - b; });
590}
591
592//===----------------------------------------------------------------------===//
593// MaxSIOp
594//===----------------------------------------------------------------------===//
595
596OpFoldResult MaxSIOp::fold(ArrayRef<Attribute> operands) {
597 assert(operands.size() == 2 && "binary operation takes two operands")(static_cast <bool> (operands.size() == 2 && "binary operation takes two operands"
) ? void (0) : __assert_fail ("operands.size() == 2 && \"binary operation takes two operands\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 597, __extension__
__PRETTY_FUNCTION__))
;
598
599 // maxsi(x,x) -> x
600 if (getLhs() == getRhs())
601 return getRhs();
602
603 APInt intValue;
604 // maxsi(x,MAX_INT) -> MAX_INT
605 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) &&
606 intValue.isMaxSignedValue())
607 return getRhs();
608
609 // maxsi(x, MIN_INT) -> x
610 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) &&
611 intValue.isMinSignedValue())
612 return getLhs();
613
614 return constFoldBinaryOp<IntegerAttr>(operands,
615 [](const APInt &a, const APInt &b) {
616 return llvm::APIntOps::smax(a, b);
617 });
618}
619
620//===----------------------------------------------------------------------===//
621// MaxUIOp
622//===----------------------------------------------------------------------===//
623
624OpFoldResult MaxUIOp::fold(ArrayRef<Attribute> operands) {
625 assert(operands.size() == 2 && "binary operation takes two operands")(static_cast <bool> (operands.size() == 2 && "binary operation takes two operands"
) ? void (0) : __assert_fail ("operands.size() == 2 && \"binary operation takes two operands\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 625, __extension__
__PRETTY_FUNCTION__))
;
626
627 // maxui(x,x) -> x
628 if (getLhs() == getRhs())
629 return getRhs();
630
631 APInt intValue;
632 // maxui(x,MAX_INT) -> MAX_INT
633 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isMaxValue())
634 return getRhs();
635
636 // maxui(x, MIN_INT) -> x
637 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isMinValue())
638 return getLhs();
639
640 return constFoldBinaryOp<IntegerAttr>(operands,
641 [](const APInt &a, const APInt &b) {
642 return llvm::APIntOps::umax(a, b);
643 });
644}
645
646//===----------------------------------------------------------------------===//
647// MinSIOp
648//===----------------------------------------------------------------------===//
649
650OpFoldResult MinSIOp::fold(ArrayRef<Attribute> operands) {
651 assert(operands.size() == 2 && "binary operation takes two operands")(static_cast <bool> (operands.size() == 2 && "binary operation takes two operands"
) ? void (0) : __assert_fail ("operands.size() == 2 && \"binary operation takes two operands\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 651, __extension__
__PRETTY_FUNCTION__))
;
652
653 // minsi(x,x) -> x
654 if (getLhs() == getRhs())
655 return getRhs();
656
657 APInt intValue;
658 // minsi(x,MIN_INT) -> MIN_INT
659 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) &&
660 intValue.isMinSignedValue())
661 return getRhs();
662
663 // minsi(x, MAX_INT) -> x
664 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) &&
665 intValue.isMaxSignedValue())
666 return getLhs();
667
668 return constFoldBinaryOp<IntegerAttr>(operands,
669 [](const APInt &a, const APInt &b) {
670 return llvm::APIntOps::smin(a, b);
671 });
672}
673
674//===----------------------------------------------------------------------===//
675// MinUIOp
676//===----------------------------------------------------------------------===//
677
678OpFoldResult MinUIOp::fold(ArrayRef<Attribute> operands) {
679 assert(operands.size() == 2 && "binary operation takes two operands")(static_cast <bool> (operands.size() == 2 && "binary operation takes two operands"
) ? void (0) : __assert_fail ("operands.size() == 2 && \"binary operation takes two operands\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 679, __extension__
__PRETTY_FUNCTION__))
;
680
681 // minui(x,x) -> x
682 if (getLhs() == getRhs())
683 return getRhs();
684
685 APInt intValue;
686 // minui(x,MIN_INT) -> MIN_INT
687 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isMinValue())
688 return getRhs();
689
690 // minui(x, MAX_INT) -> x
691 if (matchPattern(getRhs(), m_ConstantInt(&intValue)) && intValue.isMaxValue())
692 return getLhs();
693
694 return constFoldBinaryOp<IntegerAttr>(operands,
695 [](const APInt &a, const APInt &b) {
696 return llvm::APIntOps::umin(a, b);
697 });
698}
699
700//===----------------------------------------------------------------------===//
701// MulFOp
702//===----------------------------------------------------------------------===//
703
704OpFoldResult arith::MulFOp::fold(ArrayRef<Attribute> operands) {
705 return constFoldBinaryOp<FloatAttr>(
706 operands, [](const APFloat &a, const APFloat &b) { return a * b; });
707}
708
709//===----------------------------------------------------------------------===//
710// DivFOp
711//===----------------------------------------------------------------------===//
712
713OpFoldResult arith::DivFOp::fold(ArrayRef<Attribute> operands) {
714 return constFoldBinaryOp<FloatAttr>(
715 operands, [](const APFloat &a, const APFloat &b) { return a / b; });
716}
717
718//===----------------------------------------------------------------------===//
719// Utility functions for verifying cast ops
720//===----------------------------------------------------------------------===//
721
722template <typename... Types>
723using type_list = std::tuple<Types...> *;
724
725/// Returns a non-null type only if the provided type is one of the allowed
726/// types or one of the allowed shaped types of the allowed types. Returns the
727/// element type if a valid shaped type is provided.
728template <typename... ShapedTypes, typename... ElementTypes>
729static Type getUnderlyingType(Type type, type_list<ShapedTypes...>,
730 type_list<ElementTypes...>) {
731 if (type.isa<ShapedType>() && !type.isa<ShapedTypes...>())
732 return {};
733
734 auto underlyingType = getElementTypeOrSelf(type);
735 if (!underlyingType.isa<ElementTypes...>())
736 return {};
737
738 return underlyingType;
739}
740
741/// Get allowed underlying types for vectors and tensors.
742template <typename... ElementTypes>
743static Type getTypeIfLike(Type type) {
744 return getUnderlyingType(type, type_list<VectorType, TensorType>(),
745 type_list<ElementTypes...>());
746}
747
748/// Get allowed underlying types for vectors, tensors, and memrefs.
749template <typename... ElementTypes>
750static Type getTypeIfLikeOrMemRef(Type type) {
751 return getUnderlyingType(type,
752 type_list<VectorType, TensorType, MemRefType>(),
753 type_list<ElementTypes...>());
754}
755
756static bool areValidCastInputsAndOutputs(TypeRange inputs, TypeRange outputs) {
757 return inputs.size() == 1 && outputs.size() == 1 &&
758 succeeded(verifyCompatibleShapes(inputs.front(), outputs.front()));
759}
760
761//===----------------------------------------------------------------------===//
762// Verifiers for integer and floating point extension/truncation ops
763//===----------------------------------------------------------------------===//
764
765// Extend ops can only extend to a wider type.
766template <typename ValType, typename Op>
767static LogicalResult verifyExtOp(Op op) {
768 Type srcType = getElementTypeOrSelf(op.getIn().getType());
769 Type dstType = getElementTypeOrSelf(op.getType());
770
771 if (srcType.cast<ValType>().getWidth() >= dstType.cast<ValType>().getWidth())
772 return op.emitError("result type ")
773 << dstType << " must be wider than operand type " << srcType;
774
775 return success();
776}
777
778// Truncate ops can only truncate to a shorter type.
779template <typename ValType, typename Op>
780static LogicalResult verifyTruncateOp(Op op) {
781 Type srcType = getElementTypeOrSelf(op.getIn().getType());
782 Type dstType = getElementTypeOrSelf(op.getType());
783
784 if (srcType.cast<ValType>().getWidth() <= dstType.cast<ValType>().getWidth())
785 return op.emitError("result type ")
786 << dstType << " must be shorter than operand type " << srcType;
787
788 return success();
789}
790
791/// Validate a cast that changes the width of a type.
792template <template <typename> class WidthComparator, typename... ElementTypes>
793static bool checkWidthChangeCast(TypeRange inputs, TypeRange outputs) {
794 if (!areValidCastInputsAndOutputs(inputs, outputs))
795 return false;
796
797 auto srcType = getTypeIfLike<ElementTypes...>(inputs.front());
798 auto dstType = getTypeIfLike<ElementTypes...>(outputs.front());
799 if (!srcType || !dstType)
800 return false;
801
802 return WidthComparator<unsigned>()(dstType.getIntOrFloatBitWidth(),
803 srcType.getIntOrFloatBitWidth());
804}
805
806//===----------------------------------------------------------------------===//
807// ExtUIOp
808//===----------------------------------------------------------------------===//
809
810OpFoldResult arith::ExtUIOp::fold(ArrayRef<Attribute> operands) {
811 if (auto lhs = operands[0].dyn_cast_or_null<IntegerAttr>())
812 return IntegerAttr::get(
813 getType(), lhs.getValue().zext(getType().getIntOrFloatBitWidth()));
814
815 if (auto lhs = getIn().getDefiningOp<ExtUIOp>()) {
816 getInMutable().assign(lhs.getIn());
817 return getResult();
818 }
819
820 return {};
821}
822
823bool arith::ExtUIOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
824 return checkWidthChangeCast<std::greater, IntegerType>(inputs, outputs);
825}
826
827//===----------------------------------------------------------------------===//
828// ExtSIOp
829//===----------------------------------------------------------------------===//
830
831OpFoldResult arith::ExtSIOp::fold(ArrayRef<Attribute> operands) {
832 if (auto lhs = operands[0].dyn_cast_or_null<IntegerAttr>())
833 return IntegerAttr::get(
834 getType(), lhs.getValue().sext(getType().getIntOrFloatBitWidth()));
835
836 if (auto lhs = getIn().getDefiningOp<ExtSIOp>()) {
837 getInMutable().assign(lhs.getIn());
838 return getResult();
839 }
840
841 return {};
842}
843
844bool arith::ExtSIOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
845 return checkWidthChangeCast<std::greater, IntegerType>(inputs, outputs);
846}
847
848void arith::ExtSIOp::getCanonicalizationPatterns(
849 OwningRewritePatternList &patterns, MLIRContext *context) {
850 patterns.insert<ExtSIOfExtUI>(context);
851}
852
853//===----------------------------------------------------------------------===//
854// ExtFOp
855//===----------------------------------------------------------------------===//
856
857bool arith::ExtFOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
858 return checkWidthChangeCast<std::greater, FloatType>(inputs, outputs);
859}
860
861//===----------------------------------------------------------------------===//
862// TruncIOp
863//===----------------------------------------------------------------------===//
864
865OpFoldResult arith::TruncIOp::fold(ArrayRef<Attribute> operands) {
866 assert(operands.size() == 1 && "unary operation takes one operand")(static_cast <bool> (operands.size() == 1 && "unary operation takes one operand"
) ? void (0) : __assert_fail ("operands.size() == 1 && \"unary operation takes one operand\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 866, __extension__
__PRETTY_FUNCTION__))
;
867
868 // trunci(zexti(a)) -> a
869 // trunci(sexti(a)) -> a
870 if (matchPattern(getOperand(), m_Op<arith::ExtUIOp>()) ||
871 matchPattern(getOperand(), m_Op<arith::ExtSIOp>()))
872 return getOperand().getDefiningOp()->getOperand(0);
873
874 // trunci(trunci(a)) -> trunci(a))
875 if (matchPattern(getOperand(), m_Op<arith::TruncIOp>())) {
876 setOperand(getOperand().getDefiningOp()->getOperand(0));
877 return getResult();
878 }
879
880 if (!operands[0])
881 return {};
882
883 if (auto lhs = operands[0].dyn_cast<IntegerAttr>()) {
884 return IntegerAttr::get(
885 getType(), lhs.getValue().trunc(getType().getIntOrFloatBitWidth()));
886 }
887
888 return {};
889}
890
891bool arith::TruncIOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
892 return checkWidthChangeCast<std::less, IntegerType>(inputs, outputs);
893}
894
895//===----------------------------------------------------------------------===//
896// TruncFOp
897//===----------------------------------------------------------------------===//
898
899/// Perform safe const propagation for truncf, i.e. only propagate if FP value
900/// can be represented without precision loss or rounding.
901OpFoldResult arith::TruncFOp::fold(ArrayRef<Attribute> operands) {
902 assert(operands.size() == 1 && "unary operation takes one operand")(static_cast <bool> (operands.size() == 1 && "unary operation takes one operand"
) ? void (0) : __assert_fail ("operands.size() == 1 && \"unary operation takes one operand\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 902, __extension__
__PRETTY_FUNCTION__))
;
903
904 auto constOperand = operands.front();
905 if (!constOperand || !constOperand.isa<FloatAttr>())
906 return {};
907
908 // Convert to target type via 'double'.
909 double sourceValue =
910 constOperand.dyn_cast<FloatAttr>().getValue().convertToDouble();
911 auto targetAttr = FloatAttr::get(getType(), sourceValue);
912
913 // Propagate if constant's value does not change after truncation.
914 if (sourceValue == targetAttr.getValue().convertToDouble())
915 return targetAttr;
916
917 return {};
918}
919
920bool arith::TruncFOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
921 return checkWidthChangeCast<std::less, FloatType>(inputs, outputs);
922}
923
924//===----------------------------------------------------------------------===//
925// AndIOp
926//===----------------------------------------------------------------------===//
927
928void arith::AndIOp::getCanonicalizationPatterns(
929 OwningRewritePatternList &patterns, MLIRContext *context) {
930 patterns.insert<AndOfExtUI, AndOfExtSI>(context);
931}
932
933//===----------------------------------------------------------------------===//
934// OrIOp
935//===----------------------------------------------------------------------===//
936
937void arith::OrIOp::getCanonicalizationPatterns(
938 OwningRewritePatternList &patterns, MLIRContext *context) {
939 patterns.insert<OrOfExtUI, OrOfExtSI>(context);
940}
941
942//===----------------------------------------------------------------------===//
943// Verifiers for casts between integers and floats.
944//===----------------------------------------------------------------------===//
945
946template <typename From, typename To>
947static bool checkIntFloatCast(TypeRange inputs, TypeRange outputs) {
948 if (!areValidCastInputsAndOutputs(inputs, outputs))
949 return false;
950
951 auto srcType = getTypeIfLike<From>(inputs.front());
952 auto dstType = getTypeIfLike<To>(outputs.back());
953
954 return srcType && dstType;
955}
956
957//===----------------------------------------------------------------------===//
958// UIToFPOp
959//===----------------------------------------------------------------------===//
960
961bool arith::UIToFPOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
962 return checkIntFloatCast<IntegerType, FloatType>(inputs, outputs);
963}
964
965OpFoldResult arith::UIToFPOp::fold(ArrayRef<Attribute> operands) {
966 if (auto lhs = operands[0].dyn_cast_or_null<IntegerAttr>()) {
967 const APInt &api = lhs.getValue();
968 FloatType floatTy = getType().cast<FloatType>();
969 APFloat apf(floatTy.getFloatSemantics(),
970 APInt::getZero(floatTy.getWidth()));
971 apf.convertFromAPInt(api, /*IsSigned=*/false, APFloat::rmNearestTiesToEven);
972 return FloatAttr::get(floatTy, apf);
973 }
974 return {};
975}
976
977//===----------------------------------------------------------------------===//
978// SIToFPOp
979//===----------------------------------------------------------------------===//
980
981bool arith::SIToFPOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
982 return checkIntFloatCast<IntegerType, FloatType>(inputs, outputs);
983}
984
985OpFoldResult arith::SIToFPOp::fold(ArrayRef<Attribute> operands) {
986 if (auto lhs = operands[0].dyn_cast_or_null<IntegerAttr>()) {
987 const APInt &api = lhs.getValue();
988 FloatType floatTy = getType().cast<FloatType>();
989 APFloat apf(floatTy.getFloatSemantics(),
990 APInt::getZero(floatTy.getWidth()));
991 apf.convertFromAPInt(api, /*IsSigned=*/true, APFloat::rmNearestTiesToEven);
992 return FloatAttr::get(floatTy, apf);
993 }
994 return {};
995}
996//===----------------------------------------------------------------------===//
997// FPToUIOp
998//===----------------------------------------------------------------------===//
999
1000bool arith::FPToUIOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
1001 return checkIntFloatCast<FloatType, IntegerType>(inputs, outputs);
1002}
1003
1004OpFoldResult arith::FPToUIOp::fold(ArrayRef<Attribute> operands) {
1005 if (auto lhs = operands[0].dyn_cast_or_null<FloatAttr>()) {
1006 const APFloat &apf = lhs.getValue();
1007 IntegerType intTy = getType().cast<IntegerType>();
1008 bool ignored;
1009 APSInt api(intTy.getWidth(), /*isUnsigned=*/true);
1010 if (APFloat::opInvalidOp ==
1011 apf.convertToInteger(api, APFloat::rmTowardZero, &ignored)) {
1012 // Undefined behavior invoked - the destination type can't represent
1013 // the input constant.
1014 return {};
1015 }
1016 return IntegerAttr::get(getType(), api);
1017 }
1018
1019 return {};
1020}
1021
1022//===----------------------------------------------------------------------===//
1023// FPToSIOp
1024//===----------------------------------------------------------------------===//
1025
1026bool arith::FPToSIOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
1027 return checkIntFloatCast<FloatType, IntegerType>(inputs, outputs);
1028}
1029
1030OpFoldResult arith::FPToSIOp::fold(ArrayRef<Attribute> operands) {
1031 if (auto lhs = operands[0].dyn_cast_or_null<FloatAttr>()) {
1032 const APFloat &apf = lhs.getValue();
1033 IntegerType intTy = getType().cast<IntegerType>();
1034 bool ignored;
1035 APSInt api(intTy.getWidth(), /*isUnsigned=*/false);
1036 if (APFloat::opInvalidOp ==
1037 apf.convertToInteger(api, APFloat::rmTowardZero, &ignored)) {
1038 // Undefined behavior invoked - the destination type can't represent
1039 // the input constant.
1040 return {};
1041 }
1042 return IntegerAttr::get(getType(), api);
1043 }
1044
1045 return {};
1046}
1047
1048//===----------------------------------------------------------------------===//
1049// IndexCastOp
1050//===----------------------------------------------------------------------===//
1051
1052bool arith::IndexCastOp::areCastCompatible(TypeRange inputs,
1053 TypeRange outputs) {
1054 if (!areValidCastInputsAndOutputs(inputs, outputs))
1055 return false;
1056
1057 auto srcType = getTypeIfLikeOrMemRef<IntegerType, IndexType>(inputs.front());
1058 auto dstType = getTypeIfLikeOrMemRef<IntegerType, IndexType>(outputs.front());
1059 if (!srcType || !dstType)
1060 return false;
1061
1062 return (srcType.isIndex() && dstType.isSignlessInteger()) ||
1063 (srcType.isSignlessInteger() && dstType.isIndex());
1064}
1065
1066OpFoldResult arith::IndexCastOp::fold(ArrayRef<Attribute> operands) {
1067 // index_cast(constant) -> constant
1068 // A little hack because we go through int. Otherwise, the size of the
1069 // constant might need to change.
1070 if (auto value = operands[0].dyn_cast_or_null<IntegerAttr>())
1071 return IntegerAttr::get(getType(), value.getInt());
1072
1073 return {};
1074}
1075
1076void arith::IndexCastOp::getCanonicalizationPatterns(
1077 OwningRewritePatternList &patterns, MLIRContext *context) {
1078 patterns.insert<IndexCastOfIndexCast, IndexCastOfExtSI>(context);
1079}
1080
1081//===----------------------------------------------------------------------===//
1082// BitcastOp
1083//===----------------------------------------------------------------------===//
1084
1085bool arith::BitcastOp::areCastCompatible(TypeRange inputs, TypeRange outputs) {
1086 if (!areValidCastInputsAndOutputs(inputs, outputs))
1087 return false;
1088
1089 auto srcType =
1090 getTypeIfLikeOrMemRef<IntegerType, IndexType, FloatType>(inputs.front());
1091 auto dstType =
1092 getTypeIfLikeOrMemRef<IntegerType, IndexType, FloatType>(outputs.front());
1093 if (!srcType || !dstType)
1094 return false;
1095
1096 return srcType.getIntOrFloatBitWidth() == dstType.getIntOrFloatBitWidth();
1097}
1098
1099OpFoldResult arith::BitcastOp::fold(ArrayRef<Attribute> operands) {
1100 assert(operands.size() == 1 && "bitcast op expects 1 operand")(static_cast <bool> (operands.size() == 1 && "bitcast op expects 1 operand"
) ? void (0) : __assert_fail ("operands.size() == 1 && \"bitcast op expects 1 operand\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 1100, __extension__
__PRETTY_FUNCTION__))
;
1101
1102 auto resType = getType();
1103 auto operand = operands[0];
1104 if (!operand)
1105 return {};
1106
1107 /// Bitcast dense elements.
1108 if (auto denseAttr = operand.dyn_cast_or_null<DenseElementsAttr>())
1109 return denseAttr.bitcast(resType.cast<ShapedType>().getElementType());
1110 /// Other shaped types unhandled.
1111 if (resType.isa<ShapedType>())
1112 return {};
1113
1114 /// Bitcast integer or float to integer or float.
1115 APInt bits = operand.isa<FloatAttr>()
1116 ? operand.cast<FloatAttr>().getValue().bitcastToAPInt()
1117 : operand.cast<IntegerAttr>().getValue();
1118
1119 if (auto resFloatType = resType.dyn_cast<FloatType>())
1120 return FloatAttr::get(resType,
1121 APFloat(resFloatType.getFloatSemantics(), bits));
1122 return IntegerAttr::get(resType, bits);
1123}
1124
1125void arith::BitcastOp::getCanonicalizationPatterns(
1126 OwningRewritePatternList &patterns, MLIRContext *context) {
1127 patterns.insert<BitcastOfBitcast>(context);
1128}
1129
1130//===----------------------------------------------------------------------===//
1131// Helpers for compare ops
1132//===----------------------------------------------------------------------===//
1133
1134/// Return the type of the same shape (scalar, vector or tensor) containing i1.
1135static Type getI1SameShape(Type type) {
1136 auto i1Type = IntegerType::get(type.getContext(), 1);
1137 if (auto tensorType = type.dyn_cast<RankedTensorType>())
1138 return RankedTensorType::get(tensorType.getShape(), i1Type);
1139 if (type.isa<UnrankedTensorType>())
1140 return UnrankedTensorType::get(i1Type);
1141 if (auto vectorType = type.dyn_cast<VectorType>())
1142 return VectorType::get(vectorType.getShape(), i1Type,
1143 vectorType.getNumScalableDims());
1144 return i1Type;
1145}
1146
1147//===----------------------------------------------------------------------===//
1148// CmpIOp
1149//===----------------------------------------------------------------------===//
1150
1151/// Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer
1152/// comparison predicates.
1153bool mlir::arith::applyCmpPredicate(arith::CmpIPredicate predicate,
1154 const APInt &lhs, const APInt &rhs) {
1155 switch (predicate) {
1156 case arith::CmpIPredicate::eq:
1157 return lhs.eq(rhs);
1158 case arith::CmpIPredicate::ne:
1159 return lhs.ne(rhs);
1160 case arith::CmpIPredicate::slt:
1161 return lhs.slt(rhs);
1162 case arith::CmpIPredicate::sle:
1163 return lhs.sle(rhs);
1164 case arith::CmpIPredicate::sgt:
1165 return lhs.sgt(rhs);
1166 case arith::CmpIPredicate::sge:
1167 return lhs.sge(rhs);
1168 case arith::CmpIPredicate::ult:
1169 return lhs.ult(rhs);
1170 case arith::CmpIPredicate::ule:
1171 return lhs.ule(rhs);
1172 case arith::CmpIPredicate::ugt:
1173 return lhs.ugt(rhs);
1174 case arith::CmpIPredicate::uge:
1175 return lhs.uge(rhs);
1176 }
1177 llvm_unreachable("unknown cmpi predicate kind")::llvm::llvm_unreachable_internal("unknown cmpi predicate kind"
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 1177)
;
1178}
1179
1180/// Returns true if the predicate is true for two equal operands.
1181static bool applyCmpPredicateToEqualOperands(arith::CmpIPredicate predicate) {
1182 switch (predicate) {
1183 case arith::CmpIPredicate::eq:
1184 case arith::CmpIPredicate::sle:
1185 case arith::CmpIPredicate::sge:
1186 case arith::CmpIPredicate::ule:
1187 case arith::CmpIPredicate::uge:
1188 return true;
1189 case arith::CmpIPredicate::ne:
1190 case arith::CmpIPredicate::slt:
1191 case arith::CmpIPredicate::sgt:
1192 case arith::CmpIPredicate::ult:
1193 case arith::CmpIPredicate::ugt:
1194 return false;
1195 }
1196 llvm_unreachable("unknown cmpi predicate kind")::llvm::llvm_unreachable_internal("unknown cmpi predicate kind"
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 1196)
;
1197}
1198
1199static Attribute getBoolAttribute(Type type, MLIRContext *ctx, bool value) {
1200 auto boolAttr = BoolAttr::get(ctx, value);
1201 ShapedType shapedType = type.dyn_cast_or_null<ShapedType>();
1202 if (!shapedType)
1203 return boolAttr;
1204 return DenseElementsAttr::get(shapedType, boolAttr);
1205}
1206
1207OpFoldResult arith::CmpIOp::fold(ArrayRef<Attribute> operands) {
1208 assert(operands.size() == 2 && "cmpi takes two operands")(static_cast <bool> (operands.size() == 2 && "cmpi takes two operands"
) ? void (0) : __assert_fail ("operands.size() == 2 && \"cmpi takes two operands\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 1208, __extension__
__PRETTY_FUNCTION__))
;
1209
1210 // cmpi(pred, x, x)
1211 if (getLhs() == getRhs()) {
1212 auto val = applyCmpPredicateToEqualOperands(getPredicate());
1213 return getBoolAttribute(getType(), getContext(), val);
1214 }
1215
1216 if (matchPattern(getRhs(), m_Zero())) {
1217 if (auto extOp = getLhs().getDefiningOp<ExtSIOp>()) {
1218 if (extOp.getOperand().getType().cast<IntegerType>().getWidth() == 1) {
1219 // extsi(%x : i1 -> iN) != 0 -> %x
1220 if (getPredicate() == arith::CmpIPredicate::ne) {
1221 return extOp.getOperand();
1222 }
1223 }
1224 }
1225 if (auto extOp = getLhs().getDefiningOp<ExtUIOp>()) {
1226 if (extOp.getOperand().getType().cast<IntegerType>().getWidth() == 1) {
1227 // extui(%x : i1 -> iN) != 0 -> %x
1228 if (getPredicate() == arith::CmpIPredicate::ne) {
1229 return extOp.getOperand();
1230 }
1231 }
1232 }
1233 }
1234
1235 auto lhs = operands.front().dyn_cast_or_null<IntegerAttr>();
1236 auto rhs = operands.back().dyn_cast_or_null<IntegerAttr>();
1237 if (!lhs || !rhs)
1238 return {};
1239
1240 auto val = applyCmpPredicate(getPredicate(), lhs.getValue(), rhs.getValue());
1241 return BoolAttr::get(getContext(), val);
1242}
1243
1244//===----------------------------------------------------------------------===//
1245// CmpFOp
1246//===----------------------------------------------------------------------===//
1247
1248/// Compute `lhs` `pred` `rhs`, where `pred` is one of the known floating point
1249/// comparison predicates.
1250bool mlir::arith::applyCmpPredicate(arith::CmpFPredicate predicate,
1251 const APFloat &lhs, const APFloat &rhs) {
1252 auto cmpResult = lhs.compare(rhs);
1253 switch (predicate) {
1254 case arith::CmpFPredicate::AlwaysFalse:
1255 return false;
1256 case arith::CmpFPredicate::OEQ:
1257 return cmpResult == APFloat::cmpEqual;
1258 case arith::CmpFPredicate::OGT:
1259 return cmpResult == APFloat::cmpGreaterThan;
1260 case arith::CmpFPredicate::OGE:
1261 return cmpResult == APFloat::cmpGreaterThan ||
1262 cmpResult == APFloat::cmpEqual;
1263 case arith::CmpFPredicate::OLT:
1264 return cmpResult == APFloat::cmpLessThan;
1265 case arith::CmpFPredicate::OLE:
1266 return cmpResult == APFloat::cmpLessThan || cmpResult == APFloat::cmpEqual;
1267 case arith::CmpFPredicate::ONE:
1268 return cmpResult != APFloat::cmpUnordered && cmpResult != APFloat::cmpEqual;
1269 case arith::CmpFPredicate::ORD:
1270 return cmpResult != APFloat::cmpUnordered;
1271 case arith::CmpFPredicate::UEQ:
1272 return cmpResult == APFloat::cmpUnordered || cmpResult == APFloat::cmpEqual;
1273 case arith::CmpFPredicate::UGT:
1274 return cmpResult == APFloat::cmpUnordered ||
1275 cmpResult == APFloat::cmpGreaterThan;
1276 case arith::CmpFPredicate::UGE:
1277 return cmpResult == APFloat::cmpUnordered ||
1278 cmpResult == APFloat::cmpGreaterThan ||
1279 cmpResult == APFloat::cmpEqual;
1280 case arith::CmpFPredicate::ULT:
1281 return cmpResult == APFloat::cmpUnordered ||
1282 cmpResult == APFloat::cmpLessThan;
1283 case arith::CmpFPredicate::ULE:
1284 return cmpResult == APFloat::cmpUnordered ||
1285 cmpResult == APFloat::cmpLessThan || cmpResult == APFloat::cmpEqual;
1286 case arith::CmpFPredicate::UNE:
1287 return cmpResult != APFloat::cmpEqual;
1288 case arith::CmpFPredicate::UNO:
1289 return cmpResult == APFloat::cmpUnordered;
1290 case arith::CmpFPredicate::AlwaysTrue:
1291 return true;
1292 }
1293 llvm_unreachable("unknown cmpf predicate kind")::llvm::llvm_unreachable_internal("unknown cmpf predicate kind"
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 1293)
;
1294}
1295
1296OpFoldResult arith::CmpFOp::fold(ArrayRef<Attribute> operands) {
1297 assert(operands.size() == 2 && "cmpf takes two operands")(static_cast <bool> (operands.size() == 2 && "cmpf takes two operands"
) ? void (0) : __assert_fail ("operands.size() == 2 && \"cmpf takes two operands\""
, "mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp", 1297, __extension__
__PRETTY_FUNCTION__))
;
1298
1299 auto lhs = operands.front().dyn_cast_or_null<FloatAttr>();
1300 auto rhs = operands.back().dyn_cast_or_null<FloatAttr>();
1301
1302 // If one operand is NaN, making them both NaN does not change the result.
1303 if (lhs && lhs.getValue().isNaN())
1304 rhs = lhs;
1305 if (rhs && rhs.getValue().isNaN())
1306 lhs = rhs;
1307
1308 if (!lhs || !rhs)
1309 return {};
1310
1311 auto val = applyCmpPredicate(getPredicate(), lhs.getValue(), rhs.getValue());
1312 return BoolAttr::get(getContext(), val);
1313}
1314
1315//===----------------------------------------------------------------------===//
1316// Atomic Enum
1317//===----------------------------------------------------------------------===//
1318
1319/// Returns the identity value attribute associated with an AtomicRMWKind op.
1320Attribute mlir::arith::getIdentityValueAttr(AtomicRMWKind kind, Type resultType,
1321 OpBuilder &builder, Location loc) {
1322 switch (kind) {
1323 case AtomicRMWKind::maxf:
1324 return builder.getFloatAttr(
1325 resultType,
1326 APFloat::getInf(resultType.cast<FloatType>().getFloatSemantics(),
1327 /*Negative=*/true));
1328 case AtomicRMWKind::addf:
1329 case AtomicRMWKind::addi:
1330 case AtomicRMWKind::maxu:
1331 case AtomicRMWKind::ori:
1332 return builder.getZeroAttr(resultType);
1333 case AtomicRMWKind::andi:
1334 return builder.getIntegerAttr(
1335 resultType,
1336 APInt::getAllOnes(resultType.cast<IntegerType>().getWidth()));
1337 case AtomicRMWKind::maxs:
1338 return builder.getIntegerAttr(
1339 resultType,
1340 APInt::getSignedMinValue(resultType.cast<IntegerType>().getWidth()));
1341 case AtomicRMWKind::minf:
1342 return builder.getFloatAttr(
1343 resultType,
1344 APFloat::getInf(resultType.cast<FloatType>().getFloatSemantics(),
1345 /*Negative=*/false));
1346 case AtomicRMWKind::mins:
1347 return builder.getIntegerAttr(
1348 resultType,
1349 APInt::getSignedMaxValue(resultType.cast<IntegerType>().getWidth()));
1350 case AtomicRMWKind::minu:
1351 return builder.getIntegerAttr(
1352 resultType,
1353 APInt::getMaxValue(resultType.cast<IntegerType>().getWidth()));
1354 case AtomicRMWKind::muli:
1355 return builder.getIntegerAttr(resultType, 1);
1356 case AtomicRMWKind::mulf:
1357 return builder.getFloatAttr(resultType, 1);
1358 // TODO: Add remaining reduction operations.
1359 default:
1360 (void)emitOptionalError(loc, "Reduction operation type not supported");
1361 break;
1362 }
1363 return nullptr;
1364}
1365
1366/// Returns the identity value associated with an AtomicRMWKind op.
1367Value mlir::arith::getIdentityValue(AtomicRMWKind op, Type resultType,
1368 OpBuilder &builder, Location loc) {
1369 Attribute attr = getIdentityValueAttr(op, resultType, builder, loc);
1370 return builder.create<arith::ConstantOp>(loc, attr);
1
Calling 'OpBuilder::create'
1371}
1372
1373/// Return the value obtained by applying the reduction operation kind
1374/// associated with a binary AtomicRMWKind op to `lhs` and `rhs`.
1375Value mlir::arith::getReductionOp(AtomicRMWKind op, OpBuilder &builder,
1376 Location loc, Value lhs, Value rhs) {
1377 switch (op) {
1378 case AtomicRMWKind::addf:
1379 return builder.create<arith::AddFOp>(loc, lhs, rhs);
1380 case AtomicRMWKind::addi:
1381 return builder.create<arith::AddIOp>(loc, lhs, rhs);
1382 case AtomicRMWKind::mulf:
1383 return builder.create<arith::MulFOp>(loc, lhs, rhs);
1384 case AtomicRMWKind::muli:
1385 return builder.create<arith::MulIOp>(loc, lhs, rhs);
1386 case AtomicRMWKind::maxf:
1387 return builder.create<arith::MaxFOp>(loc, lhs, rhs);
1388 case AtomicRMWKind::minf:
1389 return builder.create<arith::MinFOp>(loc, lhs, rhs);
1390 case AtomicRMWKind::maxs:
1391 return builder.create<arith::MaxSIOp>(loc, lhs, rhs);
1392 case AtomicRMWKind::mins:
1393 return builder.create<arith::MinSIOp>(loc, lhs, rhs);
1394 case AtomicRMWKind::maxu:
1395 return builder.create<arith::MaxUIOp>(loc, lhs, rhs);
1396 case AtomicRMWKind::minu:
1397 return builder.create<arith::MinUIOp>(loc, lhs, rhs);
1398 case AtomicRMWKind::ori:
1399 return builder.create<arith::OrIOp>(loc, lhs, rhs);
1400 case AtomicRMWKind::andi:
1401 return builder.create<arith::AndIOp>(loc, lhs, rhs);
1402 // TODO: Add remaining reduction operations.
1403 default:
1404 (void)emitOptionalError(loc, "Reduction operation type not supported");
1405 break;
1406 }
1407 return nullptr;
1408}
1409
1410//===----------------------------------------------------------------------===//
1411// TableGen'd op method definitions
1412//===----------------------------------------------------------------------===//
1413
1414#define GET_OP_CLASSES
1415#include "mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
1416
1417//===----------------------------------------------------------------------===//
1418// TableGen'd enum attribute definitions
1419//===----------------------------------------------------------------------===//
1420
1421#include "mlir/Dialect/Arithmetic/IR/ArithmeticOpsEnums.cpp.inc"

/build/llvm-toolchain-snapshot-14~++20220125101009+ceec4383681c/mlir/include/mlir/IR/Builders.h

1//===- Builders.h - Helpers for constructing MLIR Classes -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef MLIR_IR_BUILDERS_H
10#define MLIR_IR_BUILDERS_H
11
12#include "mlir/IR/OpDefinition.h"
13#include "llvm/Support/Compiler.h"
14
15namespace mlir {
16
17class AffineExpr;
18class BlockAndValueMapping;
19class UnknownLoc;
20class FileLineColLoc;
21class Type;
22class PrimitiveType;
23class IntegerType;
24class FloatType;
25class FunctionType;
26class IndexType;
27class MemRefType;
28class VectorType;
29class RankedTensorType;
30class UnrankedTensorType;
31class TupleType;
32class NoneType;
33class BoolAttr;
34class IntegerAttr;
35class FloatAttr;
36class StringAttr;
37class TypeAttr;
38class ArrayAttr;
39class SymbolRefAttr;
40class ElementsAttr;
41class DenseElementsAttr;
42class DenseIntElementsAttr;
43class AffineMapAttr;
44class AffineMap;
45class UnitAttr;
46
47/// This class is a general helper class for creating context-global objects
48/// like types, attributes, and affine expressions.
49class Builder {
50public:
51 explicit Builder(MLIRContext *context) : context(context) {}
52 explicit Builder(Operation *op) : Builder(op->getContext()) {}
53
54 MLIRContext *getContext() const { return context; }
55
56 // Locations.
57 Location getUnknownLoc();
58 Location getFusedLoc(ArrayRef<Location> locs,
59 Attribute metadata = Attribute());
60
61 // Types.
62 FloatType getBF16Type();
63 FloatType getF16Type();
64 FloatType getF32Type();
65 FloatType getF64Type();
66 FloatType getF80Type();
67 FloatType getF128Type();
68
69 IndexType getIndexType();
70
71 IntegerType getI1Type();
72 IntegerType getI8Type();
73 IntegerType getI32Type();
74 IntegerType getI64Type();
75 IntegerType getIntegerType(unsigned width);
76 IntegerType getIntegerType(unsigned width, bool isSigned);
77 FunctionType getFunctionType(TypeRange inputs, TypeRange results);
78 TupleType getTupleType(TypeRange elementTypes);
79 NoneType getNoneType();
80
81 /// Get or construct an instance of the type 'ty' with provided arguments.
82 template <typename Ty, typename... Args>
83 Ty getType(Args... args) {
84 return Ty::get(context, args...);
85 }
86
87 // Attributes.
88 NamedAttribute getNamedAttr(StringRef name, Attribute val);
89
90 UnitAttr getUnitAttr();
91 BoolAttr getBoolAttr(bool value);
92 DictionaryAttr getDictionaryAttr(ArrayRef<NamedAttribute> value);
93 IntegerAttr getIntegerAttr(Type type, int64_t value);
94 IntegerAttr getIntegerAttr(Type type, const APInt &value);
95 FloatAttr getFloatAttr(Type type, double value);
96 FloatAttr getFloatAttr(Type type, const APFloat &value);
97 StringAttr getStringAttr(const Twine &bytes);
98 ArrayAttr getArrayAttr(ArrayRef<Attribute> value);
99
100 // Returns a 0-valued attribute of the given `type`. This function only
101 // supports boolean, integer, and 16-/32-/64-bit float types, and vector or
102 // ranked tensor of them. Returns null attribute otherwise.
103 Attribute getZeroAttr(Type type);
104
105 // Convenience methods for fixed types.
106 FloatAttr getF16FloatAttr(float value);
107 FloatAttr getF32FloatAttr(float value);
108 FloatAttr getF64FloatAttr(double value);
109
110 IntegerAttr getI8IntegerAttr(int8_t value);
111 IntegerAttr getI16IntegerAttr(int16_t value);
112 IntegerAttr getI32IntegerAttr(int32_t value);
113 IntegerAttr getI64IntegerAttr(int64_t value);
114 IntegerAttr getIndexAttr(int64_t value);
115
116 /// Signed and unsigned integer attribute getters.
117 IntegerAttr getSI32IntegerAttr(int32_t value);
118 IntegerAttr getUI32IntegerAttr(uint32_t value);
119
120 /// Vector-typed DenseIntElementsAttr getters. `values` must not be empty.
121 DenseIntElementsAttr getBoolVectorAttr(ArrayRef<bool> values);
122 DenseIntElementsAttr getI32VectorAttr(ArrayRef<int32_t> values);
123 DenseIntElementsAttr getI64VectorAttr(ArrayRef<int64_t> values);
124 DenseIntElementsAttr getIndexVectorAttr(ArrayRef<int64_t> values);
125
126 /// Tensor-typed DenseIntElementsAttr getters. `values` can be empty.
127 /// These are generally preferable for representing general lists of integers
128 /// as attributes.
129 DenseIntElementsAttr getI32TensorAttr(ArrayRef<int32_t> values);
130 DenseIntElementsAttr getI64TensorAttr(ArrayRef<int64_t> values);
131 DenseIntElementsAttr getIndexTensorAttr(ArrayRef<int64_t> values);
132
133 ArrayAttr getAffineMapArrayAttr(ArrayRef<AffineMap> values);
134 ArrayAttr getBoolArrayAttr(ArrayRef<bool> values);
135 ArrayAttr getI32ArrayAttr(ArrayRef<int32_t> values);
136 ArrayAttr getI64ArrayAttr(ArrayRef<int64_t> values);
137 ArrayAttr getIndexArrayAttr(ArrayRef<int64_t> values);
138 ArrayAttr getF32ArrayAttr(ArrayRef<float> values);
139 ArrayAttr getF64ArrayAttr(ArrayRef<double> values);
140 ArrayAttr getStrArrayAttr(ArrayRef<StringRef> values);
141 ArrayAttr getTypeArrayAttr(TypeRange values);
142
143 // Affine expressions and affine maps.
144 AffineExpr getAffineDimExpr(unsigned position);
145 AffineExpr getAffineSymbolExpr(unsigned position);
146 AffineExpr getAffineConstantExpr(int64_t constant);
147
148 // Special cases of affine maps and integer sets
149 /// Returns a zero result affine map with no dimensions or symbols: () -> ().
150 AffineMap getEmptyAffineMap();
151 /// Returns a single constant result affine map with 0 dimensions and 0
152 /// symbols. One constant result: () -> (val).
153 AffineMap getConstantAffineMap(int64_t val);
154 // One dimension id identity map: (i) -> (i).
155 AffineMap getDimIdentityMap();
156 // Multi-dimensional identity map: (d0, d1, d2) -> (d0, d1, d2).
157 AffineMap getMultiDimIdentityMap(unsigned rank);
158 // One symbol identity map: ()[s] -> (s).
159 AffineMap getSymbolIdentityMap();
160
161 /// Returns a map that shifts its (single) input dimension by 'shift'.
162 /// (d0) -> (d0 + shift)
163 AffineMap getSingleDimShiftAffineMap(int64_t shift);
164
165 /// Returns an affine map that is a translation (shift) of all result
166 /// expressions in 'map' by 'shift'.
167 /// Eg: input: (d0, d1)[s0] -> (d0, d1 + s0), shift = 2
168 /// returns: (d0, d1)[s0] -> (d0 + 2, d1 + s0 + 2)
169 AffineMap getShiftedAffineMap(AffineMap map, int64_t shift);
170
171protected:
172 MLIRContext *context;
173};
174
175/// This class helps build Operations. Operations that are created are
176/// automatically inserted at an insertion point. The builder is copyable.
177class OpBuilder : public Builder {
178public:
179 struct Listener;
180
181 /// Create a builder with the given context.
182 explicit OpBuilder(MLIRContext *ctx, Listener *listener = nullptr)
183 : Builder(ctx), listener(listener) {}
184
185 /// Create a builder and set the insertion point to the start of the region.
186 explicit OpBuilder(Region *region, Listener *listener = nullptr)
187 : OpBuilder(region->getContext(), listener) {
188 if (!region->empty())
189 setInsertionPoint(&region->front(), region->front().begin());
190 }
191 explicit OpBuilder(Region &region, Listener *listener = nullptr)
192 : OpBuilder(&region, listener) {}
193
194 /// Create a builder and set insertion point to the given operation, which
195 /// will cause subsequent insertions to go right before it.
196 explicit OpBuilder(Operation *op, Listener *listener = nullptr)
197 : OpBuilder(op->getContext(), listener) {
198 setInsertionPoint(op);
199 }
200
201 OpBuilder(Block *block, Block::iterator insertPoint,
202 Listener *listener = nullptr)
203 : OpBuilder(block->getParent()->getContext(), listener) {
204 setInsertionPoint(block, insertPoint);
205 }
206
207 /// Create a builder and set the insertion point to before the first operation
208 /// in the block but still inside the block.
209 static OpBuilder atBlockBegin(Block *block, Listener *listener = nullptr) {
210 return OpBuilder(block, block->begin(), listener);
211 }
212
213 /// Create a builder and set the insertion point to after the last operation
214 /// in the block but still inside the block.
215 static OpBuilder atBlockEnd(Block *block, Listener *listener = nullptr) {
216 return OpBuilder(block, block->end(), listener);
217 }
218
219 /// Create a builder and set the insertion point to before the block
220 /// terminator.
221 static OpBuilder atBlockTerminator(Block *block,
222 Listener *listener = nullptr) {
223 auto *terminator = block->getTerminator();
224 assert(terminator != nullptr && "the block has no terminator")(static_cast <bool> (terminator != nullptr && "the block has no terminator"
) ? void (0) : __assert_fail ("terminator != nullptr && \"the block has no terminator\""
, "mlir/include/mlir/IR/Builders.h", 224, __extension__ __PRETTY_FUNCTION__
))
;
225 return OpBuilder(block, Block::iterator(terminator), listener);
226 }
227
228 //===--------------------------------------------------------------------===//
229 // Listeners
230 //===--------------------------------------------------------------------===//
231
232 /// This class represents a listener that may be used to hook into various
233 /// actions within an OpBuilder.
234 struct Listener {
235 virtual ~Listener();
236
237 /// Notification handler for when an operation is inserted into the builder.
238 /// `op` is the operation that was inserted.
239 virtual void notifyOperationInserted(Operation *op) {}
240
241 /// Notification handler for when a block is created using the builder.
242 /// `block` is the block that was created.
243 virtual void notifyBlockCreated(Block *block) {}
244 };
245
246 /// Sets the listener of this builder to the one provided.
247 void setListener(Listener *newListener) { listener = newListener; }
248
249 /// Returns the current listener of this builder, or nullptr if this builder
250 /// doesn't have a listener.
251 Listener *getListener() const { return listener; }
252
253 //===--------------------------------------------------------------------===//
254 // Insertion Point Management
255 //===--------------------------------------------------------------------===//
256
257 /// This class represents a saved insertion point.
258 class InsertPoint {
259 public:
260 /// Creates a new insertion point which doesn't point to anything.
261 InsertPoint() = default;
262
263 /// Creates a new insertion point at the given location.
264 InsertPoint(Block *insertBlock, Block::iterator insertPt)
265 : block(insertBlock), point(insertPt) {}
266
267 /// Returns true if this insert point is set.
268 bool isSet() const { return (block != nullptr); }
269
270 Block *getBlock() const { return block; }
271 Block::iterator getPoint() const { return point; }
272
273 private:
274 Block *block = nullptr;
275 Block::iterator point;
276 };
277
278 /// RAII guard to reset the insertion point of the builder when destroyed.
279 class InsertionGuard {
280 public:
281 InsertionGuard(OpBuilder &builder)
282 : builder(&builder), ip(builder.saveInsertionPoint()) {}
283
284 ~InsertionGuard() {
285 if (builder)
286 builder->restoreInsertionPoint(ip);
287 }
288
289 InsertionGuard(const InsertionGuard &) = delete;
290 InsertionGuard &operator=(const InsertionGuard &) = delete;
291
292 /// Implement the move constructor to clear the builder field of `other`.
293 /// That way it does not restore the insertion point upon destruction as
294 /// that should be done exclusively by the just constructed InsertionGuard.
295 InsertionGuard(InsertionGuard &&other) noexcept
296 : builder(other.builder), ip(other.ip) {
297 other.builder = nullptr;
298 }
299
300 InsertionGuard &operator=(InsertionGuard &&other) = delete;
301
302 private:
303 OpBuilder *builder;
304 OpBuilder::InsertPoint ip;
305 };
306
307 /// Reset the insertion point to no location. Creating an operation without a
308 /// set insertion point is an error, but this can still be useful when the
309 /// current insertion point a builder refers to is being removed.
310 void clearInsertionPoint() {
311 this->block = nullptr;
312 insertPoint = Block::iterator();
313 }
314
315 /// Return a saved insertion point.
316 InsertPoint saveInsertionPoint() const {
317 return InsertPoint(getInsertionBlock(), getInsertionPoint());
318 }
319
320 /// Restore the insert point to a previously saved point.
321 void restoreInsertionPoint(InsertPoint ip) {
322 if (ip.isSet())
323 setInsertionPoint(ip.getBlock(), ip.getPoint());
324 else
325 clearInsertionPoint();
326 }
327
328 /// Set the insertion point to the specified location.
329 void setInsertionPoint(Block *block, Block::iterator insertPoint) {
330 // TODO: check that insertPoint is in this rather than some other block.
331 this->block = block;
332 this->insertPoint = insertPoint;
333 }
334
335 /// Sets the insertion point to the specified operation, which will cause
336 /// subsequent insertions to go right before it.
337 void setInsertionPoint(Operation *op) {
338 setInsertionPoint(op->getBlock(), Block::iterator(op));
339 }
340
341 /// Sets the insertion point to the node after the specified operation, which
342 /// will cause subsequent insertions to go right after it.
343 void setInsertionPointAfter(Operation *op) {
344 setInsertionPoint(op->getBlock(), ++Block::iterator(op));
345 }
346
347 /// Sets the insertion point to the node after the specified value. If value
348 /// has a defining operation, sets the insertion point to the node after such
349 /// defining operation. This will cause subsequent insertions to go right
350 /// after it. Otherwise, value is a BlockArgument. Sets the insertion point to
351 /// the start of its block.
352 void setInsertionPointAfterValue(Value val) {
353 if (Operation *op = val.getDefiningOp()) {
354 setInsertionPointAfter(op);
355 } else {
356 auto blockArg = val.cast<BlockArgument>();
357 setInsertionPointToStart(blockArg.getOwner());
358 }
359 }
360
361 /// Sets the insertion point to the start of the specified block.
362 void setInsertionPointToStart(Block *block) {
363 setInsertionPoint(block, block->begin());
364 }
365
366 /// Sets the insertion point to the end of the specified block.
367 void setInsertionPointToEnd(Block *block) {
368 setInsertionPoint(block, block->end());
369 }
370
371 /// Return the block the current insertion point belongs to. Note that the
372 /// the insertion point is not necessarily the end of the block.
373 Block *getInsertionBlock() const { return block; }
374
375 /// Returns the current insertion point of the builder.
376 Block::iterator getInsertionPoint() const { return insertPoint; }
377
378 /// Returns the current block of the builder.
379 Block *getBlock() const { return block; }
380
381 //===--------------------------------------------------------------------===//
382 // Block Creation
383 //===--------------------------------------------------------------------===//
384
385 /// Add new block with 'argTypes' arguments and set the insertion point to the
386 /// end of it. The block is inserted at the provided insertion point of
387 /// 'parent'. `locs` contains the locations of the inserted arguments, and
388 /// should match the size of `argTypes`.
389 Block *createBlock(Region *parent, Region::iterator insertPt = {},
390 TypeRange argTypes = llvm::None,
391 ArrayRef<Location> locs = llvm::None);
392
393 /// Add new block with 'argTypes' arguments and set the insertion point to the
394 /// end of it. The block is placed before 'insertBefore'. `locs` contains the
395 /// locations of the inserted arguments, and should match the size of
396 /// `argTypes`.
397 Block *createBlock(Block *insertBefore, TypeRange argTypes = llvm::None,
398 ArrayRef<Location> locs = llvm::None);
399
400 //===--------------------------------------------------------------------===//
401 // Operation Creation
402 //===--------------------------------------------------------------------===//
403
404 /// Insert the given operation at the current insertion point and return it.
405 Operation *insert(Operation *op);
406
407 /// Creates an operation given the fields represented as an OperationState.
408 Operation *createOperation(const OperationState &state);
409
410private:
411 /// Helper for sanity checking preconditions for create* methods below.
412 template <typename OpT>
413 RegisteredOperationName getCheckRegisteredInfo(MLIRContext *ctx) {
414 Optional<RegisteredOperationName> opName =
415 RegisteredOperationName::lookup(OpT::getOperationName(), ctx);
416 if (LLVM_UNLIKELY(!opName)__builtin_expect((bool)(!opName), false)) {
417 llvm::report_fatal_error(
418 "Building op `" + OpT::getOperationName() +
419 "` but it isn't registered in this MLIRContext: the dialect may not "
420 "be loaded or this operation isn't registered by the dialect. See "
421 "also https://mlir.llvm.org/getting_started/Faq/"
422 "#registered-loaded-dependent-whats-up-with-dialects-management");
423 }
424 return *opName;
425 }
426
427public:
428 /// Create an operation of specific op type at the current insertion point.
429 template <typename OpTy, typename... Args>
430 OpTy create(Location location, Args &&...args) {
431 OperationState state(location,
432 getCheckRegisteredInfo<OpTy>(location.getContext()));
433 OpTy::build(*this, state, std::forward<Args>(args)...);
2
Null pointer value stored to 'value.impl'
3
Calling 'ConstantOp::build'
434 auto *op = createOperation(state);
435 auto result = dyn_cast<OpTy>(op);
436 assert(result && "builder didn't return the right type")(static_cast <bool> (result && "builder didn't return the right type"
) ? void (0) : __assert_fail ("result && \"builder didn't return the right type\""
, "mlir/include/mlir/IR/Builders.h", 436, __extension__ __PRETTY_FUNCTION__
))
;
437 return result;
438 }
439
440 /// Create an operation of specific op type at the current insertion point,
441 /// and immediately try to fold it. This functions populates 'results' with
442 /// the results after folding the operation.
443 template <typename OpTy, typename... Args>
444 void createOrFold(SmallVectorImpl<Value> &results, Location location,
445 Args &&...args) {
446 // Create the operation without using 'createOperation' as we don't want to
447 // insert it yet.
448 OperationState state(location,
449 getCheckRegisteredInfo<OpTy>(location.getContext()));
450 OpTy::build(*this, state, std::forward<Args>(args)...);
451 Operation *op = Operation::create(state);
452
453 // Fold the operation. If successful destroy it, otherwise insert it.
454 if (succeeded(tryFold(op, results)))
455 op->destroy();
456 else
457 insert(op);
458 }
459
460 /// Overload to create or fold a single result operation.
461 template <typename OpTy, typename... Args>
462 typename std::enable_if<OpTy::template hasTrait<OpTrait::OneResult>(),
463 Value>::type
464 createOrFold(Location location, Args &&...args) {
465 SmallVector<Value, 1> results;
466 createOrFold<OpTy>(results, location, std::forward<Args>(args)...);
467 return results.front();
468 }
469
470 /// Overload to create or fold a zero result operation.
471 template <typename OpTy, typename... Args>
472 typename std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResult>(),
473 OpTy>::type
474 createOrFold(Location location, Args &&...args) {
475 auto op = create<OpTy>(location, std::forward<Args>(args)...);
476 SmallVector<Value, 0> unused;
477 (void)tryFold(op.getOperation(), unused);
478
479 // Folding cannot remove a zero-result operation, so for convenience we
480 // continue to return it.
481 return op;
482 }
483
484 /// Attempts to fold the given operation and places new results within
485 /// 'results'. Returns success if the operation was folded, failure otherwise.
486 /// Note: This function does not erase the operation on a successful fold.
487 LogicalResult tryFold(Operation *op, SmallVectorImpl<Value> &results);
488
489 /// Creates a deep copy of the specified operation, remapping any operands
490 /// that use values outside of the operation using the map that is provided
491 /// ( leaving them alone if no entry is present). Replaces references to
492 /// cloned sub-operations to the corresponding operation that is copied,
493 /// and adds those mappings to the map.
494 Operation *clone(Operation &op, BlockAndValueMapping &mapper);
495 Operation *clone(Operation &op);
496
497 /// Creates a deep copy of this operation but keep the operation regions
498 /// empty. Operands are remapped using `mapper` (if present), and `mapper` is
499 /// updated to contain the results.
500 Operation *cloneWithoutRegions(Operation &op, BlockAndValueMapping &mapper) {
501 return insert(op.cloneWithoutRegions(mapper));
502 }
503 Operation *cloneWithoutRegions(Operation &op) {
504 return insert(op.cloneWithoutRegions());
505 }
506 template <typename OpT>
507 OpT cloneWithoutRegions(OpT op) {
508 return cast<OpT>(cloneWithoutRegions(*op.getOperation()));
509 }
510
511private:
512 /// The current block this builder is inserting into.
513 Block *block = nullptr;
514 /// The insertion point within the block that this builder is inserting
515 /// before.
516 Block::iterator insertPoint;
517 /// The optional listener for events of this builder.
518 Listener *listener;
519};
520
521} // namespace mlir
522
523#endif

tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc

1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Op Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_OP_LIST
10#undef GET_OP_LIST
11
12::mlir::arith::AddFOp,
13::mlir::arith::AddIOp,
14::mlir::arith::AndIOp,
15::mlir::arith::BitcastOp,
16::mlir::arith::CeilDivSIOp,
17::mlir::arith::CeilDivUIOp,
18::mlir::arith::CmpFOp,
19::mlir::arith::CmpIOp,
20::mlir::arith::ConstantOp,
21::mlir::arith::DivFOp,
22::mlir::arith::DivSIOp,
23::mlir::arith::DivUIOp,
24::mlir::arith::ExtFOp,
25::mlir::arith::ExtSIOp,
26::mlir::arith::ExtUIOp,
27::mlir::arith::FPToSIOp,
28::mlir::arith::FPToUIOp,
29::mlir::arith::FloorDivSIOp,
30::mlir::arith::IndexCastOp,
31::mlir::arith::MaxFOp,
32::mlir::arith::MaxSIOp,
33::mlir::arith::MaxUIOp,
34::mlir::arith::MinFOp,
35::mlir::arith::MinSIOp,
36::mlir::arith::MinUIOp,
37::mlir::arith::MulFOp,
38::mlir::arith::MulIOp,
39::mlir::arith::NegFOp,
40::mlir::arith::OrIOp,
41::mlir::arith::RemFOp,
42::mlir::arith::RemSIOp,
43::mlir::arith::RemUIOp,
44::mlir::arith::SIToFPOp,
45::mlir::arith::ShLIOp,
46::mlir::arith::ShRSIOp,
47::mlir::arith::ShRUIOp,
48::mlir::arith::SubFOp,
49::mlir::arith::SubIOp,
50::mlir::arith::TruncFOp,
51::mlir::arith::TruncIOp,
52::mlir::arith::UIToFPOp,
53::mlir::arith::XOrIOp
54#endif // GET_OP_LIST
55
56#ifdef GET_OP_CLASSES
57#undef GET_OP_CLASSES
58
59
60//===----------------------------------------------------------------------===//
61// Local Utility Method Definitions
62//===----------------------------------------------------------------------===//
63
64namespace mlir {
65namespace arith {
66
67static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps0(
68 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
69 unsigned valueIndex) {
70 if (!(((type.isa<::mlir::FloatType>())) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isa<::mlir::FloatType>()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isa<::mlir::FloatType>()); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
71 return op->emitOpError(valueKind) << " #" << valueIndex
72 << " must be floating-point-like, but got " << type;
73 }
74 return ::mlir::success();
75}
76
77static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps1(
78 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
79 unsigned valueIndex) {
80 if (!(((type.isSignlessIntOrIndex())) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
81 return op->emitOpError(valueKind) << " #" << valueIndex
82 << " must be signless-integer-like, but got " << type;
83 }
84 return ::mlir::success();
85}
86
87static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps2(
88 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
89 unsigned valueIndex) {
90 if (!(((((type.isSignlessIntOrIndex())) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType())))) || (((type.isa<::mlir::FloatType>())) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isa<::mlir::FloatType>()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isa<::mlir::FloatType>()); }(type.cast<::mlir::ShapedType>().getElementType()))))) || (((type.isa<::mlir::MemRefType>())) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) || ((elementType.isa<::mlir::IndexType>())) || ((elementType.isa<::mlir::FloatType>())); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
91 return op->emitOpError(valueKind) << " #" << valueIndex
92 << " must be signless-integer-or-float-like or memref of signless-integer or float, but got " << type;
93 }
94 return ::mlir::success();
95}
96
97static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps3(
98 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
99 unsigned valueIndex) {
100 if (!(((type.isSignlessInteger(1))) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
101 return op->emitOpError(valueKind) << " #" << valueIndex
102 << " must be bool-like, but got " << type;
103 }
104 return ::mlir::success();
105}
106
107static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps4(
108 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
109 unsigned valueIndex) {
110 if (!(((type.isSignlessIntOrIndex())) || (((type.isa<::mlir::VectorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
111 return op->emitOpError(valueKind) << " #" << valueIndex
112 << " must be signless-integer-like, but got " << type;
113 }
114 return ::mlir::success();
115}
116
117static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps5(
118 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
119 unsigned valueIndex) {
120 if (!(((type.isSignlessInteger(1))) || (((type.isa<::mlir::VectorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger(1)); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
121 return op->emitOpError(valueKind) << " #" << valueIndex
122 << " must be bool-like, but got " << type;
123 }
124 return ::mlir::success();
125}
126
127static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps6(
128 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
129 unsigned valueIndex) {
130 if (!((true))) {
131 return op->emitOpError(valueKind) << " #" << valueIndex
132 << " must be any type, but got " << type;
133 }
134 return ::mlir::success();
135}
136
137static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps7(
138 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
139 unsigned valueIndex) {
140 if (!(((type.isSignlessInteger())) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessInteger()); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
141 return op->emitOpError(valueKind) << " #" << valueIndex
142 << " must be signless-fixed-width-integer-like, but got " << type;
143 }
144 return ::mlir::success();
145}
146
147static ::mlir::LogicalResult __mlir_ods_local_type_constraint_ArithmeticOps8(
148 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
149 unsigned valueIndex) {
150 if (!((((type.isSignlessIntOrIndex())) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType())))) || (((type.isa<::mlir::MemRefType>())) && ([](::mlir::Type elementType) { return ((elementType.isSignlessInteger())) || ((elementType.isa<::mlir::IndexType>())); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
151 return op->emitOpError(valueKind) << " #" << valueIndex
152 << " must be signless-integer-like or memref of signless-integer, but got " << type;
153 }
154 return ::mlir::success();
155}
156
157static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ArithmeticOps0(
158 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
159 if (attr && !((attr.isa<::mlir::arith::CmpFPredicateAttr>()))) {
160 return op->emitOpError("attribute '") << attrName
161 << "' failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15";
162 }
163 return ::mlir::success();
164}
165
166static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ArithmeticOps1(
167 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
168 if (attr && !((attr.isa<::mlir::arith::CmpIPredicateAttr>()))) {
169 return op->emitOpError("attribute '") << attrName
170 << "' failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";
171 }
172 return ::mlir::success();
173}
174
175static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_ArithmeticOps2(
176 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
177 if (attr && !((true))) {
178 return op->emitOpError("attribute '") << attrName
179 << "' failed to satisfy constraint: any attribute";
180 }
181 return ::mlir::success();
182}
183} // namespace arith
184} // namespace mlir
185namespace mlir {
186namespace arith {
187
188//===----------------------------------------------------------------------===//
189// ::mlir::arith::AddFOp definitions
190//===----------------------------------------------------------------------===//
191
192AddFOpAdaptor::AddFOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
193
194AddFOpAdaptor::AddFOpAdaptor(AddFOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
195
196::mlir::ValueRange AddFOpAdaptor::getOperands() {
197 return odsOperands;
198}
199
200std::pair<unsigned, unsigned> AddFOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
201 return {index, 1};
202}
203
204::mlir::ValueRange AddFOpAdaptor::getODSOperands(unsigned index) {
205 auto valueRange = getODSOperandIndexAndLength(index);
206 return {std::next(odsOperands.begin(), valueRange.first),
207 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
208}
209
210::mlir::Value AddFOpAdaptor::getLhs() {
211 return *getODSOperands(0).begin();
212}
213
214::mlir::Value AddFOpAdaptor::getRhs() {
215 return *getODSOperands(1).begin();
216}
217
218::mlir::DictionaryAttr AddFOpAdaptor::getAttributes() {
219 return odsAttrs;
220}
221
222::mlir::LogicalResult AddFOpAdaptor::verify(::mlir::Location loc) {
223 return ::mlir::success();
224}
225
226std::pair<unsigned, unsigned> AddFOp::getODSOperandIndexAndLength(unsigned index) {
227 return {index, 1};
228}
229
230::mlir::Operation::operand_range AddFOp::getODSOperands(unsigned index) {
231 auto valueRange = getODSOperandIndexAndLength(index);
232 return {std::next(getOperation()->operand_begin(), valueRange.first),
233 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
234}
235
236::mlir::Value AddFOp::getLhs() {
237 return *getODSOperands(0).begin();
238}
239
240::mlir::Value AddFOp::getRhs() {
241 return *getODSOperands(1).begin();
242}
243
244::mlir::MutableOperandRange AddFOp::getLhsMutable() {
245 auto range = getODSOperandIndexAndLength(0);
246 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
247 return mutableRange;
248}
249
250::mlir::MutableOperandRange AddFOp::getRhsMutable() {
251 auto range = getODSOperandIndexAndLength(1);
252 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
253 return mutableRange;
254}
255
256std::pair<unsigned, unsigned> AddFOp::getODSResultIndexAndLength(unsigned index) {
257 return {index, 1};
258}
259
260::mlir::Operation::result_range AddFOp::getODSResults(unsigned index) {
261 auto valueRange = getODSResultIndexAndLength(index);
262 return {std::next(getOperation()->result_begin(), valueRange.first),
263 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
264}
265
266::mlir::Value AddFOp::getResult() {
267 return *getODSResults(0).begin();
268}
269
270void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
271 odsState.addOperands(lhs);
272 odsState.addOperands(rhs);
273 odsState.addTypes(result);
274}
275
276void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
277 odsState.addOperands(lhs);
278 odsState.addOperands(rhs);
279 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 279, __extension__ __PRETTY_FUNCTION__))
;
280 odsState.addTypes(resultTypes);
281}
282
283void AddFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
284 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 284, __extension__ __PRETTY_FUNCTION__))
;
285 odsState.addOperands(operands);
286 odsState.addAttributes(attributes);
287 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 287, __extension__ __PRETTY_FUNCTION__))
;
288 odsState.addTypes(resultTypes);
289}
290
291void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
292 odsState.addOperands(lhs);
293 odsState.addOperands(rhs);
294 odsState.addTypes({lhs.getType()});
295
296}
297
298void AddFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
299 odsState.addOperands(operands);
300 odsState.addAttributes(attributes);
301 odsState.addTypes({operands[0].getType()});
302
303}
304
305::mlir::LogicalResult AddFOp::verify() {
306 {
307 unsigned index = 0; (void)index;
308 auto valueGroup0 = getODSOperands(0);
309
310 for (auto v : valueGroup0) {
311 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
312 return ::mlir::failure();
313 }
314 auto valueGroup1 = getODSOperands(1);
315
316 for (auto v : valueGroup1) {
317 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
318 return ::mlir::failure();
319 }
320 }
321 {
322 unsigned index = 0; (void)index;
323 auto valueGroup0 = getODSResults(0);
324
325 for (auto v : valueGroup0) {
326 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "result", index++)))
327 return ::mlir::failure();
328 }
329 }
330 return ::mlir::success();
331}
332
333::mlir::ParseResult AddFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
334 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
335 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
336 (void)lhsOperandsLoc;
337 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
338 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
339 (void)rhsOperandsLoc;
340 ::mlir::Type resultRawTypes[1];
341 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
342
343 lhsOperandsLoc = parser.getCurrentLocation();
344 if (parser.parseOperand(lhsRawOperands[0]))
345 return ::mlir::failure();
346 if (parser.parseComma())
347 return ::mlir::failure();
348
349 rhsOperandsLoc = parser.getCurrentLocation();
350 if (parser.parseOperand(rhsRawOperands[0]))
351 return ::mlir::failure();
352 if (parser.parseOptionalAttrDict(result.attributes))
353 return ::mlir::failure();
354 if (parser.parseColon())
355 return ::mlir::failure();
356
357 {
358 ::mlir::Type type;
359 if (parser.parseCustomTypeWithFallback(type))
360 return ::mlir::failure();
361 resultRawTypes[0] = type;
362 }
363 result.addTypes(resultTypes);
364 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
365 return ::mlir::failure();
366 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
367 return ::mlir::failure();
368 return ::mlir::success();
369}
370
371void AddFOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
372 _odsPrinter << ' ';
373 _odsPrinter << getLhs();
374 _odsPrinter << ",";
375 _odsPrinter << ' ';
376 _odsPrinter << getRhs();
377 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
378 _odsPrinter << ' ' << ":";
379 _odsPrinter << ' ';
380 {
381 auto type = getResult().getType();
382 if (auto validType = type.dyn_cast<::mlir::Type>())
383 _odsPrinter.printStrippedAttrOrType(validType);
384 else
385 _odsPrinter << type;
386 }
387}
388
389void AddFOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
390}
391
392} // namespace arith
393} // namespace mlir
394DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::AddFOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::AddFOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
395
396namespace mlir {
397namespace arith {
398
399//===----------------------------------------------------------------------===//
400// ::mlir::arith::AddIOp definitions
401//===----------------------------------------------------------------------===//
402
403AddIOpAdaptor::AddIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
404
405AddIOpAdaptor::AddIOpAdaptor(AddIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
406
407::mlir::ValueRange AddIOpAdaptor::getOperands() {
408 return odsOperands;
409}
410
411std::pair<unsigned, unsigned> AddIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
412 return {index, 1};
413}
414
415::mlir::ValueRange AddIOpAdaptor::getODSOperands(unsigned index) {
416 auto valueRange = getODSOperandIndexAndLength(index);
417 return {std::next(odsOperands.begin(), valueRange.first),
418 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
419}
420
421::mlir::Value AddIOpAdaptor::getLhs() {
422 return *getODSOperands(0).begin();
423}
424
425::mlir::Value AddIOpAdaptor::getRhs() {
426 return *getODSOperands(1).begin();
427}
428
429::mlir::DictionaryAttr AddIOpAdaptor::getAttributes() {
430 return odsAttrs;
431}
432
433::mlir::LogicalResult AddIOpAdaptor::verify(::mlir::Location loc) {
434 return ::mlir::success();
435}
436
437std::pair<unsigned, unsigned> AddIOp::getODSOperandIndexAndLength(unsigned index) {
438 return {index, 1};
439}
440
441::mlir::Operation::operand_range AddIOp::getODSOperands(unsigned index) {
442 auto valueRange = getODSOperandIndexAndLength(index);
443 return {std::next(getOperation()->operand_begin(), valueRange.first),
444 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
445}
446
447::mlir::Value AddIOp::getLhs() {
448 return *getODSOperands(0).begin();
449}
450
451::mlir::Value AddIOp::getRhs() {
452 return *getODSOperands(1).begin();
453}
454
455::mlir::MutableOperandRange AddIOp::getLhsMutable() {
456 auto range = getODSOperandIndexAndLength(0);
457 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
458 return mutableRange;
459}
460
461::mlir::MutableOperandRange AddIOp::getRhsMutable() {
462 auto range = getODSOperandIndexAndLength(1);
463 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
464 return mutableRange;
465}
466
467std::pair<unsigned, unsigned> AddIOp::getODSResultIndexAndLength(unsigned index) {
468 return {index, 1};
469}
470
471::mlir::Operation::result_range AddIOp::getODSResults(unsigned index) {
472 auto valueRange = getODSResultIndexAndLength(index);
473 return {std::next(getOperation()->result_begin(), valueRange.first),
474 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
475}
476
477::mlir::Value AddIOp::getResult() {
478 return *getODSResults(0).begin();
479}
480
481void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
482 odsState.addOperands(lhs);
483 odsState.addOperands(rhs);
484 odsState.addTypes(result);
485}
486
487void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
488 odsState.addOperands(lhs);
489 odsState.addOperands(rhs);
490 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 490, __extension__ __PRETTY_FUNCTION__))
;
491 odsState.addTypes(resultTypes);
492}
493
494void AddIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
495 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 495, __extension__ __PRETTY_FUNCTION__))
;
496 odsState.addOperands(operands);
497 odsState.addAttributes(attributes);
498 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 498, __extension__ __PRETTY_FUNCTION__))
;
499 odsState.addTypes(resultTypes);
500}
501
502void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
503 odsState.addOperands(lhs);
504 odsState.addOperands(rhs);
505 odsState.addTypes({lhs.getType()});
506
507}
508
509void AddIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
510 odsState.addOperands(operands);
511 odsState.addAttributes(attributes);
512 odsState.addTypes({operands[0].getType()});
513
514}
515
516::mlir::LogicalResult AddIOp::verify() {
517 {
518 unsigned index = 0; (void)index;
519 auto valueGroup0 = getODSOperands(0);
520
521 for (auto v : valueGroup0) {
522 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
523 return ::mlir::failure();
524 }
525 auto valueGroup1 = getODSOperands(1);
526
527 for (auto v : valueGroup1) {
528 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
529 return ::mlir::failure();
530 }
531 }
532 {
533 unsigned index = 0; (void)index;
534 auto valueGroup0 = getODSResults(0);
535
536 for (auto v : valueGroup0) {
537 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "result", index++)))
538 return ::mlir::failure();
539 }
540 }
541 return ::mlir::success();
542}
543
544::mlir::ParseResult AddIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
545 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
546 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
547 (void)lhsOperandsLoc;
548 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
549 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
550 (void)rhsOperandsLoc;
551 ::mlir::Type resultRawTypes[1];
552 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
553
554 lhsOperandsLoc = parser.getCurrentLocation();
555 if (parser.parseOperand(lhsRawOperands[0]))
556 return ::mlir::failure();
557 if (parser.parseComma())
558 return ::mlir::failure();
559
560 rhsOperandsLoc = parser.getCurrentLocation();
561 if (parser.parseOperand(rhsRawOperands[0]))
562 return ::mlir::failure();
563 if (parser.parseOptionalAttrDict(result.attributes))
564 return ::mlir::failure();
565 if (parser.parseColon())
566 return ::mlir::failure();
567
568 {
569 ::mlir::Type type;
570 if (parser.parseCustomTypeWithFallback(type))
571 return ::mlir::failure();
572 resultRawTypes[0] = type;
573 }
574 result.addTypes(resultTypes);
575 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
576 return ::mlir::failure();
577 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
578 return ::mlir::failure();
579 return ::mlir::success();
580}
581
582void AddIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
583 _odsPrinter << ' ';
584 _odsPrinter << getLhs();
585 _odsPrinter << ",";
586 _odsPrinter << ' ';
587 _odsPrinter << getRhs();
588 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
589 _odsPrinter << ' ' << ":";
590 _odsPrinter << ' ';
591 {
592 auto type = getResult().getType();
593 if (auto validType = type.dyn_cast<::mlir::Type>())
594 _odsPrinter.printStrippedAttrOrType(validType);
595 else
596 _odsPrinter << type;
597 }
598}
599
600void AddIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
601}
602
603} // namespace arith
604} // namespace mlir
605DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::AddIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::AddIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
606
607namespace mlir {
608namespace arith {
609
610//===----------------------------------------------------------------------===//
611// ::mlir::arith::AndIOp definitions
612//===----------------------------------------------------------------------===//
613
614AndIOpAdaptor::AndIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
615
616AndIOpAdaptor::AndIOpAdaptor(AndIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
617
618::mlir::ValueRange AndIOpAdaptor::getOperands() {
619 return odsOperands;
620}
621
622std::pair<unsigned, unsigned> AndIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
623 return {index, 1};
624}
625
626::mlir::ValueRange AndIOpAdaptor::getODSOperands(unsigned index) {
627 auto valueRange = getODSOperandIndexAndLength(index);
628 return {std::next(odsOperands.begin(), valueRange.first),
629 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
630}
631
632::mlir::Value AndIOpAdaptor::getLhs() {
633 return *getODSOperands(0).begin();
634}
635
636::mlir::Value AndIOpAdaptor::getRhs() {
637 return *getODSOperands(1).begin();
638}
639
640::mlir::DictionaryAttr AndIOpAdaptor::getAttributes() {
641 return odsAttrs;
642}
643
644::mlir::LogicalResult AndIOpAdaptor::verify(::mlir::Location loc) {
645 return ::mlir::success();
646}
647
648std::pair<unsigned, unsigned> AndIOp::getODSOperandIndexAndLength(unsigned index) {
649 return {index, 1};
650}
651
652::mlir::Operation::operand_range AndIOp::getODSOperands(unsigned index) {
653 auto valueRange = getODSOperandIndexAndLength(index);
654 return {std::next(getOperation()->operand_begin(), valueRange.first),
655 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
656}
657
658::mlir::Value AndIOp::getLhs() {
659 return *getODSOperands(0).begin();
660}
661
662::mlir::Value AndIOp::getRhs() {
663 return *getODSOperands(1).begin();
664}
665
666::mlir::MutableOperandRange AndIOp::getLhsMutable() {
667 auto range = getODSOperandIndexAndLength(0);
668 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
669 return mutableRange;
670}
671
672::mlir::MutableOperandRange AndIOp::getRhsMutable() {
673 auto range = getODSOperandIndexAndLength(1);
674 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
675 return mutableRange;
676}
677
678std::pair<unsigned, unsigned> AndIOp::getODSResultIndexAndLength(unsigned index) {
679 return {index, 1};
680}
681
682::mlir::Operation::result_range AndIOp::getODSResults(unsigned index) {
683 auto valueRange = getODSResultIndexAndLength(index);
684 return {std::next(getOperation()->result_begin(), valueRange.first),
685 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
686}
687
688::mlir::Value AndIOp::getResult() {
689 return *getODSResults(0).begin();
690}
691
692void AndIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
693 odsState.addOperands(lhs);
694 odsState.addOperands(rhs);
695 odsState.addTypes(result);
696}
697
698void AndIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
699 odsState.addOperands(lhs);
700 odsState.addOperands(rhs);
701 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 701, __extension__ __PRETTY_FUNCTION__))
;
702 odsState.addTypes(resultTypes);
703}
704
705void AndIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
706 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 706, __extension__ __PRETTY_FUNCTION__))
;
707 odsState.addOperands(operands);
708 odsState.addAttributes(attributes);
709 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 709, __extension__ __PRETTY_FUNCTION__))
;
710 odsState.addTypes(resultTypes);
711}
712
713void AndIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
714 odsState.addOperands(lhs);
715 odsState.addOperands(rhs);
716 odsState.addTypes({lhs.getType()});
717
718}
719
720void AndIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
721 odsState.addOperands(operands);
722 odsState.addAttributes(attributes);
723 odsState.addTypes({operands[0].getType()});
724
725}
726
727::mlir::LogicalResult AndIOp::verify() {
728 {
729 unsigned index = 0; (void)index;
730 auto valueGroup0 = getODSOperands(0);
731
732 for (auto v : valueGroup0) {
733 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
734 return ::mlir::failure();
735 }
736 auto valueGroup1 = getODSOperands(1);
737
738 for (auto v : valueGroup1) {
739 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
740 return ::mlir::failure();
741 }
742 }
743 {
744 unsigned index = 0; (void)index;
745 auto valueGroup0 = getODSResults(0);
746
747 for (auto v : valueGroup0) {
748 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "result", index++)))
749 return ::mlir::failure();
750 }
751 }
752 return ::mlir::success();
753}
754
755::mlir::ParseResult AndIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
756 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
757 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
758 (void)lhsOperandsLoc;
759 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
760 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
761 (void)rhsOperandsLoc;
762 ::mlir::Type resultRawTypes[1];
763 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
764
765 lhsOperandsLoc = parser.getCurrentLocation();
766 if (parser.parseOperand(lhsRawOperands[0]))
767 return ::mlir::failure();
768 if (parser.parseComma())
769 return ::mlir::failure();
770
771 rhsOperandsLoc = parser.getCurrentLocation();
772 if (parser.parseOperand(rhsRawOperands[0]))
773 return ::mlir::failure();
774 if (parser.parseOptionalAttrDict(result.attributes))
775 return ::mlir::failure();
776 if (parser.parseColon())
777 return ::mlir::failure();
778
779 {
780 ::mlir::Type type;
781 if (parser.parseCustomTypeWithFallback(type))
782 return ::mlir::failure();
783 resultRawTypes[0] = type;
784 }
785 result.addTypes(resultTypes);
786 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
787 return ::mlir::failure();
788 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
789 return ::mlir::failure();
790 return ::mlir::success();
791}
792
793void AndIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
794 _odsPrinter << ' ';
795 _odsPrinter << getLhs();
796 _odsPrinter << ",";
797 _odsPrinter << ' ';
798 _odsPrinter << getRhs();
799 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
800 _odsPrinter << ' ' << ":";
801 _odsPrinter << ' ';
802 {
803 auto type = getResult().getType();
804 if (auto validType = type.dyn_cast<::mlir::Type>())
805 _odsPrinter.printStrippedAttrOrType(validType);
806 else
807 _odsPrinter << type;
808 }
809}
810
811void AndIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
812}
813
814} // namespace arith
815} // namespace mlir
816DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::AndIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::AndIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
817
818namespace mlir {
819namespace arith {
820
821//===----------------------------------------------------------------------===//
822// ::mlir::arith::BitcastOp definitions
823//===----------------------------------------------------------------------===//
824
825BitcastOpAdaptor::BitcastOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
826
827BitcastOpAdaptor::BitcastOpAdaptor(BitcastOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
828
829::mlir::ValueRange BitcastOpAdaptor::getOperands() {
830 return odsOperands;
831}
832
833std::pair<unsigned, unsigned> BitcastOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
834 return {index, 1};
835}
836
837::mlir::ValueRange BitcastOpAdaptor::getODSOperands(unsigned index) {
838 auto valueRange = getODSOperandIndexAndLength(index);
839 return {std::next(odsOperands.begin(), valueRange.first),
840 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
841}
842
843::mlir::Value BitcastOpAdaptor::getIn() {
844 return *getODSOperands(0).begin();
845}
846
847::mlir::DictionaryAttr BitcastOpAdaptor::getAttributes() {
848 return odsAttrs;
849}
850
851::mlir::LogicalResult BitcastOpAdaptor::verify(::mlir::Location loc) {
852 return ::mlir::success();
853}
854
855std::pair<unsigned, unsigned> BitcastOp::getODSOperandIndexAndLength(unsigned index) {
856 return {index, 1};
857}
858
859::mlir::Operation::operand_range BitcastOp::getODSOperands(unsigned index) {
860 auto valueRange = getODSOperandIndexAndLength(index);
861 return {std::next(getOperation()->operand_begin(), valueRange.first),
862 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
863}
864
865::mlir::Value BitcastOp::getIn() {
866 return *getODSOperands(0).begin();
867}
868
869::mlir::MutableOperandRange BitcastOp::getInMutable() {
870 auto range = getODSOperandIndexAndLength(0);
871 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
872 return mutableRange;
873}
874
875std::pair<unsigned, unsigned> BitcastOp::getODSResultIndexAndLength(unsigned index) {
876 return {index, 1};
877}
878
879::mlir::Operation::result_range BitcastOp::getODSResults(unsigned index) {
880 auto valueRange = getODSResultIndexAndLength(index);
881 return {std::next(getOperation()->result_begin(), valueRange.first),
882 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
883}
884
885::mlir::Value BitcastOp::getOut() {
886 return *getODSResults(0).begin();
887}
888
889void BitcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Type destType) {
890 impl::buildCastOp(odsBuilder, odsState, source, destType);
891
892}
893
894void BitcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) {
895 odsState.addOperands(in);
896 odsState.addTypes(out);
897}
898
899void BitcastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) {
900 odsState.addOperands(in);
901 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 901, __extension__ __PRETTY_FUNCTION__))
;
902 odsState.addTypes(resultTypes);
903}
904
905void BitcastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
906 assert(operands.size() == 1u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 1u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 1u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 906, __extension__ __PRETTY_FUNCTION__))
;
907 odsState.addOperands(operands);
908 odsState.addAttributes(attributes);
909 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 909, __extension__ __PRETTY_FUNCTION__))
;
910 odsState.addTypes(resultTypes);
911}
912
913::mlir::LogicalResult BitcastOp::verify() {
914 {
915 unsigned index = 0; (void)index;
916 auto valueGroup0 = getODSOperands(0);
917
918 for (auto v : valueGroup0) {
919 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps2(*this, v.getType(), "operand", index++)))
920 return ::mlir::failure();
921 }
922 }
923 {
924 unsigned index = 0; (void)index;
925 auto valueGroup0 = getODSResults(0);
926
927 for (auto v : valueGroup0) {
928 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps2(*this, v.getType(), "result", index++)))
929 return ::mlir::failure();
930 }
931 }
932 return ::mlir::success();
933}
934
935::mlir::ParseResult BitcastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
936 ::mlir::OpAsmParser::OperandType inRawOperands[1];
937 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> inOperands(inRawOperands); ::llvm::SMLoc inOperandsLoc;
938 (void)inOperandsLoc;
939 ::mlir::Type inRawTypes[1];
940 ::llvm::ArrayRef<::mlir::Type> inTypes(inRawTypes);
941 ::mlir::Type outRawTypes[1];
942 ::llvm::ArrayRef<::mlir::Type> outTypes(outRawTypes);
943
944 inOperandsLoc = parser.getCurrentLocation();
945 if (parser.parseOperand(inRawOperands[0]))
946 return ::mlir::failure();
947 if (parser.parseOptionalAttrDict(result.attributes))
948 return ::mlir::failure();
949 if (parser.parseColon())
950 return ::mlir::failure();
951
952 {
953 ::mlir::Type type;
954 if (parser.parseCustomTypeWithFallback(type))
955 return ::mlir::failure();
956 inRawTypes[0] = type;
957 }
958 if (parser.parseKeyword("to"))
959 return ::mlir::failure();
960
961 {
962 ::mlir::Type type;
963 if (parser.parseCustomTypeWithFallback(type))
964 return ::mlir::failure();
965 outRawTypes[0] = type;
966 }
967 result.addTypes(outTypes);
968 if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands))
969 return ::mlir::failure();
970 return ::mlir::success();
971}
972
973void BitcastOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
974 _odsPrinter << ' ';
975 _odsPrinter << getIn();
976 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
977 _odsPrinter << ' ' << ":";
978 _odsPrinter << ' ';
979 {
980 auto type = getIn().getType();
981 if (auto validType = type.dyn_cast<::mlir::Type>())
982 _odsPrinter.printStrippedAttrOrType(validType);
983 else
984 _odsPrinter << type;
985 }
986 _odsPrinter << ' ' << "to";
987 _odsPrinter << ' ';
988 {
989 auto type = getOut().getType();
990 if (auto validType = type.dyn_cast<::mlir::Type>())
991 _odsPrinter.printStrippedAttrOrType(validType);
992 else
993 _odsPrinter << type;
994 }
995}
996
997void BitcastOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
998}
999
1000} // namespace arith
1001} // namespace mlir
1002DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::BitcastOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::BitcastOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
1003
1004namespace mlir {
1005namespace arith {
1006
1007//===----------------------------------------------------------------------===//
1008// ::mlir::arith::CeilDivSIOp definitions
1009//===----------------------------------------------------------------------===//
1010
1011CeilDivSIOpAdaptor::CeilDivSIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
1012
1013CeilDivSIOpAdaptor::CeilDivSIOpAdaptor(CeilDivSIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
1014
1015::mlir::ValueRange CeilDivSIOpAdaptor::getOperands() {
1016 return odsOperands;
1017}
1018
1019std::pair<unsigned, unsigned> CeilDivSIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
1020 return {index, 1};
1021}
1022
1023::mlir::ValueRange CeilDivSIOpAdaptor::getODSOperands(unsigned index) {
1024 auto valueRange = getODSOperandIndexAndLength(index);
1025 return {std::next(odsOperands.begin(), valueRange.first),
1026 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1027}
1028
1029::mlir::Value CeilDivSIOpAdaptor::getLhs() {
1030 return *getODSOperands(0).begin();
1031}
1032
1033::mlir::Value CeilDivSIOpAdaptor::getRhs() {
1034 return *getODSOperands(1).begin();
1035}
1036
1037::mlir::DictionaryAttr CeilDivSIOpAdaptor::getAttributes() {
1038 return odsAttrs;
1039}
1040
1041::mlir::LogicalResult CeilDivSIOpAdaptor::verify(::mlir::Location loc) {
1042 return ::mlir::success();
1043}
1044
1045std::pair<unsigned, unsigned> CeilDivSIOp::getODSOperandIndexAndLength(unsigned index) {
1046 return {index, 1};
1047}
1048
1049::mlir::Operation::operand_range CeilDivSIOp::getODSOperands(unsigned index) {
1050 auto valueRange = getODSOperandIndexAndLength(index);
1051 return {std::next(getOperation()->operand_begin(), valueRange.first),
1052 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1053}
1054
1055::mlir::Value CeilDivSIOp::getLhs() {
1056 return *getODSOperands(0).begin();
1057}
1058
1059::mlir::Value CeilDivSIOp::getRhs() {
1060 return *getODSOperands(1).begin();
1061}
1062
1063::mlir::MutableOperandRange CeilDivSIOp::getLhsMutable() {
1064 auto range = getODSOperandIndexAndLength(0);
1065 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1066 return mutableRange;
1067}
1068
1069::mlir::MutableOperandRange CeilDivSIOp::getRhsMutable() {
1070 auto range = getODSOperandIndexAndLength(1);
1071 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1072 return mutableRange;
1073}
1074
1075std::pair<unsigned, unsigned> CeilDivSIOp::getODSResultIndexAndLength(unsigned index) {
1076 return {index, 1};
1077}
1078
1079::mlir::Operation::result_range CeilDivSIOp::getODSResults(unsigned index) {
1080 auto valueRange = getODSResultIndexAndLength(index);
1081 return {std::next(getOperation()->result_begin(), valueRange.first),
1082 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1083}
1084
1085::mlir::Value CeilDivSIOp::getResult() {
1086 return *getODSResults(0).begin();
1087}
1088
1089void CeilDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
1090 odsState.addOperands(lhs);
1091 odsState.addOperands(rhs);
1092 odsState.addTypes(result);
1093}
1094
1095void CeilDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
1096 odsState.addOperands(lhs);
1097 odsState.addOperands(rhs);
1098 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1098, __extension__ __PRETTY_FUNCTION__))
;
1099 odsState.addTypes(resultTypes);
1100}
1101
1102void CeilDivSIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1103 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1103, __extension__ __PRETTY_FUNCTION__))
;
1104 odsState.addOperands(operands);
1105 odsState.addAttributes(attributes);
1106 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1106, __extension__ __PRETTY_FUNCTION__))
;
1107 odsState.addTypes(resultTypes);
1108}
1109
1110void CeilDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
1111 odsState.addOperands(lhs);
1112 odsState.addOperands(rhs);
1113 odsState.addTypes({lhs.getType()});
1114
1115}
1116
1117void CeilDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1118 odsState.addOperands(operands);
1119 odsState.addAttributes(attributes);
1120 odsState.addTypes({operands[0].getType()});
1121
1122}
1123
1124::mlir::LogicalResult CeilDivSIOp::verify() {
1125 {
1126 unsigned index = 0; (void)index;
1127 auto valueGroup0 = getODSOperands(0);
1128
1129 for (auto v : valueGroup0) {
1130 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
1131 return ::mlir::failure();
1132 }
1133 auto valueGroup1 = getODSOperands(1);
1134
1135 for (auto v : valueGroup1) {
1136 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
1137 return ::mlir::failure();
1138 }
1139 }
1140 {
1141 unsigned index = 0; (void)index;
1142 auto valueGroup0 = getODSResults(0);
1143
1144 for (auto v : valueGroup0) {
1145 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "result", index++)))
1146 return ::mlir::failure();
1147 }
1148 }
1149 return ::mlir::success();
1150}
1151
1152::mlir::ParseResult CeilDivSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1153 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
1154 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
1155 (void)lhsOperandsLoc;
1156 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
1157 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
1158 (void)rhsOperandsLoc;
1159 ::mlir::Type resultRawTypes[1];
1160 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
1161
1162 lhsOperandsLoc = parser.getCurrentLocation();
1163 if (parser.parseOperand(lhsRawOperands[0]))
1164 return ::mlir::failure();
1165 if (parser.parseComma())
1166 return ::mlir::failure();
1167
1168 rhsOperandsLoc = parser.getCurrentLocation();
1169 if (parser.parseOperand(rhsRawOperands[0]))
1170 return ::mlir::failure();
1171 if (parser.parseOptionalAttrDict(result.attributes))
1172 return ::mlir::failure();
1173 if (parser.parseColon())
1174 return ::mlir::failure();
1175
1176 {
1177 ::mlir::Type type;
1178 if (parser.parseCustomTypeWithFallback(type))
1179 return ::mlir::failure();
1180 resultRawTypes[0] = type;
1181 }
1182 result.addTypes(resultTypes);
1183 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
1184 return ::mlir::failure();
1185 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
1186 return ::mlir::failure();
1187 return ::mlir::success();
1188}
1189
1190void CeilDivSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1191 _odsPrinter << ' ';
1192 _odsPrinter << getLhs();
1193 _odsPrinter << ",";
1194 _odsPrinter << ' ';
1195 _odsPrinter << getRhs();
1196 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
1197 _odsPrinter << ' ' << ":";
1198 _odsPrinter << ' ';
1199 {
1200 auto type = getResult().getType();
1201 if (auto validType = type.dyn_cast<::mlir::Type>())
1202 _odsPrinter.printStrippedAttrOrType(validType);
1203 else
1204 _odsPrinter << type;
1205 }
1206}
1207
1208void CeilDivSIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
1209}
1210
1211} // namespace arith
1212} // namespace mlir
1213DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CeilDivSIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::CeilDivSIOp>() { static TypeID::Storage instance;
return TypeID(&instance); } } }
1214
1215namespace mlir {
1216namespace arith {
1217
1218//===----------------------------------------------------------------------===//
1219// ::mlir::arith::CeilDivUIOp definitions
1220//===----------------------------------------------------------------------===//
1221
1222CeilDivUIOpAdaptor::CeilDivUIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
1223
1224CeilDivUIOpAdaptor::CeilDivUIOpAdaptor(CeilDivUIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
1225
1226::mlir::ValueRange CeilDivUIOpAdaptor::getOperands() {
1227 return odsOperands;
1228}
1229
1230std::pair<unsigned, unsigned> CeilDivUIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
1231 return {index, 1};
1232}
1233
1234::mlir::ValueRange CeilDivUIOpAdaptor::getODSOperands(unsigned index) {
1235 auto valueRange = getODSOperandIndexAndLength(index);
1236 return {std::next(odsOperands.begin(), valueRange.first),
1237 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1238}
1239
1240::mlir::Value CeilDivUIOpAdaptor::getLhs() {
1241 return *getODSOperands(0).begin();
1242}
1243
1244::mlir::Value CeilDivUIOpAdaptor::getRhs() {
1245 return *getODSOperands(1).begin();
1246}
1247
1248::mlir::DictionaryAttr CeilDivUIOpAdaptor::getAttributes() {
1249 return odsAttrs;
1250}
1251
1252::mlir::LogicalResult CeilDivUIOpAdaptor::verify(::mlir::Location loc) {
1253 return ::mlir::success();
1254}
1255
1256std::pair<unsigned, unsigned> CeilDivUIOp::getODSOperandIndexAndLength(unsigned index) {
1257 return {index, 1};
1258}
1259
1260::mlir::Operation::operand_range CeilDivUIOp::getODSOperands(unsigned index) {
1261 auto valueRange = getODSOperandIndexAndLength(index);
1262 return {std::next(getOperation()->operand_begin(), valueRange.first),
1263 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1264}
1265
1266::mlir::Value CeilDivUIOp::getLhs() {
1267 return *getODSOperands(0).begin();
1268}
1269
1270::mlir::Value CeilDivUIOp::getRhs() {
1271 return *getODSOperands(1).begin();
1272}
1273
1274::mlir::MutableOperandRange CeilDivUIOp::getLhsMutable() {
1275 auto range = getODSOperandIndexAndLength(0);
1276 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1277 return mutableRange;
1278}
1279
1280::mlir::MutableOperandRange CeilDivUIOp::getRhsMutable() {
1281 auto range = getODSOperandIndexAndLength(1);
1282 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1283 return mutableRange;
1284}
1285
1286std::pair<unsigned, unsigned> CeilDivUIOp::getODSResultIndexAndLength(unsigned index) {
1287 return {index, 1};
1288}
1289
1290::mlir::Operation::result_range CeilDivUIOp::getODSResults(unsigned index) {
1291 auto valueRange = getODSResultIndexAndLength(index);
1292 return {std::next(getOperation()->result_begin(), valueRange.first),
1293 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1294}
1295
1296::mlir::Value CeilDivUIOp::getResult() {
1297 return *getODSResults(0).begin();
1298}
1299
1300void CeilDivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
1301 odsState.addOperands(lhs);
1302 odsState.addOperands(rhs);
1303 odsState.addTypes(result);
1304}
1305
1306void CeilDivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
1307 odsState.addOperands(lhs);
1308 odsState.addOperands(rhs);
1309 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1309, __extension__ __PRETTY_FUNCTION__))
;
1310 odsState.addTypes(resultTypes);
1311}
1312
1313void CeilDivUIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1314 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1314, __extension__ __PRETTY_FUNCTION__))
;
1315 odsState.addOperands(operands);
1316 odsState.addAttributes(attributes);
1317 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1317, __extension__ __PRETTY_FUNCTION__))
;
1318 odsState.addTypes(resultTypes);
1319}
1320
1321void CeilDivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
1322 odsState.addOperands(lhs);
1323 odsState.addOperands(rhs);
1324 odsState.addTypes({lhs.getType()});
1325
1326}
1327
1328void CeilDivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1329 odsState.addOperands(operands);
1330 odsState.addAttributes(attributes);
1331 odsState.addTypes({operands[0].getType()});
1332
1333}
1334
1335::mlir::LogicalResult CeilDivUIOp::verify() {
1336 {
1337 unsigned index = 0; (void)index;
1338 auto valueGroup0 = getODSOperands(0);
1339
1340 for (auto v : valueGroup0) {
1341 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
1342 return ::mlir::failure();
1343 }
1344 auto valueGroup1 = getODSOperands(1);
1345
1346 for (auto v : valueGroup1) {
1347 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
1348 return ::mlir::failure();
1349 }
1350 }
1351 {
1352 unsigned index = 0; (void)index;
1353 auto valueGroup0 = getODSResults(0);
1354
1355 for (auto v : valueGroup0) {
1356 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "result", index++)))
1357 return ::mlir::failure();
1358 }
1359 }
1360 return ::mlir::success();
1361}
1362
1363::mlir::ParseResult CeilDivUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1364 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
1365 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
1366 (void)lhsOperandsLoc;
1367 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
1368 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
1369 (void)rhsOperandsLoc;
1370 ::mlir::Type resultRawTypes[1];
1371 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
1372
1373 lhsOperandsLoc = parser.getCurrentLocation();
1374 if (parser.parseOperand(lhsRawOperands[0]))
1375 return ::mlir::failure();
1376 if (parser.parseComma())
1377 return ::mlir::failure();
1378
1379 rhsOperandsLoc = parser.getCurrentLocation();
1380 if (parser.parseOperand(rhsRawOperands[0]))
1381 return ::mlir::failure();
1382 if (parser.parseOptionalAttrDict(result.attributes))
1383 return ::mlir::failure();
1384 if (parser.parseColon())
1385 return ::mlir::failure();
1386
1387 {
1388 ::mlir::Type type;
1389 if (parser.parseCustomTypeWithFallback(type))
1390 return ::mlir::failure();
1391 resultRawTypes[0] = type;
1392 }
1393 result.addTypes(resultTypes);
1394 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
1395 return ::mlir::failure();
1396 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
1397 return ::mlir::failure();
1398 return ::mlir::success();
1399}
1400
1401void CeilDivUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1402 _odsPrinter << ' ';
1403 _odsPrinter << getLhs();
1404 _odsPrinter << ",";
1405 _odsPrinter << ' ';
1406 _odsPrinter << getRhs();
1407 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
1408 _odsPrinter << ' ' << ":";
1409 _odsPrinter << ' ';
1410 {
1411 auto type = getResult().getType();
1412 if (auto validType = type.dyn_cast<::mlir::Type>())
1413 _odsPrinter.printStrippedAttrOrType(validType);
1414 else
1415 _odsPrinter << type;
1416 }
1417}
1418
1419void CeilDivUIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
1420}
1421
1422} // namespace arith
1423} // namespace mlir
1424DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CeilDivUIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::CeilDivUIOp>() { static TypeID::Storage instance;
return TypeID(&instance); } } }
1425
1426namespace mlir {
1427namespace arith {
1428
1429//===----------------------------------------------------------------------===//
1430// ::mlir::arith::CmpFOp definitions
1431//===----------------------------------------------------------------------===//
1432
1433CmpFOpAdaptor::CmpFOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
1434
1435CmpFOpAdaptor::CmpFOpAdaptor(CmpFOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
1436
1437::mlir::ValueRange CmpFOpAdaptor::getOperands() {
1438 return odsOperands;
1439}
1440
1441std::pair<unsigned, unsigned> CmpFOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
1442 return {index, 1};
1443}
1444
1445::mlir::ValueRange CmpFOpAdaptor::getODSOperands(unsigned index) {
1446 auto valueRange = getODSOperandIndexAndLength(index);
1447 return {std::next(odsOperands.begin(), valueRange.first),
1448 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1449}
1450
1451::mlir::Value CmpFOpAdaptor::getLhs() {
1452 return *getODSOperands(0).begin();
1453}
1454
1455::mlir::Value CmpFOpAdaptor::getRhs() {
1456 return *getODSOperands(1).begin();
1457}
1458
1459::mlir::DictionaryAttr CmpFOpAdaptor::getAttributes() {
1460 return odsAttrs;
1461}
1462
1463::mlir::arith::CmpFPredicateAttr CmpFOpAdaptor::getPredicateAttr() {
1464 assert(odsAttrs && "no attributes when constructing adapter")(static_cast <bool> (odsAttrs && "no attributes when constructing adapter"
) ? void (0) : __assert_fail ("odsAttrs && \"no attributes when constructing adapter\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1464, __extension__ __PRETTY_FUNCTION__))
;
1465 ::mlir::arith::CmpFPredicateAttr attr = odsAttrs.get("predicate").cast<::mlir::arith::CmpFPredicateAttr>();
1466 return attr;
1467}
1468
1469::mlir::arith::CmpFPredicate CmpFOpAdaptor::getPredicate() {
1470 auto attr = getPredicateAttr();
1471 return attr.getValue();
1472}
1473
1474::mlir::LogicalResult CmpFOpAdaptor::verify(::mlir::Location loc) {
1475 {
1476 auto tblgen_predicate = odsAttrs.get("predicate");
1477 if (!tblgen_predicate)
1478 return emitError(loc, "'arith.cmpf' op ""requires attribute 'predicate'");
1479
1480 if (tblgen_predicate && !((tblgen_predicate.isa<::mlir::arith::CmpFPredicateAttr>())))
1481 return emitError(loc, "'arith.cmpf' op ""attribute 'predicate' failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15");
1482 }
1483 return ::mlir::success();
1484}
1485
1486std::pair<unsigned, unsigned> CmpFOp::getODSOperandIndexAndLength(unsigned index) {
1487 return {index, 1};
1488}
1489
1490::mlir::Operation::operand_range CmpFOp::getODSOperands(unsigned index) {
1491 auto valueRange = getODSOperandIndexAndLength(index);
1492 return {std::next(getOperation()->operand_begin(), valueRange.first),
1493 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1494}
1495
1496::mlir::Value CmpFOp::getLhs() {
1497 return *getODSOperands(0).begin();
1498}
1499
1500::mlir::Value CmpFOp::getRhs() {
1501 return *getODSOperands(1).begin();
1502}
1503
1504::mlir::MutableOperandRange CmpFOp::getLhsMutable() {
1505 auto range = getODSOperandIndexAndLength(0);
1506 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1507 return mutableRange;
1508}
1509
1510::mlir::MutableOperandRange CmpFOp::getRhsMutable() {
1511 auto range = getODSOperandIndexAndLength(1);
1512 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1513 return mutableRange;
1514}
1515
1516std::pair<unsigned, unsigned> CmpFOp::getODSResultIndexAndLength(unsigned index) {
1517 return {index, 1};
1518}
1519
1520::mlir::Operation::result_range CmpFOp::getODSResults(unsigned index) {
1521 auto valueRange = getODSResultIndexAndLength(index);
1522 return {std::next(getOperation()->result_begin(), valueRange.first),
1523 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1524}
1525
1526::mlir::Value CmpFOp::getResult() {
1527 return *getODSResults(0).begin();
1528}
1529
1530::mlir::arith::CmpFPredicateAttr CmpFOp::getPredicateAttr() {
1531 return (*this)->getAttr(getPredicateAttrName()).cast<::mlir::arith::CmpFPredicateAttr>();
1532}
1533
1534::mlir::arith::CmpFPredicate CmpFOp::getPredicate() {
1535 auto attr = getPredicateAttr();
1536 return attr.getValue();
1537}
1538
1539void CmpFOp::setPredicateAttr(::mlir::arith::CmpFPredicateAttr attr) {
1540 (*this)->setAttr(getPredicateAttrName(), attr);
1541}
1542
1543void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, CmpFPredicate predicate, Value lhs, Value rhs) {
1544 build(odsBuilder, odsState, ::getI1SameShape(lhs.getType()),
1545 predicate, lhs, rhs);
1546
1547}
1548
1549void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1550 odsState.addOperands(lhs);
1551 odsState.addOperands(rhs);
1552 odsState.addAttribute(getPredicateAttrName(odsState.name), predicate);
1553 odsState.addTypes(result);
1554}
1555
1556void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1557 odsState.addOperands(lhs);
1558 odsState.addOperands(rhs);
1559 odsState.addAttribute(getPredicateAttrName(odsState.name), predicate);
1560 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1560, __extension__ __PRETTY_FUNCTION__))
;
1561 odsState.addTypes(resultTypes);
1562}
1563
1564void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1565 odsState.addOperands(lhs);
1566 odsState.addOperands(rhs);
1567 odsState.addAttribute(getPredicateAttrName(odsState.name), ::mlir::arith::CmpFPredicateAttr::get(odsBuilder.getContext(), predicate));
1568 odsState.addTypes(result);
1569}
1570
1571void CmpFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpFPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1572 odsState.addOperands(lhs);
1573 odsState.addOperands(rhs);
1574 odsState.addAttribute(getPredicateAttrName(odsState.name), ::mlir::arith::CmpFPredicateAttr::get(odsBuilder.getContext(), predicate));
1575 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1575, __extension__ __PRETTY_FUNCTION__))
;
1576 odsState.addTypes(resultTypes);
1577}
1578
1579void CmpFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1580 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1580, __extension__ __PRETTY_FUNCTION__))
;
1581 odsState.addOperands(operands);
1582 odsState.addAttributes(attributes);
1583 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1583, __extension__ __PRETTY_FUNCTION__))
;
1584 odsState.addTypes(resultTypes);
1585}
1586
1587::mlir::LogicalResult CmpFOp::verify() {
1588 {
1589 auto tblgen_predicate = (*this)->getAttr(getPredicateAttrName());
1590 if (!tblgen_predicate)
1591 return emitOpError("requires attribute 'predicate'");
1592
1593 if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithmeticOps0(*this, tblgen_predicate, "predicate")))
1594 return ::mlir::failure();
1595 }
1596 {
1597 unsigned index = 0; (void)index;
1598 auto valueGroup0 = getODSOperands(0);
1599
1600 for (auto v : valueGroup0) {
1601 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
1602 return ::mlir::failure();
1603 }
1604 auto valueGroup1 = getODSOperands(1);
1605
1606 for (auto v : valueGroup1) {
1607 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
1608 return ::mlir::failure();
1609 }
1610 }
1611 {
1612 unsigned index = 0; (void)index;
1613 auto valueGroup0 = getODSResults(0);
1614
1615 for (auto v : valueGroup0) {
1616 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps3(*this, v.getType(), "result", index++)))
1617 return ::mlir::failure();
1618 }
1619 }
1620 if (!((std::equal_to<>()(::getI1SameShape((*this->getODSOperands(0).begin()).getType()), (*this->getODSResults(0).begin()).getType()))))
1621 return emitOpError("failed to verify that result type has i1 element type and same shape as operands");
1622 return ::mlir::success();
1623}
1624
1625::mlir::ParseResult CmpFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1626 ::mlir::arith::CmpFPredicateAttr predicateAttr;
1627 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
1628 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
1629 (void)lhsOperandsLoc;
1630 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
1631 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
1632 (void)rhsOperandsLoc;
1633 ::mlir::Type lhsRawTypes[1];
1634 ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes);
1635
1636 {
1637 ::llvm::StringRef attrStr;
1638 ::mlir::NamedAttrList attrStorage;
1639 auto loc = parser.getCurrentLocation();
1640 if (parser.parseOptionalKeyword(&attrStr, {"false","oeq","ogt","oge","olt","ole","one","ord","ueq","ugt","uge","ult","ule","une","uno","true"})) {
1641 ::mlir::StringAttr attrVal;
1642 ::mlir::OptionalParseResult parseResult =
1643 parser.parseOptionalAttribute(attrVal,
1644 parser.getBuilder().getNoneType(),
1645 "predicate", attrStorage);
1646 if (parseResult.hasValue()) {
1647 if (failed(*parseResult))
1648 return ::mlir::failure();
1649 attrStr = attrVal.getValue();
1650 } else {
1651 return parser.emitError(loc, "expected string or keyword containing one of the following enum values for attribute 'predicate' [false, oeq, ogt, oge, olt, ole, one, ord, ueq, ugt, uge, ult, ule, une, uno, true]");
1652 }
1653 }
1654 if (!attrStr.empty()) {
1655 auto attrOptional = ::mlir::arith::symbolizeCmpFPredicate(attrStr);
1656 if (!attrOptional)
1657 return parser.emitError(loc, "invalid ")
1658 << "predicate attribute specification: \"" << attrStr << '"';;
1659
1660 predicateAttr = ::mlir::arith::CmpFPredicateAttr::get(parser.getBuilder().getContext(), attrOptional.getValue());
1661 result.addAttribute("predicate", predicateAttr);
1662 }
1663 }
1664 if (parser.parseComma())
1665 return ::mlir::failure();
1666
1667 lhsOperandsLoc = parser.getCurrentLocation();
1668 if (parser.parseOperand(lhsRawOperands[0]))
1669 return ::mlir::failure();
1670 if (parser.parseComma())
1671 return ::mlir::failure();
1672
1673 rhsOperandsLoc = parser.getCurrentLocation();
1674 if (parser.parseOperand(rhsRawOperands[0]))
1675 return ::mlir::failure();
1676 if (parser.parseOptionalAttrDict(result.attributes))
1677 return ::mlir::failure();
1678 if (parser.parseColon())
1679 return ::mlir::failure();
1680
1681 {
1682 ::mlir::Type type;
1683 if (parser.parseCustomTypeWithFallback(type))
1684 return ::mlir::failure();
1685 lhsRawTypes[0] = type;
1686 }
1687 for (::mlir::Type type : lhsTypes) {
1688 (void)type;
1689 if (!(((type.isa<::mlir::FloatType>())) || ((((type.isa<::mlir::VectorType>())) && ((type.cast<::mlir::VectorType>().getRank() > 0))) && ([](::mlir::Type elementType) { return (elementType.isa<::mlir::FloatType>()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isa<::mlir::FloatType>()); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
1690 return parser.emitError(parser.getNameLoc()) << "'lhs' must be floating-point-like, but got " << type;
1691 }
1692 }
1693 result.addTypes(::getI1SameShape(lhsTypes[0]));
1694 if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands))
1695 return ::mlir::failure();
1696 if (parser.resolveOperands(rhsOperands, lhsTypes[0], result.operands))
1697 return ::mlir::failure();
1698 return ::mlir::success();
1699}
1700
1701void CmpFOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1702 _odsPrinter << ' ';
1703
1704 {
1705 auto caseValue = getPredicate();
1706 auto caseValueStr = stringifyCmpFPredicate(caseValue);
1707 _odsPrinter << caseValueStr;
1708 }
1709 _odsPrinter << ",";
1710 _odsPrinter << ' ';
1711 _odsPrinter << getLhs();
1712 _odsPrinter << ",";
1713 _odsPrinter << ' ';
1714 _odsPrinter << getRhs();
1715 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"predicate"});
1716 _odsPrinter << ' ' << ":";
1717 _odsPrinter << ' ';
1718 {
1719 auto type = getLhs().getType();
1720 if (auto validType = type.dyn_cast<::mlir::Type>())
1721 _odsPrinter.printStrippedAttrOrType(validType);
1722 else
1723 _odsPrinter << type;
1724 }
1725}
1726
1727void CmpFOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
1728}
1729
1730} // namespace arith
1731} // namespace mlir
1732DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CmpFOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::CmpFOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
1733
1734namespace mlir {
1735namespace arith {
1736
1737//===----------------------------------------------------------------------===//
1738// ::mlir::arith::CmpIOp definitions
1739//===----------------------------------------------------------------------===//
1740
1741CmpIOpAdaptor::CmpIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
1742
1743CmpIOpAdaptor::CmpIOpAdaptor(CmpIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
1744
1745::mlir::ValueRange CmpIOpAdaptor::getOperands() {
1746 return odsOperands;
1747}
1748
1749std::pair<unsigned, unsigned> CmpIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
1750 return {index, 1};
1751}
1752
1753::mlir::ValueRange CmpIOpAdaptor::getODSOperands(unsigned index) {
1754 auto valueRange = getODSOperandIndexAndLength(index);
1755 return {std::next(odsOperands.begin(), valueRange.first),
1756 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
1757}
1758
1759::mlir::Value CmpIOpAdaptor::getLhs() {
1760 return *getODSOperands(0).begin();
1761}
1762
1763::mlir::Value CmpIOpAdaptor::getRhs() {
1764 return *getODSOperands(1).begin();
1765}
1766
1767::mlir::DictionaryAttr CmpIOpAdaptor::getAttributes() {
1768 return odsAttrs;
1769}
1770
1771::mlir::arith::CmpIPredicateAttr CmpIOpAdaptor::getPredicateAttr() {
1772 assert(odsAttrs && "no attributes when constructing adapter")(static_cast <bool> (odsAttrs && "no attributes when constructing adapter"
) ? void (0) : __assert_fail ("odsAttrs && \"no attributes when constructing adapter\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1772, __extension__ __PRETTY_FUNCTION__))
;
1773 ::mlir::arith::CmpIPredicateAttr attr = odsAttrs.get("predicate").cast<::mlir::arith::CmpIPredicateAttr>();
1774 return attr;
1775}
1776
1777::mlir::arith::CmpIPredicate CmpIOpAdaptor::getPredicate() {
1778 auto attr = getPredicateAttr();
1779 return attr.getValue();
1780}
1781
1782::mlir::LogicalResult CmpIOpAdaptor::verify(::mlir::Location loc) {
1783 {
1784 auto tblgen_predicate = odsAttrs.get("predicate");
1785 if (!tblgen_predicate)
1786 return emitError(loc, "'arith.cmpi' op ""requires attribute 'predicate'");
1787
1788 if (tblgen_predicate && !((tblgen_predicate.isa<::mlir::arith::CmpIPredicateAttr>())))
1789 return emitError(loc, "'arith.cmpi' op ""attribute 'predicate' failed to satisfy constraint: allowed 64-bit signless integer cases: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9");
1790 }
1791 return ::mlir::success();
1792}
1793
1794std::pair<unsigned, unsigned> CmpIOp::getODSOperandIndexAndLength(unsigned index) {
1795 return {index, 1};
1796}
1797
1798::mlir::Operation::operand_range CmpIOp::getODSOperands(unsigned index) {
1799 auto valueRange = getODSOperandIndexAndLength(index);
1800 return {std::next(getOperation()->operand_begin(), valueRange.first),
1801 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1802}
1803
1804::mlir::Value CmpIOp::getLhs() {
1805 return *getODSOperands(0).begin();
1806}
1807
1808::mlir::Value CmpIOp::getRhs() {
1809 return *getODSOperands(1).begin();
1810}
1811
1812::mlir::MutableOperandRange CmpIOp::getLhsMutable() {
1813 auto range = getODSOperandIndexAndLength(0);
1814 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1815 return mutableRange;
1816}
1817
1818::mlir::MutableOperandRange CmpIOp::getRhsMutable() {
1819 auto range = getODSOperandIndexAndLength(1);
1820 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
1821 return mutableRange;
1822}
1823
1824std::pair<unsigned, unsigned> CmpIOp::getODSResultIndexAndLength(unsigned index) {
1825 return {index, 1};
1826}
1827
1828::mlir::Operation::result_range CmpIOp::getODSResults(unsigned index) {
1829 auto valueRange = getODSResultIndexAndLength(index);
1830 return {std::next(getOperation()->result_begin(), valueRange.first),
1831 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1832}
1833
1834::mlir::Value CmpIOp::getResult() {
1835 return *getODSResults(0).begin();
1836}
1837
1838::mlir::arith::CmpIPredicateAttr CmpIOp::getPredicateAttr() {
1839 return (*this)->getAttr(getPredicateAttrName()).cast<::mlir::arith::CmpIPredicateAttr>();
1840}
1841
1842::mlir::arith::CmpIPredicate CmpIOp::getPredicate() {
1843 auto attr = getPredicateAttr();
1844 return attr.getValue();
1845}
1846
1847void CmpIOp::setPredicateAttr(::mlir::arith::CmpIPredicateAttr attr) {
1848 (*this)->setAttr(getPredicateAttrName(), attr);
1849}
1850
1851void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, CmpIPredicate predicate, Value lhs, Value rhs) {
1852 build(odsBuilder, odsState, ::getI1SameShape(lhs.getType()),
1853 predicate, lhs, rhs);
1854
1855}
1856
1857void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1858 odsState.addOperands(lhs);
1859 odsState.addOperands(rhs);
1860 odsState.addAttribute(getPredicateAttrName(odsState.name), predicate);
1861 odsState.addTypes(result);
1862}
1863
1864void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicateAttr predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1865 odsState.addOperands(lhs);
1866 odsState.addOperands(rhs);
1867 odsState.addAttribute(getPredicateAttrName(odsState.name), predicate);
1868 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1868, __extension__ __PRETTY_FUNCTION__))
;
1869 odsState.addTypes(resultTypes);
1870}
1871
1872void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1873 odsState.addOperands(lhs);
1874 odsState.addOperands(rhs);
1875 odsState.addAttribute(getPredicateAttrName(odsState.name), ::mlir::arith::CmpIPredicateAttr::get(odsBuilder.getContext(), predicate));
1876 odsState.addTypes(result);
1877}
1878
1879void CmpIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::arith::CmpIPredicate predicate, ::mlir::Value lhs, ::mlir::Value rhs) {
1880 odsState.addOperands(lhs);
1881 odsState.addOperands(rhs);
1882 odsState.addAttribute(getPredicateAttrName(odsState.name), ::mlir::arith::CmpIPredicateAttr::get(odsBuilder.getContext(), predicate));
1883 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1883, __extension__ __PRETTY_FUNCTION__))
;
1884 odsState.addTypes(resultTypes);
1885}
1886
1887void CmpIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1888 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1888, __extension__ __PRETTY_FUNCTION__))
;
1889 odsState.addOperands(operands);
1890 odsState.addAttributes(attributes);
1891 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 1891, __extension__ __PRETTY_FUNCTION__))
;
1892 odsState.addTypes(resultTypes);
1893}
1894
1895::mlir::LogicalResult CmpIOp::verify() {
1896 {
1897 auto tblgen_predicate = (*this)->getAttr(getPredicateAttrName());
1898 if (!tblgen_predicate)
1899 return emitOpError("requires attribute 'predicate'");
1900
1901 if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithmeticOps1(*this, tblgen_predicate, "predicate")))
1902 return ::mlir::failure();
1903 }
1904 {
1905 unsigned index = 0; (void)index;
1906 auto valueGroup0 = getODSOperands(0);
1907
1908 for (auto v : valueGroup0) {
1909 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps4(*this, v.getType(), "operand", index++)))
1910 return ::mlir::failure();
1911 }
1912 auto valueGroup1 = getODSOperands(1);
1913
1914 for (auto v : valueGroup1) {
1915 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps4(*this, v.getType(), "operand", index++)))
1916 return ::mlir::failure();
1917 }
1918 }
1919 {
1920 unsigned index = 0; (void)index;
1921 auto valueGroup0 = getODSResults(0);
1922
1923 for (auto v : valueGroup0) {
1924 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps5(*this, v.getType(), "result", index++)))
1925 return ::mlir::failure();
1926 }
1927 }
1928 if (!((std::equal_to<>()(::getI1SameShape((*this->getODSOperands(0).begin()).getType()), (*this->getODSResults(0).begin()).getType()))))
1929 return emitOpError("failed to verify that result type has i1 element type and same shape as operands");
1930 return ::mlir::success();
1931}
1932
1933::mlir::ParseResult CmpIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1934 ::mlir::arith::CmpIPredicateAttr predicateAttr;
1935 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
1936 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
1937 (void)lhsOperandsLoc;
1938 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
1939 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
1940 (void)rhsOperandsLoc;
1941 ::mlir::Type lhsRawTypes[1];
1942 ::llvm::ArrayRef<::mlir::Type> lhsTypes(lhsRawTypes);
1943
1944 {
1945 ::llvm::StringRef attrStr;
1946 ::mlir::NamedAttrList attrStorage;
1947 auto loc = parser.getCurrentLocation();
1948 if (parser.parseOptionalKeyword(&attrStr, {"eq","ne","slt","sle","sgt","sge","ult","ule","ugt","uge"})) {
1949 ::mlir::StringAttr attrVal;
1950 ::mlir::OptionalParseResult parseResult =
1951 parser.parseOptionalAttribute(attrVal,
1952 parser.getBuilder().getNoneType(),
1953 "predicate", attrStorage);
1954 if (parseResult.hasValue()) {
1955 if (failed(*parseResult))
1956 return ::mlir::failure();
1957 attrStr = attrVal.getValue();
1958 } else {
1959 return parser.emitError(loc, "expected string or keyword containing one of the following enum values for attribute 'predicate' [eq, ne, slt, sle, sgt, sge, ult, ule, ugt, uge]");
1960 }
1961 }
1962 if (!attrStr.empty()) {
1963 auto attrOptional = ::mlir::arith::symbolizeCmpIPredicate(attrStr);
1964 if (!attrOptional)
1965 return parser.emitError(loc, "invalid ")
1966 << "predicate attribute specification: \"" << attrStr << '"';;
1967
1968 predicateAttr = ::mlir::arith::CmpIPredicateAttr::get(parser.getBuilder().getContext(), attrOptional.getValue());
1969 result.addAttribute("predicate", predicateAttr);
1970 }
1971 }
1972 if (parser.parseComma())
1973 return ::mlir::failure();
1974
1975 lhsOperandsLoc = parser.getCurrentLocation();
1976 if (parser.parseOperand(lhsRawOperands[0]))
1977 return ::mlir::failure();
1978 if (parser.parseComma())
1979 return ::mlir::failure();
1980
1981 rhsOperandsLoc = parser.getCurrentLocation();
1982 if (parser.parseOperand(rhsRawOperands[0]))
1983 return ::mlir::failure();
1984 if (parser.parseOptionalAttrDict(result.attributes))
1985 return ::mlir::failure();
1986 if (parser.parseColon())
1987 return ::mlir::failure();
1988
1989 {
1990 ::mlir::Type type;
1991 if (parser.parseCustomTypeWithFallback(type))
1992 return ::mlir::failure();
1993 lhsRawTypes[0] = type;
1994 }
1995 for (::mlir::Type type : lhsTypes) {
1996 (void)type;
1997 if (!(((type.isSignlessIntOrIndex())) || (((type.isa<::mlir::VectorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))) || (((type.isa<::mlir::TensorType>())) && ([](::mlir::Type elementType) { return (elementType.isSignlessIntOrIndex()); }(type.cast<::mlir::ShapedType>().getElementType()))))) {
1998 return parser.emitError(parser.getNameLoc()) << "'lhs' must be signless-integer-like, but got " << type;
1999 }
2000 }
2001 result.addTypes(::getI1SameShape(lhsTypes[0]));
2002 if (parser.resolveOperands(lhsOperands, lhsTypes, lhsOperandsLoc, result.operands))
2003 return ::mlir::failure();
2004 if (parser.resolveOperands(rhsOperands, lhsTypes[0], result.operands))
2005 return ::mlir::failure();
2006 return ::mlir::success();
2007}
2008
2009void CmpIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2010 _odsPrinter << ' ';
2011
2012 {
2013 auto caseValue = getPredicate();
2014 auto caseValueStr = stringifyCmpIPredicate(caseValue);
2015 _odsPrinter << caseValueStr;
2016 }
2017 _odsPrinter << ",";
2018 _odsPrinter << ' ';
2019 _odsPrinter << getLhs();
2020 _odsPrinter << ",";
2021 _odsPrinter << ' ';
2022 _odsPrinter << getRhs();
2023 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"predicate"});
2024 _odsPrinter << ' ' << ":";
2025 _odsPrinter << ' ';
2026 {
2027 auto type = getLhs().getType();
2028 if (auto validType = type.dyn_cast<::mlir::Type>())
2029 _odsPrinter.printStrippedAttrOrType(validType);
2030 else
2031 _odsPrinter << type;
2032 }
2033}
2034
2035void CmpIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
2036}
2037
2038} // namespace arith
2039} // namespace mlir
2040DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::CmpIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::CmpIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
2041
2042namespace mlir {
2043namespace arith {
2044
2045//===----------------------------------------------------------------------===//
2046// ::mlir::arith::ConstantOp definitions
2047//===----------------------------------------------------------------------===//
2048
2049ConstantOpAdaptor::ConstantOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
2050
2051ConstantOpAdaptor::ConstantOpAdaptor(ConstantOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
2052
2053::mlir::ValueRange ConstantOpAdaptor::getOperands() {
2054 return odsOperands;
2055}
2056
2057std::pair<unsigned, unsigned> ConstantOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
2058 return {index, 1};
2059}
2060
2061::mlir::ValueRange ConstantOpAdaptor::getODSOperands(unsigned index) {
2062 auto valueRange = getODSOperandIndexAndLength(index);
2063 return {std::next(odsOperands.begin(), valueRange.first),
2064 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
2065}
2066
2067::mlir::DictionaryAttr ConstantOpAdaptor::getAttributes() {
2068 return odsAttrs;
2069}
2070
2071::mlir::Attribute ConstantOpAdaptor::getValueAttr() {
2072 assert(odsAttrs && "no attributes when constructing adapter")(static_cast <bool> (odsAttrs && "no attributes when constructing adapter"
) ? void (0) : __assert_fail ("odsAttrs && \"no attributes when constructing adapter\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2072, __extension__ __PRETTY_FUNCTION__))
;
2073 ::mlir::Attribute attr = odsAttrs.get("value").cast<::mlir::Attribute>();
2074 return attr;
2075}
2076
2077::mlir::Attribute ConstantOpAdaptor::getValue() {
2078 auto attr = getValueAttr();
2079 return attr;
2080}
2081
2082::mlir::LogicalResult ConstantOpAdaptor::verify(::mlir::Location loc) {
2083 {
2084 auto tblgen_value = odsAttrs.get("value");
2085 if (!tblgen_value)
2086 return emitError(loc, "'arith.constant' op ""requires attribute 'value'");
2087
2088 if (tblgen_value && !((true)))
2089 return emitError(loc, "'arith.constant' op ""attribute 'value' failed to satisfy constraint: any attribute");
2090 }
2091 return ::mlir::success();
2092}
2093
2094std::pair<unsigned, unsigned> ConstantOp::getODSOperandIndexAndLength(unsigned index) {
2095 return {index, 1};
2096}
2097
2098::mlir::Operation::operand_range ConstantOp::getODSOperands(unsigned index) {
2099 auto valueRange = getODSOperandIndexAndLength(index);
2100 return {std::next(getOperation()->operand_begin(), valueRange.first),
2101 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
2102}
2103
2104std::pair<unsigned, unsigned> ConstantOp::getODSResultIndexAndLength(unsigned index) {
2105 return {index, 1};
2106}
2107
2108::mlir::Operation::result_range ConstantOp::getODSResults(unsigned index) {
2109 auto valueRange = getODSResultIndexAndLength(index);
2110 return {std::next(getOperation()->result_begin(), valueRange.first),
2111 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
2112}
2113
2114::mlir::Value ConstantOp::getResult() {
2115 return *getODSResults(0).begin();
2116}
2117
2118::mlir::Attribute ConstantOp::getValueAttr() {
2119 return (*this)->getAttr(getValueAttrName()).cast<::mlir::Attribute>();
2120}
2121
2122::mlir::Attribute ConstantOp::getValue() {
2123 auto attr = getValueAttr();
2124 return attr;
2125}
2126
2127void ConstantOp::setValueAttr(::mlir::Attribute attr) {
2128 (*this)->setAttr(getValueAttrName(), attr);
2129}
2130
2131void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Attribute value) {
2132 build(odsBuilder, odsState, value.getType(), value);
4
Calling 'Attribute::getType'
2133}
2134
2135void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Attribute value, Type type) {
2136 build(odsBuilder, odsState, type, value);
2137}
2138
2139void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Attribute value) {
2140 odsState.addAttribute(getValueAttrName(odsState.name), value);
2141 odsState.addTypes(result);
2142}
2143
2144void ConstantOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Attribute value) {
2145 odsState.addAttribute(getValueAttrName(odsState.name), value);
2146 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2146, __extension__ __PRETTY_FUNCTION__))
;
2147 odsState.addTypes(resultTypes);
2148}
2149
2150void ConstantOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2151 assert(operands.size() == 0u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 0u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 0u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2151, __extension__ __PRETTY_FUNCTION__))
;
2152 odsState.addOperands(operands);
2153 odsState.addAttributes(attributes);
2154 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2154, __extension__ __PRETTY_FUNCTION__))
;
2155 odsState.addTypes(resultTypes);
2156}
2157
2158::mlir::LogicalResult ConstantOp::verify() {
2159 {
2160 auto tblgen_value = (*this)->getAttr(getValueAttrName());
2161 if (!tblgen_value)
2162 return emitOpError("requires attribute 'value'");
2163
2164 if (::mlir::failed(__mlir_ods_local_attr_constraint_ArithmeticOps2(*this, tblgen_value, "value")))
2165 return ::mlir::failure();
2166 }
2167 {
2168 unsigned index = 0; (void)index;
2169 auto valueGroup0 = getODSResults(0);
2170
2171 for (auto v : valueGroup0) {
2172 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps6(*this, v.getType(), "result", index++)))
2173 return ::mlir::failure();
2174 }
2175 }
2176 if (!((std::equal_to<>()((*this)->getAttr(getValueAttrName()).getType(), (*this->getODSResults(0).begin()).getType()))))
2177 return emitOpError("failed to verify that result and attribute have the same type");
2178 return ::verify(*this);
2179}
2180
2181::mlir::ParseResult ConstantOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
2182 ::mlir::Attribute valueAttr;
2183 if (parser.parseOptionalAttrDict(result.attributes))
2184 return ::mlir::failure();
2185
2186 if (parser.parseAttribute(valueAttr, ::mlir::Type{}, "value", result.attributes))
2187 return ::mlir::failure();
2188 result.addTypes(valueAttr.getType());
2189 return ::mlir::success();
2190}
2191
2192void ConstantOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2193 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"value"});
2194 _odsPrinter << ' ';
2195 _odsPrinter.printAttribute(getValueAttr());
2196}
2197
2198void ConstantOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
2199}
2200
2201} // namespace arith
2202} // namespace mlir
2203DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ConstantOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::ConstantOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
2204
2205namespace mlir {
2206namespace arith {
2207
2208//===----------------------------------------------------------------------===//
2209// ::mlir::arith::DivFOp definitions
2210//===----------------------------------------------------------------------===//
2211
2212DivFOpAdaptor::DivFOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
2213
2214DivFOpAdaptor::DivFOpAdaptor(DivFOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
2215
2216::mlir::ValueRange DivFOpAdaptor::getOperands() {
2217 return odsOperands;
2218}
2219
2220std::pair<unsigned, unsigned> DivFOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
2221 return {index, 1};
2222}
2223
2224::mlir::ValueRange DivFOpAdaptor::getODSOperands(unsigned index) {
2225 auto valueRange = getODSOperandIndexAndLength(index);
2226 return {std::next(odsOperands.begin(), valueRange.first),
2227 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
2228}
2229
2230::mlir::Value DivFOpAdaptor::getLhs() {
2231 return *getODSOperands(0).begin();
2232}
2233
2234::mlir::Value DivFOpAdaptor::getRhs() {
2235 return *getODSOperands(1).begin();
2236}
2237
2238::mlir::DictionaryAttr DivFOpAdaptor::getAttributes() {
2239 return odsAttrs;
2240}
2241
2242::mlir::LogicalResult DivFOpAdaptor::verify(::mlir::Location loc) {
2243 return ::mlir::success();
2244}
2245
2246std::pair<unsigned, unsigned> DivFOp::getODSOperandIndexAndLength(unsigned index) {
2247 return {index, 1};
2248}
2249
2250::mlir::Operation::operand_range DivFOp::getODSOperands(unsigned index) {
2251 auto valueRange = getODSOperandIndexAndLength(index);
2252 return {std::next(getOperation()->operand_begin(), valueRange.first),
2253 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
2254}
2255
2256::mlir::Value DivFOp::getLhs() {
2257 return *getODSOperands(0).begin();
2258}
2259
2260::mlir::Value DivFOp::getRhs() {
2261 return *getODSOperands(1).begin();
2262}
2263
2264::mlir::MutableOperandRange DivFOp::getLhsMutable() {
2265 auto range = getODSOperandIndexAndLength(0);
2266 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2267 return mutableRange;
2268}
2269
2270::mlir::MutableOperandRange DivFOp::getRhsMutable() {
2271 auto range = getODSOperandIndexAndLength(1);
2272 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2273 return mutableRange;
2274}
2275
2276std::pair<unsigned, unsigned> DivFOp::getODSResultIndexAndLength(unsigned index) {
2277 return {index, 1};
2278}
2279
2280::mlir::Operation::result_range DivFOp::getODSResults(unsigned index) {
2281 auto valueRange = getODSResultIndexAndLength(index);
2282 return {std::next(getOperation()->result_begin(), valueRange.first),
2283 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
2284}
2285
2286::mlir::Value DivFOp::getResult() {
2287 return *getODSResults(0).begin();
2288}
2289
2290void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
2291 odsState.addOperands(lhs);
2292 odsState.addOperands(rhs);
2293 odsState.addTypes(result);
2294}
2295
2296void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
2297 odsState.addOperands(lhs);
2298 odsState.addOperands(rhs);
2299 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2299, __extension__ __PRETTY_FUNCTION__))
;
2300 odsState.addTypes(resultTypes);
2301}
2302
2303void DivFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2304 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2304, __extension__ __PRETTY_FUNCTION__))
;
2305 odsState.addOperands(operands);
2306 odsState.addAttributes(attributes);
2307 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2307, __extension__ __PRETTY_FUNCTION__))
;
2308 odsState.addTypes(resultTypes);
2309}
2310
2311void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
2312 odsState.addOperands(lhs);
2313 odsState.addOperands(rhs);
2314 odsState.addTypes({lhs.getType()});
2315
2316}
2317
2318void DivFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2319 odsState.addOperands(operands);
2320 odsState.addAttributes(attributes);
2321 odsState.addTypes({operands[0].getType()});
2322
2323}
2324
2325::mlir::LogicalResult DivFOp::verify() {
2326 {
2327 unsigned index = 0; (void)index;
2328 auto valueGroup0 = getODSOperands(0);
2329
2330 for (auto v : valueGroup0) {
2331 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
2332 return ::mlir::failure();
2333 }
2334 auto valueGroup1 = getODSOperands(1);
2335
2336 for (auto v : valueGroup1) {
2337 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
2338 return ::mlir::failure();
2339 }
2340 }
2341 {
2342 unsigned index = 0; (void)index;
2343 auto valueGroup0 = getODSResults(0);
2344
2345 for (auto v : valueGroup0) {
2346 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "result", index++)))
2347 return ::mlir::failure();
2348 }
2349 }
2350 return ::mlir::success();
2351}
2352
2353::mlir::ParseResult DivFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
2354 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
2355 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
2356 (void)lhsOperandsLoc;
2357 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
2358 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
2359 (void)rhsOperandsLoc;
2360 ::mlir::Type resultRawTypes[1];
2361 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
2362
2363 lhsOperandsLoc = parser.getCurrentLocation();
2364 if (parser.parseOperand(lhsRawOperands[0]))
2365 return ::mlir::failure();
2366 if (parser.parseComma())
2367 return ::mlir::failure();
2368
2369 rhsOperandsLoc = parser.getCurrentLocation();
2370 if (parser.parseOperand(rhsRawOperands[0]))
2371 return ::mlir::failure();
2372 if (parser.parseOptionalAttrDict(result.attributes))
2373 return ::mlir::failure();
2374 if (parser.parseColon())
2375 return ::mlir::failure();
2376
2377 {
2378 ::mlir::Type type;
2379 if (parser.parseCustomTypeWithFallback(type))
2380 return ::mlir::failure();
2381 resultRawTypes[0] = type;
2382 }
2383 result.addTypes(resultTypes);
2384 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
2385 return ::mlir::failure();
2386 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
2387 return ::mlir::failure();
2388 return ::mlir::success();
2389}
2390
2391void DivFOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2392 _odsPrinter << ' ';
2393 _odsPrinter << getLhs();
2394 _odsPrinter << ",";
2395 _odsPrinter << ' ';
2396 _odsPrinter << getRhs();
2397 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
2398 _odsPrinter << ' ' << ":";
2399 _odsPrinter << ' ';
2400 {
2401 auto type = getResult().getType();
2402 if (auto validType = type.dyn_cast<::mlir::Type>())
2403 _odsPrinter.printStrippedAttrOrType(validType);
2404 else
2405 _odsPrinter << type;
2406 }
2407}
2408
2409void DivFOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
2410}
2411
2412} // namespace arith
2413} // namespace mlir
2414DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::DivFOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::DivFOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
2415
2416namespace mlir {
2417namespace arith {
2418
2419//===----------------------------------------------------------------------===//
2420// ::mlir::arith::DivSIOp definitions
2421//===----------------------------------------------------------------------===//
2422
2423DivSIOpAdaptor::DivSIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
2424
2425DivSIOpAdaptor::DivSIOpAdaptor(DivSIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
2426
2427::mlir::ValueRange DivSIOpAdaptor::getOperands() {
2428 return odsOperands;
2429}
2430
2431std::pair<unsigned, unsigned> DivSIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
2432 return {index, 1};
2433}
2434
2435::mlir::ValueRange DivSIOpAdaptor::getODSOperands(unsigned index) {
2436 auto valueRange = getODSOperandIndexAndLength(index);
2437 return {std::next(odsOperands.begin(), valueRange.first),
2438 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
2439}
2440
2441::mlir::Value DivSIOpAdaptor::getLhs() {
2442 return *getODSOperands(0).begin();
2443}
2444
2445::mlir::Value DivSIOpAdaptor::getRhs() {
2446 return *getODSOperands(1).begin();
2447}
2448
2449::mlir::DictionaryAttr DivSIOpAdaptor::getAttributes() {
2450 return odsAttrs;
2451}
2452
2453::mlir::LogicalResult DivSIOpAdaptor::verify(::mlir::Location loc) {
2454 return ::mlir::success();
2455}
2456
2457std::pair<unsigned, unsigned> DivSIOp::getODSOperandIndexAndLength(unsigned index) {
2458 return {index, 1};
2459}
2460
2461::mlir::Operation::operand_range DivSIOp::getODSOperands(unsigned index) {
2462 auto valueRange = getODSOperandIndexAndLength(index);
2463 return {std::next(getOperation()->operand_begin(), valueRange.first),
2464 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
2465}
2466
2467::mlir::Value DivSIOp::getLhs() {
2468 return *getODSOperands(0).begin();
2469}
2470
2471::mlir::Value DivSIOp::getRhs() {
2472 return *getODSOperands(1).begin();
2473}
2474
2475::mlir::MutableOperandRange DivSIOp::getLhsMutable() {
2476 auto range = getODSOperandIndexAndLength(0);
2477 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2478 return mutableRange;
2479}
2480
2481::mlir::MutableOperandRange DivSIOp::getRhsMutable() {
2482 auto range = getODSOperandIndexAndLength(1);
2483 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2484 return mutableRange;
2485}
2486
2487std::pair<unsigned, unsigned> DivSIOp::getODSResultIndexAndLength(unsigned index) {
2488 return {index, 1};
2489}
2490
2491::mlir::Operation::result_range DivSIOp::getODSResults(unsigned index) {
2492 auto valueRange = getODSResultIndexAndLength(index);
2493 return {std::next(getOperation()->result_begin(), valueRange.first),
2494 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
2495}
2496
2497::mlir::Value DivSIOp::getResult() {
2498 return *getODSResults(0).begin();
2499}
2500
2501void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
2502 odsState.addOperands(lhs);
2503 odsState.addOperands(rhs);
2504 odsState.addTypes(result);
2505}
2506
2507void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
2508 odsState.addOperands(lhs);
2509 odsState.addOperands(rhs);
2510 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2510, __extension__ __PRETTY_FUNCTION__))
;
2511 odsState.addTypes(resultTypes);
2512}
2513
2514void DivSIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2515 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2515, __extension__ __PRETTY_FUNCTION__))
;
2516 odsState.addOperands(operands);
2517 odsState.addAttributes(attributes);
2518 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2518, __extension__ __PRETTY_FUNCTION__))
;
2519 odsState.addTypes(resultTypes);
2520}
2521
2522void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
2523 odsState.addOperands(lhs);
2524 odsState.addOperands(rhs);
2525 odsState.addTypes({lhs.getType()});
2526
2527}
2528
2529void DivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2530 odsState.addOperands(operands);
2531 odsState.addAttributes(attributes);
2532 odsState.addTypes({operands[0].getType()});
2533
2534}
2535
2536::mlir::LogicalResult DivSIOp::verify() {
2537 {
2538 unsigned index = 0; (void)index;
2539 auto valueGroup0 = getODSOperands(0);
2540
2541 for (auto v : valueGroup0) {
2542 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
2543 return ::mlir::failure();
2544 }
2545 auto valueGroup1 = getODSOperands(1);
2546
2547 for (auto v : valueGroup1) {
2548 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
2549 return ::mlir::failure();
2550 }
2551 }
2552 {
2553 unsigned index = 0; (void)index;
2554 auto valueGroup0 = getODSResults(0);
2555
2556 for (auto v : valueGroup0) {
2557 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "result", index++)))
2558 return ::mlir::failure();
2559 }
2560 }
2561 return ::mlir::success();
2562}
2563
2564::mlir::ParseResult DivSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
2565 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
2566 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
2567 (void)lhsOperandsLoc;
2568 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
2569 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
2570 (void)rhsOperandsLoc;
2571 ::mlir::Type resultRawTypes[1];
2572 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
2573
2574 lhsOperandsLoc = parser.getCurrentLocation();
2575 if (parser.parseOperand(lhsRawOperands[0]))
2576 return ::mlir::failure();
2577 if (parser.parseComma())
2578 return ::mlir::failure();
2579
2580 rhsOperandsLoc = parser.getCurrentLocation();
2581 if (parser.parseOperand(rhsRawOperands[0]))
2582 return ::mlir::failure();
2583 if (parser.parseOptionalAttrDict(result.attributes))
2584 return ::mlir::failure();
2585 if (parser.parseColon())
2586 return ::mlir::failure();
2587
2588 {
2589 ::mlir::Type type;
2590 if (parser.parseCustomTypeWithFallback(type))
2591 return ::mlir::failure();
2592 resultRawTypes[0] = type;
2593 }
2594 result.addTypes(resultTypes);
2595 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
2596 return ::mlir::failure();
2597 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
2598 return ::mlir::failure();
2599 return ::mlir::success();
2600}
2601
2602void DivSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2603 _odsPrinter << ' ';
2604 _odsPrinter << getLhs();
2605 _odsPrinter << ",";
2606 _odsPrinter << ' ';
2607 _odsPrinter << getRhs();
2608 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
2609 _odsPrinter << ' ' << ":";
2610 _odsPrinter << ' ';
2611 {
2612 auto type = getResult().getType();
2613 if (auto validType = type.dyn_cast<::mlir::Type>())
2614 _odsPrinter.printStrippedAttrOrType(validType);
2615 else
2616 _odsPrinter << type;
2617 }
2618}
2619
2620void DivSIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
2621}
2622
2623} // namespace arith
2624} // namespace mlir
2625DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::DivSIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::DivSIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
2626
2627namespace mlir {
2628namespace arith {
2629
2630//===----------------------------------------------------------------------===//
2631// ::mlir::arith::DivUIOp definitions
2632//===----------------------------------------------------------------------===//
2633
2634DivUIOpAdaptor::DivUIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
2635
2636DivUIOpAdaptor::DivUIOpAdaptor(DivUIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
2637
2638::mlir::ValueRange DivUIOpAdaptor::getOperands() {
2639 return odsOperands;
2640}
2641
2642std::pair<unsigned, unsigned> DivUIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
2643 return {index, 1};
2644}
2645
2646::mlir::ValueRange DivUIOpAdaptor::getODSOperands(unsigned index) {
2647 auto valueRange = getODSOperandIndexAndLength(index);
2648 return {std::next(odsOperands.begin(), valueRange.first),
2649 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
2650}
2651
2652::mlir::Value DivUIOpAdaptor::getLhs() {
2653 return *getODSOperands(0).begin();
2654}
2655
2656::mlir::Value DivUIOpAdaptor::getRhs() {
2657 return *getODSOperands(1).begin();
2658}
2659
2660::mlir::DictionaryAttr DivUIOpAdaptor::getAttributes() {
2661 return odsAttrs;
2662}
2663
2664::mlir::LogicalResult DivUIOpAdaptor::verify(::mlir::Location loc) {
2665 return ::mlir::success();
2666}
2667
2668std::pair<unsigned, unsigned> DivUIOp::getODSOperandIndexAndLength(unsigned index) {
2669 return {index, 1};
2670}
2671
2672::mlir::Operation::operand_range DivUIOp::getODSOperands(unsigned index) {
2673 auto valueRange = getODSOperandIndexAndLength(index);
2674 return {std::next(getOperation()->operand_begin(), valueRange.first),
2675 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
2676}
2677
2678::mlir::Value DivUIOp::getLhs() {
2679 return *getODSOperands(0).begin();
2680}
2681
2682::mlir::Value DivUIOp::getRhs() {
2683 return *getODSOperands(1).begin();
2684}
2685
2686::mlir::MutableOperandRange DivUIOp::getLhsMutable() {
2687 auto range = getODSOperandIndexAndLength(0);
2688 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2689 return mutableRange;
2690}
2691
2692::mlir::MutableOperandRange DivUIOp::getRhsMutable() {
2693 auto range = getODSOperandIndexAndLength(1);
2694 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2695 return mutableRange;
2696}
2697
2698std::pair<unsigned, unsigned> DivUIOp::getODSResultIndexAndLength(unsigned index) {
2699 return {index, 1};
2700}
2701
2702::mlir::Operation::result_range DivUIOp::getODSResults(unsigned index) {
2703 auto valueRange = getODSResultIndexAndLength(index);
2704 return {std::next(getOperation()->result_begin(), valueRange.first),
2705 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
2706}
2707
2708::mlir::Value DivUIOp::getResult() {
2709 return *getODSResults(0).begin();
2710}
2711
2712void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
2713 odsState.addOperands(lhs);
2714 odsState.addOperands(rhs);
2715 odsState.addTypes(result);
2716}
2717
2718void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
2719 odsState.addOperands(lhs);
2720 odsState.addOperands(rhs);
2721 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2721, __extension__ __PRETTY_FUNCTION__))
;
2722 odsState.addTypes(resultTypes);
2723}
2724
2725void DivUIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2726 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2726, __extension__ __PRETTY_FUNCTION__))
;
2727 odsState.addOperands(operands);
2728 odsState.addAttributes(attributes);
2729 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2729, __extension__ __PRETTY_FUNCTION__))
;
2730 odsState.addTypes(resultTypes);
2731}
2732
2733void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
2734 odsState.addOperands(lhs);
2735 odsState.addOperands(rhs);
2736 odsState.addTypes({lhs.getType()});
2737
2738}
2739
2740void DivUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2741 odsState.addOperands(operands);
2742 odsState.addAttributes(attributes);
2743 odsState.addTypes({operands[0].getType()});
2744
2745}
2746
2747::mlir::LogicalResult DivUIOp::verify() {
2748 {
2749 unsigned index = 0; (void)index;
2750 auto valueGroup0 = getODSOperands(0);
2751
2752 for (auto v : valueGroup0) {
2753 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
2754 return ::mlir::failure();
2755 }
2756 auto valueGroup1 = getODSOperands(1);
2757
2758 for (auto v : valueGroup1) {
2759 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
2760 return ::mlir::failure();
2761 }
2762 }
2763 {
2764 unsigned index = 0; (void)index;
2765 auto valueGroup0 = getODSResults(0);
2766
2767 for (auto v : valueGroup0) {
2768 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "result", index++)))
2769 return ::mlir::failure();
2770 }
2771 }
2772 return ::mlir::success();
2773}
2774
2775::mlir::ParseResult DivUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
2776 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
2777 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
2778 (void)lhsOperandsLoc;
2779 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
2780 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
2781 (void)rhsOperandsLoc;
2782 ::mlir::Type resultRawTypes[1];
2783 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
2784
2785 lhsOperandsLoc = parser.getCurrentLocation();
2786 if (parser.parseOperand(lhsRawOperands[0]))
2787 return ::mlir::failure();
2788 if (parser.parseComma())
2789 return ::mlir::failure();
2790
2791 rhsOperandsLoc = parser.getCurrentLocation();
2792 if (parser.parseOperand(rhsRawOperands[0]))
2793 return ::mlir::failure();
2794 if (parser.parseOptionalAttrDict(result.attributes))
2795 return ::mlir::failure();
2796 if (parser.parseColon())
2797 return ::mlir::failure();
2798
2799 {
2800 ::mlir::Type type;
2801 if (parser.parseCustomTypeWithFallback(type))
2802 return ::mlir::failure();
2803 resultRawTypes[0] = type;
2804 }
2805 result.addTypes(resultTypes);
2806 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
2807 return ::mlir::failure();
2808 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
2809 return ::mlir::failure();
2810 return ::mlir::success();
2811}
2812
2813void DivUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2814 _odsPrinter << ' ';
2815 _odsPrinter << getLhs();
2816 _odsPrinter << ",";
2817 _odsPrinter << ' ';
2818 _odsPrinter << getRhs();
2819 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
2820 _odsPrinter << ' ' << ":";
2821 _odsPrinter << ' ';
2822 {
2823 auto type = getResult().getType();
2824 if (auto validType = type.dyn_cast<::mlir::Type>())
2825 _odsPrinter.printStrippedAttrOrType(validType);
2826 else
2827 _odsPrinter << type;
2828 }
2829}
2830
2831void DivUIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
2832}
2833
2834} // namespace arith
2835} // namespace mlir
2836DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::DivUIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::DivUIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
2837
2838namespace mlir {
2839namespace arith {
2840
2841//===----------------------------------------------------------------------===//
2842// ::mlir::arith::ExtFOp definitions
2843//===----------------------------------------------------------------------===//
2844
2845ExtFOpAdaptor::ExtFOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
2846
2847ExtFOpAdaptor::ExtFOpAdaptor(ExtFOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
2848
2849::mlir::ValueRange ExtFOpAdaptor::getOperands() {
2850 return odsOperands;
2851}
2852
2853std::pair<unsigned, unsigned> ExtFOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
2854 return {index, 1};
2855}
2856
2857::mlir::ValueRange ExtFOpAdaptor::getODSOperands(unsigned index) {
2858 auto valueRange = getODSOperandIndexAndLength(index);
2859 return {std::next(odsOperands.begin(), valueRange.first),
2860 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
2861}
2862
2863::mlir::Value ExtFOpAdaptor::getIn() {
2864 return *getODSOperands(0).begin();
2865}
2866
2867::mlir::DictionaryAttr ExtFOpAdaptor::getAttributes() {
2868 return odsAttrs;
2869}
2870
2871::mlir::LogicalResult ExtFOpAdaptor::verify(::mlir::Location loc) {
2872 return ::mlir::success();
2873}
2874
2875std::pair<unsigned, unsigned> ExtFOp::getODSOperandIndexAndLength(unsigned index) {
2876 return {index, 1};
2877}
2878
2879::mlir::Operation::operand_range ExtFOp::getODSOperands(unsigned index) {
2880 auto valueRange = getODSOperandIndexAndLength(index);
2881 return {std::next(getOperation()->operand_begin(), valueRange.first),
2882 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
2883}
2884
2885::mlir::Value ExtFOp::getIn() {
2886 return *getODSOperands(0).begin();
2887}
2888
2889::mlir::MutableOperandRange ExtFOp::getInMutable() {
2890 auto range = getODSOperandIndexAndLength(0);
2891 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
2892 return mutableRange;
2893}
2894
2895std::pair<unsigned, unsigned> ExtFOp::getODSResultIndexAndLength(unsigned index) {
2896 return {index, 1};
2897}
2898
2899::mlir::Operation::result_range ExtFOp::getODSResults(unsigned index) {
2900 auto valueRange = getODSResultIndexAndLength(index);
2901 return {std::next(getOperation()->result_begin(), valueRange.first),
2902 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
2903}
2904
2905::mlir::Value ExtFOp::getOut() {
2906 return *getODSResults(0).begin();
2907}
2908
2909void ExtFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Type destType) {
2910 impl::buildCastOp(odsBuilder, odsState, source, destType);
2911
2912}
2913
2914void ExtFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) {
2915 odsState.addOperands(in);
2916 odsState.addTypes(out);
2917}
2918
2919void ExtFOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) {
2920 odsState.addOperands(in);
2921 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2921, __extension__ __PRETTY_FUNCTION__))
;
2922 odsState.addTypes(resultTypes);
2923}
2924
2925void ExtFOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
2926 assert(operands.size() == 1u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 1u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 1u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2926, __extension__ __PRETTY_FUNCTION__))
;
2927 odsState.addOperands(operands);
2928 odsState.addAttributes(attributes);
2929 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 2929, __extension__ __PRETTY_FUNCTION__))
;
2930 odsState.addTypes(resultTypes);
2931}
2932
2933::mlir::LogicalResult ExtFOp::verify() {
2934 {
2935 unsigned index = 0; (void)index;
2936 auto valueGroup0 = getODSOperands(0);
2937
2938 for (auto v : valueGroup0) {
2939 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
2940 return ::mlir::failure();
2941 }
2942 }
2943 {
2944 unsigned index = 0; (void)index;
2945 auto valueGroup0 = getODSResults(0);
2946
2947 for (auto v : valueGroup0) {
2948 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "result", index++)))
2949 return ::mlir::failure();
2950 }
2951 }
2952 return verifyExtOp<FloatType>(*this);
2953}
2954
2955::mlir::ParseResult ExtFOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
2956 ::mlir::OpAsmParser::OperandType inRawOperands[1];
2957 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> inOperands(inRawOperands); ::llvm::SMLoc inOperandsLoc;
2958 (void)inOperandsLoc;
2959 ::mlir::Type inRawTypes[1];
2960 ::llvm::ArrayRef<::mlir::Type> inTypes(inRawTypes);
2961 ::mlir::Type outRawTypes[1];
2962 ::llvm::ArrayRef<::mlir::Type> outTypes(outRawTypes);
2963
2964 inOperandsLoc = parser.getCurrentLocation();
2965 if (parser.parseOperand(inRawOperands[0]))
2966 return ::mlir::failure();
2967 if (parser.parseOptionalAttrDict(result.attributes))
2968 return ::mlir::failure();
2969 if (parser.parseColon())
2970 return ::mlir::failure();
2971
2972 {
2973 ::mlir::Type type;
2974 if (parser.parseCustomTypeWithFallback(type))
2975 return ::mlir::failure();
2976 inRawTypes[0] = type;
2977 }
2978 if (parser.parseKeyword("to"))
2979 return ::mlir::failure();
2980
2981 {
2982 ::mlir::Type type;
2983 if (parser.parseCustomTypeWithFallback(type))
2984 return ::mlir::failure();
2985 outRawTypes[0] = type;
2986 }
2987 result.addTypes(outTypes);
2988 if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands))
2989 return ::mlir::failure();
2990 return ::mlir::success();
2991}
2992
2993void ExtFOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
2994 _odsPrinter << ' ';
2995 _odsPrinter << getIn();
2996 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
2997 _odsPrinter << ' ' << ":";
2998 _odsPrinter << ' ';
2999 {
3000 auto type = getIn().getType();
3001 if (auto validType = type.dyn_cast<::mlir::Type>())
3002 _odsPrinter.printStrippedAttrOrType(validType);
3003 else
3004 _odsPrinter << type;
3005 }
3006 _odsPrinter << ' ' << "to";
3007 _odsPrinter << ' ';
3008 {
3009 auto type = getOut().getType();
3010 if (auto validType = type.dyn_cast<::mlir::Type>())
3011 _odsPrinter.printStrippedAttrOrType(validType);
3012 else
3013 _odsPrinter << type;
3014 }
3015}
3016
3017void ExtFOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
3018}
3019
3020} // namespace arith
3021} // namespace mlir
3022DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ExtFOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::ExtFOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
3023
3024namespace mlir {
3025namespace arith {
3026
3027//===----------------------------------------------------------------------===//
3028// ::mlir::arith::ExtSIOp definitions
3029//===----------------------------------------------------------------------===//
3030
3031ExtSIOpAdaptor::ExtSIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
3032
3033ExtSIOpAdaptor::ExtSIOpAdaptor(ExtSIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
3034
3035::mlir::ValueRange ExtSIOpAdaptor::getOperands() {
3036 return odsOperands;
3037}
3038
3039std::pair<unsigned, unsigned> ExtSIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
3040 return {index, 1};
3041}
3042
3043::mlir::ValueRange ExtSIOpAdaptor::getODSOperands(unsigned index) {
3044 auto valueRange = getODSOperandIndexAndLength(index);
3045 return {std::next(odsOperands.begin(), valueRange.first),
3046 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
3047}
3048
3049::mlir::Value ExtSIOpAdaptor::getIn() {
3050 return *getODSOperands(0).begin();
3051}
3052
3053::mlir::DictionaryAttr ExtSIOpAdaptor::getAttributes() {
3054 return odsAttrs;
3055}
3056
3057::mlir::LogicalResult ExtSIOpAdaptor::verify(::mlir::Location loc) {
3058 return ::mlir::success();
3059}
3060
3061std::pair<unsigned, unsigned> ExtSIOp::getODSOperandIndexAndLength(unsigned index) {
3062 return {index, 1};
3063}
3064
3065::mlir::Operation::operand_range ExtSIOp::getODSOperands(unsigned index) {
3066 auto valueRange = getODSOperandIndexAndLength(index);
3067 return {std::next(getOperation()->operand_begin(), valueRange.first),
3068 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
3069}
3070
3071::mlir::Value ExtSIOp::getIn() {
3072 return *getODSOperands(0).begin();
3073}
3074
3075::mlir::MutableOperandRange ExtSIOp::getInMutable() {
3076 auto range = getODSOperandIndexAndLength(0);
3077 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
3078 return mutableRange;
3079}
3080
3081std::pair<unsigned, unsigned> ExtSIOp::getODSResultIndexAndLength(unsigned index) {
3082 return {index, 1};
3083}
3084
3085::mlir::Operation::result_range ExtSIOp::getODSResults(unsigned index) {
3086 auto valueRange = getODSResultIndexAndLength(index);
3087 return {std::next(getOperation()->result_begin(), valueRange.first),
3088 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
3089}
3090
3091::mlir::Value ExtSIOp::getOut() {
3092 return *getODSResults(0).begin();
3093}
3094
3095void ExtSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Type destType) {
3096 impl::buildCastOp(odsBuilder, odsState, source, destType);
3097
3098}
3099
3100void ExtSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) {
3101 odsState.addOperands(in);
3102 odsState.addTypes(out);
3103}
3104
3105void ExtSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) {
3106 odsState.addOperands(in);
3107 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3107, __extension__ __PRETTY_FUNCTION__))
;
3108 odsState.addTypes(resultTypes);
3109}
3110
3111void ExtSIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
3112 assert(operands.size() == 1u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 1u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 1u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3112, __extension__ __PRETTY_FUNCTION__))
;
3113 odsState.addOperands(operands);
3114 odsState.addAttributes(attributes);
3115 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3115, __extension__ __PRETTY_FUNCTION__))
;
3116 odsState.addTypes(resultTypes);
3117}
3118
3119::mlir::LogicalResult ExtSIOp::verify() {
3120 {
3121 unsigned index = 0; (void)index;
3122 auto valueGroup0 = getODSOperands(0);
3123
3124 for (auto v : valueGroup0) {
3125 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps7(*this, v.getType(), "operand", index++)))
3126 return ::mlir::failure();
3127 }
3128 }
3129 {
3130 unsigned index = 0; (void)index;
3131 auto valueGroup0 = getODSResults(0);
3132
3133 for (auto v : valueGroup0) {
3134 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps7(*this, v.getType(), "result", index++)))
3135 return ::mlir::failure();
3136 }
3137 }
3138 return verifyExtOp<IntegerType>(*this);
3139}
3140
3141::mlir::ParseResult ExtSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
3142 ::mlir::OpAsmParser::OperandType inRawOperands[1];
3143 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> inOperands(inRawOperands); ::llvm::SMLoc inOperandsLoc;
3144 (void)inOperandsLoc;
3145 ::mlir::Type inRawTypes[1];
3146 ::llvm::ArrayRef<::mlir::Type> inTypes(inRawTypes);
3147 ::mlir::Type outRawTypes[1];
3148 ::llvm::ArrayRef<::mlir::Type> outTypes(outRawTypes);
3149
3150 inOperandsLoc = parser.getCurrentLocation();
3151 if (parser.parseOperand(inRawOperands[0]))
3152 return ::mlir::failure();
3153 if (parser.parseOptionalAttrDict(result.attributes))
3154 return ::mlir::failure();
3155 if (parser.parseColon())
3156 return ::mlir::failure();
3157
3158 {
3159 ::mlir::Type type;
3160 if (parser.parseCustomTypeWithFallback(type))
3161 return ::mlir::failure();
3162 inRawTypes[0] = type;
3163 }
3164 if (parser.parseKeyword("to"))
3165 return ::mlir::failure();
3166
3167 {
3168 ::mlir::Type type;
3169 if (parser.parseCustomTypeWithFallback(type))
3170 return ::mlir::failure();
3171 outRawTypes[0] = type;
3172 }
3173 result.addTypes(outTypes);
3174 if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands))
3175 return ::mlir::failure();
3176 return ::mlir::success();
3177}
3178
3179void ExtSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
3180 _odsPrinter << ' ';
3181 _odsPrinter << getIn();
3182 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
3183 _odsPrinter << ' ' << ":";
3184 _odsPrinter << ' ';
3185 {
3186 auto type = getIn().getType();
3187 if (auto validType = type.dyn_cast<::mlir::Type>())
3188 _odsPrinter.printStrippedAttrOrType(validType);
3189 else
3190 _odsPrinter << type;
3191 }
3192 _odsPrinter << ' ' << "to";
3193 _odsPrinter << ' ';
3194 {
3195 auto type = getOut().getType();
3196 if (auto validType = type.dyn_cast<::mlir::Type>())
3197 _odsPrinter.printStrippedAttrOrType(validType);
3198 else
3199 _odsPrinter << type;
3200 }
3201}
3202
3203void ExtSIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
3204}
3205
3206} // namespace arith
3207} // namespace mlir
3208DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ExtSIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::ExtSIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
3209
3210namespace mlir {
3211namespace arith {
3212
3213//===----------------------------------------------------------------------===//
3214// ::mlir::arith::ExtUIOp definitions
3215//===----------------------------------------------------------------------===//
3216
3217ExtUIOpAdaptor::ExtUIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
3218
3219ExtUIOpAdaptor::ExtUIOpAdaptor(ExtUIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
3220
3221::mlir::ValueRange ExtUIOpAdaptor::getOperands() {
3222 return odsOperands;
3223}
3224
3225std::pair<unsigned, unsigned> ExtUIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
3226 return {index, 1};
3227}
3228
3229::mlir::ValueRange ExtUIOpAdaptor::getODSOperands(unsigned index) {
3230 auto valueRange = getODSOperandIndexAndLength(index);
3231 return {std::next(odsOperands.begin(), valueRange.first),
3232 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
3233}
3234
3235::mlir::Value ExtUIOpAdaptor::getIn() {
3236 return *getODSOperands(0).begin();
3237}
3238
3239::mlir::DictionaryAttr ExtUIOpAdaptor::getAttributes() {
3240 return odsAttrs;
3241}
3242
3243::mlir::LogicalResult ExtUIOpAdaptor::verify(::mlir::Location loc) {
3244 return ::mlir::success();
3245}
3246
3247std::pair<unsigned, unsigned> ExtUIOp::getODSOperandIndexAndLength(unsigned index) {
3248 return {index, 1};
3249}
3250
3251::mlir::Operation::operand_range ExtUIOp::getODSOperands(unsigned index) {
3252 auto valueRange = getODSOperandIndexAndLength(index);
3253 return {std::next(getOperation()->operand_begin(), valueRange.first),
3254 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
3255}
3256
3257::mlir::Value ExtUIOp::getIn() {
3258 return *getODSOperands(0).begin();
3259}
3260
3261::mlir::MutableOperandRange ExtUIOp::getInMutable() {
3262 auto range = getODSOperandIndexAndLength(0);
3263 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
3264 return mutableRange;
3265}
3266
3267std::pair<unsigned, unsigned> ExtUIOp::getODSResultIndexAndLength(unsigned index) {
3268 return {index, 1};
3269}
3270
3271::mlir::Operation::result_range ExtUIOp::getODSResults(unsigned index) {
3272 auto valueRange = getODSResultIndexAndLength(index);
3273 return {std::next(getOperation()->result_begin(), valueRange.first),
3274 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
3275}
3276
3277::mlir::Value ExtUIOp::getOut() {
3278 return *getODSResults(0).begin();
3279}
3280
3281void ExtUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Type destType) {
3282 impl::buildCastOp(odsBuilder, odsState, source, destType);
3283
3284}
3285
3286void ExtUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) {
3287 odsState.addOperands(in);
3288 odsState.addTypes(out);
3289}
3290
3291void ExtUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) {
3292 odsState.addOperands(in);
3293 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3293, __extension__ __PRETTY_FUNCTION__))
;
3294 odsState.addTypes(resultTypes);
3295}
3296
3297void ExtUIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
3298 assert(operands.size() == 1u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 1u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 1u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3298, __extension__ __PRETTY_FUNCTION__))
;
3299 odsState.addOperands(operands);
3300 odsState.addAttributes(attributes);
3301 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3301, __extension__ __PRETTY_FUNCTION__))
;
3302 odsState.addTypes(resultTypes);
3303}
3304
3305::mlir::LogicalResult ExtUIOp::verify() {
3306 {
3307 unsigned index = 0; (void)index;
3308 auto valueGroup0 = getODSOperands(0);
3309
3310 for (auto v : valueGroup0) {
3311 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps7(*this, v.getType(), "operand", index++)))
3312 return ::mlir::failure();
3313 }
3314 }
3315 {
3316 unsigned index = 0; (void)index;
3317 auto valueGroup0 = getODSResults(0);
3318
3319 for (auto v : valueGroup0) {
3320 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps7(*this, v.getType(), "result", index++)))
3321 return ::mlir::failure();
3322 }
3323 }
3324 return verifyExtOp<IntegerType>(*this);
3325}
3326
3327::mlir::ParseResult ExtUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
3328 ::mlir::OpAsmParser::OperandType inRawOperands[1];
3329 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> inOperands(inRawOperands); ::llvm::SMLoc inOperandsLoc;
3330 (void)inOperandsLoc;
3331 ::mlir::Type inRawTypes[1];
3332 ::llvm::ArrayRef<::mlir::Type> inTypes(inRawTypes);
3333 ::mlir::Type outRawTypes[1];
3334 ::llvm::ArrayRef<::mlir::Type> outTypes(outRawTypes);
3335
3336 inOperandsLoc = parser.getCurrentLocation();
3337 if (parser.parseOperand(inRawOperands[0]))
3338 return ::mlir::failure();
3339 if (parser.parseOptionalAttrDict(result.attributes))
3340 return ::mlir::failure();
3341 if (parser.parseColon())
3342 return ::mlir::failure();
3343
3344 {
3345 ::mlir::Type type;
3346 if (parser.parseCustomTypeWithFallback(type))
3347 return ::mlir::failure();
3348 inRawTypes[0] = type;
3349 }
3350 if (parser.parseKeyword("to"))
3351 return ::mlir::failure();
3352
3353 {
3354 ::mlir::Type type;
3355 if (parser.parseCustomTypeWithFallback(type))
3356 return ::mlir::failure();
3357 outRawTypes[0] = type;
3358 }
3359 result.addTypes(outTypes);
3360 if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands))
3361 return ::mlir::failure();
3362 return ::mlir::success();
3363}
3364
3365void ExtUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
3366 _odsPrinter << ' ';
3367 _odsPrinter << getIn();
3368 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
3369 _odsPrinter << ' ' << ":";
3370 _odsPrinter << ' ';
3371 {
3372 auto type = getIn().getType();
3373 if (auto validType = type.dyn_cast<::mlir::Type>())
3374 _odsPrinter.printStrippedAttrOrType(validType);
3375 else
3376 _odsPrinter << type;
3377 }
3378 _odsPrinter << ' ' << "to";
3379 _odsPrinter << ' ';
3380 {
3381 auto type = getOut().getType();
3382 if (auto validType = type.dyn_cast<::mlir::Type>())
3383 _odsPrinter.printStrippedAttrOrType(validType);
3384 else
3385 _odsPrinter << type;
3386 }
3387}
3388
3389void ExtUIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
3390}
3391
3392} // namespace arith
3393} // namespace mlir
3394DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::ExtUIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::ExtUIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
3395
3396namespace mlir {
3397namespace arith {
3398
3399//===----------------------------------------------------------------------===//
3400// ::mlir::arith::FPToSIOp definitions
3401//===----------------------------------------------------------------------===//
3402
3403FPToSIOpAdaptor::FPToSIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
3404
3405FPToSIOpAdaptor::FPToSIOpAdaptor(FPToSIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
3406
3407::mlir::ValueRange FPToSIOpAdaptor::getOperands() {
3408 return odsOperands;
3409}
3410
3411std::pair<unsigned, unsigned> FPToSIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
3412 return {index, 1};
3413}
3414
3415::mlir::ValueRange FPToSIOpAdaptor::getODSOperands(unsigned index) {
3416 auto valueRange = getODSOperandIndexAndLength(index);
3417 return {std::next(odsOperands.begin(), valueRange.first),
3418 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
3419}
3420
3421::mlir::Value FPToSIOpAdaptor::getIn() {
3422 return *getODSOperands(0).begin();
3423}
3424
3425::mlir::DictionaryAttr FPToSIOpAdaptor::getAttributes() {
3426 return odsAttrs;
3427}
3428
3429::mlir::LogicalResult FPToSIOpAdaptor::verify(::mlir::Location loc) {
3430 return ::mlir::success();
3431}
3432
3433std::pair<unsigned, unsigned> FPToSIOp::getODSOperandIndexAndLength(unsigned index) {
3434 return {index, 1};
3435}
3436
3437::mlir::Operation::operand_range FPToSIOp::getODSOperands(unsigned index) {
3438 auto valueRange = getODSOperandIndexAndLength(index);
3439 return {std::next(getOperation()->operand_begin(), valueRange.first),
3440 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
3441}
3442
3443::mlir::Value FPToSIOp::getIn() {
3444 return *getODSOperands(0).begin();
3445}
3446
3447::mlir::MutableOperandRange FPToSIOp::getInMutable() {
3448 auto range = getODSOperandIndexAndLength(0);
3449 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
3450 return mutableRange;
3451}
3452
3453std::pair<unsigned, unsigned> FPToSIOp::getODSResultIndexAndLength(unsigned index) {
3454 return {index, 1};
3455}
3456
3457::mlir::Operation::result_range FPToSIOp::getODSResults(unsigned index) {
3458 auto valueRange = getODSResultIndexAndLength(index);
3459 return {std::next(getOperation()->result_begin(), valueRange.first),
3460 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
3461}
3462
3463::mlir::Value FPToSIOp::getOut() {
3464 return *getODSResults(0).begin();
3465}
3466
3467void FPToSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Type destType) {
3468 impl::buildCastOp(odsBuilder, odsState, source, destType);
3469
3470}
3471
3472void FPToSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) {
3473 odsState.addOperands(in);
3474 odsState.addTypes(out);
3475}
3476
3477void FPToSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) {
3478 odsState.addOperands(in);
3479 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3479, __extension__ __PRETTY_FUNCTION__))
;
3480 odsState.addTypes(resultTypes);
3481}
3482
3483void FPToSIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
3484 assert(operands.size() == 1u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 1u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 1u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3484, __extension__ __PRETTY_FUNCTION__))
;
3485 odsState.addOperands(operands);
3486 odsState.addAttributes(attributes);
3487 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3487, __extension__ __PRETTY_FUNCTION__))
;
3488 odsState.addTypes(resultTypes);
3489}
3490
3491::mlir::LogicalResult FPToSIOp::verify() {
3492 {
3493 unsigned index = 0; (void)index;
3494 auto valueGroup0 = getODSOperands(0);
3495
3496 for (auto v : valueGroup0) {
3497 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
3498 return ::mlir::failure();
3499 }
3500 }
3501 {
3502 unsigned index = 0; (void)index;
3503 auto valueGroup0 = getODSResults(0);
3504
3505 for (auto v : valueGroup0) {
3506 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps7(*this, v.getType(), "result", index++)))
3507 return ::mlir::failure();
3508 }
3509 }
3510 return ::mlir::success();
3511}
3512
3513::mlir::ParseResult FPToSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
3514 ::mlir::OpAsmParser::OperandType inRawOperands[1];
3515 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> inOperands(inRawOperands); ::llvm::SMLoc inOperandsLoc;
3516 (void)inOperandsLoc;
3517 ::mlir::Type inRawTypes[1];
3518 ::llvm::ArrayRef<::mlir::Type> inTypes(inRawTypes);
3519 ::mlir::Type outRawTypes[1];
3520 ::llvm::ArrayRef<::mlir::Type> outTypes(outRawTypes);
3521
3522 inOperandsLoc = parser.getCurrentLocation();
3523 if (parser.parseOperand(inRawOperands[0]))
3524 return ::mlir::failure();
3525 if (parser.parseOptionalAttrDict(result.attributes))
3526 return ::mlir::failure();
3527 if (parser.parseColon())
3528 return ::mlir::failure();
3529
3530 {
3531 ::mlir::Type type;
3532 if (parser.parseCustomTypeWithFallback(type))
3533 return ::mlir::failure();
3534 inRawTypes[0] = type;
3535 }
3536 if (parser.parseKeyword("to"))
3537 return ::mlir::failure();
3538
3539 {
3540 ::mlir::Type type;
3541 if (parser.parseCustomTypeWithFallback(type))
3542 return ::mlir::failure();
3543 outRawTypes[0] = type;
3544 }
3545 result.addTypes(outTypes);
3546 if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands))
3547 return ::mlir::failure();
3548 return ::mlir::success();
3549}
3550
3551void FPToSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
3552 _odsPrinter << ' ';
3553 _odsPrinter << getIn();
3554 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
3555 _odsPrinter << ' ' << ":";
3556 _odsPrinter << ' ';
3557 {
3558 auto type = getIn().getType();
3559 if (auto validType = type.dyn_cast<::mlir::Type>())
3560 _odsPrinter.printStrippedAttrOrType(validType);
3561 else
3562 _odsPrinter << type;
3563 }
3564 _odsPrinter << ' ' << "to";
3565 _odsPrinter << ' ';
3566 {
3567 auto type = getOut().getType();
3568 if (auto validType = type.dyn_cast<::mlir::Type>())
3569 _odsPrinter.printStrippedAttrOrType(validType);
3570 else
3571 _odsPrinter << type;
3572 }
3573}
3574
3575void FPToSIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
3576}
3577
3578} // namespace arith
3579} // namespace mlir
3580DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::FPToSIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::FPToSIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
3581
3582namespace mlir {
3583namespace arith {
3584
3585//===----------------------------------------------------------------------===//
3586// ::mlir::arith::FPToUIOp definitions
3587//===----------------------------------------------------------------------===//
3588
3589FPToUIOpAdaptor::FPToUIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
3590
3591FPToUIOpAdaptor::FPToUIOpAdaptor(FPToUIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
3592
3593::mlir::ValueRange FPToUIOpAdaptor::getOperands() {
3594 return odsOperands;
3595}
3596
3597std::pair<unsigned, unsigned> FPToUIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
3598 return {index, 1};
3599}
3600
3601::mlir::ValueRange FPToUIOpAdaptor::getODSOperands(unsigned index) {
3602 auto valueRange = getODSOperandIndexAndLength(index);
3603 return {std::next(odsOperands.begin(), valueRange.first),
3604 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
3605}
3606
3607::mlir::Value FPToUIOpAdaptor::getIn() {
3608 return *getODSOperands(0).begin();
3609}
3610
3611::mlir::DictionaryAttr FPToUIOpAdaptor::getAttributes() {
3612 return odsAttrs;
3613}
3614
3615::mlir::LogicalResult FPToUIOpAdaptor::verify(::mlir::Location loc) {
3616 return ::mlir::success();
3617}
3618
3619std::pair<unsigned, unsigned> FPToUIOp::getODSOperandIndexAndLength(unsigned index) {
3620 return {index, 1};
3621}
3622
3623::mlir::Operation::operand_range FPToUIOp::getODSOperands(unsigned index) {
3624 auto valueRange = getODSOperandIndexAndLength(index);
3625 return {std::next(getOperation()->operand_begin(), valueRange.first),
3626 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
3627}
3628
3629::mlir::Value FPToUIOp::getIn() {
3630 return *getODSOperands(0).begin();
3631}
3632
3633::mlir::MutableOperandRange FPToUIOp::getInMutable() {
3634 auto range = getODSOperandIndexAndLength(0);
3635 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
3636 return mutableRange;
3637}
3638
3639std::pair<unsigned, unsigned> FPToUIOp::getODSResultIndexAndLength(unsigned index) {
3640 return {index, 1};
3641}
3642
3643::mlir::Operation::result_range FPToUIOp::getODSResults(unsigned index) {
3644 auto valueRange = getODSResultIndexAndLength(index);
3645 return {std::next(getOperation()->result_begin(), valueRange.first),
3646 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
3647}
3648
3649::mlir::Value FPToUIOp::getOut() {
3650 return *getODSResults(0).begin();
3651}
3652
3653void FPToUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Type destType) {
3654 impl::buildCastOp(odsBuilder, odsState, source, destType);
3655
3656}
3657
3658void FPToUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) {
3659 odsState.addOperands(in);
3660 odsState.addTypes(out);
3661}
3662
3663void FPToUIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) {
3664 odsState.addOperands(in);
3665 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3665, __extension__ __PRETTY_FUNCTION__))
;
3666 odsState.addTypes(resultTypes);
3667}
3668
3669void FPToUIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
3670 assert(operands.size() == 1u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 1u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 1u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3670, __extension__ __PRETTY_FUNCTION__))
;
3671 odsState.addOperands(operands);
3672 odsState.addAttributes(attributes);
3673 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3673, __extension__ __PRETTY_FUNCTION__))
;
3674 odsState.addTypes(resultTypes);
3675}
3676
3677::mlir::LogicalResult FPToUIOp::verify() {
3678 {
3679 unsigned index = 0; (void)index;
3680 auto valueGroup0 = getODSOperands(0);
3681
3682 for (auto v : valueGroup0) {
3683 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps0(*this, v.getType(), "operand", index++)))
3684 return ::mlir::failure();
3685 }
3686 }
3687 {
3688 unsigned index = 0; (void)index;
3689 auto valueGroup0 = getODSResults(0);
3690
3691 for (auto v : valueGroup0) {
3692 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps7(*this, v.getType(), "result", index++)))
3693 return ::mlir::failure();
3694 }
3695 }
3696 return ::mlir::success();
3697}
3698
3699::mlir::ParseResult FPToUIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
3700 ::mlir::OpAsmParser::OperandType inRawOperands[1];
3701 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> inOperands(inRawOperands); ::llvm::SMLoc inOperandsLoc;
3702 (void)inOperandsLoc;
3703 ::mlir::Type inRawTypes[1];
3704 ::llvm::ArrayRef<::mlir::Type> inTypes(inRawTypes);
3705 ::mlir::Type outRawTypes[1];
3706 ::llvm::ArrayRef<::mlir::Type> outTypes(outRawTypes);
3707
3708 inOperandsLoc = parser.getCurrentLocation();
3709 if (parser.parseOperand(inRawOperands[0]))
3710 return ::mlir::failure();
3711 if (parser.parseOptionalAttrDict(result.attributes))
3712 return ::mlir::failure();
3713 if (parser.parseColon())
3714 return ::mlir::failure();
3715
3716 {
3717 ::mlir::Type type;
3718 if (parser.parseCustomTypeWithFallback(type))
3719 return ::mlir::failure();
3720 inRawTypes[0] = type;
3721 }
3722 if (parser.parseKeyword("to"))
3723 return ::mlir::failure();
3724
3725 {
3726 ::mlir::Type type;
3727 if (parser.parseCustomTypeWithFallback(type))
3728 return ::mlir::failure();
3729 outRawTypes[0] = type;
3730 }
3731 result.addTypes(outTypes);
3732 if (parser.resolveOperands(inOperands, inTypes, inOperandsLoc, result.operands))
3733 return ::mlir::failure();
3734 return ::mlir::success();
3735}
3736
3737void FPToUIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
3738 _odsPrinter << ' ';
3739 _odsPrinter << getIn();
3740 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
3741 _odsPrinter << ' ' << ":";
3742 _odsPrinter << ' ';
3743 {
3744 auto type = getIn().getType();
3745 if (auto validType = type.dyn_cast<::mlir::Type>())
3746 _odsPrinter.printStrippedAttrOrType(validType);
3747 else
3748 _odsPrinter << type;
3749 }
3750 _odsPrinter << ' ' << "to";
3751 _odsPrinter << ' ';
3752 {
3753 auto type = getOut().getType();
3754 if (auto validType = type.dyn_cast<::mlir::Type>())
3755 _odsPrinter.printStrippedAttrOrType(validType);
3756 else
3757 _odsPrinter << type;
3758 }
3759}
3760
3761void FPToUIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
3762}
3763
3764} // namespace arith
3765} // namespace mlir
3766DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::FPToUIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::FPToUIOp>() { static TypeID::Storage instance; return
TypeID(&instance); } } }
3767
3768namespace mlir {
3769namespace arith {
3770
3771//===----------------------------------------------------------------------===//
3772// ::mlir::arith::FloorDivSIOp definitions
3773//===----------------------------------------------------------------------===//
3774
3775FloorDivSIOpAdaptor::FloorDivSIOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
3776
3777FloorDivSIOpAdaptor::FloorDivSIOpAdaptor(FloorDivSIOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
3778
3779::mlir::ValueRange FloorDivSIOpAdaptor::getOperands() {
3780 return odsOperands;
3781}
3782
3783std::pair<unsigned, unsigned> FloorDivSIOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
3784 return {index, 1};
3785}
3786
3787::mlir::ValueRange FloorDivSIOpAdaptor::getODSOperands(unsigned index) {
3788 auto valueRange = getODSOperandIndexAndLength(index);
3789 return {std::next(odsOperands.begin(), valueRange.first),
3790 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
3791}
3792
3793::mlir::Value FloorDivSIOpAdaptor::getLhs() {
3794 return *getODSOperands(0).begin();
3795}
3796
3797::mlir::Value FloorDivSIOpAdaptor::getRhs() {
3798 return *getODSOperands(1).begin();
3799}
3800
3801::mlir::DictionaryAttr FloorDivSIOpAdaptor::getAttributes() {
3802 return odsAttrs;
3803}
3804
3805::mlir::LogicalResult FloorDivSIOpAdaptor::verify(::mlir::Location loc) {
3806 return ::mlir::success();
3807}
3808
3809std::pair<unsigned, unsigned> FloorDivSIOp::getODSOperandIndexAndLength(unsigned index) {
3810 return {index, 1};
3811}
3812
3813::mlir::Operation::operand_range FloorDivSIOp::getODSOperands(unsigned index) {
3814 auto valueRange = getODSOperandIndexAndLength(index);
3815 return {std::next(getOperation()->operand_begin(), valueRange.first),
3816 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
3817}
3818
3819::mlir::Value FloorDivSIOp::getLhs() {
3820 return *getODSOperands(0).begin();
3821}
3822
3823::mlir::Value FloorDivSIOp::getRhs() {
3824 return *getODSOperands(1).begin();
3825}
3826
3827::mlir::MutableOperandRange FloorDivSIOp::getLhsMutable() {
3828 auto range = getODSOperandIndexAndLength(0);
3829 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
3830 return mutableRange;
3831}
3832
3833::mlir::MutableOperandRange FloorDivSIOp::getRhsMutable() {
3834 auto range = getODSOperandIndexAndLength(1);
3835 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
3836 return mutableRange;
3837}
3838
3839std::pair<unsigned, unsigned> FloorDivSIOp::getODSResultIndexAndLength(unsigned index) {
3840 return {index, 1};
3841}
3842
3843::mlir::Operation::result_range FloorDivSIOp::getODSResults(unsigned index) {
3844 auto valueRange = getODSResultIndexAndLength(index);
3845 return {std::next(getOperation()->result_begin(), valueRange.first),
3846 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
3847}
3848
3849::mlir::Value FloorDivSIOp::getResult() {
3850 return *getODSResults(0).begin();
3851}
3852
3853void FloorDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value lhs, ::mlir::Value rhs) {
3854 odsState.addOperands(lhs);
3855 odsState.addOperands(rhs);
3856 odsState.addTypes(result);
3857}
3858
3859void FloorDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value lhs, ::mlir::Value rhs) {
3860 odsState.addOperands(lhs);
3861 odsState.addOperands(rhs);
3862 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3862, __extension__ __PRETTY_FUNCTION__))
;
3863 odsState.addTypes(resultTypes);
3864}
3865
3866void FloorDivSIOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
3867 assert(operands.size() == 2u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 2u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 2u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3867, __extension__ __PRETTY_FUNCTION__))
;
3868 odsState.addOperands(operands);
3869 odsState.addAttributes(attributes);
3870 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 3870, __extension__ __PRETTY_FUNCTION__))
;
3871 odsState.addTypes(resultTypes);
3872}
3873
3874void FloorDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value lhs, ::mlir::Value rhs) {
3875 odsState.addOperands(lhs);
3876 odsState.addOperands(rhs);
3877 odsState.addTypes({lhs.getType()});
3878
3879}
3880
3881void FloorDivSIOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
3882 odsState.addOperands(operands);
3883 odsState.addAttributes(attributes);
3884 odsState.addTypes({operands[0].getType()});
3885
3886}
3887
3888::mlir::LogicalResult FloorDivSIOp::verify() {
3889 {
3890 unsigned index = 0; (void)index;
3891 auto valueGroup0 = getODSOperands(0);
3892
3893 for (auto v : valueGroup0) {
3894 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
3895 return ::mlir::failure();
3896 }
3897 auto valueGroup1 = getODSOperands(1);
3898
3899 for (auto v : valueGroup1) {
3900 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "operand", index++)))
3901 return ::mlir::failure();
3902 }
3903 }
3904 {
3905 unsigned index = 0; (void)index;
3906 auto valueGroup0 = getODSResults(0);
3907
3908 for (auto v : valueGroup0) {
3909 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps1(*this, v.getType(), "result", index++)))
3910 return ::mlir::failure();
3911 }
3912 }
3913 return ::mlir::success();
3914}
3915
3916::mlir::ParseResult FloorDivSIOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
3917 ::mlir::OpAsmParser::OperandType lhsRawOperands[1];
3918 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> lhsOperands(lhsRawOperands); ::llvm::SMLoc lhsOperandsLoc;
3919 (void)lhsOperandsLoc;
3920 ::mlir::OpAsmParser::OperandType rhsRawOperands[1];
3921 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> rhsOperands(rhsRawOperands); ::llvm::SMLoc rhsOperandsLoc;
3922 (void)rhsOperandsLoc;
3923 ::mlir::Type resultRawTypes[1];
3924 ::llvm::ArrayRef<::mlir::Type> resultTypes(resultRawTypes);
3925
3926 lhsOperandsLoc = parser.getCurrentLocation();
3927 if (parser.parseOperand(lhsRawOperands[0]))
3928 return ::mlir::failure();
3929 if (parser.parseComma())
3930 return ::mlir::failure();
3931
3932 rhsOperandsLoc = parser.getCurrentLocation();
3933 if (parser.parseOperand(rhsRawOperands[0]))
3934 return ::mlir::failure();
3935 if (parser.parseOptionalAttrDict(result.attributes))
3936 return ::mlir::failure();
3937 if (parser.parseColon())
3938 return ::mlir::failure();
3939
3940 {
3941 ::mlir::Type type;
3942 if (parser.parseCustomTypeWithFallback(type))
3943 return ::mlir::failure();
3944 resultRawTypes[0] = type;
3945 }
3946 result.addTypes(resultTypes);
3947 if (parser.resolveOperands(lhsOperands, resultTypes[0], result.operands))
3948 return ::mlir::failure();
3949 if (parser.resolveOperands(rhsOperands, resultTypes[0], result.operands))
3950 return ::mlir::failure();
3951 return ::mlir::success();
3952}
3953
3954void FloorDivSIOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
3955 _odsPrinter << ' ';
3956 _odsPrinter << getLhs();
3957 _odsPrinter << ",";
3958 _odsPrinter << ' ';
3959 _odsPrinter << getRhs();
3960 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{});
3961 _odsPrinter << ' ' << ":";
3962 _odsPrinter << ' ';
3963 {
3964 auto type = getResult().getType();
3965 if (auto validType = type.dyn_cast<::mlir::Type>())
3966 _odsPrinter.printStrippedAttrOrType(validType);
3967 else
3968 _odsPrinter << type;
3969 }
3970}
3971
3972void FloorDivSIOp::getEffects(::mlir::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
3973}
3974
3975} // namespace arith
3976} // namespace mlir
3977DEFINE_EXPLICIT_TYPE_ID(::mlir::arith::FloorDivSIOp)namespace mlir { namespace detail { template <> __attribute__
((visibility("default"))) TypeID TypeIDExported::get< ::mlir
::arith::FloorDivSIOp>() { static TypeID::Storage instance
; return TypeID(&instance); } } }
3978
3979namespace mlir {
3980namespace arith {
3981
3982//===----------------------------------------------------------------------===//
3983// ::mlir::arith::IndexCastOp definitions
3984//===----------------------------------------------------------------------===//
3985
3986IndexCastOpAdaptor::IndexCastOpAdaptor(::mlir::ValueRange values, ::mlir::DictionaryAttr attrs, ::mlir::RegionRange regions) : odsOperands(values), odsAttrs(attrs), odsRegions(regions) {}
3987
3988IndexCastOpAdaptor::IndexCastOpAdaptor(IndexCastOp &op) : odsOperands(op->getOperands()), odsAttrs(op->getAttrDictionary()), odsRegions(op->getRegions()) {}
3989
3990::mlir::ValueRange IndexCastOpAdaptor::getOperands() {
3991 return odsOperands;
3992}
3993
3994std::pair<unsigned, unsigned> IndexCastOpAdaptor::getODSOperandIndexAndLength(unsigned index) {
3995 return {index, 1};
3996}
3997
3998::mlir::ValueRange IndexCastOpAdaptor::getODSOperands(unsigned index) {
3999 auto valueRange = getODSOperandIndexAndLength(index);
4000 return {std::next(odsOperands.begin(), valueRange.first),
4001 std::next(odsOperands.begin(), valueRange.first + valueRange.second)};
4002}
4003
4004::mlir::Value IndexCastOpAdaptor::getIn() {
4005 return *getODSOperands(0).begin();
4006}
4007
4008::mlir::DictionaryAttr IndexCastOpAdaptor::getAttributes() {
4009 return odsAttrs;
4010}
4011
4012::mlir::LogicalResult IndexCastOpAdaptor::verify(::mlir::Location loc) {
4013 return ::mlir::success();
4014}
4015
4016std::pair<unsigned, unsigned> IndexCastOp::getODSOperandIndexAndLength(unsigned index) {
4017 return {index, 1};
4018}
4019
4020::mlir::Operation::operand_range IndexCastOp::getODSOperands(unsigned index) {
4021 auto valueRange = getODSOperandIndexAndLength(index);
4022 return {std::next(getOperation()->operand_begin(), valueRange.first),
4023 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
4024}
4025
4026::mlir::Value IndexCastOp::getIn() {
4027 return *getODSOperands(0).begin();
4028}
4029
4030::mlir::MutableOperandRange IndexCastOp::getInMutable() {
4031 auto range = getODSOperandIndexAndLength(0);
4032 auto mutableRange = ::mlir::MutableOperandRange(getOperation(), range.first, range.second);
4033 return mutableRange;
4034}
4035
4036std::pair<unsigned, unsigned> IndexCastOp::getODSResultIndexAndLength(unsigned index) {
4037 return {index, 1};
4038}
4039
4040::mlir::Operation::result_range IndexCastOp::getODSResults(unsigned index) {
4041 auto valueRange = getODSResultIndexAndLength(index);
4042 return {std::next(getOperation()->result_begin(), valueRange.first),
4043 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
4044}
4045
4046::mlir::Value IndexCastOp::getOut() {
4047 return *getODSResults(0).begin();
4048}
4049
4050void IndexCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, Value source, Type destType) {
4051 impl::buildCastOp(odsBuilder, odsState, source, destType);
4052
4053}
4054
4055void IndexCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type out, ::mlir::Value in) {
4056 odsState.addOperands(in);
4057 odsState.addTypes(out);
4058}
4059
4060void IndexCastOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value in) {
4061 odsState.addOperands(in);
4062 assert(resultTypes.size() == 1u && "mismatched number of results")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of results") ? void (0) : __assert_fail (
"resultTypes.size() == 1u && \"mismatched number of results\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 4062, __extension__ __PRETTY_FUNCTION__))
;
4063 odsState.addTypes(resultTypes);
4064}
4065
4066void IndexCastOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
4067 assert(operands.size() == 1u && "mismatched number of parameters")(static_cast <bool> (operands.size() == 1u && "mismatched number of parameters"
) ? void (0) : __assert_fail ("operands.size() == 1u && \"mismatched number of parameters\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 4067, __extension__ __PRETTY_FUNCTION__))
;
4068 odsState.addOperands(operands);
4069 odsState.addAttributes(attributes);
4070 assert(resultTypes.size() == 1u && "mismatched number of return types")(static_cast <bool> (resultTypes.size() == 1u &&
"mismatched number of return types") ? void (0) : __assert_fail
("resultTypes.size() == 1u && \"mismatched number of return types\""
, "tools/mlir/include/mlir/Dialect/Arithmetic/IR/ArithmeticOps.cpp.inc"
, 4070, __extension__ __PRETTY_FUNCTION__))
;
4071 odsState.addTypes(resultTypes);
4072}
4073
4074::mlir::LogicalResult IndexCastOp::verify() {
4075 {
4076 unsigned index = 0; (void)index;
4077 auto valueGroup0 = getODSOperands(0);
4078
4079 for (auto v : valueGroup0) {
4080 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps8(*this, v.getType(), "operand", index++)))
4081 return ::mlir::failure();
4082 }
4083 }
4084 {
4085 unsigned index = 0; (void)index;
4086 auto valueGroup0 = getODSResults(0);
4087
4088 for (auto v : valueGroup0) {
4089 if (::mlir::failed(__mlir_ods_local_type_constraint_ArithmeticOps8(*this, v.getType(), "result", index++)))
4090 return ::mlir::failure();
4091 }
4092 }
4093 return ::mlir::success();
4094}
4095
4096::mlir::ParseResult IndexCastOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
4097 ::mlir::OpAsmParser::OperandType inRawOperands[1];
4098 ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> inOperands(inRawOperands); ::llvm::SMLoc inOperandsLoc;
4099 (void)inOperandsLoc;
4100 ::mlir::Type inRawTypes[1];
4101 ::llvm::ArrayRef<::mlir::Type> inTypes(inRawTypes);
4102 ::mlir::Type outRawTypes[1];
4103 ::llvm::ArrayRef<::mlir::Type> outTypes(outRawTypes);
4104
4105 inOperandsLoc = parser.getCurrentLocation();
4106 if (parser.parseOperand(inRawOperands[0]))
4107 return ::mlir::failure();
4108 if (parser.parseOptionalAttrDict(result.attributes))
4109 return ::mlir::failure();
4110 if (parser.parseColon())
4111 return ::mlir::failure();
4112
4113 {
4114 ::mlir::Type type;
4115 if (parser.parseCustomTypeWithFallback(type))
4116 return ::mlir::failure();
4117 inRawTypes[0] = type;
4118 }
4119 if (parser.parseKeyword("to"))
4120 return ::mlir::failure();
4121
4122 {
4123 ::mlir::Type type;