MLIR: include/mlir/IR/Operation.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13 #ifndef MLIR_IR_OPERATION_H

14 #define MLIR_IR_OPERATION_H

15

21 #include "llvm/ADT/Twine.h"

22 #include

23

24 namespace mlir {

25 namespace detail {

26

27

29 }

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

85 : public llvm::ilist_node_with_parent<Operation, Block>,

86 private llvm::TrailingObjects<Operation, detail::OperandStorage,

87 detail::OpProperties, BlockOperand, Region,

88 OpOperand> {

89 public:

90

91

92

97 unsigned numRegions);

98

99

100

103 DictionaryAttr attributes,

105 unsigned numRegions);

106

107

109

110

117

118

120

121

122

125 }

126

127

128

130

131

133

134

136

137

138

139

140

141

142

144 public:

145

146

148

149

150

152

153

154

156

157

158

159

160

161

162

164

165

167

168

169

171

172

174

175 private:

176

177 bool cloneRegionsFlag : 1;

178

179 bool cloneOperandsFlag : 1;

180 };

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

199

200

201

202

203

204

206

207

208

209

211

212

214

215

217

218

219

221

222

224

225

227

228

229

231

232

233

235

236

237 template

239 auto *op = this;

240 while ((op = op->getParentOp()))

241 if (auto parentOp = dyn_cast(op))

242 return parentOp;

243 return OpTy();

244 }

245

246

247 template <template class Trait>

252 return op;

253 return nullptr;

254 }

255

256

257

259

260

261

262

265 }

266

267

269

270

271 template

274 }

275

276

277

278 template

282 shouldReplace);

283 }

284

285

287

288

289

290

292

293

295

296

297

298

300

301

302

303 void moveBefore(Block *block, llvm::iplist::iterator iterator);

304

305

306

307

309

310

311

312 void moveAfter(Block *block, llvm::iplist::iterator iterator);

313

314

315

316

317

318

320

324

325

326

327

329

330

331

332

333

334

335

337

338

339

340

342

343

345

347 return LLVM_LIKELY(hasOperandStorage) ? getOperandStorage().size() : 0;

348 }

349

353 }

354

355

357

358

359

362 }

363

364

365

368 }

369

370

373

376

377

380 return OperandRange(operands.data(), operands.size());

381 }

382

384 return LLVM_LIKELY(hasOperandStorage) ? getOperandStorage().getOperands()

386 }

387

389 return getOperandStorage().getOperands()[idx];

390 }

391

392

398

399

400

401

402

403

405

406

408

409

412

416 return numResults == 0 ? result_range(nullptr, 0)

417 : result_range(getInlineOpResult(0), numResults);

418 }

419

422

423

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443 std::optional getInherentAttr(StringRef name);

444

445

446

447

448

450

451

452

454

455

456

458

459

462 if (attributes.set(name, value) != value)

464 }

467 }

468

469

470

471

475 if (removedAttr)

477 return removedAttr;

478 }

481 }

482

483

484

485

487 std::optional opName = getRegisteredInfo();

491 return llvm::make_filter_range(

492 attrs.getValue(),

493 [this, attributeNames](const NamedAttribute attribute) {

494 return getPropertiesStorage() ||

495 !llvm::is_contained(attributeNames, attribute.getName());

496 });

497 }

498

499

500

503 return attrs;

506 }

507

508

510

511

513

514

516

517

518

519

520 void setAttrs(DictionaryAttr newAttrs);

522

524 assert(newAttrs && "expected valid attribute dictionary");

525 attrs = newAttrs;

526 }

529 }

530

531

532

533

536 if (std::optional inherentAttr = getInherentAttr(name))

537 return *inherentAttr;

538 }

539 return attrs.get(name);

540 }

543 if (std::optional inherentAttr = getInherentAttr(name))

544 return *inherentAttr;

545 }

546 return attrs.get(name);

547 }

548

549 template

551 return llvm::dyn_cast_or_null(getAttr(name));

552 }

553 template

555 return llvm::dyn_cast_or_null(getAttr(name));

556 }

