17 #include "llvm/ADT/StringExtras.h" 31 return create(location, name, resultTypes, operands,
32 DictionaryAttr::get(location.
getContext(), attributes),
33 successors, numRegions);
46 DictionaryAttr attributes,
BlockRange successors,
48 unsigned numRegions = regions.size();
49 Operation *op =
create(location, name, resultTypes, operands, attributes,
50 successors, numRegions);
51 for (
unsigned i = 0; i < numRegions; ++i)
61 DictionaryAttr attributes,
BlockRange successors,
62 unsigned numRegions) {
63 assert(llvm::all_of(resultTypes, [](
Type t) {
return t; }) &&
64 "unexpected null result type");
67 unsigned numTrailingResults = OpResult::getNumTrailing(resultTypes.size());
68 unsigned numInlineResults = OpResult::getNumInline(resultTypes.size());
69 unsigned numSuccessors = successors.size();
70 unsigned numOperands = operands.size();
71 unsigned numResults = resultTypes.size();
75 bool needsOperandStorage =
82 totalSizeToAlloc<detail::OperandStorage, BlockOperand, Region, OpOperand>(
83 needsOperandStorage ? 1 : 0, numSuccessors, numRegions, numOperands);
84 size_t prefixByteSize = llvm::alignTo(
85 Operation::prefixAllocSize(numTrailingResults, numInlineResults),
87 char *mallocMem =
reinterpret_cast<char *
>(malloc(byteSize + prefixByteSize));
88 void *rawMem = mallocMem + prefixByteSize;
92 ::new (rawMem)
Operation(location, name, numResults, numSuccessors,
93 numRegions, attributes, needsOperandStorage);
96 "unexpected successors in a non-terminator operation");
99 auto resultTypeIt = resultTypes.begin();
100 for (
unsigned i = 0; i < numInlineResults; ++i, ++resultTypeIt)
102 for (
unsigned i = 0; i < numTrailingResults; ++i, ++resultTypeIt) {
103 new (op->getOutOfLineOpResult(i))
108 for (
unsigned i = 0; i != numRegions; ++i)
112 if (needsOperandStorage) {
114 op, op->getTrailingObjects<
OpOperand>(), operands);
119 for (
unsigned i = 0; i != numSuccessors; ++i)
120 new (&blockOperands[i])
BlockOperand(op, successors[i]);
126 unsigned numSuccessors,
unsigned numRegions,
127 DictionaryAttr attributes,
bool hasOperandStorage)
128 : location(location), numResults(numResults), numSuccs(numSuccessors),
129 numRegions(numRegions), hasOperandStorage(hasOperandStorage), name(name),
131 assert(attributes &&
"unexpected null attribute dictionary");
134 llvm::report_fatal_error(
136 " created with unregistered dialect. If this is intended, please call " 137 "allowUnregisteredDialects() on the MLIRContext, or use " 138 "-allow-unregistered-dialect with the MLIR tool used.");
144 Operation::~Operation() {
145 assert(block ==
nullptr &&
"operation destroyed but still in a block");
150 emitOpError(
"operation destroyed but still has uses");
152 diag.
attachNote(user->getLoc()) <<
"- use: " << *user <<
"\n";
154 llvm::report_fatal_error(
"operation destroyed but still has uses");
158 if (hasOperandStorage)
163 successor.~BlockOperand();
174 char *rawMem =
reinterpret_cast<char *
>(
this) -
175 llvm::alignTo(prefixAllocSize(),
alignof(
Operation));
194 if (operand.get() == from)
201 if (LLVM_LIKELY(hasOperandStorage))
202 return getOperandStorage().
setOperands(
this, operands);
203 assert(operands.empty() &&
"setting operands without an operand storage");
212 "invalid operand range specified");
213 if (LLVM_LIKELY(hasOperandStorage))
214 return getOperandStorage().
setOperands(
this, start, length, operands);
215 assert(operands.empty() &&
"setting operands without an operand storage");
220 if (LLVM_LIKELY(hasOperandStorage))
222 assert(operands.empty() &&
"inserting operands without an operand storage");
233 if (
getContext()->shouldPrintOpOnDiagnostic()) {
235 .
append(
"see current operation: ")
245 if (
getContext()->shouldPrintOpOnDiagnostic())
254 if (
getContext()->shouldPrintOpOnDiagnostic())
263 constexpr
unsigned Operation::kInvalidOrderIdx;
264 constexpr
unsigned Operation::kOrderStride;
272 assert(block &&
"Operations without parent blocks have no order.");
273 assert(other && other->block == block &&
274 "Expected other operation to have the same parent block.");
281 updateOrderIfNecessary();
282 other->updateOrderIfNecessary();
285 return orderIndex < other->orderIndex;
290 void Operation::updateOrderIfNecessary() {
291 assert(block &&
"expected valid parent");
301 assert(blockFront != blockBack &&
"expected more than one operation");
304 if (
this == blockBack) {
306 if (!prevNode->hasValidOrder())
310 orderIndex = prevNode->orderIndex + kOrderStride;
316 if (
this == blockFront) {
318 if (!nextNode->hasValidOrder())
321 if (nextNode->orderIndex == 0)
326 if (nextNode->orderIndex <= kOrderStride)
327 orderIndex = (nextNode->orderIndex / 2);
329 orderIndex = kOrderStride;
335 Operation *prevNode = getPrevNode(), *nextNode = getNextNode();
336 if (!prevNode->hasValidOrder() || !nextNode->hasValidOrder())
338 unsigned prevOrder = prevNode->orderIndex, nextOrder = nextNode->orderIndex;
341 if (prevOrder + 1 == nextOrder)
343 orderIndex = prevOrder + ((nextOrder - prevOrder) / 2);
350 auto llvm::ilist_detail::SpecificNodeAccess<
351 typename llvm::ilist_detail::compute_node_options<
353 return NodeAccess::getNodePtr<OptionsT>(n);
356 auto llvm::ilist_detail::SpecificNodeAccess<
357 typename llvm::ilist_detail::compute_node_options<
359 ->
const node_type * {
360 return NodeAccess::getNodePtr<OptionsT>(n);
363 auto llvm::ilist_detail::SpecificNodeAccess<
364 typename llvm::ilist_detail::compute_node_options<
366 return NodeAccess::getValuePtr<OptionsT>(n);
369 auto llvm::ilist_detail::SpecificNodeAccess<
370 typename llvm::ilist_detail::compute_node_options<
373 return NodeAccess::getValuePtr<OptionsT>(n);
380 Block *llvm::ilist_traits<::mlir::Operation>::getContainingBlock() {
382 iplist<Operation> *anchor(
static_cast<iplist<Operation> *
>(
this));
383 return reinterpret_cast<Block *
>(
reinterpret_cast<char *
>(anchor) - offset);
389 assert(!op->
getBlock() &&
"already in an operation block!");
390 op->block = getContainingBlock();
393 op->orderIndex = Operation::kInvalidOrderIdx;
399 assert(op->block &&
"not already in an operation block!");
407 Block *curParent = getContainingBlock();
414 if (curParent == otherList.getContainingBlock())
418 for (; first != last; ++first)
419 first->block = curParent;
426 parent->getOperations().erase(
this);
434 parent->getOperations().remove(
this);
447 llvm::iplist<Operation>::iterator iterator) {
461 llvm::iplist<Operation>::iterator iterator) {
462 assert(iterator != block->
end() &&
"cannot move after end of block");
474 region.dropAllReferences();
486 for (
auto &block : region)
501 if (info &&
succeeded(info->foldHook(
this, operands, results)))
509 auto *
interface = dyn_cast<DialectFoldInterface>(dialect);
513 return interface->fold(
this, operands, results);
527 : cloneRegionsFlag(false), cloneOperandsFlag(false) {}
530 : cloneRegionsFlag(cloneRegions), cloneOperandsFlag(cloneOperands) {}
537 cloneRegionsFlag = enable;
542 cloneOperandsFlag = enable;
587 for (
unsigned i = 0; i != numRegions; ++i)
600 return clone(mapper, options);
612 return (*parseFn)(parser, result);
620 printOpName(op, p, defaultDialect);
630 StringRef defaultDialect) {
632 if (name.startswith((defaultDialect +
".").str()) && name.count(
'.') == 1)
633 name = name.drop_front(defaultDialect.size() + 1);
640 return getOperation()->emitError(message);
646 return getOperation()->emitOpError(message);
652 return getOperation()->emitWarning(message);
658 return getOperation()->emitRemark(message);
668 if (argumentOp && op->
getName() == argumentOp->getName()) {
681 if (argumentOp && op->
getName() == argumentOp->getName()) {
691 return op->
emitOpError() <<
"requires zero operands";
697 return op->
emitOpError() <<
"requires a single operand";
702 unsigned numOperands) {
704 return op->
emitOpError() <<
"expected " << numOperands
711 unsigned numOperands) {
714 <<
"expected " << numOperands <<
" or more operands, but found " 722 if (
auto vec = type.
dyn_cast<VectorType>())
723 return vec.getElementType();
751 if (!type.isSignlessIntOrIndex())
752 return op->
emitOpError() <<
"requires an integer or index type";
775 return op->
emitOpError() <<
"requires all operands to have the same type";
781 return op->
emitOpError() <<
"requires zero regions";
792 unsigned numRegions) {
794 return op->
emitOpError() <<
"expected " << numRegions <<
" regions";
799 unsigned numRegions) {
801 return op->
emitOpError() <<
"expected " << numRegions <<
" or more regions";
807 return op->
emitOpError() <<
"requires zero results";
818 unsigned numOperands) {
820 return op->
emitOpError() <<
"expected " << numOperands <<
" results";
825 unsigned numOperands) {
828 <<
"expected " << numOperands <<
" or more results";
837 return op->
emitOpError() <<
"requires the same shape for all operands";
852 <<
"requires the same shape for all operands and results";
862 for (
auto operand : llvm::drop_begin(op->
getOperands(), 1)) {
864 return op->
emitOpError(
"requires the same element type for all operands");
879 for (
auto result : llvm::drop_begin(op->
getResults(), 1)) {
882 "requires the same element type for all operands and results");
889 "requires the same element type for all operands and results");
906 <<
"requires the same type for all operands and results";
912 <<
"requires the same type for all operands and results";
920 if (!block || &block->
back() != op)
921 return op->
emitOpError(
"must be the last operation in the parent block");
930 if (succ->getParent() != parent)
931 return op->
emitError(
"reference to block defined in another region");
937 return op->
emitOpError(
"requires 0 successors but found ")
945 return op->
emitOpError(
"requires 1 successor but found ")
951 unsigned numSuccessors) {
954 << numSuccessors <<
" successors but found " 960 unsigned numSuccessors) {
963 << numSuccessors <<
" successors but found " 972 bool isBoolType = elementType.isInteger(1);
974 return op->
emitOpError() <<
"requires a bool result type";
983 return op->
emitOpError() <<
"requires a floating point type";
992 return op->
emitOpError() <<
"requires an integer or index type";
998 StringRef valueGroupName,
999 size_t expectedCount) {
1002 return op->
emitOpError(
"requires 1D i32 elements attribute '")
1005 auto sizeAttrType = sizeAttr.getType();
1006 if (sizeAttrType.getRank() != 1 ||
1007 !sizeAttrType.getElementType().isInteger(32))
1008 return op->
emitOpError(
"requires 1D i32 elements attribute '")
1011 if (llvm::any_of(sizeAttr.getValues<APInt>(), [](
const APInt &element) {
1012 return !element.isNonNegative();
1015 << attrName <<
"' attribute cannot have negative elements";
1017 size_t totalCount = std::accumulate(
1018 sizeAttr.begin(), sizeAttr.end(), 0,
1019 [](
unsigned all,
const APInt &one) {
return all + one.getZExtValue(); });
1021 if (totalCount != expectedCount)
1023 << valueGroupName <<
" count (" << expectedCount
1024 <<
") does not match with the total size (" << totalCount
1025 <<
") specified in attribute '" << attrName <<
"'";
1030 StringRef attrName) {
1035 StringRef attrName) {
1044 if (region.getNumArguments() != 0) {
1047 << region.getRegionNumber() <<
" should have no arguments";
1048 return op->
emitOpError(
"region should have no arguments");
1055 auto isMappableType = [](
Type type) {
1058 auto resultMappableTypes = llvm::to_vector<1>(
1060 auto operandMappableTypes = llvm::to_vector<2>(
1065 if (resultMappableTypes.empty() && operandMappableTypes.empty())
1068 if (!resultMappableTypes.empty() && operandMappableTypes.empty())
1069 return op->
emitOpError(
"if a result is non-scalar, then at least one " 1070 "operand must be non-scalar");
1072 assert(!operandMappableTypes.empty());
1074 if (resultMappableTypes.empty())
1075 return op->
emitOpError(
"if an operand is non-scalar, then there must be at " 1076 "least one non-scalar result");
1080 "if an operand is non-scalar, then all results must be non-scalar");
1083 llvm::concat<Type>(operandMappableTypes, resultMappableTypes));
1084 TypeID expectedBaseTy = types.front().getTypeID();
1085 if (!llvm::all_of(types,
1088 return op->
emitOpError() <<
"all non-scalar operands/results must have the " 1089 "same shape and base type";
1099 "Intended to check IsolatedFromAbove ops");
1105 for (
auto ®ion : isolatedOp->
getRegions()) {
1106 pendingRegions.push_back(®ion);
1109 while (!pendingRegions.empty()) {
1110 for (
Operation &op : pendingRegions.pop_back_val()->getOps()) {
1111 for (
Value operand : op.getOperands()) {
1114 auto *operandRegion = operand.getParentRegion();
1116 return op.emitError(
"operation's operand is unlinked");
1117 if (!region.isAncestor(operandRegion)) {
1118 return op.emitOpError(
"using value defined outside the region")
1119 .attachNote(isolatedOp->
getLoc())
1120 <<
"required by region isolation constraints";
1127 if (op.getNumRegions() &&
1129 for (
Region &subRegion : op.getRegions())
1130 pendingRegions.push_back(&subRegion);
1153 if (operands.empty())
1159 foldResults.append(operands.begin(), operands.end());
1170 if (llvm::empty(resultTypes))
1172 <<
"expected at least one result for cast operation";
1175 if (!areCastCompatible(operandTypes, resultTypes)) {
1177 if (llvm::empty(operandTypes))
1179 else if (llvm::size(operandTypes) == 1)
1180 diag <<
" " << *operandTypes.begin();
1182 diag <<
"s " << operandTypes;
1183 return diag <<
" and result type" << (resultTypes.size() == 1 ?
" " :
"s ")
1184 << resultTypes <<
" are cast incompatible";
1210 builder.
insert(buildTerminatorOp(builder, loc));
void moveBefore(Operation *existingOp)
Unlink this operation from its current block and insert it right before existingOp which may be in th...
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
static Operation * create(Location location, OperationName name, TypeRange resultTypes, ValueRange operands, ArrayRef< NamedAttribute > attributes, BlockRange successors, unsigned numRegions)
Create a new Operation with the specific fields.
This class contains a list of basic blocks and a link to the parent operation it is attached to...
void removeNodeFromList(Operation *op)
This is a trait method invoked when an operation is removed from a block.
static std::string diag(llvm::Value &v)
MLIRContext * getContext() const
virtual raw_ostream & getStream() const
Return the raw output stream used by this printer.
LogicalResult verifyNSuccessors(Operation *op, unsigned numSuccessors)
LogicalResult verifyCompatibleShape(ArrayRef< int64_t > shape1, ArrayRef< int64_t > shape2)
Returns success if the given two shapes are compatible.
Operation is a basic unit of execution within MLIR.
MutableArrayRef< Region > getRegions()
Returns the regions held by this operation.
LogicalResult verifyZeroOperands(Operation *op)
SmallVector< Block *, 1 > successors
Successors of this operation and their respective operands.
CloneOptions & cloneRegions(bool enable=true)
Configures whether cloning should traverse into any of the regions of the operation.
LogicalResult verifyElementwise(Operation *op)
LogicalResult verifyResultsAreFloatLike(Operation *op)
operand_range getOperands()
Returns an iterator on the underlying Value's.
unsigned getNumRegions()
Returns the number of regions held by this operation.
This class represents a diagnostic that is inflight and set to be reported.
void setOperands(ValueRange operands)
Replace the current operands of this operation with the ones provided in 'operands'.
LogicalResult foldCastInterfaceOp(Operation *op, ArrayRef< Attribute > attrOperands, SmallVectorImpl< OpFoldResult > &foldResults)
Attempt to fold the given cast operation.
LogicalResult verifyResultSizeAttr(Operation *op, StringRef sizeAttrName)
Block represents an ordered list of Operations.
LogicalResult verifyIsInvolution(Operation *op)
LogicalResult verifySameOperandsAndResultShape(Operation *op)
CloneOptions()
Default constructs an option with all flags set to false.
void addNodeToList(Operation *op)
This is a trait method invoked when an operation is added to a block.
LogicalResult verifyIsIsolatedFromAbove(Operation *op)
Check for any values used by operations regions attached to the specified "IsIsolatedFromAbove" opera...
OpFoldResult foldIdempotent(Operation *op)
This class represents a single result from folding an operation.
Value getOperand(unsigned idx)
AttrClass getAttrOfType(StringAttr name)
bool hasElementwiseMappableTraits(Operation *op)
Together, Elementwise, Scalarizable, Vectorizable, and Tensorizable provide an easy way for scalar op...
OpListType & getOperations()
LogicalResult verifyNOperands(Operation *op, unsigned numOperands)
void invalidateOpOrder()
Invalidates the current ordering of operations.
void print(raw_ostream &os, OpPrintingFlags flags=llvm::None)
Print the operation to the given stream.
bool shouldCloneOperands() const
Returns whether operands should be cloned as well.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value...
unsigned getNumOperands()
LogicalResult verifySameOperandsElementType(Operation *op)
bool mightHaveTrait()
Returns true if the operation might have the provided trait.
A block operand represents an operand that holds a reference to a Block, e.g.
void transferNodesFromList(ilist_traits< Operation > &otherList, op_iterator first, op_iterator last)
This is a trait method invoked when an operation is moved from one block to another.
operand_type_range getOperandTypes()
OpFoldResult foldInvolution(Operation *op)
LogicalResult verifyCastInterfaceOp(Operation *op, function_ref< bool(TypeRange, TypeRange)> areCastCompatible)
Attempt to verify the given cast operation.
bool isBeforeInBlock(Operation *other)
Given an operation 'other' that is within the same parent block, return whether the current operation...
DictionaryAttr getDictionary(MLIRContext *context) const
Return a dictionary attribute for the underlying dictionary.
virtual llvm::unique_function< void(Operation *, OpAsmPrinter &printer)> getOperationPrinter(Operation *op) const
Print an operation registered to this dialect.
This class implements the result iterators for the Operation class.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value...
This class provides the API for ops that are known to be terminators.
type_range getTypes() const
unsigned getNumSuccessors()
The OpAsmParser has methods for interacting with the asm parser: parsing things from it...
LogicalResult verifyAtLeastNSuccessors(Operation *op, unsigned numSuccessors)
Block * getBlock()
Returns the operation block that contains this operation.
LogicalResult verifySameOperandsAndResultElementType(Operation *op)
void insertOperands(unsigned index, ValueRange operands)
Insert the given operands into the operand list at the given 'index'.
LogicalResult verifyOperandsAreFloatLike(Operation *op)
CloneOptions & cloneOperands(bool enable=true)
Configures whether operation' operands should be cloned.
LogicalResult verifyResultsAreBoolLike(Operation *op)
void destroy()
Destroys this operation and its subclass data.
void takeBody(Region &other)
Takes body of another region (that region will have no body after this operation completes).
InFlightDiagnostic emitWarning(Location loc)
Utility method to emit a warning message using this location.
LogicalResult verifySameOperandsAndResultType(Operation *op)
void erase()
Remove this operation from its parent block and delete it.
SmallVector< Value, 4 > operands
This class provides an efficient unique identifier for a specific C++ type.
void setSuccessor(Block *block, unsigned index)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
LogicalResult verifyOneOperand(Operation *op)
static ParseResult parse(OpAsmParser &parser, OperationState &result)
Parse the custom form of an operation.
LogicalResult verifyAtLeastNResults(Operation *op, unsigned numOperands)
LogicalResult verifySameTypeOperands(Operation *op)
void map(Block *from, Block *to)
Inserts a new mapping for 'from' to 'to'.
MLIRContext * getContext()
Return the context this operation is associated with.
LogicalResult verifyNRegions(Operation *op, unsigned numRegions)
bool hasTrait() const
Returns true if the operation was registered with a particular trait, e.g.
MutableArrayRef< OpOperand > getOpOperands()
static CloneOptions all()
Returns an instance with all flags set to true.
StringRef getStringRef() const
Return the name of this operation. This always succeeds.
bool shouldCloneRegions() const
Returns whether regions of the operation should be cloned as well.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
This class represents an efficient way to signal success or failure.
LogicalResult verifyOneResult(Operation *op)
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
This trait tags Elementwise operatons that can be systematically tensorized.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.
void ensureRegionTerminator(Region ®ion, OpBuilder &builder, Location loc, function_ref< Operation *(OpBuilder &, Location)> buildTerminatorOp)
Insert an operation, generated by buildTerminatorOp, at the end of the region's only block if it does...
InFlightDiagnostic emitRemark(const Twine &message={})
Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening...
Operation * insert(Operation *op)
Insert the given operation at the current insertion point and return it.
static Type getTensorOrVectorElementType(Type type)
If this is a vector type, or a tensor type, return the scalar element type that it is built around...
Operation * clone(BlockAndValueMapping &mapper, CloneOptions options=CloneOptions::all())
Create a deep copy of this operation, remapping any operands that use values outside of the operation...
void setOperands(Operation *owner, ValueRange values)
Replace the operands contained in the storage with the ones provided in 'values'. ...
LogicalResult verifyAtLeastNRegions(Operation *op, unsigned numRegions)
Diagnostic & attachNote(Optional< Location > noteLoc=llvm::None)
Attaches a note to this diagnostic.
LogicalResult verifyZeroResults(Operation *op)
simple_ilist< Operation >::iterator op_iterator
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
LogicalResult verifyValueSizeAttr(Operation *op, StringRef attrName, StringRef valueGroupName, size_t expectedCount)
bool isSignlessIntOrIndex() const
Return true if this is a signless integer or index type.
virtual void printGenericOp(Operation *op, bool printOpName=true)=0
Print the entire operation with the default generic assembly form.
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
This class provides an abstraction over the various different ranges of value types.
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
virtual Optional< ParseOpHook > getParseOperationHook(StringRef opName) const
Return the hook to parse an operation registered to this dialect, if any.
Location getLoc()
The source location the operation was defined or derived from.
This represents an operation in an abstracted form, suitable for use with the builder APIs...
MutableArrayRef< BlockOperand > getBlockOperands()
LogicalResult verifyOneSuccessor(Operation *op)
Diagnostic & append(Arg1 &&arg1, Arg2 &&arg2, Args &&... args)
Append arguments to the diagnostic.
void dropAllDefinedValueUses()
Drop uses of all values defined by this operation or its nested regions.
static LogicalResult verifyTerminatorSuccessors(Operation *op)
InFlightDiagnostic emitWarning(const Twine &message={})
Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening...
void cloneInto(Region *dest, BlockAndValueMapping &mapper)
Clone the internal blocks from this region into dest.
Tensor types represent multi-dimensional arrays, and have two variants: RankedTensorType and Unranked...
InFlightDiagnostic emitRemark(const Twine &message={})
Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening...
void dropAllDefinedValueUses()
This drops all uses of values defined in this block or in the blocks of nested regions wherever the u...
This trait tags element-wise ops on vectors or tensors.
void dropAllUses()
Drop all uses of results of this operation.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
bool use_empty()
Returns true if this operation has no uses.
bool isOpOrderValid()
Returns true if the ordering of the child operations is valid, false otherwise.
LogicalResult verifySameOperandsShape(Operation *op)
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
static OpListType Block::* getSublistAccess(Operation *)
Returns pointer to member of operation list.
void remove()
Remove the operation from its parent block, but don't delete it.
InFlightDiagnostic emitWarning(const Twine &message={})
Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening...
LogicalResult verifyAtLeastNOperands(Operation *op, unsigned numOperands)
static llvm::ManagedStatic< PassManagerOptions > options
LogicalResult verifyResultsAreSignlessIntegerLike(Operation *op)
MLIRContext * getContext() const
Get the context held by this operation state.
void dropAllReferences()
This drops all operand uses from this operation, which is an essential step in breaking cyclic depend...
void moveAfter(Operation *existingOp)
Unlink this operation from its current block and insert it right after existingOp which may be in the...
SuccessorRange getSuccessors()
RAII guard to reset the insertion point of the builder when destroyed.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
Set of flags used to control the behavior of the various IR print methods (e.g.
MLIRContext * getContext() const
Return the context this location is uniqued in.
Class encompassing various options related to cloning an operation.
This class is a general helper class for creating context-global objects like types, attributes, and affine expressions.
Type getType() const
Return the type of this value.
TypeID getTypeID()
Return a unique identifier for the concrete type.
This class provides the API for ops that are known to be isolated from above.
LogicalResult verifyCompatibleShapes(TypeRange types1, TypeRange types2)
Returns success if the given two arrays have the same number of elements and each pair wise entries h...
This class provides the implementation for an operation result whose index cannot be represented "inl...
Dialect * getDialect()
Return the dialect this operation is associated with, or nullptr if the associated dialect is not loa...
void recomputeOpOrder()
Recomputes the ordering of child operations within the block.
This trait tags Elementwise operatons that can be systematically scalarized.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Block * lookupOrDefault(Block *from) const
Lookup a mapped value within the map.
This class provides the API for ops that are known to have no SSA operand.
LogicalResult verifyNoRegionArguments(Operation *op)
This class represents an operand of an operation.
This class provides an abstraction over the different types of ranges over Blocks.
This class provides an abstraction over the different types of ranges over Regions.
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers...
LogicalResult verifyOperandsAreSignlessIntegerLike(Operation *op)
This class implements the operand iterators for the Operation class.
void setInsertionPointToEnd(Block *block)
Sets the insertion point to the end of the specified block.
Dialect * getDialect() const
Return the dialect this operation is registered to if the dialect is loaded in the context...
Region * getParentRegion()
Returns the region to which the instruction belongs.
LogicalResult verifyIsIdempotent(Operation *op)
LogicalResult fold(ArrayRef< Attribute > operands, SmallVectorImpl< OpFoldResult > &results)
Attempt to fold this operation with the specified constant operand values.
unsigned getNumResults()
Return the number of results held by this operation.
LogicalResult verifyZeroRegions(Operation *op)
InFlightDiagnostic emitRemark(Location loc)
Utility method to emit a remark message using this location.
SmallVector< std::unique_ptr< Region >, 1 > regions
Regions that the op will hold.
Block * createBlock(Region *parent, Region::iterator insertPt={}, TypeRange argTypes=llvm::None, ArrayRef< Location > locs=llvm::None)
Add new block with 'argTypes' arguments and set the insertion point to the end of it...
LogicalResult verifyZeroSuccessors(Operation *op)
LogicalResult verifyNResults(Operation *op, unsigned numOperands)
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers...
Optional< RegisteredOperationName > getRegisteredInfo()
If this operation has a registered operation description, return it.
This trait tags Elementwise operatons that can be systematically vectorized.
OperationName getName()
The name of an operation is the key identifier for it.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
This class represents success/failure for parsing-like operations that find it important to chain tog...
user_range getUsers()
Returns a range of all users.
void replaceUsesOfWith(Value from, Value to)
Replace any uses of 'from' with 'to' within this operation.
result_range getResults()
This class helps build Operations.
This class provides an abstraction over the different types of ranges over Values.
static void deleteNode(Operation *op)
Diagnostic & appendOp(Operation &val, const OpPrintingFlags &flags)
Append an operation with the given printing flags.
result_type_range getResultTypes()
bool isProperAncestor(Operation *other)
Return true if this operation is a proper ancestor of the other operation.
This class provides the implementation for an operation result whose index can be represented "inline...
LogicalResult verifyOperandSizeAttr(Operation *op, StringRef sizeAttrName)
Region & getRegion(unsigned index)
Returns the region held by this operation at position 'index'.
LogicalResult verifyIsTerminator(Operation *op)
LogicalResult verifyOneRegion(Operation *op)
Operation * cloneWithoutRegions()
Create a partial copy of this operation without traversing into attached regions. ...
An attribute that represents a reference to a dense integer vector or tensor object.
type_range getTypes() const
SmallVector< Type, 4 > types
Types of the results of this operation.
static void printOpName(Operation *op, OpAsmPrinter &p, StringRef defaultDialect)
Print an operation name, eliding the dialect prefix if necessary.
This class handles the management of operation operands.