1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Dialect Declarations *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: IndexOps.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10#include "mlir/IR/Dialect.h"
11
12namespace mlir::index {
13
14/// The Index dialect
15/// The Index dialect contains operations for manipulating values of the builtin
16/// `index` type. The index type models target-specific values of pointer width,
17/// like `intptr_t`. Index values are typically used as loop bounds, array
18/// subscripts, tensor dimensions, etc.
19///
20/// The operations in this dialect operate exclusively on scalar index types.
21/// The dialect and its operations treat the index type as signless and contains
22/// signed and unsigned versions of certain operations where the distinction is
23/// meaningful. In particular, the operations and transformations are careful to
24/// be aware of the target-independent-ness of the index type, such as when
25/// folding.
26///
27/// The folding semantics of the Index dialect operations ensure that folding
28/// produces the same results irrespective of the eventual target pointer width.
29/// All index constants are stored in `APInt`s of maximum index bitwidth: 64.
30/// Operations are folded using 64-bit integer arithmetic.
31///
32/// For operations where the values of the upper 32 bits don't impact the values
33/// of the lower 32 bits, no additional handling is required because if the
34/// target is 32-bit, the truncated folded result will be the same as if the
35/// operation were computed with 32-bit arithmetic, and if the target is 64-bit,
36/// the fold result is valid by default.
37///
38/// Consider addition: an overflow in 32-bit is the same as truncating the
39/// result computed in 64-bit. For example, `add(0x800000008, 0x800000008)` is
40/// `0x1000000010` in 64-bit, which truncates to `0x10`, the same result as
41/// truncating the operands first: `add(0x08, 0x08)`. Specifically, an operation
42/// `f` can always be folded if it satisfies the following for all 64-bit values
43/// of `a` and `b`:
44///
45/// ```
46/// trunc(f(a, b)) = f(trunc(a), trunc(b))
47/// ```
48///
49/// When materializing target-specific code, constants just need to be truncated
50/// as appropriate.
51///
52/// Operations where the values of the upper 32 bits do impact the values of the
53/// lower 32 bits are not folded if the results would be different in 32-bit.
54/// These are operations that right shift -- division, remainder, etc. These
55/// operations are only folded for subsets of `a` and `b` for which the above
56/// property is satisfied. This is checked per fold attempt.
57///
58/// Consider division: the 32-bit computation will differ from 64-bit if the
59/// latter results in a high bit shifted into the lower 32 bits. For example,
60/// `div(0x100000002, 2)` is `0x80000001` in 64-bit but `0x01` in 32-bit; it
61/// cannot be folded. However, `div(0x200000002, 2)` can be folded. The 64-bit
62/// result is `0x100000001`, which truncated to 32 bits is `0x01`. The 32-bit
63/// result of the operation with truncated operands `div(0x02, 2)` which is
64/// `0x01`, the same as truncating the 64-bit result.
65class IndexDialect : public ::mlir::Dialect {
66 explicit IndexDialect(::mlir::MLIRContext *context);
67
68 void initialize();
69 friend class ::mlir::MLIRContext;
70public:
71 ~IndexDialect() override;
72 static constexpr ::llvm::StringLiteral getDialectNamespace() {
73 return ::llvm::StringLiteral("index");
74 }
75
76 /// Parse an attribute registered to this dialect.
77 ::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser,
78 ::mlir::Type type) const override;
79
80 /// Print an attribute registered to this dialect.
81 void printAttribute(::mlir::Attribute attr,
82 ::mlir::DialectAsmPrinter &os) const override;
83
84 /// Materialize a single constant operation from a given attribute value with
85 /// the desired resultant type.
86 ::mlir::Operation *materializeConstant(::mlir::OpBuilder &builder,
87 ::mlir::Attribute value,
88 ::mlir::Type type,
89 ::mlir::Location loc) override;
90
91 /// Register all dialect attributes.
92 void registerAttributes();
93 /// Register all dialect operations.
94 void registerOperations();
95 };
96
97} // namespace mlir::index
98MLIR_DECLARE_EXPLICIT_TYPE_ID(::mlir::index::IndexDialect)
99