MLIR: lib/CAPI/IR/IR.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

11

32 #include "llvm/ADT/SmallPtrSet.h"

33 #include "llvm/Support/ThreadPool.h"

34

35 #include

36 #include

37 #include

38

39 using namespace mlir;

40

41

42

43

44

47 return wrap(context);

48 }

49

53 }

54

57 return wrap(context);

58 }

59

61 bool threadingEnabled) {

62 auto *context =

64 return wrap(context);

65 }

66

69 }

70

72

74 unwrap(context)->allowUnregisteredDialects(allow);

75 }

76

78 return unwrap(context)->allowsUnregisteredDialects();

79 }

81 return static_cast<intptr_t>(unwrap(context)->getAvailableDialects().size());

82 }

83

85 MlirDialectRegistry registry) {

86 unwrap(ctx)->appendDialectRegistry(*unwrap(registry));

87 }

88

89

90

92 return static_cast<intptr_t>(unwrap(context)->getLoadedDialects().size());

93 }

94

98 }

99

101 return unwrap(context)->isOperationRegistered(unwrap(name));

102 }

103

105 return unwrap(context)->enableMultithreading(enable);

106 }

107

109 unwrap(context)->loadAllAvailableDialects();

110 }

111

113 MlirLlvmThreadPool threadPool) {

114 unwrap(context)->setThreadPool(*unwrap(threadPool));

115 }

116

118 return unwrap(context)->getNumThreads();

119 }

120

122 return wrap(&unwrap(context)->getThreadPool());

123 }

124

125

126

127

128

131 }

132

135 }

136

138 return wrap(unwrap(dialect)->getNamespace());

139 }

140

141

142

143

144

147 }

148

150 delete unwrap(registry);

151 }

152

153

154

155

156

158 MlirOpPrintingFlags flags) {

160 }

161

163 do {

164

165

167 break;

168

169

171 if (!parentOp)

172 break;

173 op = parentOp;

174 } while (true);

175 return op;

176 }

177

179 MlirOpPrintingFlags flags) {

182 if (auto result = llvm::dyn_cast(val)) {

183 op = result.getOwner();

184 } else {

185 op = llvm::cast(val).getOwner()->getParentOp();

186 if (!op) {

188 return {nullptr};

189 }

190 }

193 }

194

195

197

198

199

200

201

204 }

205

207 delete unwrap(flags);

208 }

209

211 intptr_t largeElementLimit) {

212 unwrap(flags)->elideLargeElementsAttrs(largeElementLimit);

213 }

214

216 intptr_t largeResourceLimit) {

217 unwrap(flags)->elideLargeResourceString(largeResourceLimit);

218 }

219

221 bool prettyForm) {

222 unwrap(flags)->enableDebugInfo(enable, prettyForm);

223 }

224

226 unwrap(flags)->printGenericOpForm();

227 }

228

230 unwrap(flags)->printNameLocAsPrefix();

231 }

232

234 unwrap(flags)->useLocalScope();

235 }

236

238 unwrap(flags)->assumeVerified();

239 }

240

242 unwrap(flags)->skipRegions();

243 }

244

245

246

247

250 }

251

254 }

255

257 int64_t version) {

258 unwrap(flags)->setDesiredBytecodeVersion(version);

259 }

260

261

262

263

264

267 }

268

270 return wrap(Location(llvm::dyn_cast(unwrap(attribute))));

271 }

272

275 unsigned col) {

278 }

279

280 MlirLocation

282 unsigned startLine, unsigned startCol,

283 unsigned endLine, unsigned endCol) {

286 startLine, startCol, endLine, endCol)));

287 }

288

290 return wrap(llvm::dyn_cast(unwrap(location)).getFilename());

291 }

292

294 if (auto loc = llvm::dyn_cast(unwrap(location)))

295 return loc.getStartLine();

296 return -1;

297 }

298

300 if (auto loc = llvm::dyn_cast(unwrap(location)))

301 return loc.getStartColumn();

302 return -1;

303 }

304

306 if (auto loc = llvm::dyn_cast(unwrap(location)))

307 return loc.getEndLine();

308 return -1;

309 }

310

312 if (auto loc = llvm::dyn_cast(unwrap(location)))

313 return loc.getEndColumn();

314 return -1;

315 }

316

318 return wrap(FileLineColRange::getTypeID());

319 }

320

322 return isa(unwrap(location));

323 }

324

327 }

328

331 Location(llvm::dyn_cast(unwrap(location)).getCallee()));

332 }

333

336 Location(llvm::dyn_cast(unwrap(location)).getCaller()));

337 }

338

340 return wrap(CallSiteLoc::getTypeID());

341 }

342

344 return isa(unwrap(location));

345 }

346

348 MlirLocation const *locations,

349 MlirAttribute metadata) {

353 }

354

356 if (auto locationsArrRef = llvm::dyn_cast(unwrap(location)))

357 return locationsArrRef.getLocations().size();

358 return 0;

359 }

360

362 MlirLocation *locationsCPtr) {

363 if (auto locationsArrRef = llvm::dyn_cast(unwrap(location))) {

364 for (auto [i, location] : llvm::enumerate(locationsArrRef.getLocations()))

365 locationsCPtr[i] = wrap(location);

366 }

367 }

368

370 return wrap(llvm::dyn_cast(unwrap(location)).getMetadata());

371 }

372

374

376 return isa(unwrap(location));

377 }

378

380 MlirLocation childLoc) {

386 }

387

389 return wrap((llvm::dyn_cast(unwrap(location)).getName()));

390 }

391

394 Location(llvm::dyn_cast(unwrap(location)).getChildLoc()));

395 }

396

398

400 return isa(unwrap(location));

401 }

402

405 }

406

409 }

410

413 }

414

416 void *userData) {

418 unwrap(location).print(stream);

419 }

420

421

422

423

424

426 return wrap(ModuleOp::create(unwrap(location)));

427 }

428

431 parseSourceString(unwrap(module), unwrap(context));

432 if (!owning)

433 return MlirModule{nullptr};

434 return MlirModule{owning.release().getOperation()};

435 }

436

440 parseSourceFile(unwrap(fileName), unwrap(context));

441 if (!owning)

442 return MlirModule{nullptr};

443 return MlirModule{owning.release().getOperation()};

444 }

445

448 }

449

451 return wrap(unwrap(module).getBody());

452 }

453

455

456

458 }

459

461 return wrap(unwrap(module).getOperation());

462 }

463

465 return wrap(dyn_cast(unwrap(op)));

466 }

467

468

469

470

471

474 state.name = name;

475 state.location = loc;

476 state.nResults = 0;