557

558

559

562 if (std::optional inherentAttr = getInherentAttr(name))

563 return (bool)*inherentAttr;

564 }

565 return attrs.contains(name);

566 }

569 if (std::optional inherentAttr = getInherentAttr(name))

570 return (bool)*inherentAttr;

571 }

572 return attrs.contains(name);

573 }

574 template <typename AttrClass, typename NameT>

576 return static_cast<bool>(

577 getAttrOfType(std::forward(name)));

578 }

579

580

581

586 return;

587 }

588 }

590 if (attributes.set(name, value) != value)

592 }

595 }

596

597

598

599

602 if (std::optional inherentAttr = getInherentAttr(name)) {

604 return *inherentAttr;

605 }

606 }

609 if (removedAttr)

611 return removedAttr;

612 }

615 }

616

617

619 : public llvm::filter_iterator<ArrayRef::iterator,

620 bool (*)(NamedAttribute)> {

622

623 return attr.getName().strref().count('.');

624 }

625

628 : llvm::filter_iterator<ArrayRef::iterator,

630

631

633 };

635

636

641 }

645 }

649 }

650

651

652 template

655 attrs.append(std::begin(dialectAttrs), std::end(dialectAttrs));

657 if (!attr.getName().strref().contains('.'))

660 }

661

662

667 }

668

669

670

671

672

673

675

676

678

679 if (numRegions == 0)

681

682 return getTrailingObjects(numRegions);

683 }

684

685

687 assert(index < numRegions && "invalid region index");

689 }

690

691

692

693

694

696 return getTrailingObjects(numSuccs);

697 }

698

699

704

707

711 }

713

714

715

716

717

718

719

720

721

722

723

724

725

726

729

730

731

732

733

734

735

736

738

739

740

741 template

744 }

745

746

747

748 template <template class Trait>

750 return name.hasTrait();

751 }

752

753

754

755

756 template <template class Trait>

759 }

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

795 std::enable_if_t<llvm::function_traits<std::decay_t>::num_args == 1,

796 RetT>

798 return detail::walk<Order, Iterator>(this, std::forward(callback));

799 }

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822 template <typename FnT, typename RetT = detail::walkResultType>

823 std::enable_if_t<llvm::function_traits<std::decay_t>::num_args == 2,

824 RetT>

826 return detail::walk(this, std::forward(callback));

827 }

828

829

830

831

832

833

836 result.dropAllUses();

837 }

838

841

844

845

847

848

850

851

853

854

855

859 });

860 }

861

862

863

864

865

868

871

872

874

875

876

877

878

879

880

882

883

884

885 InFlightDiagnostic emitError(const Twine &message = {});

886

887

888

889 InFlightDiagnostic emitWarning(const Twine &message = {});

890

891

892

893 InFlightDiagnostic emitRemark(const Twine &message = {});

894

895

897 return ((int)propertiesStorageSize) * 8;

898 }

899

901 if (propertiesStorageSize)

903 return {nullptr};

904 }

906 if (propertiesStorageSize)

908 getTrailingObjectsdetail::OpProperties()))};

909 return {nullptr};

910 }

911

912

914 return {

915 reinterpret_cast<void *>(getTrailingObjectsdetail::OpProperties())};

916 }

917

918

919

920

922

923

924

925

926

927

928

929 LogicalResult

932

933

934

936

937

939

940 private:

941

942

943

944

945

946

947 static constexpr unsigned kInvalidOrderIdx = -1;

948

949

950

951 static constexpr unsigned kOrderStride = 5;

952

953

954

955 void updateOrderIfNecessary();

956

957

958 bool hasValidOrder() { return orderIndex != kInvalidOrderIdx; }

959

960 private:

961 Operation(Location location, OperationName name, unsigned numResults,

962 unsigned numSuccessors, unsigned numRegions,

963 int propertiesStorageSize, DictionaryAttr attributes,

964 OpaqueProperties properties, bool hasOperandStorage);

965

966

967

968 ~Operation();

969

970

971

