21#include "llvm/ADT/STLExtras.h"
41template <
typename PredicateAttr,
typename Predicate>
44 function_ref<std::optional<Predicate>(StringRef)> symbolize) {
49 std::optional<Predicate> value = symbolize(spelling);
53 <<
"' is an incorrect value of the 'predicate' attribute";
54 predicate = PredicateAttr::get(parser.
getContext(), *value);
59 ICmpPredicateAttr &predicate) {
62 [](StringRef spelling) {
return symbolizeICmpPredicate(spelling); });
66 FCmpPredicateAttr &predicate) {
69 [](StringRef spelling) {
return symbolizeFCmpPredicate(spelling); });
73 ICmpPredicateAttr predicate) {
74 printer <<
'"' << stringifyICmpPredicate(predicate.getValue()) <<
'"';
78 FCmpPredicateAttr predicate) {
79 printer <<
'"' << stringifyFCmpPredicate(predicate.getValue()) <<
'"';
85 ShapedType shapedType = dyn_cast<ShapedType>(type);
92 if (getPredicate() != ICmpPredicate::eq &&
93 getPredicate() != ICmpPredicate::ne)
97 if (getLhs() == getRhs())
99 getPredicate() == ICmpPredicate::eq);
102 if (getLhs().getDefiningOp<AllocaOp>() && getRhs().getDefiningOp<ZeroOp>())
104 getPredicate() == ICmpPredicate::ne);
107 if (getLhs().getDefiningOp<ZeroOp>() && getRhs().getDefiningOp<AllocaOp>()) {
108 Value lhs = getLhs();
109 Value rhs = getRhs();
110 getLhsMutable().assign(rhs);
111 getRhsMutable().assign(lhs);
123 auto rhs = dyn_cast_or_null<IntegerAttr>(adaptor.getRhs());
127 if (rhs.getValue().uge(getLhs().
getType().getIntOrFloatBitWidth()))
130 auto lhs = dyn_cast_or_null<IntegerAttr>(adaptor.getLhs());
134 return IntegerAttr::get(
getType(), lhs.getValue().shl(rhs.getValue()));
142 auto lhs = dyn_cast_or_null<IntegerAttr>(adaptor.getLhs());
146 auto rhs = dyn_cast_or_null<IntegerAttr>(adaptor.getRhs());
150 return IntegerAttr::get(
getType(), lhs.getValue() | rhs.getValue());
158 Value divisor = getRhs();
173 Value divisor = getRhs();
187 Value divisor = getRhs();
201 Value divisor = getRhs();
209#define GET_OP_CLASSES
210#include "mlir/Dialect/LLVMIR/LLVMArithOps.cpp.inc"
static ParseResult parseCmpPredicateImpl(OpAsmParser &parser, PredicateAttr &predicate, function_ref< std::optional< Predicate >(StringRef)> symbolize)
static Attribute getBoolAttribute(Type type, MLIRContext *ctx, bool value)
Returns a scalar or vector boolean attribute of the given type.
MLIRContext * getContext() const
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
ParseResult parseString(std::string *string)
Parse a quoted string token.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
Attributes are known-constant values of operations.
static BoolAttr get(MLIRContext *context, bool value)
static DenseElementsAttr get(ShapedType type, ArrayRef< Attribute > values)
Constructs a dense elements attribute from an array of element values.
MLIRContext is the top-level object for a collection of MLIR operations.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This class represents a single result from folding an operation.
Operation is the basic unit of execution within MLIR.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getVectorType(Type elementType, unsigned numElements, bool isScalable=false)
Creates an LLVM dialect-compatible vector type with the given element type and length.
mlir::ParseResult parseCmpPredicate(mlir::OpAsmParser &parser, mlir::LLVM::ICmpPredicateAttr &predicate)
void printCmpPredicate(mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::LLVM::ICmpPredicateAttr predicate)
bool isCompatibleVectorType(Type type)
Returns true if the given type is a vector type compatible with the LLVM dialect.
mlir::Type getI1SameShape(mlir::Type type)
Returns a boolean type that has the same shape as type.
llvm::ElementCount getVectorNumElements(Type type)
Returns the element count of any LLVM-compatible vector type.
Speculatability
This enum is returned from the getSpeculatability method in the ConditionallySpeculatable op interfac...
constexpr auto Speculatable
constexpr auto NotSpeculatable
Include the generated interface declarations.
bool matchPattern(Value value, const Pattern &pattern)
Entry point for matching a pattern over a Value.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
detail::constant_int_range_predicate_matcher m_IntRangeWithoutNegOneS()
Matches a constant scalar / vector splat / tensor splat integer or a signed integer range that does n...
detail::constant_int_range_predicate_matcher m_IntRangeWithoutZeroS()
Matches a constant scalar / vector splat / tensor splat integer or a signed integer range that does n...
llvm::function_ref< Fn > function_ref
detail::constant_int_range_predicate_matcher m_IntRangeWithoutZeroU()
Matches a constant scalar / vector splat / tensor splat integer or a unsigned integer range that does...