477 state.results = nullptr;

478 state.nOperands = 0;

479 state.operands = nullptr;

480 state.nRegions = 0;

481 state.regions = nullptr;

482 state.nSuccessors = 0;

483 state.successors = nullptr;

484 state.nAttributes = 0;

485 state.attributes = nullptr;

486 state.enableResultTypeInference = false;

487 return state;

488 }

489

490 #define APPEND_ELEMS(type, sizeName, elemName) \

491 state->elemName = \

492 (type *)realloc(state->elemName, (state->sizeName + n) * sizeof(type)); \

493 memcpy(state->elemName + state->sizeName, elemName, n * sizeof(type)); \

494 state->sizeName += n;

495

497 MlirType const *results) {

499 }

500

502 MlirValue const *operands) {

503 APPEND_ELEMS(MlirValue, nOperands, operands);

504 }

506 MlirRegion const *regions) {

508 }

510 MlirBlock const *successors) {

511 APPEND_ELEMS(MlirBlock, nSuccessors, successors);

512 }

516 }

517

519 state->enableResultTypeInference = true;

520 }

521

522

523

524

525

527 MLIRContext *context = state.getContext();

528 std::optional info = state.name.getRegisteredInfo();

529 if (!info) {

531 << "type inference was requested for the operation " << state.name

532 << ", but the operation was not registered; ensure that the dialect "

533 "containing the operation is linked into MLIR and registered with "

534 "the context";

535 return failure();

536 }

537

538 auto *inferInterface = info->getInterface();

539 if (!inferInterface) {

541 << "type inference was requested for the operation " << state.name

542 << ", but the operation does not support type inference; result "

543 "types must be specified explicitly";

544 return failure();

545 }

546

547 DictionaryAttr attributes = state.attributes.getDictionary(context);

549

550 if (!properties && info->getOpPropertyByteSize() > 0 && !attributes.empty()) {

551 auto prop = std::make_unique<char[]>(info->getOpPropertyByteSize());

553 if (properties) {

556 << " failed properties conversion while building "

557 << state.name.getStringRef() << " with `" << attributes << "`: ";

558 };

559 if (failed(info->setOpPropertiesFromAttribute(state.name, properties,

561 return failure();

562 }

563 if (succeeded(inferInterface->inferReturnTypes(

564 context, state.location, state.operands, attributes, properties,

565 state.regions, state.types))) {

566 return success();

567 }

568

569 return failure();

570 }

571

572 if (succeeded(inferInterface->inferReturnTypes(

573 context, state.location, state.operands, attributes, properties,

574 state.regions, state.types)))

575 return success();

576

577

578 return failure();

579 }

580

582 assert(state);

587 cppState.addTypes(unwrapList(state->nResults, state->results, resultStorage));

589 unwrapList(state->nOperands, state->operands, operandStorage));

591 unwrapList(state->nSuccessors, state->successors, successorStorage));

592

594 for (intptr_t i = 0; i < state->nAttributes; ++i)

596 unwrap(state->attributes[i].attribute));

597

598 for (intptr_t i = 0; i < state->nRegions; ++i)

599 cppState.addRegion(std::unique_ptr(unwrap(state->regions[i])));

600

601 free(state->results);

602 free(state->operands);

603 free(state->successors);

604 free(state->regions);

605 free(state->attributes);

606

607

608 if (state->enableResultTypeInference) {

609 assert(cppState.types.empty() &&

610 "result type inference enabled and result types provided");

612 return {nullptr};

613 }

614

616 }

617

621

624 .release());

625 }

626

629 }

630

632

634

637 }

638

641 }

642

645 }

646

648 if (auto info = unwrap(op)->getRegisteredInfo())

649 return wrap(info->getTypeID());

650 return {nullptr};

651 }

652

654 return wrap(unwrap(op)->getName().getIdentifier());

655 }

656

659 }

660

662 return wrap(unwrap(op)->getParentOp());

663 }

664

666 return static_cast<intptr_t>(unwrap(op)->getNumRegions());

667 }

668

670 return wrap(&unwrap(op)->getRegion(static_cast<unsigned>(pos)));

671 }

672

676 return wrap(static_cast<Region *>(nullptr));

678 }

679

686 return wrap(static_cast<Region *>(nullptr));

687 }

688

690 return wrap(unwrap(op)->getNextNode());

691 }

692

694 return static_cast<intptr_t>(unwrap(op)->getNumOperands());

695 }

696

698 return wrap(unwrap(op)->getOperand(static_cast<unsigned>(pos)));

699 }

700

702 MlirValue newValue) {

703 unwrap(op)->setOperand(static_cast<unsigned>(pos), unwrap(newValue));

704 }

705

707 MlirValue const *operands) {

709 unwrap(op)->setOperands(unwrapList(nOperands, operands, ops));

710 }

711

713 return static_cast<intptr_t>(unwrap(op)->getNumResults());

714 }

715

717 return wrap(unwrap(op)->getResult(static_cast<unsigned>(pos)));

718 }

719

721 return static_cast<intptr_t>(unwrap(op)->getNumSuccessors());

722 }

723

725 return wrap(unwrap(op)->getSuccessor(static_cast<unsigned>(pos)));

726 }

727

730 std::optional attr = unwrap(op)->getInherentAttr(unwrap(name));

731 return attr.has_value();

732 }

733

736 std::optional attr = unwrap(op)->getInherentAttr(unwrap(name));

737 if (attr.has_value())

738 return wrap(*attr);

739 return {};

740 }

741

744 MlirAttribute attr) {

745 unwrap(op)->setInherentAttr(

747 }

748

750 return static_cast<intptr_t>(

751 llvm::range_size(unwrap(op)->getDiscardableAttrs()));

752 }

753

755 intptr_t pos) {

757 *std::next(unwrap(op)->getDiscardableAttrs().begin(), pos);

759 }

760

764 }

765

768 MlirAttribute attr) {

770 }

771

774 return !unwrap(op)->removeDiscardableAttr(unwrap(name));

775 }

776

778 MlirBlock block) {

779 unwrap(op)->setSuccessor(unwrap(block), static_cast<unsigned>(pos));

780 }

781

783 return static_cast<intptr_t>(unwrap(op)->getAttrs().size());

784 }

785

789 }

790

794 }

795

797 MlirAttribute attr) {

799 }

800

802 return !unwrap(op)->removeAttr(unwrap(name));

803 }

804

806 void *userData) {

808 unwrap(op)->print(stream);

809 }

810

815 }

816

820 if (state.ptr)

822 unwrap(op)->print(stream);

823 }

824

826 void *userData) {

828

830 }

831