972 static size_t prefixAllocSize(unsigned numOutOfLineResults,

973 unsigned numInlineResults) {

974 return sizeof(detail::OutOfLineOpResult) * numOutOfLineResults +

975 sizeof(detail::InlineOpResult) * numInlineResults;

976 }

977

978 size_t prefixAllocSize() {

980 unsigned numOutOfLineResults = OpResult::getNumTrailing(numResults);

981 unsigned numInlineResults = OpResult::getNumInline(numResults);

982 return prefixAllocSize(numOutOfLineResults, numInlineResults);

983 }

984

985

986 detail::OperandStorage &getOperandStorage() {

987 assert(hasOperandStorage && "expected operation to have operand storage");

988 return *getTrailingObjectsdetail::OperandStorage();

989 }

990

991

992 detail::OutOfLineOpResult *getOutOfLineOpResult(unsigned resultNumber) {

993

994

995 return reinterpret_cast<detail::OutOfLineOpResult *>(getInlineOpResult(

997 ++resultNumber;

998 }

999

1000

1001 detail::InlineOpResult *getInlineOpResult(unsigned resultNumber) {

1002

1003

1004 return reinterpret_cast<detail::InlineOpResult *>(this) - ++resultNumber;

1005 }

1006

1007

1008

1009 detail::OpResultImpl *getOpResultImpl(unsigned resultNumber) {

1011 "Result number is out of range for operation");

1013 if (resultNumber < maxInlineResults)

1014 return getInlineOpResult(resultNumber);

1015 return getOutOfLineOpResult(resultNumber - maxInlineResults);

1016 }

1017

1018

1019

1020

1021

1022

1023 Block *getParent() const { return block; }

1024

1025

1026

1027 #ifndef NDEBUG

1030 LLVM_DUMP_METHOD SuccessorRange debug_getSuccessors() {

1032 }

1033 LLVM_DUMP_METHOD MutableArrayRef debug_getRegions() {

1035 }

1036 #endif

1037

1038

1039 Block *block = nullptr;

1040

1041

1042

1043 Location location;

1044

1045

1046

1047 mutable unsigned orderIndex = 0;

1048

1049 const unsigned numResults;

1050 const unsigned numSuccs;

1051 const unsigned numRegions : 23;

1052

1053

1054

1055

1056 bool hasOperandStorage : 1;

1057

1058

1059

1060

1061 unsigned char propertiesStorageSize : 8;

1062

1063

1064 static constexpr int64_t propertiesCapacity = 8 * 256;

1065

1066

1067 OperationName name;

1068

1069

1070 DictionaryAttr attrs;

1071

1072

1073 friend struct llvm::ilist_traits<Operation>;

1074

1075

1077

1078

1080

1081

1082 friend class llvm::ilist_node_with_parent<Operation, Block>;

1083

1084

1088 size_t numTrailingObjects(OverloadTokendetail::OperandStorage) const {

1089 return hasOperandStorage ? 1 : 0;

1090 }

1091 size_t numTrailingObjects(OverloadToken) const {

1092 return numSuccs;

1093 }

1094 size_t numTrailingObjects(OverloadToken) const { return numRegions; }

1095 size_t numTrailingObjects(OverloadTokendetail::OpProperties) const {

1097 }

1098 };

1099

1102 return os;

1103 }

1104

1105 }

1106

1107 namespace llvm {

1108

1109 template

1112 CastInfo<T, ::mlir::Operation *>> {

1114 };

1115 template

1118 CastInfo<T, ::mlir::Operation *>> {};

1119

1120

1121 template

1125 CastInfo<T, ::mlir::Operation>> {

1126

1127

1130 };

1131 template

1134 CastInfo<T, ::mlir::Operation>> {};

1135

1136

1137

1138

1139 template <>

1143 ::mlir::Operation *, ::mlir::Operation *,

1144 CastInfo<::mlir::Operation *, ::mlir::Operation *>> {

1147 };

1148 template <>

1151 const ::mlir::Operation *, const ::mlir::Operation *,

1152 CastInfo<::mlir::Operation *, ::mlir::Operation *>> {};

1153 }

