27#include "llvm/ADT/STLExtras.h"
30#include "mlir/Dialect/ControlFlow/IR/ControlFlowOpsDialect.cpp.inc"
41struct ControlFlowInlinerInterface :
public DialectInlinerInterface {
42 using DialectInlinerInterface::DialectInlinerInterface;
43 ~ControlFlowInlinerInterface()
override =
default;
47 bool wouldBeCloned)
const final {
50 bool isLegalToInline(Operation *, Region *,
bool, IRMapping &)
const final {
55 void handleTerminator(Operation *op,
Block *newDest)
const final {}
63void ControlFlowDialect::initialize() {
64 addInterfaces<ControlFlowInlinerInterface>();
65 declarePromisedInterface<ConvertToLLVMPatternInterface, ControlFlowDialect>();
66 declarePromisedInterfaces<bufferization::BufferizableOpInterface, BranchOp,
68 declarePromisedInterface<bufferization::BufferDeallocationOpInterface,
76LogicalResult AssertOp::canonicalize(AssertOp op,
PatternRewriter &rewriter) {
86void AssertOp::getEffects(
106 if (std::next(successor->
begin()) != successor->
end())
109 BranchOp successorBranch = dyn_cast<BranchOp>(successor->
getTerminator());
110 if (!successorBranch)
115 if (user != successorBranch)
119 Block *successorDest = successorBranch.getDest();
120 if (successorDest == successor)
123 BranchOp nextBranch = dyn_cast<BranchOp>(successorDest->
getTerminator());
126 Block *nextBranchDest = nextBranch.getDest();
127 if (visited.contains(nextBranchDest))
129 visited.insert(nextBranchDest);
130 nextBranch = dyn_cast<BranchOp>(nextBranchDest->
getTerminator());
137 successor = successorDest;
138 successorOperands = operands;
143 for (
Value operand : operands) {
144 BlockArgument argOperand = llvm::dyn_cast<BlockArgument>(operand);
145 if (argOperand && argOperand.
getOwner() == successor)
146 argStorage.push_back(successorOperands[argOperand.
getArgNumber()]);
148 argStorage.push_back(operand);
150 successor = successorDest;
151 successorOperands = argStorage;
160 Block *succ = op.getDest();
161 Block *opParent = op->getBlock();
162 if (succ == opParent || !llvm::hasSingleElement(succ->
getPredecessors()))
168 for (
Value operand : op.getOperands())
169 if (
auto ba = dyn_cast<BlockArgument>(operand))
170 if (ba.getOwner() == succ)
188 Block *dest = op.getDest();
194 if (dest == op->getBlock() ||
222 bool changed =
false;
229 auto branch = dyn_cast<BranchOpInterface>(pred->getTerminator());
231 commonValue =
Value();
235 for (
auto [i, succ] : llvm::enumerate(branch->getSuccessors())) {
240 Value val = branch.getSuccessorOperands(i)[arg.getArgNumber()];
241 if (commonValue && commonValue != val) {
242 commonValue =
Value();
252 if (commonValue && commonValue != arg) {
263struct SimplifyUniformBlockArguments
266 LogicalResult matchAndRewrite(BranchOpInterface op,
267 PatternRewriter &rewriter)
const override {
268 bool changed =
false;
269 for (
Block *succ : op->getSuccessors())
276LogicalResult BranchOp::canonicalize(BranchOp op,
PatternRewriter &rewriter) {
282void BranchOp::setDest(
Block *block) {
return setSuccessor(block); }
284void BranchOp::eraseOperand(
unsigned index) { (*this)->eraseOperand(
index); }
287 assert(
index == 0 &&
"invalid successor index");
308 LogicalResult matchAndRewrite(CondBranchOp condbr,
309 PatternRewriter &rewriter)
const override {
313 condbr.getTrueOperands());
319 condbr.getFalseOperands());
334struct SimplifyPassThroughCondBranch :
public OpRewritePattern<CondBranchOp> {
335 using OpRewritePattern<CondBranchOp>::OpRewritePattern;
337 LogicalResult matchAndRewrite(CondBranchOp condbr,
338 PatternRewriter &rewriter)
const override {
339 Block *trueDest = condbr.getTrueDest(), *falseDest = condbr.getFalseDest();
340 ValueRange trueDestOperands = condbr.getTrueOperands();
341 ValueRange falseDestOperands = condbr.getFalseOperands();
342 SmallVector<Value, 4> trueDestOperandStorage, falseDestOperandStorage;
345 LogicalResult collapsedTrue =
346 collapseBranch(trueDest, trueDestOperands, trueDestOperandStorage);
347 LogicalResult collapsedFalse =
348 collapseBranch(falseDest, falseDestOperands, falseDestOperandStorage);
354 condbr, condbr.getCondition(), trueDest, trueDestOperands, falseDest,
355 falseDestOperands, condbr.getWeights());
367struct SimplifyCondBranchIdenticalSuccessors
369 using OpRewritePattern<CondBranchOp>::OpRewritePattern;
371 LogicalResult matchAndRewrite(CondBranchOp condbr,
372 PatternRewriter &rewriter)
const override {
375 Block *trueDest = condbr.getTrueDest();
376 if (trueDest != condbr.getFalseDest())
380 OperandRange trueOperands = condbr.getTrueOperands();
381 OperandRange falseOperands = condbr.getFalseOperands();
382 if (trueOperands == falseOperands) {
393 SmallVector<Value, 8> mergedOperands;
394 mergedOperands.reserve(trueOperands.size());
395 Value condition = condbr.getCondition();
396 for (
auto it : llvm::zip(trueOperands, falseOperands)) {
397 if (std::get<0>(it) == std::get<1>(it))
398 mergedOperands.push_back(std::get<0>(it));
400 mergedOperands.push_back(
401 arith::SelectOp::create(rewriter, condbr.getLoc(), condition,
402 std::get<0>(it), std::get<1>(it)));
426struct SimplifyCondBranchFromCondBranchOnSameCondition
428 using OpRewritePattern<CondBranchOp>::OpRewritePattern;
430 LogicalResult matchAndRewrite(CondBranchOp condbr,
431 PatternRewriter &rewriter)
const override {
433 Block *currentBlock = condbr->getBlock();
440 auto predBranch = dyn_cast<CondBranchOp>(predecessor->
getTerminator());
441 if (!predBranch || condbr.getCondition() != predBranch.getCondition())
445 if (currentBlock == predBranch.getTrueDest())
447 condbr.getTrueDestOperands());
450 condbr.getFalseDestOperands());
476 using OpRewritePattern<CondBranchOp>::OpRewritePattern;
478 LogicalResult matchAndRewrite(CondBranchOp condbr,
479 PatternRewriter &rewriter)
const override {
481 bool replaced =
false;
486 Value constantTrue =
nullptr;
487 Value constantFalse =
nullptr;
494 if (condbr.getTrueDest()->getSinglePredecessor()) {
495 for (OpOperand &use :
496 llvm::make_early_inc_range(condbr.getCondition().getUses())) {
497 if (use.getOwner()->getBlock() == condbr.getTrueDest()) {
501 constantTrue = arith::ConstantOp::create(
502 rewriter, condbr.getLoc(), ty, rewriter.
getBoolAttr(
true));
505 [&] { use.set(constantTrue); });
509 if (condbr.getFalseDest()->getSinglePredecessor()) {
510 for (OpOperand &use :
511 llvm::make_early_inc_range(condbr.getCondition().getUses())) {
512 if (use.getOwner()->getBlock() == condbr.getFalseDest()) {
516 constantFalse = arith::ConstantOp::create(
517 rewriter, condbr.getLoc(), ty, rewriter.
getBoolAttr(
false));
520 [&] { use.set(constantFalse); });
529static bool isUnreachableBlock(
Block *block) {
530 return llvm::hasSingleElement(*block) &&
537 using OpRewritePattern<CondBranchOp>::OpRewritePattern;
539 LogicalResult matchAndRewrite(CondBranchOp condbr,
540 PatternRewriter &rewriter)
const override {
543 Block *trueDest = condbr.getTrueDest();
544 Block *falseDest = condbr.getFalseDest();
545 if (isUnreachableBlock(trueDest)) {
547 condbr.getFalseOperands());
553 if (isUnreachableBlock(falseDest)) {
555 condbr.getTrueOperands());
566 results.
add<SimplifyConstCondBranchPred, SimplifyPassThroughCondBranch,
567 SimplifyCondBranchIdenticalSuccessors,
568 SimplifyCondBranchFromCondBranchOnSameCondition,
569 CondBranchTruthPropagation, DropUnreachableCondBranch,
570 SimplifyUniformBlockArguments>(context);
574 assert(
index < getNumSuccessors() &&
"invalid successor index");
576 : getFalseDestOperandsMutable());
580 if (IntegerAttr condAttr =
581 llvm::dyn_cast_or_null<IntegerAttr>(operands.front()))
582 return condAttr.getValue().isOne() ? getTrueDest() : getFalseDest();
595 build(builder,
result, value, defaultOperands, caseOperands, caseValues,
596 defaultDestination, caseDestinations);
604 if (!caseValues.empty()) {
605 ShapedType caseValueType = VectorType::get(
609 build(builder,
result, value, defaultDestination, defaultOperands,
610 caseValuesAttr, caseDestinations, caseOperands);
618 if (!caseValues.empty()) {
619 ShapedType caseValueType = VectorType::get(
623 build(builder,
result, value, defaultDestination, defaultOperands,
624 caseValuesAttr, caseDestinations, caseOperands);
654 if (value.isNegative() ? !value.isSignedIntN(bitWidth)
655 : !value.isIntN(bitWidth))
657 <<
"case value is out of range for " << flagType;
658 values.push_back(value.sextOrTrunc(bitWidth));
673 caseDestinations.push_back(destination);
674 caseOperands.emplace_back(operands);
675 caseOperandTypes.emplace_back(operandTypes);
678 if (!values.empty()) {
679 ShapedType caseValueType =
680 VectorType::get(
static_cast<int64_t>(values.size()), flagType);
697 for (
const auto &it : llvm::enumerate(caseValues.getValues<APInt>())) {
704 caseOperands[it.index()]);
709LogicalResult SwitchOp::verify() {
710 auto caseValues = getCaseValues();
711 auto caseDestinations = getCaseDestinations();
713 if (!caseValues && caseDestinations.empty())
716 Type flagType = getFlag().getType();
717 Type caseValueType = caseValues->getType().getElementType();
718 if (caseValueType != flagType)
719 return emitOpError() <<
"'flag' type (" << flagType
720 <<
") should match case value type (" << caseValueType
724 caseValues->size() !=
static_cast<int64_t>(caseDestinations.size()))
725 return emitOpError() <<
"number of case values (" << caseValues->size()
726 <<
") should match number of "
727 "case destinations ("
728 << caseDestinations.size() <<
")";
732 llvm::SmallDenseMap<APInt, unsigned> firstCase;
733 for (
auto [
index, value] :
734 llvm::enumerate(caseValues->getValues<APInt>())) {
738 std::string asSigned = llvm::toString(value, 10,
true);
739 std::string asUnsigned = llvm::toString(value, 10,
false);
741 if (asSigned != asUnsigned)
742 diag <<
" (unsigned " << asUnsigned <<
")";
743 return diag <<
" is repeated (cases " << it->second <<
" and " <<
index
751 assert(
index < getNumSuccessors() &&
"invalid successor index");
753 : getCaseOperandsMutable(
index - 1));
757 std::optional<DenseIntElementsAttr> caseValues = getCaseValues();
760 return getDefaultDestination();
763 if (
auto value = llvm::dyn_cast_or_null<IntegerAttr>(operands.front())) {
764 for (
const auto &it : llvm::enumerate(caseValues->getValues<APInt>()))
765 if (it.value() == value.getValue())
766 return caseDests[it.index()];
767 return getDefaultDestination();
778 if (!op.getCaseDestinations().empty())
782 op.getDefaultOperands());
801 bool requiresChange =
false;
802 auto caseValues = op.getCaseValues();
803 auto caseDests = op.getCaseDestinations();
805 for (
const auto &it : llvm::enumerate(caseValues->getValues<APInt>())) {
806 if (caseDests[it.index()] == op.getDefaultDestination() &&
807 op.getCaseOperands(it.index()) == op.getDefaultOperands()) {
808 requiresChange =
true;
811 newCaseDestinations.push_back(caseDests[it.index()]);
812 newCaseOperands.push_back(op.getCaseOperands(it.index()));
813 newCaseValues.push_back(it.value());
820 op, op.getFlag(), op.getDefaultDestination(), op.getDefaultOperands(),
821 newCaseValues, newCaseDestinations, newCaseOperands);
842 std::optional<DenseIntElementsAttr> caseValues = op.getCaseValues();
849 auto caseDests = op.getCaseDestinations();
850 for (
const auto &it : llvm::enumerate(caseValues->getValues<APInt>())) {
851 if (isUnreachableBlock(caseDests[it.index()]))
853 newCaseValues.push_back(it.value());
854 newCaseDestinations.push_back(caseDests[it.index()]);
855 newCaseOperands.push_back(op.getCaseOperands(it.index()));
858 Block *defaultDest = op.getDefaultDestination();
859 ValueRange defaultOperands = op.getDefaultOperands();
860 if (isUnreachableBlock(defaultDest)) {
862 if (newCaseDestinations.empty()) {
868 defaultDest = newCaseDestinations.pop_back_val();
869 defaultOperands = newCaseOperands.pop_back_val();
870 newCaseValues.pop_back();
871 }
else if (newCaseDestinations.size() == caseDests.size()) {
875 if (newCaseDestinations.empty()) {
880 defaultOperands, newCaseValues,
881 newCaseDestinations, newCaseOperands);
893 const APInt &caseValue) {
894 auto caseValues = op.getCaseValues();
895 for (
const auto &it : llvm::enumerate(caseValues->getValues<APInt>())) {
896 if (it.value() == caseValue) {
898 op, op.getCaseDestinations()[it.index()],
899 op.getCaseOperands(it.index()));
904 op.getDefaultOperands());
939 auto caseValues = op.getCaseValues();
940 argStorage.reserve(caseValues->size() + 1);
941 auto caseDests = op.getCaseDestinations();
942 bool requiresChange =
false;
943 for (
int64_t i = 0, size = caseValues->size(); i < size; ++i) {
944 Block *caseDest = caseDests[i];
945 ValueRange caseOperands = op.getCaseOperands(i);
946 argStorage.emplace_back();
947 if (succeeded(
collapseBranch(caseDest, caseOperands, argStorage.back())))
948 requiresChange =
true;
950 newCaseDests.push_back(caseDest);
951 newCaseOperands.push_back(caseOperands);
954 Block *defaultDest = op.getDefaultDestination();
955 ValueRange defaultOperands = op.getDefaultOperands();
956 argStorage.emplace_back();
960 requiresChange =
true;
966 defaultOperands, *caseValues,
967 newCaseDests, newCaseOperands);
1010 Block *currentBlock = op->getBlock();
1018 auto predSwitch = dyn_cast<SwitchOp>(predecessor->
getTerminator());
1019 if (!predSwitch || op.getFlag() != predSwitch.getFlag() ||
1020 predSwitch.getDefaultDestination() == currentBlock)
1025 auto it = llvm::find(predDests, currentBlock);
1026 if (it != predDests.end()) {
1027 std::optional<DenseIntElementsAttr> predCaseValues =
1028 predSwitch.getCaseValues();
1030 predCaseValues->getValues<APInt>()[it - predDests.begin()]);
1033 op.getDefaultOperands());
1062 Block *currentBlock = op->getBlock();
1070 auto predSwitch = dyn_cast<SwitchOp>(predecessor->
getTerminator());
1071 if (!predSwitch || op.getFlag() != predSwitch.getFlag() ||
1072 predSwitch.getDefaultDestination() != currentBlock)
1077 auto predDests = predSwitch.getCaseDestinations();
1078 auto predCaseValues = predSwitch.getCaseValues();
1079 for (
int64_t i = 0, size = predCaseValues->size(); i < size; ++i)
1080 if (currentBlock != predDests[i])
1081 caseValuesToRemove.insert(predCaseValues->getValues<APInt>()[i]);
1086 bool requiresChange =
false;
1088 auto caseValues = op.getCaseValues();
1089 auto caseDests = op.getCaseDestinations();
1090 for (
const auto &it : llvm::enumerate(caseValues->getValues<APInt>())) {
1091 if (caseValuesToRemove.contains(it.value())) {
1092 requiresChange =
true;
1095 newCaseDestinations.push_back(caseDests[it.index()]);
1096 newCaseOperands.push_back(op.getCaseOperands(it.index()));
1097 newCaseValues.push_back(it.value());
1100 if (!requiresChange)
1104 op, op.getFlag(), op.getDefaultDestination(), op.getDefaultOperands(),
1105 newCaseValues, newCaseDestinations, newCaseOperands);
1118 .
add<SimplifyUniformBlockArguments>(context);
1125#define GET_OP_CLASSES
1126#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.cpp.inc"
static LogicalResult simplifyUniformBlockArgs(Block *dest, PatternRewriter &rewriter)
If all incoming values for a block argument from all predecessors are the same SSA value,...
static LogicalResult simplifySwitchFromSwitchOnSameCondition(SwitchOp op, PatternRewriter &rewriter)
switch flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: switch flag : i32, [ default: ^bb3,...
static LogicalResult simplifyConstSwitchValue(SwitchOp op, PatternRewriter &rewriter)
switch c_42 : i32, [ default: ^bb1, 42: ^bb2, 43: ^bb3 ] -> br ^bb2
static LogicalResult simplifySwitchWithOnlyDefault(SwitchOp op, PatternRewriter &rewriter)
switch flag : i32, [ default: ^bb1 ] -> br ^bb1
static void foldSwitch(SwitchOp op, PatternRewriter &rewriter, const APInt &caseValue)
Helper for folding a switch with a constant value.
static void printSwitchOpCases(OpAsmPrinter &p, SwitchOp op, Type flagType, Block *defaultDestination, OperandRange defaultOperands, TypeRange defaultOperandTypes, DenseIntElementsAttr caseValues, SuccessorRange caseDestinations, OperandRangeRange caseOperands, const TypeRangeRange &caseOperandTypes)
static LogicalResult simplifyPassThroughBr(BranchOp op, PatternRewriter &rewriter)
br ^bb1 ^bb1 br ^bbN(...)
static LogicalResult simplifyBrToBlockWithSinglePred(BranchOp op, PatternRewriter &rewriter)
Simplify a branch to a block that has a single predecessor.
static LogicalResult collapseBranch(Block *&successor, ValueRange &successorOperands, SmallVectorImpl< Value > &argStorage)
Given a successor, try to collapse it to a new destination if it only contains a passthrough uncondit...
static LogicalResult dropSwitchCasesThatMatchDefault(SwitchOp op, PatternRewriter &rewriter)
switch flag : i32, [ default: ^bb1, 42: ^bb1, 43: ^bb2 ] -> switch flag : i32, [ default: ^bb1,...
static LogicalResult dropUnreachableSwitchCases(SwitchOp op, PatternRewriter &rewriter)
Drop cases whose destination block contains only ub.unreachable.
static LogicalResult simplifyPassThroughSwitch(SwitchOp op, PatternRewriter &rewriter)
switch c_42 : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3 -> switch c_42 : i32,...
static LogicalResult simplifySwitchFromDefaultSwitchOnSameCondition(SwitchOp op, PatternRewriter &rewriter)
switch flag : i32, [ default: ^bb1, 42: ^bb2 ] ^bb1: switch flag : i32, [ default: ^bb3,...
static ParseResult parseSwitchOpCases(OpAsmParser &parser, Type &flagType, Block *&defaultDestination, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &defaultOperands, SmallVectorImpl< Type > &defaultOperandTypes, DenseIntElementsAttr &caseValues, SmallVectorImpl< Block * > &caseDestinations, SmallVectorImpl< SmallVector< OpAsmParser::UnresolvedOperand > > &caseOperands, SmallVectorImpl< SmallVector< Type > > &caseOperandTypes)
<cases> ::= default : bb-id (( ssa-use-and-type-list ))?
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be inserted(the insertion happens right before the *insertion point). Since `begin` can itself be invalidated due to the memref *rewriting done from this method
@ None
Zero or more operands with no delimiters.
virtual ParseResult parseColonTypeList(SmallVectorImpl< Type > &result)=0
Parse a colon followed by a type list, which must have at least one type.
virtual ParseResult parseRParen()=0
Parse a ) token.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
virtual ParseResult parseOptionalComma()=0
Parse a , token if present.
virtual ParseResult parseColon()=0
Parse a : token.
virtual ParseResult parseOptionalLParen()=0
Parse a ( token if present.
ParseResult parseKeyword(StringRef keyword)
Parse a given keyword.
virtual void printNewline()
Print a newline and indent the printer to the start of the current operation/attribute/type.
This class represents an argument of a Block.
unsigned getArgNumber() const
Returns the number of this argument.
Block * getOwner() const
Returns the block that owns this argument.
This class provides an abstraction over the different types of ranges over Blocks.
Block represents an ordered list of Operations.
iterator_range< pred_iterator > getPredecessors()
Block * getSinglePredecessor()
If this block has exactly one predecessor, return it.
Operation * getTerminator()
Get the terminator operation of this block.
BlockArgListType getArguments()
Block * getUniquePredecessor()
If this block has a unique predecessor, i.e., all incoming edges originate from one block,...
bool hasNoPredecessors()
Return true if this block has no predecessors.
BoolAttr getBoolAttr(bool value)
An attribute that represents a reference to a dense integer vector or tensor object.
static DenseIntElementsAttr get(const ShapedType &type, Arg &&arg)
Get an instance of a DenseIntElementsAttr with the given arguments.
This class represents a diagnostic that is inflight and set to be reported.
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,...
virtual ParseResult parseSuccessor(Block *&dest)=0
Parse a single operation successor.
virtual ParseResult parseOperandList(SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None, bool allowResultNumber=true, int requiredOperandCount=-1)=0
Parse zero or more SSA comma-separated operand references with a specified surrounding delimiter,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
virtual void printSuccessorAndUseList(Block *successor, ValueRange succOperands)=0
Print the successor and its operands.
This class helps build Operations.
This class represents a contiguous range of operand ranges, e.g.
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
user_range getUsers()
Returns a range of all users.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
virtual void eraseOp(Operation *op)
This method erases an operation that is known to have no uses.
void mergeBlocks(Block *source, Block *dest, ValueRange argValues={})
Inline the operations of block 'source' into the end of block 'dest'.
void modifyOpInPlace(Operation *root, CallableT &&callable)
This method is a utility wrapper around an in-place modification of an operation.
virtual void replaceAllUsesWith(Value from, Value to)
Find uses of from and replace them with to.
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
This class represents a specific instance of an effect.
static DerivedEffect * get()
This class models how operands are forwarded to block arguments in control flow.
This class implements the successor iterators for Block.
This class provides an abstraction for a range of TypeRange.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
Include the generated interface declarations.
bool matchPattern(Value value, const Pattern &pattern)
Entry point for matching a pattern over a Value.
detail::constant_int_value_binder m_ConstantInt(IntegerAttr::ValueType *bind_value)
Matches a constant holding a scalar/vector/tensor integer (splat) and writes the integer value to bin...
llvm::DenseSet< ValueT, ValueInfoT > DenseSet
detail::constant_int_predicate_matcher m_Zero()
Matches a constant scalar / vector splat / tensor splat integer zero.
detail::constant_int_predicate_matcher m_One()
Matches a constant scalar / vector splat / tensor splat integer one.
detail::constant_int_predicate_matcher m_NonZero()
Matches a constant scalar / vector splat / tensor splat integer that is any non-zero value.
OpInterfaceRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting a...
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...
This represents an operation in an abstracted form, suitable for use with the builder APIs.