833 MlirOperation op, MlirBytecodeWriterConfig config,

837 }

838

840

843 }

844

847 }

848

850 return unwrap(op)->moveBefore(unwrap(other));

851 }

852

854 switch (result) {

857

860

863 }

864 llvm_unreachable("unknown result in WalkResult::unwrap");

865 }

866

869 switch (walkOrder) {

870

873 [callback, userData](Operation *op) {

874 return unwrap(callback(wrap(op), userData));

875 });

876 break;

879 [callback, userData](Operation *op) {

880 return unwrap(callback(wrap(op), userData));

881 });

882 }

883 }

884

885

886

887

888

890

893 }

894

897 if (cppRegion->empty())

898 return wrap(static_cast<Block *>(nullptr));

899 return wrap(&cppRegion->front());

900 }

901

904 }

905

907 MlirBlock block) {

908 auto &blockList = unwrap(region)->getBlocks();

909 blockList.insert(std::next(blockList.begin(), pos), unwrap(block));

910 }

911

913 MlirBlock block) {

917 return;

918 }

919

920 assert(unwrap(reference)->getParent() == unwrap(region) &&

921 "expected reference block to belong to the region");

924 }

925

927 MlirBlock block) {

930

931 assert(unwrap(reference)->getParent() == unwrap(region) &&

932 "expected reference block to belong to the region");

935 }

936

938 delete static_cast<Region *>(region.ptr);

939 }

940

943 }

944

945

946

947

948

950 MlirLocation const *locs) {

952 for (intptr_t i = 0; i < nArgs; ++i)

954 return wrap(b);

955 }

956

959 }

960

962 return wrap(unwrap(block)->getParentOp());

963 }

964

966 return wrap(unwrap(block)->getParent());

967 }

968

970 return wrap(unwrap(block)->getNextNode());

971 }

972

975 if (cppBlock->empty())

978 }

979

982 if (cppBlock->empty())

987 return wrap(&back);

988 }

989

992 }

993

995 MlirOperation operation) {

996 auto &opList = unwrap(block)->getOperations();

997 opList.insert(std::next(opList.begin(), pos), unwrap(operation));

998 }

999

1001 MlirOperation reference,

1002 MlirOperation operation) {

1006 return;

1007 }

1008

1009 assert(unwrap(reference)->getBlock() == unwrap(block) &&

1010 "expected reference operation to belong to the block");

1013 }

1014

1016 MlirOperation reference,

1017 MlirOperation operation) {

1020

1021 assert(unwrap(reference)->getBlock() == unwrap(block) &&

1022 "expected reference operation to belong to the block");

1025 }

1026

1028

1032 }

1033

1035 return static_cast<intptr_t>(unwrap(block)->getNumArguments());

1036 }

1037

1039 MlirLocation loc) {

1041 }

1042

1044 return unwrap(block)->eraseArgument(index);

1045 }

1046

1048 MlirLocation loc) {

1050 }

1051

1053 return wrap(unwrap(block)->getArgument(static_cast<unsigned>(pos)));

1054 }

1055

1057 void *userData) {

1059 unwrap(block)->print(stream);

1060 }

1061

1062

1063

1064

1065

1068 }

1069

1071 return llvm::isa(unwrap(value));

1072 }

1073

1075 return llvm::isa(unwrap(value));

1076 }

1077

1079 return wrap(llvm::dyn_cast(unwrap(value)).getOwner());

1080 }

1081

1083 return static_cast<intptr_t>(

1084 llvm::dyn_cast(unwrap(value)).getArgNumber());

1085 }

1086

1088 if (auto blockArg = llvm::dyn_cast(unwrap(value)))

1089 blockArg.setType(unwrap(type));

1090 }

1091

1093 return wrap(llvm::dyn_cast(unwrap(value)).getOwner());

1094 }

1095

1097 return static_cast<intptr_t>(

1098 llvm::dyn_cast(unwrap(value)).getResultNumber());

1099 }

1100

1103 }

1104

1107 }

1108

1110

1112 void *userData) {

1114 unwrap(value).print(stream);

1115 }

1116

1122 }

1123

1127 return {};

1128

1130

1131 return wrap(opOperand);

1132 }

1133

1135 unwrap(oldValue).replaceAllUsesWith(unwrap(newValue));

1136 }

1137

1139 intptr_t numExceptions,

1140 MlirOperation *exceptions) {

1143

1145 for (intptr_t i = 0; i < numExceptions; ++i) {

1146 exceptionSet.insert(unwrap(exceptions[i]));

1147 }

1148

1150 }

1151

1154 }

1155

1158 }

1159

1160

1161

1162

1163

1165

1167 return wrap(unwrap(opOperand)->getOwner());

1168 }

1169

1172 }

1173

1175 return unwrap(opOperand)->getOperandNumber();

1176 }

1177

1180 return {};

1181

1183 unwrap(opOperand)->getNextOperandUsingThisValue());

1184

1185 if (!nextOpOperand)

1186 return {};

1187

1188 return wrap(nextOpOperand);

1189 }

1190

1191

1192

1193

1194

1197 }

1198

1201 }

1202

1204 return wrap(unwrap(type).getTypeID());

1205 }

1206

1208 return wrap(&unwrap(type).getDialect());

1209 }

1210

1213 }

1214

1217 unwrap(type).print(stream);

1218 }

1219

1221

1222

1223

1224

1225

1228 }

1229

1232 }

1233

1236 if (auto typedAttr = llvm::dyn_cast(attr))

1237 return wrap(typedAttr.getType());

1239 }

1240

1242 return wrap(unwrap(attr).getTypeID());

1243 }

1244

1246 return wrap(&unwrap(attr).getDialect());

1247 }

1248

1251 }

1252

1254 void *userData) {

1256 unwrap(attr).print(stream);

1257 }

1258

1260

1262 MlirAttribute attr) {

1264 }

1265

1266

1267

1268

1269

1272 }

1273

1276 }

1277

1280 }

1281

1283 return wrap(unwrap(ident).strref());

1284 }

1285

1286

1287

1288

1289

1292 }

1293

1296 }

1297

1299 if (unwrap(operation)->hasTraitOpTrait::SymbolTable())

1302 }

1303

1305 delete unwrap(symbolTable);

1306 }

1307

1310 return wrap(unwrap(symbolTable)->lookup(StringRef(name.data, name.length)));

1311 }

1312

1314 MlirOperation operation) {

1316 }

1317

1319 MlirOperation operation) {

1320 unwrap(symbolTable)->erase(unwrap(operation));

1321 }

1322