1154

1155 #endif

static llvm::ManagedStatic< PassManagerOptions > options

static void print(spirv::VerCapExtAttr triple, DialectAsmPrinter &printer)

This class provides management for the lifetime of the state used when printing the IR.

Attributes are known-constant values of operations.

MLIRContext * getContext() const

Return the context this attribute belongs to.

A block operand represents an operand that holds a reference to a Block, e.g.

This class provides an abstraction over the different types of ranges over Blocks.

Block represents an ordered list of Operations.

Region * getParent() const

Provide a 'getParent' method for ilist_node_with_parent methods.

Operation * getParentOp()

Returns the closest surrounding operation that contains this block.

Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...

This is a utility class for mapping one set of IR entities to another.

IRValueT get() const

Return the current value being used by this operand.

void set(IRValueT newValue)

Set the current value being used by this operand.

This class represents a diagnostic that is inflight and set to be reported.

This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...

MLIRContext is the top-level object for a collection of MLIR operations.

NamedAttrList is array of NamedAttributes that tracks whether it is sorted and does some basic work t...

DictionaryAttr getDictionary(MLIRContext *context) const

Return a dictionary attribute for the underlying dictionary.

void push_back(NamedAttribute newAttribute)

Add an attribute with the specified name.

Attribute erase(StringAttr name)

Erase the attribute with the given name from the list.

void append(StringRef name, Attribute attr)

Add an attribute with the specified name.

Attribute set(StringAttr name, Attribute value)

If the an attribute exists with the specified name, change it to the new value.

NamedAttribute represents a combination of a name and an Attribute value.

StringAttr getName() const

Return the name of the attribute.

This class represents an operand of an operation.

