My Project
Operation.h
Go to the documentation of this file.
1 //===- Operation.h - MLIR Operation Class -----------------------*- C++ -*-===//
2 //
3 // Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the Operation class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef MLIR_IR_OPERATION_H
14 #define MLIR_IR_OPERATION_H
15 
16 #include "mlir/IR/Block.h"
17 #include "mlir/IR/Diagnostics.h"
19 #include "mlir/IR/Region.h"
20 #include "llvm/ADT/Twine.h"
21 
22 namespace mlir {
27 class Operation final
28  : public IRMultiObjectWithUseList<OpOperand>,
29  public llvm::ilist_node_with_parent<Operation, Block>,
30  private llvm::TrailingObjects<Operation, detail::TrailingOpResult,
31  BlockOperand, Region,
32  detail::OperandStorage> {
33 public:
35  static Operation *create(Location location, OperationName name,
36  ArrayRef<Type> resultTypes, ArrayRef<Value> operands,
37  ArrayRef<NamedAttribute> attributes,
38  ArrayRef<Block *> successors, unsigned numRegions,
39  bool resizableOperandList);
40 
43  static Operation *create(Location location, OperationName name,
44  ArrayRef<Type> resultTypes, ArrayRef<Value> operands,
45  NamedAttributeList attributes,
46  ArrayRef<Block *> successors, unsigned numRegions,
47  bool resizableOperandList);
48 
50  static Operation *create(const OperationState &state);
51 
53  static Operation *create(Location location, OperationName name,
54  ArrayRef<Type> resultTypes, ArrayRef<Value> operands,
55  NamedAttributeList attributes,
56  ArrayRef<Block *> successors = {},
57  RegionRange regions = {},
58  bool resizableOperandList = false);
59 
61  OperationName getName() { return name; }
62 
66  return getName().getAbstractOperation();
67  }
68 
71  bool isRegistered() { return getAbstractOperation(); }
72 
74  void erase();
75 
82  Operation *clone();
83 
90 
95 
97  Block *getBlock() { return block; }
98 
101 
104  Dialect *getDialect();
105 
107  Location getLoc() { return location; }
108 
110  void setLoc(Location loc) { location = loc; }
111 
115 
119 
121  template <typename OpTy> OpTy getParentOfType() {
122  auto *op = this;
123  while ((op = op->getParentOp()))
124  if (auto parentOp = dyn_cast<OpTy>(op))
125  return parentOp;
126  return OpTy();
127  }
128 
131  bool isProperAncestor(Operation *other);
132 
136  bool isAncestor(Operation *other) {
137  return this == other || isProperAncestor(other);
138  }
139 
141  void replaceUsesOfWith(Value from, Value to);
142 
144  template <typename ValuesT,
145  typename = decltype(std::declval<ValuesT>().begin())>
146  void replaceAllUsesWith(ValuesT &&values) {
147  assert(std::distance(values.begin(), values.end()) == getNumResults() &&
148  "expected 'values' to correspond 1-1 with the number of results");
149 
150  auto valueIt = values.begin();
151  for (unsigned i = 0, e = getNumResults(); i != e; ++i)
152  getResult(i)->replaceAllUsesWith(*(valueIt++));
153  }
154 
157  assert(getNumResults() == op->getNumResults());
158  for (unsigned i = 0, e = getNumResults(); i != e; ++i)
160  }
161 
163  void destroy();
164 
168  void dropAllReferences();
169 
172 
176  void moveBefore(Operation *existingOp);
177 
180  void moveBefore(Block *block, llvm::iplist<Operation>::iterator iterator);
181 
187  bool isBeforeInBlock(Operation *other);
188 
189  void print(raw_ostream &os, OpPrintingFlags flags = llvm::None);
190  void dump();
191 
192  //===--------------------------------------------------------------------===//
193  // Operands
194  //===--------------------------------------------------------------------===//
195 
198  bool hasResizableOperandsList() { return getOperandStorage().isResizable(); }
199 
203  void setOperands(ValueRange operands);
204 
205  unsigned getNumOperands() { return getOperandStorage().size(); }
206 
207  Value getOperand(unsigned idx) { return getOpOperand(idx).get(); }
208  void setOperand(unsigned idx, Value value) {
209  return getOpOperand(idx).set(value);
210  }
211 
212  // Support operand iteration.
214  using operand_iterator = operand_range::iterator;
215 
218 
221 
223  void eraseOperand(unsigned idx) { getOperandStorage().eraseOperand(idx); }
224 
226  return getOperandStorage().getOperands();
227  }
228 
229  OpOperand &getOpOperand(unsigned idx) { return getOpOperands()[idx]; }
230 
231  // Support operand type iteration.
237 
238  //===--------------------------------------------------------------------===//
239  // Results
240  //===--------------------------------------------------------------------===//
241 
243  unsigned getNumResults();
244 
246  OpResult getResult(unsigned idx) { return OpResult(this, idx); }
247 
250  using result_iterator = result_range::iterator;
251 
255 
257  OpResult getOpResult(unsigned idx) { return getResult(idx); }
258 
265 
266  //===--------------------------------------------------------------------===//
267  // Attributes
268  //===--------------------------------------------------------------------===//
269 
270  // Operations may optionally carry a list of attributes that associate
271  // constants to names. Attributes may be dynamically added and removed over
272  // the lifetime of an operation.
273 
276 
278  NamedAttributeList &getAttrList() { return attrs; }
279 
283  void setAttrs(NamedAttributeList newAttrs) { attrs = newAttrs; }
284 
286  Attribute getAttr(Identifier name) { return attrs.get(name); }
287  Attribute getAttr(StringRef name) { return attrs.get(name); }
288 
289  template <typename AttrClass> AttrClass getAttrOfType(Identifier name) {
290  return getAttr(name).dyn_cast_or_null<AttrClass>();
291  }
292 
293  template <typename AttrClass> AttrClass getAttrOfType(StringRef name) {
294  return getAttr(name).dyn_cast_or_null<AttrClass>();
295  }
296 
299  void setAttr(Identifier name, Attribute value) { attrs.set(name, value); }
300  void setAttr(StringRef name, Attribute value) {
301  setAttr(Identifier::get(name, getContext()), value);
302  }
303 
307  return attrs.remove(name);
308  }
309 
312  : public llvm::filter_iterator<ArrayRef<NamedAttribute>::iterator,
313  bool (*)(NamedAttribute)> {
314  static bool filter(NamedAttribute attr) {
315  // Dialect attributes are prefixed by the dialect name, like operations.
316  return attr.first.strref().count('.');
317  }
318 
321  : llvm::filter_iterator<ArrayRef<NamedAttribute>::iterator,
322  bool (*)(NamedAttribute)>(it, end, &filter) {}
323 
324  // Allow access to the constructor.
325  friend Operation;
326  };
328 
331  auto attrs = getAttrs();
332  return {dialect_attr_iterator(attrs.begin(), attrs.end()),
333  dialect_attr_iterator(attrs.end(), attrs.end())};
334  }
336  auto attrs = getAttrs();
337  return dialect_attr_iterator(attrs.begin(), attrs.end());
338  }
340  auto attrs = getAttrs();
341  return dialect_attr_iterator(attrs.end(), attrs.end());
342  }
343 
345  template <typename DialectAttrT>
346  void setDialectAttrs(DialectAttrT &&dialectAttrs) {
348  attrs.assign(std::begin(dialectAttrs), std::end(dialectAttrs));
349  for (auto attr : getAttrs())
350  if (!attr.first.strref().count('.'))
351  attrs.push_back(attr);
352  setAttrs(llvm::makeArrayRef(attrs));
353  }
354 
355  //===--------------------------------------------------------------------===//
356  // Blocks
357  //===--------------------------------------------------------------------===//
358 
360  unsigned getNumRegions() { return numRegions; }
361 
364  auto *regions = getTrailingObjects<Region>();
365  return {regions, numRegions};
366  }
367 
369  Region &getRegion(unsigned index) {
370  assert(index < numRegions && "invalid region index");
371  return getRegions()[index];
372  }
373 
374  //===--------------------------------------------------------------------===//
375  // Terminators
376  //===--------------------------------------------------------------------===//
377 
379  return {getTrailingObjects<BlockOperand>(), numSuccs};
380  }
381 
382  // Successor iteration.
383  using succ_iterator = SuccessorRange::iterator;
387 
390 
391  operand_range getSuccessorOperands(unsigned index);
392 
393  Value getSuccessorOperand(unsigned succIndex, unsigned opIndex) {
394  assert(!isKnownNonTerminator() && "only terminators may have successors");
395  assert(opIndex < getNumSuccessorOperands(succIndex));
396  return getOperand(getSuccessorOperandIndex(succIndex) + opIndex);
397  }
398 
399  bool hasSuccessors() { return numSuccs != 0; }
400  unsigned getNumSuccessors() { return numSuccs; }
401  unsigned getNumSuccessorOperands(unsigned index) {
402  assert(!isKnownNonTerminator() && "only terminators may have successors");
403  assert(index < getNumSuccessors());
404  return getBlockOperands()[index].numSuccessorOperands;
405  }
406 
407  Block *getSuccessor(unsigned index) {
408  assert(index < getNumSuccessors());
409  return getBlockOperands()[index].get();
410  }
411  void setSuccessor(Block *block, unsigned index);
412 
415  void eraseSuccessorOperand(unsigned succIndex, unsigned opIndex) {
416  assert(succIndex < getNumSuccessors());
417  assert(opIndex < getNumSuccessorOperands(succIndex));
418  getOperandStorage().eraseOperand(getSuccessorOperandIndex(succIndex) +
419  opIndex);
420  --getBlockOperands()[succIndex].numSuccessorOperands;
421  }
422 
425  unsigned getSuccessorOperandIndex(unsigned index);
426 
433  decomposeSuccessorOperandIndex(unsigned operandIndex);
434 
438  auto decomposed = decomposeSuccessorOperandIndex(operandIndex);
439  if (!decomposed.hasValue())
440  return None;
441  return getSuccessor(decomposed->first)->getArgument(decomposed->second);
442  }
443 
444  //===--------------------------------------------------------------------===//
445  // Accessors for various properties of operations
446  //===--------------------------------------------------------------------===//
447 
449  bool isCommutative() {
450  if (auto *absOp = getAbstractOperation())
451  return absOp->hasProperty(OperationProperty::Commutative);
452  return false;
453  }
454 
457  if (auto *absOp = getAbstractOperation())
458  return absOp->hasProperty(OperationProperty::NoSideEffect);
459  return false;
460  }
461 
465  enum class TerminatorStatus { Terminator, NonTerminator, Unknown };
466 
469  if (auto *absOp = getAbstractOperation()) {
470  return absOp->hasProperty(OperationProperty::Terminator)
473  }
475  }
476 
480  }
481 
485  }
486 
491  if (auto *absOp = getAbstractOperation())
492  return absOp->hasProperty(OperationProperty::IsolatedFromAbove);
493  return false;
494  }
495 
502 
505  template <template <typename T> class Trait> bool hasTrait() {
506  auto *absOp = getAbstractOperation();
507  return absOp ? absOp->hasTrait<Trait>() : false;
508  }
509 
510  //===--------------------------------------------------------------------===//
511  // Operation Walkers
512  //===--------------------------------------------------------------------===//
513 
529  template <typename FnT, typename RetT = detail::walkResultType<FnT>>
530  RetT walk(FnT &&callback) {
531  return detail::walkOperations(this, std::forward<FnT>(callback));
532  }
533 
534  //===--------------------------------------------------------------------===//
535  // Other
536  //===--------------------------------------------------------------------===//
537 
540  InFlightDiagnostic emitOpError(const Twine &message = {});
541 
544  InFlightDiagnostic emitError(const Twine &message = {});
545 
548  InFlightDiagnostic emitWarning(const Twine &message = {});
549 
552  InFlightDiagnostic emitRemark(const Twine &message = {});
553 
554 private:
555  //===--------------------------------------------------------------------===//
556  // Ordering
557  //===--------------------------------------------------------------------===//
558 
561  static constexpr unsigned kInvalidOrderIdx = -1;
562 
565  static constexpr unsigned kOrderStride = 5;
566 
569  void updateOrderIfNecessary();
570 
572  bool hasValidOrder() { return orderIndex != kInvalidOrderIdx; }
573 
574 private:
575  Operation(Location location, OperationName name, ArrayRef<Type> resultTypes,
576  unsigned numSuccessors, unsigned numRegions,
577  const NamedAttributeList &attributes);
578 
579  // Operations are deleted through the destroy() member because they are
580  // allocated with malloc.
581  ~Operation();
582 
584  detail::OperandStorage &getOperandStorage() {
585  return *getTrailingObjects<detail::OperandStorage>();
586  }
587 
592  detail::TrailingOpResult *getTrailingResult(unsigned trailingResultNumber) {
593  return getTrailingObjects<detail::TrailingOpResult>() +
594  trailingResultNumber;
595  }
596 
602  Block *getParent() const { return block; }
603 
605  Block *block = nullptr;
606 
609  Location location;
610 
613  mutable unsigned orderIndex = 0;
614 
615  const unsigned numSuccs;
616  const unsigned numRegions : 31;
617 
625  bool hasSingleResult : 1;
626  Type resultType;
627 
629  OperationName name;
630 
632  NamedAttributeList attrs;
633 
634  // allow ilist_traits access to 'block' field.
635  friend struct llvm::ilist_traits<Operation>;
636 
637  // allow block to access the 'orderIndex' field.
638  friend class Block;
639 
640  // allow value to access the 'getTrailingResult' method.
641  friend class Value;
642 
643  // allow ilist_node_with_parent to access the 'getParent' method.
644  friend class llvm::ilist_node_with_parent<Operation, Block>;
645 
646  // This stuff is used by the TrailingObjects template.
647  friend llvm::TrailingObjects<Operation, detail::TrailingOpResult,
649  size_t numTrailingObjects(OverloadToken<detail::TrailingOpResult>) const {
650  return OpResult::getNumTrailing(
651  const_cast<Operation *>(this)->getNumResults());
652  }
653  size_t numTrailingObjects(OverloadToken<BlockOperand>) const {
654  return numSuccs;
655  }
656  size_t numTrailingObjects(OverloadToken<Region>) const { return numRegions; }
657 };
658 
659 inline raw_ostream &operator<<(raw_ostream &os, Operation &op) {
660  op.print(os);
661  return os;
662 }
663 
664 } // end namespace mlir
665 
666 namespace llvm {
668 template <typename T> struct isa_impl<T, ::mlir::Operation> {
669  static inline bool doit(const ::mlir::Operation &op) {
670  return T::classof(const_cast<::mlir::Operation *>(&op));
671  }
672 };
673 
676 template <typename T> struct cast_retty_impl<T, ::mlir::Operation *> {
677  using ret_type = T;
678 };
679 template <typename T> struct cast_retty_impl<T, ::mlir::Operation> {
680  using ret_type = T;
681 };
682 template <class T>
683 struct cast_convert_val<T, ::mlir::Operation, ::mlir::Operation> {
684  static T doit(::mlir::Operation &val) { return T(&val); }
685 };
686 template <class T>
687 struct cast_convert_val<T, ::mlir::Operation *, ::mlir::Operation *> {
688  static T doit(::mlir::Operation *val) { return T(val); }
689 };
690 } // end namespace llvm
691 
692 #endif // MLIR_IR_OPERATION_H
NamedAttributeList::RemoveResult removeAttr(Identifier name)
Definition: Operation.h:306
operand_range::iterator operand_iterator
Definition: Operation.h:214
void moveBefore(Operation *existingOp)
Definition: Operation.cpp:511
AttrClass getAttrOfType(Identifier name)
Definition: Operation.h:289
Definition: InferTypeOpInterface.cpp:20
void setAttr(Identifier name, Attribute value)
Definition: Operation.h:299
TerminatorStatus getTerminatorStatus()
Returns the status of whether this operation is a terminator or not.
Definition: Operation.h:468
Definition: Region.h:23
Attribute getAttr(Identifier name)
Return the specified attribute if present, null otherwise.
Definition: Operation.h:286
bool hasSuccessors()
Definition: Operation.h:399
void eraseOperand(unsigned index)
Erase an operand held by the storage.
Definition: OperationSupport.cpp:107
U dyn_cast_or_null() const
Definition: Attributes.h:1350
Definition: PassRegistry.cpp:413
Definition: Operation.h:27
operand_range getSuccessorOperands(unsigned index)
Definition: Operation.cpp:597
MutableArrayRef< Region > getRegions()
Returns the regions held by this operation.
Definition: Operation.h:363
bool isAncestor(Operation *other)
Definition: Operation.h:136
This is a value defined by a result of an operation.
Definition: Value.h:287
operand_range getOperands()
Returns an iterator on the underlying Value&#39;s (Value ).
Definition: Operation.h:220
unsigned getNumRegions()
Returns the number of regions held by this operation.
Definition: Operation.h:360
Definition: Diagnostics.h:320
void setOperands(ValueRange operands)
Definition: Operation.cpp:290
Block represents an ordered list of Operations.
Definition: Block.h:21
TerminatorStatus
Definition: Operation.h:465
void replaceAllUsesWith(Value newValue) const
Definition: Value.cpp:111
void set(Value value)
Set the operand to the given value.
Definition: Value.cpp:212
ArrayRef< NamedAttribute > getAttrs()
Return all of the attributes on this operation.
Definition: Operation.h:275
Value getOperand(unsigned idx)
Definition: Operation.h:207
Dialect * getDialect()
Definition: Operation.cpp:252
unsigned getNumOperands()
Definition: Operation.h:205
static Identifier get(StringRef str, MLIRContext *context)
Return an identifier for the specified string.
Definition: MLIRContext.cpp:426
Definition: Identifier.h:26
Terminator operations can have Block operands to represent successors.
Definition: UseDefLists.h:288
operand_type_range getOperandTypes()
Definition: Operation.h:236
bool isBeforeInBlock(Operation *other)
Definition: Operation.cpp:348
This class implements the result iterators for the Operation class.
Definition: OperationSupport.h:588
bool isResizable() const
Returns if this storage is resizable.
Definition: OperationSupport.h:420
unsigned getNumSuccessors()
Definition: Operation.h:400
Definition: LLVM.h:40
bool isRegistered()
Definition: Operation.h:71
Block * getBlock()
Returns the operation block that contains this operation.
Definition: Operation.h:97
MLIRContext * getContext()
Return the context this operation is associated with.
Definition: Operation.cpp:248
void destroy()
Destroys this operation and its subclass data.
Definition: Operation.cpp:242
BlockArgument getArgument(unsigned i)
Definition: Block.h:96
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type &#39;OpTy&#39;.
Definition: Operation.h:121
Definition: LLVM.h:34
void replaceAllUsesWith(Operation *op)
Replace all uses of results of this operation with results of &#39;op&#39;.
Definition: Operation.h:156
void erase()
Remove this operation from its parent block and delete it.
Definition: Operation.cpp:501
void setSuccessor(Block *block, unsigned index)
Definition: Operation.cpp:554
Definition: Location.h:52
std::pair< Identifier, Attribute > NamedAttribute
Definition: Attributes.h:264
operand_range getNonSuccessorOperands()
Return the operands of this operation that are not successor arguments.
Definition: Operation.cpp:559
unsigned getNumResults()
Return the number of results held by this operation.
Definition: Operation.cpp:548
MutableArrayRef< OpOperand > getOpOperands()
Definition: Operation.h:225
AttrClass getAttrOfType(StringRef name)
Definition: Operation.h:293
RemoveResult remove(Identifier name)
Definition: Attributes.cpp:1082
This class implements iteration on the types of a given range of values.
Definition: OperationSupport.h:540
bool hasNoSideEffect()
Returns whether the operation has side-effects.
Definition: Operation.h:456
Definition: LogicalResult.h:18
Definition: LLVM.h:37
succ_iterator successor_end()
Definition: Operation.h:385
Operation * clone()
Definition: Operation.cpp:702
Block * getSuccessor(unsigned index)
Definition: Operation.h:407
bool hasResizableOperandsList()
Definition: Operation.h:198
dialect_attr_iterator dialect_attr_begin()
Definition: Operation.h:335
SuccessorRange::iterator succ_iterator
Definition: Operation.h:383
static T doit(::mlir::Operation &val)
Definition: Operation.h:684
void setAttrs(NamedAttributeList newAttrs)
Definition: Operation.h:283
Region * getParentRegion()
Definition: Operation.cpp:261
Definition: Attributes.h:53
dialect_attr_iterator dialect_attr_end()
Definition: Operation.h:339
iterator_range< type_iterator > getTypes() const
Definition: OperationSupport.h:598
bool hasTrait()
Definition: Operation.h:505
T ret_type
Definition: Operation.h:680
Definition: LLVM.h:38
Attribute get(StringRef name) const
Return the specified attribute if present, null otherwise.
Definition: Attributes.cpp:1051
Definition: Dialect.h:39
OpResult getResult(unsigned idx)
Get the &#39;idx&#39;th result of this operation.
Definition: Operation.h:246
succ_iterator successor_begin()
Definition: Operation.h:384
Definition: OperationSupport.h:83
iterator begin() const
Definition: STLExtras.h:228
void walkOperations(Operation *op, function_ref< void(Operation *op)> callback)
Walk all of the operations nested under and including the given operation.
Definition: Visitors.cpp:15
This class provides the implementation for a trailing operation result.
Definition: OperationSupport.h:461
Location getLoc()
The source location the operation was defined or derived from.
Definition: Operation.h:107
Definition: OperationSupport.h:261
MutableArrayRef< BlockOperand > getBlockOperands()
Definition: Operation.h:378
unsigned size() const
Return the number of operands held in the storage.
Definition: OperationSupport.h:411
Definition: Attributes.h:1374
result_type_iterator result_type_end()
Definition: Operation.h:263
void dropAllDefinedValueUses()
Drop uses of all values defined by this operation or its nested regions.
Definition: Operation.cpp:539
InFlightDiagnostic emitWarning(const Twine &message={})
Definition: Operation.cpp:320
operand_type_iterator operand_type_begin()
Definition: Operation.h:234
ArrayRef< NamedAttribute > getAttrs() const
Return all of the attributes on this operation.
Definition: Attributes.cpp:1037
InFlightDiagnostic emitRemark(const Twine &message={})
Definition: Operation.cpp:329
bool isKnownNonTerminator()
Returns if the operation is known to not be a terminator.
Definition: Operation.h:483
result_range getOpResults()
Definition: Operation.h:256
void setOperand(unsigned idx, Value value)
Definition: Operation.h:208
This class implements the successor iterators for Block.
Definition: BlockSupport.h:56
Definition: Types.h:84
void replaceAllUsesWith(ValuesT &&values)
Replace all uses of results of this operation with the provided &#39;values&#39;.
Definition: Operation.h:146
bool isCommutative()
Returns whether the operation is commutative.
Definition: Operation.h:449
ValueTypeIterator< iterator > type_iterator
Returns the types of the values within this range.
Definition: OperationSupport.h:567
void print(raw_ostream &os, OpPrintingFlags flags=llvm::None)
Definition: AsmPrinter.cpp:2122
Definition: Value.h:38
Definition: BlockAndValueMapping.h:26
operand_type_iterator operand_type_end()
Definition: Operation.h:235
static Operation * create(Location location, OperationName name, ArrayRef< Type > resultTypes, ArrayRef< Value > operands, ArrayRef< NamedAttribute > attributes, ArrayRef< Block *> successors, unsigned numRegions, bool resizableOperandList)
Create a new Operation with the specific fields.
Definition: Operation.cpp:71
void eraseOperand(unsigned idx)
Erase the operand at position idx.
Definition: Operation.h:223
Definition: LLVM.h:35
void dropAllReferences()
Definition: Operation.cpp:526
operand_iterator operand_begin()
Definition: Operation.h:216
Optional< std::pair< unsigned, unsigned > > decomposeSuccessorOperandIndex(unsigned operandIndex)
Definition: Operation.cpp:583
SuccessorRange getSuccessors()
Definition: Operation.h:386
Definition: OperationSupport.h:474
result_iterator result_end()
Definition: Operation.h:253
void setAttr(StringRef name, Attribute value)
Definition: Operation.h:300
iterator end() const
Definition: STLExtras.h:229
Definition: LLVM.h:50
result_type_iterator result_type_begin()
Definition: Operation.h:262
void setLoc(Location loc)
Set the source location the operation was defined or derived from.
Definition: Operation.h:110
A utility iterator that filters out non-dialect attributes.
Definition: Operation.h:311
OperandRange operand_range
Definition: Operation.h:213
ValueTypeIterator< iterator > type_iterator
Returns the types of the values within this range.
Definition: OperationSupport.h:597
OpOperand & getOpOperand(unsigned idx)
Definition: Operation.h:229
Definition: UseDefLists.h:109
OpResult getOpResult(unsigned idx)
Definition: Operation.h:257
Definition: MLIRContext.h:34
Operation * getParentOp()
Definition: Operation.cpp:265
A reference to a value, suitable for use as an operand of an operation.
Definition: UseDefLists.h:330
Definition: Region.h:159
unsigned getSuccessorOperandIndex(unsigned index)
Definition: Operation.cpp:566
void setDialectAttrs(DialectAttrT &&dialectAttrs)
Set the dialect attributes for this operation, and preserve all dependent.
Definition: Operation.h:346
Value get() const
Return the current value being used by this operand.
Definition: Value.cpp:207
This class implements the operand iterators for the Operation class.
Definition: OperationSupport.h:559
Optional< BlockArgument > getSuccessorBlockArgument(unsigned operandIndex)
Definition: Operation.h:437
result_range::iterator result_iterator
Definition: Operation.h:250
bool isKnownTerminator()
Returns if the operation is known to be a terminator.
Definition: Operation.h:478
Attribute getAttr(StringRef name)
Definition: Operation.h:287
LogicalResult fold(ArrayRef< Attribute > operands, SmallVectorImpl< OpFoldResult > &results)
Attempt to fold this operation using the Op&#39;s registered foldHook.
Definition: Operation.cpp:603
Definition: StandardTypes.h:63
RemoveResult
Definition: Attributes.h:1405
Value getSuccessorOperand(unsigned succIndex, unsigned opIndex)
Definition: Operation.h:393
dialect_attr_range getDialectAttrs()
Return a range corresponding to the dialect attributes for this operation.
Definition: Operation.h:330
ResultRange result_range
Support result iteration.
Definition: Operation.h:249
MutableArrayRef< OpOperand > getOperands()
Get the operation operands held by the storage.
Definition: OperationSupport.h:406
unsigned getNumSuccessorOperands(unsigned index)
Definition: Operation.h:401
static bool doit(const ::mlir::Operation &op)
Definition: Operation.h:669
raw_ostream & operator<<(raw_ostream &os, SubViewOp::Range &range)
Definition: Ops.cpp:2759
bool isKnownIsolatedFromAbove()
Definition: Operation.h:490
operand_iterator operand_end()
Definition: Operation.h:217
InFlightDiagnostic emitOpError(const Twine &message={})
Definition: Operation.cpp:625
OperationName getName()
The name of an operation is the key identifier for it.
Definition: Operation.h:61
const AbstractOperation * getAbstractOperation() const
Definition: Operation.cpp:58
void dump()
Definition: AsmPrinter.cpp:2146
InFlightDiagnostic emitError(const Twine &message={})
Definition: Operation.cpp:300
void set(Identifier name, Attribute value)
Definition: Attributes.cpp:1062
void replaceUsesOfWith(Value from, Value to)
Replace any uses of &#39;from&#39; with &#39;to&#39; within this operation.
Definition: Operation.cpp:279
Definition: OperationSupport.h:203
result_range getResults()
Definition: Operation.h:254
Definition: OperationSupport.h:640
result_type_range getResultTypes()
Definition: Operation.h:264
static T doit(::mlir::Operation *val)
Definition: Operation.h:688
iterator_range< type_iterator > getTypes() const
Definition: OperationSupport.h:568
bool isProperAncestor(Operation *other)
Definition: Operation.cpp:271
Region & getRegion(unsigned index)
Returns the region held by this operation at position &#39;index&#39;.
Definition: Operation.h:369
result_iterator result_begin()
Definition: Operation.h:252
RetT walk(FnT &&callback)
Definition: Operation.h:530
NamedAttributeList & getAttrList()
Return the internal attribute list on this operation.
Definition: Operation.h:278
Operation * cloneWithoutRegions()
Definition: Operation.cpp:682
void eraseSuccessorOperand(unsigned succIndex, unsigned opIndex)
Definition: Operation.h:415
const AbstractOperation * getAbstractOperation()
Definition: Operation.h:65
Definition: OperationSupport.h:375