1325 MlirOperation from) {

1326 auto *cppFrom = unwrap(from);

1327 auto *context = cppFrom->getContext();

1332 }

1333

1335 void (*callback)(MlirOperation, bool,

1336 void *userData),

1337 void *userData) {

1339 [&](Operation *foundOpCpp, bool isVisible) {

1340 callback(wrap(foundOpCpp), isVisible,

1341 userData);

1342 });

1343 }

unsigned mlirOpOperandGetOperandNumber(MlirOpOperand opOperand)

Returns the operand number of an op operand.

MlirLocation mlirValueGetLocation(MlirValue v)

Gets the location of the value.

void mlirContextDestroy(MlirContext context)

Takes an MLIR context owned by the caller and destroys it.

void mlirOperationDump(MlirOperation op)

Prints an operation to stderr.

MlirAttribute mlirOperationGetDiscardableAttributeByName(MlirOperation op, MlirStringRef name)

Returns a discardable attribute attached to the operation given its name.

MlirOperation mlirSymbolTableLookup(MlirSymbolTable symbolTable, MlirStringRef name)

Looks up a symbol with the given name in the given symbol table and returns the operation that corres...

MlirRegion mlirRegionCreate()

Creates a new empty region and transfers ownership to the caller.

void mlirOperationPrint(MlirOperation op, MlirStringCallback callback, void *userData)

Prints an operation by sending chunks of the string representation and forwarding userData tocallback...

MlirContext mlirModuleGetContext(MlirModule module)

Gets the context that a module was created with.

void mlirValuePrint(MlirValue value, MlirStringCallback callback, void *userData)

Prints a value by sending chunks of the string representation and forwarding userData tocallback`.

MlirContext mlirLocationGetContext(MlirLocation location)

Gets the context that a location was created with.

bool mlirLocationIsAName(MlirLocation location)

Checks whether the given location is an Name.

MlirOperation mlirOpOperandGetOwner(MlirOpOperand opOperand)

Returns the owner operation of an op operand.

bool mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2)

Checks if two dialects that belong to the same context are equal.

MlirRegion mlirRegionGetNextInOperation(MlirRegion region)

Returns the region immediately following the given region in its parent operation.

MlirLogicalResult mlirOperationWriteBytecodeWithConfig(MlirOperation op, MlirBytecodeWriterConfig config, MlirStringCallback callback, void *userData)

Same as mlirOperationWriteBytecode but with writer config and returns failure only if desired bytecod...

MlirIdentifier mlirOperationGetName(MlirOperation op)

Gets the name of the operation as an identifier.

void mlirDialectRegistryDestroy(MlirDialectRegistry registry)

Takes a dialect registry owned by the caller and destroys it.

bool mlirIdentifierEqual(MlirIdentifier ident, MlirIdentifier other)

Checks whether two identifiers are the same.

void mlirOperationPrintWithFlags(MlirOperation op, MlirOpPrintingFlags flags, MlirStringCallback callback, void *userData)

Same as mlirOperationPrint but accepts flags controlling the printing behavior.

bool mlirValueIsABlockArgument(MlirValue value)

Returns 1 if the value is a block argument, 0 otherwise.

MlirTypeID mlirTypeGetTypeID(MlirType type)

Gets the type ID of the type.

void mlirValueReplaceAllUsesOfWith(MlirValue oldValue, MlirValue newValue)

Replace all uses of 'of' value with the 'with' value, updating anything in the IR that uses 'of' to u...

MlirValue mlirBlockAddArgument(MlirBlock block, MlirType type, MlirLocation loc)

Appends an argument of the specified type to the block.

intptr_t mlirOperationGetNumRegions(MlirOperation op)

Returns the number of regions attached to the given operation.

MlirBlock mlirOperationGetBlock(MlirOperation op)

Gets the block that owns this operation, returning null if the operation is not owned.

void mlirContextAppendDialectRegistry(MlirContext ctx, MlirDialectRegistry registry)

Append the contents of the given dialect registry to the registry associated with the context.

MlirIdentifier mlirIdentifierGet(MlirContext context, MlirStringRef str)

Gets an identifier with the given string value.

void mlirBlockArgumentSetType(MlirValue value, MlirType type)

Sets the type of the block argument to the given type.

MlirLocation mlirLocationFileLineColGet(MlirContext context, MlirStringRef filename, unsigned line, unsigned col)

Creates an File/Line/Column location owned by the given context.

intptr_t mlirContextGetNumLoadedDialects(MlirContext context)

Returns the number of dialects loaded by the context.

MlirNamedAttribute mlirNamedAttributeGet(MlirIdentifier name, MlirAttribute attr)

Associates an attribute with the name. Takes ownership of neither.

MlirStringRef mlirSymbolTableGetVisibilityAttributeName()

Returns the name of the attribute used to store symbol visibility.

void mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n, MlirNamedAttribute const *attributes)

MlirValue mlirOperationGetResult(MlirOperation op, intptr_t pos)

Returns pos-th result of the operation.

bool mlirLocationIsACallSite(MlirLocation location)

Checks whether the given location is an CallSite.

void mlirSymbolTableWalkSymbolTables(MlirOperation from, bool allSymUsesVisible, void(*callback)(MlirOperation, bool, void *userData), void *userData)

Walks all symbol table operations nested within, and including, op.

void mlirContextLoadAllAvailableDialects(MlirContext context)

Eagerly loads all available dialects registered with a context, making them available for use for IR ...

MlirModule mlirModuleCreateParseFromFile(MlirContext context, MlirStringRef fileName)

Parses a module from file and transfers ownership to the caller.

void mlirAttributePrint(MlirAttribute attr, MlirStringCallback callback, void *userData)

Prints an attribute by sending chunks of the string representation and forwarding userData tocallback...

MlirBlock mlirRegionGetFirstBlock(MlirRegion region)

Gets the first block in the region.

MlirLogicalResult mlirSymbolTableReplaceAllSymbolUses(MlirStringRef oldSymbol, MlirStringRef newSymbol, MlirOperation from)

Attempt to replace all uses that are nested within the given operation of the given symbol 'oldSymbol...

MlirLocation mlirLocationFusedGet(MlirContext ctx, intptr_t nLocations, MlirLocation const *locations, MlirAttribute metadata)

Creates a fused location with an array of locations and metadata.

MlirAsmState mlirAsmStateCreateForValue(MlirValue value, MlirOpPrintingFlags flags)

Creates new AsmState from value.

intptr_t mlirOperationGetNumResults(MlirOperation op)

Returns the number of results of the operation.

MlirOpOperand mlirValueGetFirstUse(MlirValue value)

Returns an op operand representing the first use of the value, or a null op operand if there are no u...

void mlirRegionInsertOwnedBlockAfter(MlirRegion region, MlirBlock reference, MlirBlock block)

Takes a block owned by the caller and inserts it after the (non-owned) reference block in the given r...

void mlirOperationDestroy(MlirOperation op)

Takes an operation owned by the caller and destroys it.

void mlirValueReplaceAllUsesExcept(MlirValue oldValue, MlirValue newValue, intptr_t numExceptions, MlirOperation *exceptions)

Replace all uses of 'of' value with 'with' value, updating anything in the IR that uses 'of' to use '...

void mlirBlockAppendOwnedOperation(MlirBlock block, MlirOperation operation)

Takes an operation owned by the caller and appends it to the block.

MlirRegion mlirOperationGetFirstRegion(MlirOperation op)

Returns first region attached to the operation.

MlirAttribute mlirOperationGetInherentAttributeByName(MlirOperation op, MlirStringRef name)

Returns an inherent attribute attached to the operation given its name.

MlirDialect mlirContextGetOrLoadDialect(MlirContext context, MlirStringRef name)

Gets the dialect instance owned by the given context using the dialect namespace to identify it,...

MlirContext mlirAttributeGetContext(MlirAttribute attribute)

Gets the context that an attribute was created with.

MlirStringRef mlirSymbolTableGetSymbolAttributeName()

Returns the name of the attribute used to store symbol names compatible with symbol tables.

void mlirBlockInsertOwnedOperation(MlirBlock block, intptr_t pos, MlirOperation operation)

Takes an operation owned by the caller and inserts it as pos to the block.

MlirRegion mlirBlockGetParentRegion(MlirBlock block)

Returns the region that contains this block.

MlirType mlirValueGetType(MlirValue value)

Returns the type of the value.

void mlirOperationMoveAfter(MlirOperation op, MlirOperation other)

Moves the given operation immediately after the other operation in its parent block.

void mlirRegionAppendOwnedBlock(MlirRegion region, MlirBlock block)

Takes a block owned by the caller and appends it to the given region.

void mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData)

Prints a block by sending chunks of the string representation and forwarding userData tocallback`.

