MLIR
19.0.0git
|
#include "mlir/Dialect/Index/IR/IndexOps.h"
#include "mlir/Dialect/Index/IR/IndexAttrs.h"
#include "mlir/Dialect/Index/IR/IndexDialect.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/Utils/InferIntRangeCommon.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Dialect/Index/IR/IndexOps.cpp.inc"
Go to the source code of this file.
Macros | |
#define | GET_OP_LIST |
#define | GET_OP_CLASSES |
Functions | |
static OpFoldResult | foldBinaryOpUnchecked (ArrayRef< Attribute > operands, function_ref< std::optional< APInt >(const APInt &, const APInt &)> calculate) |
Fold an index operation irrespective of the target bitwidth. More... | |
static OpFoldResult | foldBinaryOpChecked (ArrayRef< Attribute > operands, function_ref< std::optional< APInt >(const APInt &, const APInt &lhs)> calculate) |
Fold an index operation only if the truncated 64-bit result matches the 32-bit result for operations that don't satisfy the above property. More... | |
static std::optional< APInt > | calculateCeilDivS (const APInt &n, const APInt &m) |
Compute ceildivs(n, m) as x = m > 0 ? -1 : 1 and then n*m > 0 ? (n+x)/m + 1 : -(-n/m) . More... | |
static std::optional< APInt > | calculateFloorDivS (const APInt &n, const APInt &m) |
Compute floordivs(n, m) as x = m < 0 ? 1 : -1 and then n*m < 0 ? -1 - (x-n)/m : n/m . More... | |
static OpFoldResult | foldCastOp (Attribute input, Type type, function_ref< APInt(const APInt &, unsigned)> extFn, function_ref< APInt(const APInt &, unsigned)> extOrTruncFn) |
bool | compareIndices (const APInt &lhs, const APInt &rhs, IndexCmpPredicate pred) |
Compare two integers according to the comparison predicate. More... | |
static std::optional< bool > | foldCmpOfMaxOrMin (Operation *lhsOp, const APInt &cstA, const APInt &cstB, unsigned width, IndexCmpPredicate pred) |
cmp(max/min(x, cstA), cstB) can be folded to a constant depending on the values of cstA and cstB , the max or min operation, and the comparison predicate. More... | |
static bool | compareSameArgs (IndexCmpPredicate pred) |
Return the result of cmp(pred, x, x) More... | |
#define GET_OP_CLASSES |
Definition at line 700 of file IndexOps.cpp.
#define GET_OP_LIST |
|
static |
Compute ceildivs(n, m)
as x = m > 0 ? -1 : 1
and then n*m > 0 ? (n+x)/m + 1 : -(-n/m)
.
Definition at line 217 of file IndexOps.cpp.
|
static |
Compute floordivs(n, m)
as x = m < 0 ? 1 : -1
and then n*m < 0 ? -1 - (x-n)/m : n/m
.
Definition at line 268 of file IndexOps.cpp.
bool compareIndices | ( | const APInt & | lhs, |
const APInt & | rhs, | ||
IndexCmpPredicate | pred | ||
) |
Compare two integers according to the comparison predicate.
Definition at line 525 of file IndexOps.cpp.
|
static |
Return the result of cmp(pred, x, x)
Definition at line 582 of file IndexOps.cpp.
|
static |
Fold an index operation only if the truncated 64-bit result matches the 32-bit result for operations that don't satisfy the above property.
These are operations where the upper bits of the operands can affect the lower bits of the results.
The function accepts a lambda that computes the integer result in both 64-bit and 32-bit. If either call returns std::nullopt
, the operation is not folded.
Definition at line 95 of file IndexOps.cpp.
References mlir::get().
|
static |
Fold an index operation irrespective of the target bitwidth.
The operation must satisfy the property:
For all values of a
and b
. The function accepts a lambda that computes the integer result, which in turn must satisfy the above property.
Definition at line 69 of file IndexOps.cpp.
References mlir::get().
|
static |
Definition at line 448 of file IndexOps.cpp.
References mlir::get().
|
static |
cmp(max/min(x, cstA), cstB)
can be folded to a constant depending on the values of cstA
and cstB
, the max or min operation, and the comparison predicate.
Check whether the value folds in both 32-bit and 64-bit arithmetic and to the same value.
Definition at line 556 of file IndexOps.cpp.