Set of flags used to control the behavior of the various IR print methods (e.g.

OpPrintingFlags & useLocalScope(bool enable=true)

Use local scope when printing the operation.

This is a value defined by a result of an operation.

Simple wrapper around a void* in order to express generically how to pass in op properties through AP...

This class implements the operand iterators for the Operation class.

type_range getTypes() const

ValueTypeRange< OperandRange > type_range

ValueTypeIterator< iterator > type_iterator

Returns the types of the values within this range.

bool hasTrait() const

Returns true if the operation was registered with a particular trait, e.g.

bool hasPromiseOrImplementsInterface() const

Returns true if InterfaceT has been promised by the dialect or implemented.

Dialect * getDialect() const

Return the dialect this operation is registered to if the dialect is loaded in the context,...

std::optional< RegisteredOperationName > getRegisteredInfo() const

If this operation is registered, returns the registered information, std::nullopt otherwise.

bool mightHaveTrait() const

Returns true if the operation might have the provided trait.

bool isRegistered() const

Return if this operation is registered.

void populateDefaultAttrs(NamedAttrList &attrs) const

This hook implements the method to populate defaults attributes that are unset.

Class encompassing various options related to cloning an operation.

bool shouldCloneRegions() const

Returns whether regions of the operation should be cloned as well.

CloneOptions()

Default constructs an option with all flags set to false.

static CloneOptions all()

Returns an instance with all flags set to true.

bool shouldCloneOperands() const

Returns whether operands should be cloned as well.

CloneOptions & cloneRegions(bool enable=true)

Configures whether cloning should traverse into any of the regions of the operation.

CloneOptions & cloneOperands(bool enable=true)

Configures whether operation' operands should be cloned.

A utility iterator that filters out non-dialect attributes.

Operation is the basic unit of execution within MLIR.

AttrClass getAttrOfType(StringRef name)

void setLoc(Location loc)

Set the source location the operation was defined or derived from.

void setInherentAttr(StringAttr name, Attribute value)

Set an inherent attribute by name.

void eraseOperands(const BitVector &eraseIndices)

Erases the operands that have their corresponding bit set in eraseIndices and removes them from the o...

Attribute getDiscardableAttr(StringRef name)

Access a discardable attribute by name, returns an null Attribute if the discardable attribute does n...

void replaceUsesOfWith(Value from, Value to)

Replace any uses of 'from' with 'to' within this operation.

DictionaryAttr getAttrDictionary()

Return all of the attributes on this operation as a DictionaryAttr.

ResultRange result_range

Support result iteration.

LogicalResult fold(ArrayRef< Attribute > operands, SmallVectorImpl< OpFoldResult > &results)

Attempt to fold this operation with the specified constant operand values.

bool use_empty()

Returns true if this operation has no uses.

Value getOperand(unsigned idx)

OpResult getOpResult(unsigned idx)

bool hasTrait()

Returns true if the operation was registered with a particular trait, e.g.

Operation * cloneWithoutRegions()

Create a partial copy of this operation without traversing into attached regions.

Dialect * getDialect()

Return the dialect this operation is associated with, or nullptr if the associated dialect is not loa...

void insertOperands(unsigned index, ValueRange operands)

Insert the given operands into the operand list at the given 'index'.

void dropAllUses()

Drop all uses of results of this operation.

AttrClass getAttrOfType(StringAttr name)

Attribute getAttr(StringAttr name)

Return the specified attribute if present, null otherwise.

bool hasAttr(StringRef name)

OpOperand & getOpOperand(unsigned idx)

bool hasAttrOfType(NameT &&name)

void setOperand(unsigned idx, Value value)

Block * getSuccessor(unsigned index)

void setAttrs(DictionaryAttr newAttrs)

Set the attributes from a dictionary on this operation.

bool hasAttr(StringAttr name)

Return true if the operation has an attribute with the provided name, false otherwise.

OpaqueProperties getPropertiesStorage() const

unsigned getNumSuccessors()

bool isBeforeInBlock(Operation *other)

Given an operation 'other' that is within the same parent block, return whether the current operation...

result_iterator result_begin()

void eraseOperands(unsigned idx, unsigned length=1)

Erase the operands starting at position idx and ending at position 'idx'+'length'.

void dropAllReferences()

This drops all operand uses from this operation, which is an essential step in breaking cyclic depend...

bool isRegistered()

Returns true if this operation has a registered operation description, otherwise false.

InFlightDiagnostic emitWarning(const Twine &message={})

Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening.

Operation * clone(IRMapping &mapper, CloneOptions options=CloneOptions::all())

Create a deep copy of this operation, remapping any operands that use values outside of the operation...

result_range::iterator result_iterator

operand_iterator operand_begin()

OpaqueProperties getPropertiesStorageUnsafe()

Returns the properties storage without checking whether properties are present.

bool mightHaveTrait()

Returns true if the operation might have the provided trait.

bool hasOneUse()

Returns true if this operation has exactly one use.

dialect_attr_iterator dialect_attr_begin()

Attribute getAttr(StringRef name)

void setDiscardableAttr(StringAttr name, Attribute value)

Set a discardable attribute by name.

Attribute removeAttr(StringRef name)

OpResult getResult(unsigned idx)

Get the 'idx'th result of this operation.

std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)

Walk the operation by calling the callback for each nested operation (including this one),...

std::optional< Attribute > getInherentAttr(StringRef name)

Access an inherent attribute by name: returns an empty optional if there is no inherent attribute wit...

void print(raw_ostream &os, const OpPrintingFlags &flags=std::nullopt)

operand_type_iterator operand_type_end()

Attribute removeDiscardableAttr(StringRef name)

MLIRContext * getContext()

Return the context this operation is associated with.

unsigned getNumRegions()

Returns the number of regions held by this operation.

void setDialectAttrs(DialectAttrT &&dialectAttrs)

Set the dialect attributes for this operation, and preserve all inherent.

std::optional< RegisteredOperationName > getRegisteredInfo()

If this operation has a registered operation description, return it.

Location getLoc()

The source location the operation was defined or derived from.

void replaceUsesWithIf(ValuesT &&values, function_ref< bool(OpOperand &)> shouldReplace)

Replace uses of results of this operation with the provided values if the given callback returns true...

void eraseOperand(unsigned idx)

Erase the operand at position idx.

bool hasPromiseOrImplementsInterface() const