void mlirOperationSetDiscardableAttributeByName(MlirOperation op, MlirStringRef name, MlirAttribute attr)

Sets a discardable attribute by name, replacing the existing if it exists or adding a new one otherwi...

MlirOpPrintingFlags mlirOpPrintingFlagsCreate()

Creates new printing flags with defaults, intended for customization.

void mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags, intptr_t largeElementLimit)

Enables the elision of large elements attributes by printing a lexically valid but otherwise meaningl...

MlirBlock mlirBlockGetNextInRegion(MlirBlock block)

Returns the block immediately following the given block in its parent region.

void mlirOperationSetSuccessor(MlirOperation op, intptr_t pos, MlirBlock block)

Set pos-th successor of the operation.

MlirValue mlirOpOperandGetValue(MlirOpOperand opOperand)

Returns the value of an op operand.

#define APPEND_ELEMS(type, sizeName, elemName)

bool mlirContextIsRegisteredOperation(MlirContext context, MlirStringRef name)

Returns whether the given fully-qualified operation (i.e.

MlirOperation mlirOperationGetNextInBlock(MlirOperation op)

Returns an operation immediately following the given operation it its enclosing block.

void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool enable, bool prettyForm)

Enable or disable printing of debug information (based on enable).

MlirOperation mlirModuleGetOperation(MlirModule module)

Views the module as a generic operation.

static mlir::WalkResult unwrap(MlirWalkResult result)

void mlirOpPrintingFlagsElideLargeResourceString(MlirOpPrintingFlags flags, intptr_t largeResourceLimit)

Enables the elision of large resources strings by omitting them from the dialect_resources section.

void mlirRegionInsertOwnedBlockBefore(MlirRegion region, MlirBlock reference, MlirBlock block)

Takes a block owned by the caller and inserts it before the (non-owned) reference block in the given ...

MlirValue mlirBlockGetArgument(MlirBlock block, intptr_t pos)

Returns pos-th argument of the block.

unsigned mlirLocationFusedGetNumLocations(MlirLocation location)

Getter for number of locations fused together.

MlirStringRef mlirDialectGetNamespace(MlirDialect dialect)

Returns the namespace of the given dialect.

void mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags)

Use local scope when printing the operation.

MlirTypeID mlirOperationGetTypeID(MlirOperation op)

Gets the type id of the operation.

intptr_t mlirBlockArgumentGetArgNumber(MlirValue value)

Returns the position of the value in the argument list of its block.

void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback, void *userData, MlirWalkOrder walkOrder)

Walks operation op in walkOrder and calls callback on that operation.

MlirBlock mlirOperationGetSuccessor(MlirOperation op, intptr_t pos)

Returns pos-th successor of the operation.

void mlirBlockInsertOwnedOperationBefore(MlirBlock block, MlirOperation reference, MlirOperation operation)

Takes an operation owned by the caller and inserts it before the (non-owned) reference operation in t...

bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2)

Checks if two attributes are equal.

MlirAsmState mlirAsmStateCreateForOperation(MlirOperation op, MlirOpPrintingFlags flags)

Creates new AsmState, as with AsmState the IR should not be mutated in-between using this state.

bool mlirOperationEqual(MlirOperation op, MlirOperation other)

Checks whether two operation handles point to the same operation.

void mlirOperationSetInherentAttributeByName(MlirOperation op, MlirStringRef name, MlirAttribute attr)

Sets an inherent attribute by name, replacing the existing if it exists.

void mlirOpPrintingFlagsAssumeVerified(MlirOpPrintingFlags flags)

Do not verify the operation when using custom operation printers.

bool mlirValueEqual(MlirValue value1, MlirValue value2)

Returns 1 if two values are equal, 0 otherwise.

MlirContext mlirIdentifierGetContext(MlirIdentifier ident)

Returns the context associated with this identifier.

void mlirBytecodeWriterConfigDestroy(MlirBytecodeWriterConfig config)

Destroys printing flags created with mlirBytecodeWriterConfigCreate.

void mlirModuleDestroy(MlirModule module)

Takes a module owned by the caller and deletes it.

MlirModule mlirModuleCreateEmpty(MlirLocation location)

Creates a new, empty module and transfers ownership to the caller.

void mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags)

Always print operations in the generic form.

MlirOperation mlirOperationGetParentOperation(MlirOperation op)

Gets the operation that owns this operation, returning null if the operation is not owned.

void mlirRegionTakeBody(MlirRegion target, MlirRegion source)

Moves the entire content of the source region to the target region.

MlirLlvmThreadPool mlirContextGetThreadPool(MlirContext context)

Gets the thread pool of the context when enabled multithreading, otherwise an assertion is raised.

MlirValue mlirBlockInsertArgument(MlirBlock block, intptr_t pos, MlirType type, MlirLocation loc)

Inserts an argument of the specified type at a specified index to the block.

void mlirValueSetType(MlirValue value, MlirType type)

Set the type of the value.

intptr_t mlirOperationGetNumSuccessors(MlirOperation op)

Returns the number of successor blocks of the operation.

MlirDialect mlirAttributeGetDialect(MlirAttribute attr)

Gets the dialect of the attribute.

void mlirLocationPrint(MlirLocation location, MlirStringCallback callback, void *userData)

Prints a location by sending chunks of the string representation and forwarding userData tocallback`.

void mlirOperationSetAttributeByName(MlirOperation op, MlirStringRef name, MlirAttribute attr)

Sets an attribute by name, replacing the existing if it exists or adding a new one otherwise.

void mlirBlockDestroy(MlirBlock block)

Takes a block owned by the caller and destroys it.

void mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos, MlirBlock block)

Takes a block owned by the caller and inserts it at pos to the given region.

void mlirOperationSetOperand(MlirOperation op, intptr_t pos, MlirValue newValue)

Sets the pos-th operand of the operation.

intptr_t mlirBlockGetNumArguments(MlirBlock block)

Returns the number of arguments of the block.

MlirTypeID mlirLocationFileLineColRangeGetTypeID()

TypeID Getter for FileLineColRange.

MlirOperation mlirOpResultGetOwner(MlirValue value)

Returns an operation that produced this value as its result.

void mlirBlockEraseArgument(MlirBlock block, unsigned index)

Erase the argument at 'index' and remove it from the argument list.

bool mlirOpOperandIsNull(MlirOpOperand opOperand)

Returns whether the op operand is null.

MlirDialect mlirTypeGetDialect(MlirType type)

Gets the dialect a type belongs to.

MlirModule mlirModuleCreateParse(MlirContext context, MlirStringRef module)

Parses a module from the string and transfers ownership to the caller.

MlirContext mlirContextCreateWithRegistry(MlirDialectRegistry registry, bool threadingEnabled)

Creates an MLIR context, setting the multithreading setting explicitly and pre-loading the dialects f...

void mlirContextSetAllowUnregisteredDialects(MlirContext context, bool allow)

Sets whether unregistered dialects are allowed in this context.

void mlirOperationStateAddResults(MlirOperationState *state, intptr_t n, MlirType const *results)

Adds a list of components to the operation state.

void mlirOperationMoveBefore(MlirOperation op, MlirOperation other)

Moves the given operation immediately before the other operation in its parent block.

static LogicalResult inferOperationTypes(OperationState &state)

MlirOperation mlirOperationClone(MlirOperation op)

Creates a deep copy of an operation.

void mlirValuePrintAsOperand(MlirValue value, MlirAsmState state, MlirStringCallback callback, void *userData)

Prints a value as an operand (i.e., the ValueID).

MlirBlock mlirBlockArgumentGetOwner(MlirValue value)

Returns the block in which this value is defined as an argument.

MlirDialectRegistry mlirDialectRegistryCreate()

Creates a dialect registry and transfers its ownership to the caller.

MlirValue mlirOperationGetOperand(MlirOperation op, intptr_t pos)

Returns pos-th operand of the operation.

bool mlirContextGetAllowUnregisteredDialects(MlirContext context)

Returns whether the context allows unregistered dialects.

MlirAttribute mlirLocationGetAttribute(MlirLocation location)

Returns the underlying location attribute of this location.

MlirModule mlirModuleFromOperation(MlirOperation op)

Views the generic operation as a module.

MlirTypeID mlirLocationNameGetTypeID()

TypeID Getter for Name.

MlirLocation mlirOperationGetLocation(MlirOperation op)

Gets the location of the operation.

bool mlirTypeEqual(MlirType t1, MlirType t2)

Checks if two types are equal.

bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2)

Checks if two contexts are equal.

MlirAttribute mlirOperationGetAttributeByName(MlirOperation op, MlirStringRef name)

Returns an attribute attached to the operation given its name.

MlirTypeID mlirAttributeGetTypeID(MlirAttribute attr)

Gets the type id of the attribute.

static Operation * findParent(Operation *op, bool shouldUseLocalScope)

MlirAttribute mlirSymbolTableInsert(MlirSymbolTable symbolTable, MlirOperation operation)

Inserts the given operation into the given symbol table.

bool mlirLocationIsAFileLineColRange(MlirLocation location)

Checks whether the given location is an FileLineColRange.

intptr_t mlirOperationGetNumDiscardableAttributes(MlirOperation op)

Returns the number of discardable attributes attached to the operation.

MlirSymbolTable mlirSymbolTableCreate(MlirOperation operation)

Creates a symbol table for the given operation.

void mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n, MlirRegion const *regions)

MlirLocation mlirLocationUnknownGet(MlirContext context)

Creates a location with unknown position owned by the given context.

MlirLocation mlirLocationCallSiteGetCallee(MlirLocation location)

Getter for callee of CallSite.

MlirOperation mlirBlockGetFirstOperation(MlirBlock block)

Returns the first operation in the block.

MlirType mlirAttributeGetType(MlirAttribute attribute)

Gets the type of this attribute.

bool mlirOperationRemoveDiscardableAttributeByName(MlirOperation op, MlirStringRef name)

Removes a discardable attribute by name.

void mlirRegionDestroy(MlirRegion region)

Takes a region owned by the caller and destroys it.

bool mlirOperationRemoveAttributeByName(MlirOperation op, MlirStringRef name)

Removes an attribute by name.

bool mlirValueIsAOpResult(MlirValue value)

Returns 1 if the value is an operation result, 0 otherwise.

MLIR_CAPI_EXPORTED bool mlirOperationHasInherentAttributeByName(MlirOperation op, MlirStringRef name)

Returns true if this operation defines an inherent attribute with this name.

MlirContext mlirContextCreateWithThreading(bool threadingEnabled)

Creates an MLIR context with an explicit setting of the multithreading setting and transfers its owne...

MlirTypeID mlirLocationCallSiteGetTypeID()

TypeID Getter for CallSite.

MlirOperation mlirBlockGetTerminator(MlirBlock block)

Returns the terminator operation in the block or null if no terminator.

bool mlirLocationEqual(MlirLocation l1, MlirLocation l2)

Checks if two locations are equal.

MlirRegion mlirOperationGetRegion(MlirOperation op, intptr_t pos)

Returns pos-th region attached to the operation.

int mlirLocationFileLineColRangeGetEndColumn(MlirLocation location)

Getter for end_column of FileLineColRange.

MlirOperation mlirOperationCreate(MlirOperationState *state)

Creates an operation and transfers ownership to the caller.

unsigned mlirContextGetNumThreads(MlirContext context)

Gets the number of threads of the thread pool of the context when multithreading is enabled.

void mlirBytecodeWriterConfigDesiredEmitVersion(MlirBytecodeWriterConfig flags, int64_t version)

Sets the version to emit in the writer config.

int mlirLocationFileLineColRangeGetStartColumn(MlirLocation location)

Getter for start_column of FileLineColRange.

MlirAttribute mlirAttributeParseGet(MlirContext context, MlirStringRef attr)

Parses an attribute. The attribute is owned by the context.

void mlirLocationFusedGetLocations(MlirLocation location, MlirLocation *locationsCPtr)

Getter for locations of Fused.

void mlirOperationRemoveFromParent(MlirOperation op)

Removes the given operation from its parent block.

void mlirSymbolTableDestroy(MlirSymbolTable symbolTable)

Destroys the symbol table created with mlirSymbolTableCreate.

MlirContext mlirContextCreate()

Creates an MLIR context and transfers its ownership to the caller.

void mlirOperationPrintWithState(MlirOperation op, MlirAsmState state, MlirStringCallback callback, void *userData)

Same as mlirOperationPrint but accepts AsmState controlling the printing behavior as well as caching ...

bool mlirOperationVerify(MlirOperation op)

Verify the operation and return true if it passes, false if it fails.

void mlirBlockDetach(MlirBlock block)

Detach a block from the owning region and assume ownership.

int mlirLocationFileLineColRangeGetEndLine(MlirLocation location)

Getter for end_line of FileLineColRange.

MlirNamedAttribute mlirOperationGetAttribute(MlirOperation op, intptr_t pos)

Return pos-th attribute of the operation.

void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags)

Destroys printing flags created with mlirOpPrintingFlagsCreate.

MlirLocation mlirLocationCallSiteGet(MlirLocation callee, MlirLocation caller)

Creates a call site location with a callee and a caller.

void mlirOperationWriteBytecode(MlirOperation op, MlirStringCallback callback, void *userData)

Same as mlirOperationPrint but writing the bytecode format.

void mlirValueDump(MlirValue value)

Prints the value to the standard error stream.

void mlirBlockInsertOwnedOperationAfter(MlirBlock block, MlirOperation reference, MlirOperation operation)

Takes an operation owned by the caller and inserts it after the (non-owned) reference operation in th...

intptr_t mlirContextGetNumRegisteredDialects(MlirContext context)

Returns the number of dialects registered with the given context.

MlirTypeID mlirLocationFusedGetTypeID()

TypeID Getter for Fused.

void mlirOperationSetOperands(MlirOperation op, intptr_t nOperands, MlirValue const *operands)

Replaces the operands of the operation.

static MLIRContext::Threading toThreadingEnum(bool threadingEnabled)

MlirIdentifier mlirLocationFileLineColRangeGetFilename(MlirLocation location)

Getter for filename of FileLineColRange.

MlirContext mlirTypeGetContext(MlirType type)

Gets the context that a type was created with.

void mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData)

Prints a location by sending chunks of the string representation and forwarding userData tocallback`.