Returns true if InterfaceT has been promised by the dialect or implemented.

DictionaryAttr getRawDictionaryAttrs()

Return all attributes that are not stored as properties.

void dropAllDefinedValueUses()

Drop uses of all values defined by this operation or its nested regions.

unsigned getNumOperands()

result_type_iterator result_type_end()

static Operation * create(Location location, OperationName name, TypeRange resultTypes, ValueRange operands, NamedAttrList &&attributes, OpaqueProperties properties, BlockRange successors, unsigned numRegions)

Create a new Operation with the specific fields.

Attribute getPropertiesAsAttribute()

Return the properties converted to an attribute.

Operation * getParentOp()

Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...

ArrayRef< NamedAttribute > getAttrs()

Return all of the attributes on this operation.

OperandRange operand_range

void populateDefaultAttrs()

Sets default attributes on unset attributes.

InFlightDiagnostic emitError(const Twine &message={})

Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...

Block * getBlock()

Returns the operation block that contains this operation.

ValueUserIterator< use_iterator, OpOperand > user_iterator

OpTy getParentOfType()

Return the closest surrounding parent operation that is of type 'OpTy'.

operand_iterator operand_end()

Attribute getDiscardableAttr(StringAttr name)

Access a discardable attribute by name, returns an null Attribute if the discardable attribute does n...

Region & getRegion(unsigned index)

Returns the region held by this operation at position 'index'.

bool isUsedOutsideOfBlock(Block *block)

Returns true if the results of this operation are used outside of the given block.

result_type_iterator result_type_begin()

void setAttr(StringAttr name, Attribute value)

If the an attribute exists with the specified name, change it to the new value.

Operation * getParentWithTrait()

Returns the closest surrounding parent operation with trait Trait.

MutableArrayRef< Region > getRegions()

Returns the regions held by this operation.

void destroy()

Destroys this operation and its subclass data.

auto getDiscardableAttrs()

Return a range of all of discardable attributes on this operation.

OperationName getName()

The name of an operation is the key identifier for it.

DictionaryAttr getDiscardableAttrDictionary()

Return all of the discardable attributes on this operation as a DictionaryAttr.

void remove()

Remove the operation from its parent block, but don't delete it.

void setDiscardableAttrs(ArrayRef< NamedAttribute > newAttrs)

dialect_attr_range getDialectAttrs()

Return a range corresponding to the dialect attributes for this operation.

LogicalResult setPropertiesFromAttribute(Attribute attr, function_ref< InFlightDiagnostic()> emitError)

Set the properties from the provided attribute.

MutableArrayRef< BlockOperand > getBlockOperands()

operand_type_range getOperandTypes()

result_iterator result_end()

MutableArrayRef< OpOperand > getOpOperands()

result_type_range getResultTypes()

Attribute removeDiscardableAttr(StringAttr name)

Remove the discardable attribute with the specified name if it exists.

LLVM_DUMP_METHOD void dumpPretty()

void setDiscardableAttr(StringRef name, Attribute value)

operand_range getOperands()

Returns an iterator on the underlying Value's.

void setSuccessor(Block *block, unsigned index)

void moveBefore(Operation *existingOp)

Unlink this operation from its current block and insert it right before existingOp which may be in th...

bool isAncestor(Operation *other)

Return true if this operation is an ancestor of the other operation.

void replaceAllUsesWith(ValuesT &&values)

Replace all uses of results of this operation with the provided 'values'.

void setOperands(ValueRange operands)

Replace the current operands of this operation with the ones provided in 'operands'.

user_range getUsers()

Returns a range of all users.

SuccessorRange getSuccessors()

result_range getOpResults()

Region * getParentRegion()

Returns the region to which the instruction belongs.

result_range getResults()

int getPropertiesStorageSize() const

Returns the properties storage size.

Attribute removeAttr(StringAttr name)

Remove the attribute with the specified name if it exists.

SuccessorRange::iterator succ_iterator

dialect_attr_iterator dialect_attr_end()

bool isProperAncestor(Operation *other)

Return true if this operation is a proper ancestor of the other operation.