MlirBlock mlirModuleGetBody(MlirModule module)

Gets the body of the module, i.e. the only block it contains.

MlirContext mlirDialectGetContext(MlirDialect dialect)

Returns the context that owns the dialect.

bool mlirRegionEqual(MlirRegion region, MlirRegion other)

Checks whether two region handles point to the same region.

int mlirLocationFileLineColRangeGetStartLine(MlirLocation location)

Getter for start_line of FileLineColRange.

MlirOperation mlirOperationCreateParse(MlirContext context, MlirStringRef sourceStr, MlirStringRef sourceName)

Parses an operation, giving ownership to the caller.

MlirLocation mlirLocationCallSiteGetCaller(MlirLocation location)

Getter for caller of CallSite.

void mlirAsmStateDestroy(MlirAsmState state)

Destroys printing flags created with mlirAsmStateCreate.

MlirContext mlirOperationGetContext(MlirOperation op)

Gets the context this operation is associated with.

intptr_t mlirOpResultGetResultNumber(MlirValue value)

Returns the position of the value in the list of results of the operation that produced it.

MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name, MlirLocation childLoc)

Creates a name location owned by the given context.

MlirLocation mlirLocationFileLineColRangeGet(MlirContext context, MlirStringRef filename, unsigned startLine, unsigned startCol, unsigned endLine, unsigned endCol)

Creates an File/Line/Column range location owned by the given context.

bool mlirBlockEqual(MlirBlock block, MlirBlock other)

Checks whether two blocks handles point to the same block.

bool mlirLocationIsAFused(MlirLocation location)

Checks whether the given location is an Fused.

MlirAttribute mlirLocationFusedGetMetadata(MlirLocation location)

Getter for metadata of Fused.

void mlirSymbolTableErase(MlirSymbolTable symbolTable, MlirOperation operation)

Removes the given operation from the symbol table and erases it.

MlirLocation mlirLocationNameGetChildLoc(MlirLocation location)

Getter for childLoc of Name.

MlirNamedAttribute mlirOperationGetDiscardableAttribute(MlirOperation op, intptr_t pos)

Return pos-th discardable attribute of the operation.

void mlirOperationStateEnableResultTypeInference(MlirOperationState *state)

Enables result type inference for the operation under construction.

void mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n, MlirBlock const *successors)

MlirBytecodeWriterConfig mlirBytecodeWriterConfigCreate()

Creates new printing flags with defaults, intended for customization.

void mlirAttributeDump(MlirAttribute attr)

Prints the attribute to the standard error stream.

void mlirOpPrintingFlagsPrintNameLocAsPrefix(MlirOpPrintingFlags flags)

Print the name and location, if NamedLoc, as a prefix to the SSA ID.

MlirIdentifier mlirLocationNameGetName(MlirLocation location)

Getter for name of Name.

MlirStringRef mlirIdentifierStr(MlirIdentifier ident)

Gets the string value of the identifier.

void mlirOpPrintingFlagsSkipRegions(MlirOpPrintingFlags flags)

Skip printing regions.

void mlirOperationStateAddOperands(MlirOperationState *state, intptr_t n, MlirValue const *operands)

MlirOperationState mlirOperationStateGet(MlirStringRef name, MlirLocation loc)