use_range getUses()

Returns a range of all uses, which is useful for iterating over all uses.

void setAttr(StringRef name, Attribute value)

InFlightDiagnostic emitRemark(const Twine &message={})

Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening.

operand_range::iterator operand_iterator

user_iterator user_begin()

void setDiscardableAttrs(DictionaryAttr newAttrs)

Set the discardable attribute dictionary on this operation.

void moveAfter(Operation *existingOp)

Unlink this operation from its current block and insert it right after existingOp which may be in the...

llvm::hash_code hashProperties()

Compute a hash for the op properties (if any).

InFlightDiagnostic emitOpError(const Twine &message={})

Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.

succ_iterator successor_end()

OpaqueProperties getPropertiesStorage()

Returns the properties storage.

void erase()

Remove this operation from its parent block and delete it.

void copyProperties(OpaqueProperties rhs)

Copy properties from an existing other properties object.

succ_iterator successor_begin()

std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==2, RetT > walk(FnT &&callback)

Generic walker with a stage aware callback.

unsigned getNumResults()

Return the number of results held by this operation.

operand_type_iterator operand_type_begin()

This class provides an abstraction over the different types of ranges over Regions.

This class contains a list of basic blocks and a link to the parent operation it is attached to.

This class implements a use iterator for a range of operation results.

This class implements the result iterators for the Operation class.

use_range getUses() const

Returns a range of all uses of results within this range, which is useful for iterating over all uses...

bool use_empty() const

Returns true if no results in this range have uses.

ValueTypeRange< ResultRange > type_range

use_iterator use_begin() const

ValueTypeIterator< iterator > type_iterator

Returns the types of the values within this range.

use_iterator use_end() const

std::enable_if_t<!std::is_convertible< ValuesT, Operation * >::value > replaceUsesWithIf(ValuesT &&values, function_ref< bool(OpOperand &)> shouldReplace)

Replace uses of results of this range with the provided 'values' if the given callback returns true.

type_range getTypes() const

std::enable_if_t<!std::is_convertible< ValuesT, Operation * >::value > replaceAllUsesWith(ValuesT &&values)

Replace all uses of results of this range with the provided 'values'.

iterator_range< use_iterator > use_range

This class implements the successor iterators for Block.

This class provides an abstraction over the various different ranges of value types.

This class provides an abstraction over the different types of ranges over Values.

This class implements iteration on the types of a given range of values.

This class implements iteration on the types of a given range of values.

An iterator over the users of an IRObject.

This class represents an instance of an SSA value in the MLIR system, representing a computable value...

bool isUsedOutsideOfBlock(Block *block) const

Returns true if the value is used outside of the given block.

static unsigned getMaxInlineResults()

Returns the maximum number of results that can be stored inline.

This class handles the management of operation operands.

MutableArrayRef< OpOperand > getOperands()

Get the operation operands held by the storage.

void eraseOperands(unsigned start, unsigned length)

Erase the operands held by the storage within the given range.

unsigned size()

Return the number of operands held in the storage.

The OpAsmOpInterface, see OpAsmInterface.td for more details.

void walk(Operation *op, function_ref< void(Region *)> callback, WalkOrder order)

Walk all of the regions, blocks, or operations nested under (and including) the given operation.

decltype(walk(nullptr, std::declval< FnT >())) walkResultType

Utility to provide the return type of a templated walk method.

OpProperties

This is a "tag" used for mapping the properties storage in llvm::TrailingObjects.

Include the generated interface declarations.

WalkOrder

Traversal order for region, block and operation walk utilities.

auto get(MLIRContext *context, Ts &&...params)

Helper method that injects context only if needed, this helps unify some of the attribute constructio...

raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)

static T doCast(::mlir::Operation &val)

static bool isPossible(::mlir::Operation &val)

static bool isPossible(::mlir::Operation *op)

::mlir::Operation * doCast(::mlir::Operation *op)

static bool isPossible(::mlir::Operation *op)

This iterator enumerates the elements in "forward" order.

This represents an operation in an abstracted form, suitable for use with the builder APIs.