Constructs an operation state from a name and a location.

MlirLocation mlirLocationFromAttribute(MlirAttribute attribute)

Creates a location from a location attribute.

MlirOperation mlirBlockGetParentOperation(MlirBlock block)

Returns the closest surrounding operation that contains this block.

MlirOpOperand mlirOpOperandGetNextUse(MlirOpOperand opOperand)

Returns an op operand representing the next use of the value, or a null op operand if there is no nex...

intptr_t mlirOperationGetNumOperands(MlirOperation op)

Returns the number of operands of the operation.

void mlirContextSetThreadPool(MlirContext context, MlirLlvmThreadPool threadPool)

Sets the thread pool of the context explicitly, enabling multithreading in the process.

MlirType mlirTypeParseGet(MlirContext context, MlirStringRef type)

Parses a type. The type is owned by the context.

MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType const *args, MlirLocation const *locs)

Creates a new empty block with the given argument types and transfers ownership to the caller.

void mlirContextEnableMultithreading(MlirContext context, bool enable)

Set threading mode (must be set to false to mlir-print-ir-after-all).

void mlirTypeDump(MlirType type)

Prints the type to the standard error stream.

intptr_t mlirOperationGetNumAttributes(MlirOperation op)

Returns the number of attributes attached to the operation.

MlirContext mlirValueGetContext(MlirValue v)

Gets the context that a value was created with.

static MLIRContext * getContext(OpFoldResult val)

static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)

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.

Block represents an ordered list of Operations.

OpListType::iterator iterator

Region * getParent() const

Provide a 'getParent' method for ilist_node_with_parent methods.

BlockArgument addArgument(Type type, Location loc)

Add one value to the argument list.

OpListType & getOperations()

This class contains the configuration used for the bytecode writer.

The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.

static FileLineColLoc get(StringAttr filename, unsigned line, unsigned column)

Location objects represent source locations information in MLIR.

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.

void reserve(size_type N)

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

StringAttr getName() const

Return the name of the attribute.

Attribute getValue() const

Return the value 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.

This class provides the API for ops that are known to be isolated from above.

This class provides the API for ops that are known to be terminators.

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

Operation is the basic unit of execution within MLIR.

bool hasTrait()

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

unsigned getNumRegions()

Returns the number of regions held by this operation.

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.

Operation * getParentOp()

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

Region & getRegion(unsigned index)

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

OpTy release()

Release the referenced op.

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

unsigned getRegionNumber()

Return the number of this region in the parent operation.

Operation * getParentOp()

Return the parent operation this region is attached to.

BlockListType & getBlocks()

BlockListType::iterator iterator

This class allows for representing and managing the symbol table used by operations with the 'SymbolT...

static StringRef getSymbolAttrName()

Return the name of the attribute used for symbol names.

static LogicalResult replaceAllSymbolUses(StringAttr oldSymbol, StringAttr newSymbol, Operation *from)

Attempt to replace all uses of the given symbol 'oldSymbol' with the provided symbol 'newSymbol' that...

static StringRef getVisibilityAttrName()

Return the name of the attribute used for symbol visibility.

static void walkSymbolTables(Operation *op, bool allSymUsesVisible, function_ref< void(Operation *, bool)> callback)

Walks all symbol table operations nested within, and including, op.

OperandType * getOperand() const

Returns the current operands.

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

bool use_empty() const

Returns true if this value has no uses.

void replaceAllUsesExcept(Value newValue, const SmallPtrSetImpl< Operation * > &exceptions)

Replace all uses of 'this' value with 'newValue', updating anything in the IR that uses 'this' to use...

void printAsOperand(raw_ostream &os, AsmState &state) const

Print this value as if it were an operand.

Location getLoc() const

Return the location of this value.

use_iterator use_begin() const

A utility result that is used to signal how to proceed with an ongoing walk:

static WalkResult advance()

static WalkResult interrupt()

A simple raw ostream subclass that forwards write_impl calls to the user-supplied callback together w...

MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)

MlirWalkResult(* MlirOperationWalkCallback)(MlirOperation, void *userData)

Operation walker type.

MlirWalkOrder

Traversal order for operation walk.

MlirWalkResult

Operation walk result.

@ MlirWalkResultInterrupt

static bool mlirBlockIsNull(MlirBlock block)

Checks whether a block is null.

static bool mlirLocationIsNull(MlirLocation location)

Checks if the location is null.

static bool mlirOperationIsNull(MlirOperation op)

Checks whether the underlying operation is null.

#define MLIR_CAPI_EXPORTED

void(* MlirStringCallback)(MlirStringRef, void *)

A callback for returning string references.

constexpr void enumerate(std::tuple< Tys... > &tuple, CallbackT &&callback)

Include the generated interface declarations.

Type getType(OpFoldResult ofr)

Returns the int type of the integer in ofr.

const FrozenRewritePatternSet GreedyRewriteConfig config

InFlightDiagnostic emitError(Location loc)

Utility method to emit an error message using this location.

Attribute parseAttribute(llvm::StringRef attrStr, MLIRContext *context, Type type={}, size_t *numRead=nullptr, bool isKnownNullTerminated=false)

This parses a single MLIR attribute to an MLIR context if it was valid.

LogicalResult parseSourceString(llvm::StringRef sourceStr, Block *block, const ParserConfig &config, StringRef sourceName="", LocationAttr *sourceFileLoc=nullptr)

This parses the IR string and appends parsed operations to the given block.

Operation * clone(OpBuilder &b, Operation *op, TypeRange newResultTypes, ValueRange newOperands)

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

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

Type parseType(llvm::StringRef typeStr, MLIRContext *context, size_t *numRead=nullptr, bool isKnownNullTerminated=false)

This parses a single MLIR type to an MLIR context if it was valid.

LogicalResult writeBytecodeToFile(Operation *op, raw_ostream &os, const BytecodeWriterConfig &config={})

Write the bytecode for the given operation to the provided output stream.

LogicalResult verify(Operation *op, bool verifyRecursively=true)

Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...

A logical result value, essentially a boolean with named states.

An auxiliary class for constructing operations.

A pointer to a sized fragment of a string, not necessarily null-terminated.

const char * data

Pointer to the first symbol.

size_t length

Length of the fragment.

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

void addOperands(ValueRange newOperands)

void addAttribute(StringRef name, Attribute attr)

Add an attribute with the specified name.

void addSuccessors(Block *successor)

Adds a successor to the operation sate. successor must not be null.

void addTypes(ArrayRef< Type > newTypes)

SmallVector< Type, 4 > types

Types of the results of this operation.

Region * addRegion()

Create a region that should be attached to the operation.