MLIR: include/mlir/IR/OpImplementation.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef MLIR_IR_OPIMPLEMENTATION_H
14#define MLIR_IR_OPIMPLEMENTATION_H
15
20#include "llvm/ADT/Twine.h"
21#include "llvm/Support/SMLoc.h"
22#include
23
24namespace {
25
26template <typename T, typename = void>
27struct HasStaticName : std::false_type {};
28
29template
30struct HasStaticName<T,
31 typename std::enable_if<
32 std::is_same<::llvm::StringLiteral,
33 std::decay_t<decltype(T::name)>>::value,
34 void>::type> : std::true_type {};
35}
36
37namespace mlir {
41
42
43
44
45
46
48public:
51 : resource(resource), opaqueID(resourceID), dialect(dialect) {}
53 return resource == other.resource;
54 }
55
56
58
59
61
62
64
65private:
66
67 void *resource = nullptr;
68
70
72};
73
74
75
76
77template <typename DerivedT, typename ResourceT, typename DialectT>
79public:
81
82
83
90
91
98
99
103
104
108};
109
113
114
115
116
117
118
119
121public:
122
123
125
126
129
130
132
133
134
135
136 virtual void printFloat(const APFloat &value);
137
138
139
140 template
141 std::enable_if_t<std::is_integral_v, void> printInteger(IntT value) {
142
143 if constexpr (std::is_same_v<IntT, int8_t> ||
144 std::is_same_v<IntT, uint8_t>) {
145 getStream() << static_cast<int>(value);
146 } else {
148 }
149 }
150
153
154
155 template
157 decltype(std::declval().print(std::declval<AsmPrinter &>()));
158 template
160 llvm::is_detected<has_print_method, AttrOrType>;
161
162
163
164
165 template <typename AttrOrType,
166 std::enable_if_t<detect_has_print_method::value>
167 *sfinae = nullptr>
169 if (succeeded(printAlias(attrOrType)))
170 return;
171
173 uint64_t posPrior = os.tell();
174 attrOrType.print(*this);
175 if (posPrior != os.tell())
176 return;
177
178
179
180 *this << attrOrType;
181 }
182
183
184
185
186
187 template <typename AttrOrType,
188 std::enable_if_t<detect_has_print_method::value>
189 *sfinae = nullptr>
191 llvm::interleaveComma(
194 }
195
196
197
198
199 template <typename AttrOrType,
200 std::enable_if_t<!detect_has_print_method::value>
201 *sfinae = nullptr>
203 *this << attrOrType;
204 }
205
206
207
209
210
212
213
214
216
217
218
220
221
222
224
225
226
227 virtual void printString(StringRef string);
228
229
230
231
232
234
235
236
238
239
240 template
242 if (types.begin() != types.end())
244 }
245 template
247 auto &os = getStream() << " -> ";
248
249 bool wrapped = !llvm::hasSingleElement(types) ||
250 llvm::isa((*types.begin()));
251 if (wrapped)
252 os << '(';
253 llvm::interleaveComma(types, *this);
254 if (wrapped)
255 os << ')';
256 }
257
258
259 template <typename InputRangeT, typename ResultRangeT>
262 os << '(';
263 llvm::interleaveComma(inputs, *this);
264 os << ')';
266 }
267
269
270
272 public:
274
276 if (printer)
277 printer->popCyclicPrinting();
278 }
279
281
283
285 : printer(std::exchange(rhs.printer, nullptr)) {}
286
288 printer = std::exchange(rhs.printer, nullptr);
289 return *this;
290 }
291
292 private:
294 };
295
296
297
298
299
300
301
302
303
304
305 template
307 static_assert(
308 std::is_base_of_v<AttributeTrait::IsMutable,
309 AttrOrTypeT> ||
310 std::is_base_of_v<TypeTrait::IsMutable, AttrOrTypeT>,
311 "Only mutable attributes or types can be cyclic");
313 return failure();
315 }
316
317protected:
318
319
321
322
323
324
325
327
328
329
330
332
333private:
335 void operator=(const AsmPrinter &) = delete;
336
337
339};
340
341template
342inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
343 AsmPrinterT &>
344operator<<(AsmPrinterT &p, Type type) {
345 p.printType(type);
346 return p;
347}
348
349template
350inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
351 AsmPrinterT &>
353 p.printAttribute(attr);
354 return p;
355}
356
357template
358inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
359 AsmPrinterT &>
360operator<<(AsmPrinterT &p, const APFloat &value) {
361 p.printFloat(value);
362 return p;
363}
364template
365inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
366 AsmPrinterT &>
367operator<<(AsmPrinterT &p, float value) {
368 return p << APFloat(value);
369}
370template
371inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
372 AsmPrinterT &>
373operator<<(AsmPrinterT &p, double value) {
374 return p << APFloat(value);
375}
376
377
378
379
380template <typename AsmPrinterT, typename T,
381 std::enable_if_t<!std::is_convertible<T &, Value &>::value &&
382 !std::is_convertible<T &, Type &>::value &&
383 !std::is_convertible<T &, Attribute &>::value &&
384 !std::is_convertible<T &, ValueRange>::value &&
385 !std::is_convertible<T &, APFloat &>::value &&
386 !llvm::is_one_of<T, bool, float, double>::value,
387 T> * = nullptr>
388inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
389 AsmPrinterT &>
390operator<<(AsmPrinterT &p, const T &other) {
391 p.getStream() << other;
392 return p;
393}
394
395template
396inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
397 AsmPrinterT &>
398operator<<(AsmPrinterT &p, bool value) {
399 return p << (value ? StringRef("true") : "false");
400}
401
402template <typename AsmPrinterT, typename ValueRangeT>
403inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
404 AsmPrinterT &>
406 llvm::interleaveComma(types, p);
407 return p;
408}
409
410template
411inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
412 AsmPrinterT &>
414 llvm::interleaveComma(types, p);
415 return p;
416}
417
418
419
420
421
422
423template <typename AsmPrinterT, typename T>
424inline std::enable_if_t<std::is_same<AsmPrinter, AsmPrinterT>::value &&
425 std::is_convertible<T &, ValueRange>::value,
426 AsmPrinterT &>
427operator<<(AsmPrinterT &p, const T &other) = delete;
428
429template <typename AsmPrinterT, typename ElementT>
430inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
431 AsmPrinterT &>
433 llvm::interleaveComma(types, p);
434 return p;
435}
436
437
438
439
440
441
442
444public:
447
448
450
451
452
454
455
457
458
460
461
462
463
464
465
468 bool omitType = false) = 0;
469
470
473
474
475 template
479
480
481 template
483 llvm::interleaveComma(llvm::make_range(it, end), getStream(),
485 }
486
487
489
490
493
494
495
496
497
500
501
502
503 virtual void
506
507
508
510
511
512
513
515
516
517
518
519
520
522 bool printBlockTerminators = true,
523 bool printEmptyBlock = false) = 0;
524
525
526
527
528
530
531
532
533
534
537
538
539
540
541
544
545
548};
549
550
555
556template <typename T,
557 std::enable_if_t<std::is_convertible<T &, ValueRange>::value &&
558 !std::is_convertible<T &, Value &>::value,
559 T> * = nullptr>
564
569
570
571
572
573
574
575
577public:
580
582
583
585
586
587
588
589
590
592 const Twine &message = {}) = 0;
593
594
595
597
598
599
605
606
607
608
610
611
612
613
614
615
617
618
620
621
623
624
626
627
629
630
632
633
635
636
638
639
641
642
644
645
647
648
650
651
653
654
656
657
659
660
662
663
665
666
668
669
671
672
674
675
677
678
680
681
683
684
686
687
689
690
692
693
695
696
698
699
703 return emitError(loc, "expected string");
705 }
706
707
709
710
712
713
715
716
718
719
721
722
724
725
727
728
730
731
733
734
736
737
739
740
742
743
745
746
747 virtual ParseResult parseFloat(const llvm::fltSemantics &semantics,
748 APFloat &result) = 0;
749
750
751 template
756 return emitError(loc, "expected integer value");
757 return *parseResult;
758 }
759
760
761 template
766 return emitError(loc, "expected decimal integer value");
767 return *parseResult;
768 }
769
770
773
774private:
775 template <typename IntT, typename ParseFn>
777 ParseFn &&parseFn) {
779 APInt uintResult;
781 if (!parseResult.has_value() || failed(*parseResult))
782 return parseResult;
783
784
785
786
788 (IntT)uintResult.sextOrTrunc(sizeof(IntT) * CHAR_BIT).getLimitedValue();
789 if (APInt(uintResult.getBitWidth(), result,
790 std::is_signed_v,
791 true) != uintResult)
792 return emitError(loc, "integer value too large");
794 }
795
796public:
797 template
799 return parseOptionalIntegerAndCheck(
801 }
802
803 template
805 return parseOptionalIntegerAndCheck(result, [&](APInt &result) {
807 });
808 }
809
810
811
813
815
817
819
821
823
825
827
829
831 };
832
833
834
835
836
837
838
839 virtual ParseResult
842 StringRef contextMessage = StringRef()) = 0;
843
844
845
846 ParseResult
850
851
852
853
854
855
856
857
858
859
860 template
862 public:
865 if (keyword && !keyword->empty())
866 this->keyword = *keyword;
867 else if (failed(parser.parseKeywordOrCompletion(&this->keyword)))
868 result = failure();
869 }
870
872 return Case(str, [&](StringRef, SMLoc) { return std::move(value); });
873 }
875 return Default([&](StringRef, SMLoc) { return std::move(value); });
876 }
877
878
879
880 template
881 std::enable_if_t<!std::is_convertible<FnT, ResultT>::value, KeywordSwitch &>
882 Case(StringLiteral str, FnT &&fn) {
883 if (result)
884 return *this;
885
886
887 if (keyword.empty())
888 parser.codeCompleteExpectedTokens(str);
889 else if (keyword == str)
890 result.emplace(std::move(fn(keyword, loc)));
891 return *this;
892 }
893 template
894 std::enable_if_t<!std::is_convertible<FnT, ResultT>::value, KeywordSwitch &>
896 if (!result)
897 result.emplace(fn(keyword, loc));
898 return *this;
899 }
900
901
902 bool hasValue() const { return result.has_value(); }
903
904
905 [[nodiscard]] operator ResultT() {
906 if (!result)
907 return parser.emitError(loc, "unexpected keyword: ") << keyword;
908 return std::move(*result);
909 }
910
911 private:
912
914
915
916 SMLoc loc;
917
918
919 StringRef keyword;
920
921
922 std::optional result;
923 };
924
925
929 virtual ParseResult parseKeyword(StringRef keyword, const Twine &msg) = 0;
930
931
935 return emitError(loc, "expected valid keyword");
937 }
938
939
941
942
944
945
946
947 virtual ParseResult
950
951
955 << "expected valid keyword or string";
957 }
958
959
961
962
963
964
965
966
967
968
969
970 template <typename T, typename... ParamsT>
971 auto getChecked(SMLoc loc, ParamsT &&...params) {
972 return T::getChecked([&] { return emitError(loc); },
973 std::forward(params)...);
974 }
975
976
977 template <typename T, typename... ParamsT>
980 std::forward(params)...);
981 }
982
983
984
985
986
987
989
990
991
996
997
998 template
1001
1002
1005 return failure();
1006
1007
1008 if (!(result = llvm::dyn_cast(attr)))
1009 return emitError(loc, "invalid kind of attribute specified");
1010
1012 }
1013
1014
1015
1020
1021
1022 template
1027
1028
1029
1030
1031 template
1035
1036
1039 return failure();
1040
1041
1042 result = llvm::dyn_cast(attr);
1044 return emitError(loc, "invalid kind of attribute specified");
1045
1048 }
1049
1050
1051 template
1052 using has_parse_method = decltype(AttrType::parse(std::declval<AsmParser &>(),
1053 std::declval()));
1054 template
1056
1057
1058
1059
1060
1061 template
1062 std::enable_if_t<detect_has_parse_method::value, ParseResult>
1066
1067
1071 result = AttrType::parse(*this, type);
1073 return failure();
1075 }))
1076 return failure();
1077
1078
1079 result = llvm::dyn_cast(attr);
1081 return emitError(loc, "invalid kind of attribute specified");
1082
1085 }
1086
1087
1088 template
1089 std::enable_if_t<!detect_has_parse_method::value, ParseResult>
1094
1095
1096
1097
1098 template
1099 std::enable_if_t<detect_has_parse_method::value, ParseResult>
1102
1103
1107 result = AttrType::parse(*this, type);
1109 }))
1110 return failure();
1111
1112
1113 result = llvm::dyn_cast(attr);
1115 return emitError(loc, "invalid kind of attribute specified");
1117 }
1118
1119
1120 template
1121 std::enable_if_t<!detect_has_parse_method::value, ParseResult>
1125
1126
1127
1129 Type type = {}) = 0;
1130
1131
1133 Type type = {}) = 0;
1134
1135
1137 Type type = {}) = 0;
1138
1139
1141 Type type = {}) = 0;
1142
1143
1144
1145 template
1147 StringRef attrName,
1150 }
1151
1152
1153
1154 template
1156 StringRef attrName,
1159 if (parseResult.has_value() && succeeded(*parseResult))
1161 return parseResult;
1162 }
1163
1164
1166
1167
1168
1169 virtual ParseResult
1171
1172
1174
1175
1176
1177 virtual ParseResult
1180
1181
1183
1184
1185
1186
1187
1188
1189
1193 << "expected valid '@'-identifier for symbol name";
1195 }
1196
1197
1198
1202 return failure();
1205 }
1206
1207
1208
1210
1211
1212
1218 }
1219 return failure();
1220 }
1221
1222
1223
1224
1225
1226
1227 template
1230
1231
1232 auto *dialect =
1234 if (!dialect) {
1236 << "dialect '" << ResourceT::Dialect::getDialectNamespace()
1237 << "' is unknown";
1238 }
1239
1240 FailureOr handle = parseResourceHandle(dialect);
1241 if (failed(handle))
1242 return failure();
1243 if (auto *result = dyn_cast(&*handle))
1244 return std::move(*result);
1245 return emitError(handleLoc) << "provided resource handle differs from the "
1246 "expected resource type";
1247 }
1248
1249
1250
1251
1252
1253
1255
1256
1257
1260
1261
1263
1264
1265 template
1268
1269
1272 return failure();
1273
1274
1275 result = llvm::dyn_cast(type);
1278 emitError(loc, "invalid kind of type specified");
1279 if constexpr (HasStaticName::value)
1280 diag << ": expected " << TypeT::name << ", but found " << type;
1281 return diag;
1282 }
1283
1285 }
1286
1287
1288 template
1290 decltype(TypeT::parse(std::declval<AsmParser &>()));
1291 template
1293 llvm::is_detected<type_has_parse_method, TypeT>;
1294
1295
1296
1297
1298 template
1299 std::enable_if_t<detect_type_has_parse_method::value, ParseResult>
1302
1303
1306 result = TypeT::parse(*this);
1308 }))
1309 return failure();
1310
1311
1312 result = llvm::dyn_cast(type);
1315 emitError(loc, "invalid kind of type specified");
1316 if constexpr (HasStaticName::value)
1317 diag << ": expected " << TypeT::name << ", but found " << type;
1318 return diag;
1319 }
1321 }
1322
1323
1324 template
1325 std::enable_if_t<!detect_type_has_parse_method::value, ParseResult>
1329
1330
1332
1333
1335
1336
1337 virtual ParseResult
1339
1340
1342
1343
1344 template
1347
1348
1351 return failure();
1352
1353
1354 result = llvm::dyn_cast(type);
1357 emitError(loc, "invalid kind of type specified");
1358 if constexpr (HasStaticName::value)
1359 diag << ": expected " << TypeType::name << ", but found " << type;
1360 return diag;
1361 }
1362
1364 }
1365
1366
1368
1369
1370
1371 virtual ParseResult
1373
1374
1378
1379
1380
1381
1383 result.push_back(type);
1385 }
1386
1387
1388
1389
1392 result.append(types.begin(), types.end());
1394 }
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1410 bool allowDynamic = true,
1411 bool withTrailingX = true) = 0;
1412
1413
1414
1415
1417
1418
1420 public:
1422
1424 if (parser)
1425 parser->popCyclicParsing();
1426 }
1427
1431 : parser(std::exchange(rhs.parser, nullptr)) {}
1433 parser = std::exchange(rhs.parser, nullptr);
1434 return *this;
1435 }
1436
1437 private:
1439 };
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449 template
1451 static_assert(
1452 std::is_base_of_v<AttributeTrait::IsMutable,
1453 AttrOrTypeT> ||
1454 std::is_base_of_v<TypeTrait::IsMutable, AttrOrTypeT>,
1455 "Only mutable attributes or types can be cyclic");
1457 return failure();
1458
1460 }
1461
1462protected:
1463
1464
1465 virtual FailureOr
1467
1468
1469
1470
1471
1473
1474
1475
1476
1478
1479
1480
1481
1482
1483
1484
1486
1487
1489
1490private:
1492 void operator=(const AsmParser &) = delete;
1493};
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1515public:
1518
1519
1520
1521
1522
1523 virtual ParseResult
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537 virtual std::pair<StringRef, unsigned>
1539
1540
1541
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1555
1556
1557
1559
1560
1561
1562
1563
1564
1570
1571
1572
1573
1574
1575
1579 std::nullopt,
1580 std::optional<ArrayRef<Block *>> parsedSuccessors = std::nullopt,
1581 std::optional<MutableArrayRef<std::unique_ptr>> parsedRegions =
1582 std::nullopt,
1584 std::optional parsedPropertiesAttribute = std::nullopt,
1585 std::optional parsedFnType = std::nullopt) = 0;
1586
1587
1588
1590 bool allowResultNumber = true) = 0;
1591
1592
1595 bool allowResultNumber = true) = 0;
1596
1597
1598
1599 virtual ParseResult
1602 bool allowResultNumber = true,
1603 int requiredOperandCount = -1) = 0;
1604
1605
1607 int requiredOperandCount,
1610 true, requiredOperandCount);
1611 }
1612
1613
1614
1615
1616
1617 ParseResult
1624
1625
1629
1630
1631
1632
1633 template <typename Operands = ArrayRef>
1638 return failure();
1640 }
1641 template <typename Operands = ArrayRef>
1646
1647
1648
1649
1650 template <typename Operands = ArrayRef,
1651 typename Types = ArrayRef>
1652 std::enable_if_t<!std::is_convertible<Types, Type>::value, ParseResult>
1655 size_t operandSize = llvm::range_size(operands);
1656 size_t typeSize = llvm::range_size(types);
1657 if (operandSize != typeSize) {
1658
1660 << "number of operands and types do not match: got " << operandSize
1661 << " operands and " << typeSize << " types";
1662 }
1663
1664 for (auto [operand, type] : llvm::zip_equal(operands, types))
1666 return failure();
1668 }
1669
1670
1671
1672
1673 virtual ParseResult
1675 Attribute &map, StringRef attrName,
1678
1679
1680
1681
1682 virtual ParseResult
1686
1687
1688
1689
1690
1697
1698
1699
1700
1701
1702
1703
1705 bool allowAttrs = false) = 0;
1706
1707
1710 bool allowAttrs = false) = 0;
1711
1712
1715 bool allowType = false,
1716 bool allowAttrs = false) = 0;
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1732 bool enableNameShadowing = false) = 0;
1733
1734
1737 bool enableNameShadowing = false) = 0;
1738
1739
1740
1741
1745 bool enableNameShadowing = false) = 0;
1746
1747
1748
1749
1750
1751
1753
1754
1756
1757
1758 virtual ParseResult
1760
1761
1762
1763
1764
1765
1766
1770 if (.has_value())
1772 return result.value();
1773 }
1774
1778};
1779
1780
1781
1782
1783
1786public:
1788
1790
1791
1792
1793
1794
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810 virtual FailureOr
1812 return failure();
1813 }
1814
1815
1816
1817 virtual std::string
1819 llvm_unreachable(
1820 "Dialect must implement `getResourceKey` when defining resources");
1821 }
1822
1823
1824
1825
1827
1828
1829
1830
1831
1832 virtual void
1836};
1837
1838
1839
1840
1841
1842
1844 ArrayRef<int64_t> dimensions);
1847
1848}
1849
1850
1851
1852
1853
1854
1855#include "mlir/IR/OpAsmOpInterface.h.inc"
1856
1857namespace llvm {
1858template <>
1873 return lhs.getResource() == rhs.getResource();
1874 }
1875};
1876}
1877
1878#endif
static std::string diag(const llvm::Value &value)
Base type for affine expression.
A multi-dimensional affine map Affine map's are immutable like Type's, and they are uniqued.
@ NoAlias
The two locations do not alias at all.
AsmDialectResourceHandleBase(AsmDialectResourceHandle handle)
Definition OpImplementation.h:86
const ResourceT * getResource() const
Definition OpImplementation.h:95
static bool classof(const AsmDialectResourceHandle *handle)
Support llvm style casting.
Definition OpImplementation.h:105
AsmDialectResourceHandleBase(ResourceT *resource, DialectT *dialect)
Construct a handle from a pointer to the resource.
Definition OpImplementation.h:84
ResourceT * getResource()
Return the resource referenced by this handle.
Definition OpImplementation.h:92
DialectT Dialect
Definition OpImplementation.h:80
DialectT * getDialect() const
Return the dialect that owns the resource.
Definition OpImplementation.h:100
This class represents an opaque handle to a dialect resource entry.
Definition OpImplementation.h:47
AsmDialectResourceHandle()=default
TypeID getTypeID() const
Return the type ID of the resource.
Definition OpImplementation.h:60
Dialect * getDialect() const
Return the dialect that owns the resource.
Definition OpImplementation.h:63
void * getResource() const
Return an opaque pointer to the referenced resource.
Definition OpImplementation.h:57
bool operator==(const AsmDialectResourceHandle &other) const
Definition OpImplementation.h:52
AsmDialectResourceHandle(void *resource, TypeID resourceID, Dialect *dialect)
Definition OpImplementation.h:50
This class represents a single parsed resource entry.
Class used to automatically end a cyclic region on destruction.
Definition OpImplementation.h:1419
CyclicParseReset & operator=(CyclicParseReset &&rhs)
Definition OpImplementation.h:1432
CyclicParseReset(const CyclicParseReset &)=delete
CyclicParseReset & operator=(const CyclicParseReset &)=delete
~CyclicParseReset()
Definition OpImplementation.h:1423
CyclicParseReset(AsmParser *parser)
Definition OpImplementation.h:1421
CyclicParseReset(CyclicParseReset &&rhs)
Definition OpImplementation.h:1430
This class represents a StringSwitch like class that is useful for parsing expected keywords.
Definition OpImplementation.h:861
std::enable_if_t<!std::is_convertible< FnT, ResultT >::value, KeywordSwitch & > Default(FnT &&fn)
Definition OpImplementation.h:895
std::enable_if_t<!std::is_convertible< FnT, ResultT >::value, KeywordSwitch & > Case(StringLiteral str, FnT &&fn)
Case that invokes the provided functor when true.
Definition OpImplementation.h:882
bool hasValue() const
Returns true if this switch has a value yet.
Definition OpImplementation.h:902
KeywordSwitch & Default(ResultT value)
Definition OpImplementation.h:874
KeywordSwitch & Case(StringLiteral str, ResultT value)
Case that uses the provided value when true.
Definition OpImplementation.h:871
KeywordSwitch(AsmParser &parser, StringRef *keyword=nullptr)
Definition OpImplementation.h:863
virtual ParseResult parseMinus()=0
Parse a '-' token.
llvm::is_detected< has_parse_method, AttrType > detect_has_parse_method
Definition OpImplementation.h:1055
ParseResult parseSymbolName(StringAttr &result)
Parse an -identifier and store it (without the '@' symbol) in a string attribute.
Definition OpImplementation.h:1190
std::enable_if_t< detect_has_parse_method< AttrType >::value, ParseResult > parseCustomAttributeWithFallback(AttrType &result, Type type={})
Parse a custom attribute of a given type unless the next token is #, in which case the generic parser...
Definition OpImplementation.h:1100
virtual ParseResult parseLBrace()=0
Parse a { token.
Delimiter
These are the supported delimiters around operand lists and region argument lists,...
Definition OpImplementation.h:812
@ Paren
Parens surrounding zero or more operands.
Definition OpImplementation.h:816
@ None
Zero or more operands with no delimiters.
Definition OpImplementation.h:814
@ OptionalLessGreater
<> brackets supporting zero or more ops, or nothing.
Definition OpImplementation.h:828
@ Braces
{} brackets surrounding zero or more operands.
Definition OpImplementation.h:822
@ OptionalBraces
{} brackets surrounding zero or more operands, or nothing.
Definition OpImplementation.h:830
@ OptionalParen
Parens supporting zero or more operands, or nothing.
Definition OpImplementation.h:824
@ Square
Square brackets surrounding zero or more operands.
Definition OpImplementation.h:818
@ LessGreater
<> brackets surrounding zero or more operands.
Definition OpImplementation.h:820
@ OptionalSquare
Square brackets supporting zero or more ops, or nothing.
Definition OpImplementation.h:826
decltype(TypeT::parse(std::declval< AsmParser & >())) type_has_parse_method
Trait to check if TypeT provides a parse method.
Definition OpImplementation.h:1289
virtual OptionalParseResult parseOptionalInteger(APInt &result)=0
Parse an optional integer value from the stream.
virtual ParseResult parseColonTypeList(SmallVectorImpl< Type > &result)=0
Parse a colon followed by a type list, which must have at least one type.
virtual ParseResult parseIntegerSet(IntegerSet &set)=0
Parse an integer set instance into 'set'.
virtual ParseResult parseOptionalKeywordOrString(std::string *result)=0
Parse an optional keyword or string.
virtual ParseResult parseOptionalSymbolName(StringAttr &result)=0
Parse an optional -identifier and store it (without the '@' symbol) in a string attribute.
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
virtual ParseResult parseOptionalRBrace()=0
Parse a } token if present.
ParseResult parseDecimalInteger(IntT &result)
Parse a decimal integer value from the stream.
Definition OpImplementation.h:762
virtual ParseResult parseOptionalMinus()=0
Parse a '-' token if present.
virtual ParseResult parsePlus()=0
Parse a '+' token.
ParseResult parseKeyword(StringRef *keyword)
Parse a keyword into 'keyword'.
Definition OpImplementation.h:932
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
virtual void popCyclicParsing()=0
Removes the element that was last inserted with a successful call to pushCyclicParsing.
virtual ParseResult parseOptionalAttrDict(NamedAttrList &result)=0
Parse a named dictionary into 'result' if it is present.
virtual ParseResult parseOptionalEqual()=0
Parse a = token if present.
decltype(AttrType::parse(std::declval< AsmParser & >(), std::declval< Type >())) has_parse_method
Trait to check if AttrType provides a parse method.
Definition OpImplementation.h:1052
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
virtual OptionalParseResult parseOptionalType(Type &result)=0
Parse an optional type.
MLIRContext * getContext() const
virtual Location getEncodedSourceLoc(SMLoc loc)=0
Re-encode the given source location as an MLIR location and return it.
virtual ParseResult parseRParen()=0
Parse a ) token.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual ParseResult parseOptionalColon()=0
Parse a : token if present.
virtual ParseResult parseLSquare()=0
Parse a [ token.
virtual ParseResult parseRSquare()=0
Parse a ] token.
virtual ParseResult parseOptionalColonTypeList(SmallVectorImpl< Type > &result)=0
Parse an optional colon followed by a type list, which if present must have at least one type.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
Definition OpImplementation.h:752
virtual ParseResult parseOptionalArrow()=0
Parse a '->' token if present.
ParseResult parseOptionalSymbolName(StringAttr &result, StringRef attrName, NamedAttrList &attrs)
Parse an optional -identifier and store it (without the '@' symbol) in a string attribute named 'attr...
Definition OpImplementation.h:1213
virtual OptionalParseResult parseOptionalDecimalInteger(APInt &result)=0
ParseResult parseAttribute(AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
Parse an arbitrary attribute of a given type and populate it in result.
Definition OpImplementation.h:1032
ParseResult parseAttribute(AttrType &result, Type type={})
Parse an attribute of a specific kind and type.
Definition OpImplementation.h:999
ParseResult parseKeywordOrString(std::string *result)
Parse a keyword or a quoted string.
Definition OpImplementation.h:952
virtual void codeCompleteExpectedTokens(ArrayRef< StringRef > tokens)=0
Signal the code completion of a set of expected tokens.
virtual ParseResult parseRBrace()=0
Parse a } token.
virtual ParseResult parseAffineMap(AffineMap &map)=0
Parse an affine map instance into 'map'.
ParseResult addTypeToList(Type type, SmallVectorImpl< Type > &result)
Add the specified type to the end of the specified type list and return success.
Definition OpImplementation.h:1382
virtual ParseResult parseOptionalRParen()=0
Parse a ) token if present.
virtual ParseResult parseCustomAttributeWithFallback(Attribute &result, Type type, function_ref< ParseResult(Attribute &result, Type type)> parseAttribute)=0
Parse a custom attribute with the provided callback, unless the next token is #, in which case the ge...
virtual ParseResult parseLess()=0
Parse a '<' token.
virtual ParseResult parseDimensionList(SmallVectorImpl< int64_t > &dimensions, bool allowDynamic=true, bool withTrailingX=true)=0
Parse a dimension list of a tensor or memref type.
ParseResult parseString(std::string *string)
Parse a quoted string token.
Definition OpImplementation.h:700
virtual ParseResult parseOptionalPlus()=0
Parse a '+' token if present.
virtual ParseResult parseOptionalKeyword(StringRef *keyword, ArrayRef< StringRef > allowedValues)=0
Parse a keyword, if present, and if one of the 'allowedValues', into 'keyword'.
virtual ParseResult parseOptionalGreater()=0
Parse a '>' token if present.
std::enable_if_t<!detect_has_parse_method< AttrType >::value, ParseResult > parseCustomAttributeWithFallback(AttrType &result, Type type={})
SFINAE parsing method for Attribute that don't implement a parse method.
Definition OpImplementation.h:1122
virtual ParseResult parseEqual()=0
Parse a = token.
virtual ParseResult parseCustomTypeWithFallback(Type &result, function_ref< ParseResult(Type &result)> parseType)=0
Parse a custom type with the provided callback, unless the next token is #, in which case the generic...
virtual ParseResult parseFloat(const llvm::fltSemantics &semantics, APFloat &result)=0
Parse a floating point value into APFloat from the stream.
virtual OptionalParseResult parseOptionalAttribute(ArrayAttr &result, Type type={})=0
Parse an optional array attribute and return it in result.
virtual ParseResult parseStar()=0
Parse a '*' token.
virtual ParseResult parseOptionalAttrDictWithKeyword(NamedAttrList &result)=0
Parse a named dictionary into 'result' if the attributes keyword is present.
virtual ParseResult parseColonType(Type &result)=0
Parse a colon followed by a type.
virtual OptionalParseResult parseOptionalAttribute(Attribute &result, Type type={})=0
Parse an arbitrary optional attribute of a given type and return it in result.
virtual ParseResult parseSlash()=0
Parse a '/' token.
ParseResult parseCommaSeparatedList(function_ref< ParseResult()> parseElementFn)
Parse a comma separated list of elements that must have at least one entry in it.
Definition OpImplementation.h:847
virtual ParseResult parseVerticalBar()=0
Parse a '|' token.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
virtual ParseResult parseOptionalComma()=0
Parse a , token if present.
std::enable_if_t<!detect_type_has_parse_method< TypeT >::value, ParseResult > parseCustomTypeWithFallback(TypeT &result)
SFINAE parsing method for Type that don't implement a parse method.
Definition OpImplementation.h:1326
OptionalParseResult parseOptionalAttribute(AttrType &result, StringRef attrName, NamedAttrList &attrs)
Parse an optional attribute of a specific type and add it to the list with the specified name.
Definition OpImplementation.h:1146
auto getChecked(SMLoc loc, ParamsT &&...params)
Invoke the getChecked method of the given Attribute or Type class, using the provided location to emi...
Definition OpImplementation.h:971
std::enable_if_t< detect_type_has_parse_method< TypeT >::value, ParseResult > parseCustomTypeWithFallback(TypeT &result)
Parse a custom Type of a given type unless the next token is #, in which case the generic parser is i...
Definition OpImplementation.h:1300
virtual ParseResult parseColon()=0
Parse a : token.
ParseResult addTypesToList(ArrayRef< Type > types, SmallVectorImpl< Type > &result)
Add the specified types to the end of the specified type list and return success.
Definition OpImplementation.h:1390
ParseResult parseAttribute(Attribute &result, StringRef attrName, NamedAttrList &attrs)
Parse an arbitrary attribute and return it in result.
Definition OpImplementation.h:1016
FailureOr< ResourceT > parseResourceHandle()
Parse a handle to a resource within the assembly format.
Definition OpImplementation.h:1228
virtual OptionalParseResult parseOptionalAttribute(StringAttr &result, Type type={})=0
Parse an optional string attribute and return it in result.
llvm::is_detected< type_has_parse_method, TypeT > detect_type_has_parse_method
Definition OpImplementation.h:1292
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
virtual ParseResult parseOptionalString(std::string *string)=0
Parse a quoted string token if present.
std::enable_if_t< detect_has_parse_method< AttrType >::value, ParseResult > parseCustomAttributeWithFallback(AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
Parse a custom attribute of a given type unless the next token is #, in which case the generic parser...
Definition OpImplementation.h:1063
OptionalParseResult parseOptionalInteger(IntT &result)
Definition OpImplementation.h:798
ParseResult getCurrentLocation(SMLoc *loc)
Definition OpImplementation.h:601
virtual ParseResult parseOptionalLess()=0
Parse a '<' token if present.
virtual ParseResult parseOptionalStar()=0
Parse a '*' token if present.
OptionalParseResult parseOptionalAttribute(AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
Parse an optional attribute of a specific type and add it to the list with the specified name.
Definition OpImplementation.h:1155
virtual OptionalParseResult parseOptionalAttribute(SymbolRefAttr &result, Type type={})=0
Parse an optional symbol ref attribute and return it in result.
virtual ParseResult parseQuestion()=0
Parse a '?' token.
virtual ParseResult parseOptionalSlash()=0
Parse a '/' token if present.
ParseResult parseType(TypeT &result)
Parse a type of a specific type.
Definition OpImplementation.h:1266
FailureOr< CyclicParseReset > tryStartCyclicParse(AttrOrTypeT attrOrType)
Attempts to start a cyclic parsing region for attrOrType.
Definition OpImplementation.h:1450
virtual ParseResult parseOptionalRSquare()=0
Parse a ] token if present.
virtual ParseResult parseArrow()=0
Parse a '->' token.
ParseResult parseColonType(TypeType &result)
Parse a colon followed by a type of a specific kind, e.g. a FunctionType.
Definition OpImplementation.h:1345
virtual ParseResult parseGreater()=0
Parse a '>' token.
OptionalParseResult parseOptionalDecimalInteger(IntT &result)
Definition OpImplementation.h:804
virtual ParseResult parseLParen()=0
Parse a ( token.
virtual ParseResult parseOptionalEllipsis()=0
Parse a ... token if present;.
virtual ParseResult parseType(Type &result)=0
Parse a type.
ParseResult parseAttribute(AttrType &result, StringRef attrName, NamedAttrList &attrs)
Parse an attribute of a specific kind and type.
Definition OpImplementation.h:1023
virtual FailureOr< AsmDialectResourceHandle > parseResourceHandle(Dialect *dialect)=0
Parse a handle to a resource within the assembly format for the given dialect.
virtual ParseResult parseEllipsis()=0
Parse a ... token.
auto getChecked(ParamsT &&...params)
A variant of getChecked that uses the result of getNameLoc to emit errors.
Definition OpImplementation.h:978
virtual ParseResult parseComma()=0
Parse a , token.
virtual ParseResult parseOptionalArrowTypeList(SmallVectorImpl< Type > &result)=0
Parse an optional arrow followed by a type list.
virtual ParseResult parseOptionalLParen()=0
Parse a ( token if present.
ParseResult parseKeywordType(const char *keyword, Type &result)
Parse a keyword followed by a type.
Definition OpImplementation.h:1375
virtual ParseResult parseArrowTypeList(SmallVectorImpl< Type > &result)=0
Parse an arrow followed by a type list.
virtual ParseResult parseOptionalVerticalBar()=0
Parse a '|' token if present.
ParseResult parseTypeList(SmallVectorImpl< Type > &result)
Parse a type list.
virtual ParseResult parseBase64Bytes(std::vector< char > *bytes)=0
Parses a Base64 encoded string of bytes.
virtual ParseResult parseAffineExpr(ArrayRef< std::pair< StringRef, AffineExpr > > symbolSet, AffineExpr &expr)=0
Parse an affine expr instance into 'expr' using the already computed mapping from symbols to affine e...
virtual ParseResult parseKeywordOrCompletion(StringRef *keyword)=0
Parse a keyword, or an empty string if the current location signals a code completion.
virtual ParseResult parseFloat(double &result)=0
Parse a floating point value from the stream.
ParseResult parseSymbolName(StringAttr &result, StringRef attrName, NamedAttrList &attrs)
Parse an -identifier and store it (without the '@' symbol) in a string attribute named 'attrName'.
Definition OpImplementation.h:1199
virtual ParseResult parseOptionalKeyword(StringRef *keyword)=0
Parse a keyword, if present, into 'keyword'.
ParseResult parseKeyword(StringRef keyword)
Parse a given keyword.
Definition OpImplementation.h:926
virtual ParseResult parseOptionalLSquare()=0
Parse a [ token if present.
virtual LogicalResult pushCyclicParsing(const void *opaquePointer)=0
Pushes a new attribute or type in the form of a type erased pointer into an internal set.
std::enable_if_t<!detect_has_parse_method< AttrType >::value, ParseResult > parseCustomAttributeWithFallback(AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
SFINAE parsing method for Attribute that don't implement a parse method.
Definition OpImplementation.h:1090
virtual ParseResult parseOptionalQuestion()=0
Parse a '?' token if present.
virtual ParseResult parseAttribute(Attribute &result, Type type={})=0
Parse an arbitrary attribute of a given type and return it in result.
virtual ParseResult parseXInDimensionList()=0
Parse an 'x' token in a dimension list, handling the case where the x is juxtaposed with an element t...
virtual ParseResult parseOptionalLBrace()=0
Parse a { token if present.
virtual ParseResult parseKeyword(StringRef keyword, const Twine &msg)=0
Class used to automatically end a cyclic region on destruction.
Definition OpImplementation.h:271
CyclicPrintReset(AsmPrinter *printer)
Definition OpImplementation.h:273
CyclicPrintReset & operator=(CyclicPrintReset &&rhs)
Definition OpImplementation.h:287
CyclicPrintReset & operator=(const CyclicPrintReset &)=delete
~CyclicPrintReset()
Definition OpImplementation.h:275
CyclicPrintReset(const CyclicPrintReset &)=delete
CyclicPrintReset(CyclicPrintReset &&rhs)
Definition OpImplementation.h:284
void printStrippedAttrOrType(ArrayRef< AttrOrType > attrOrTypes)
Print the provided array of attributes or types in the context of an operation custom printer/parser:...
Definition OpImplementation.h:190
decltype(std::declval< AttrOrType >().print(std::declval< AsmPrinter & >())) has_print_method
Trait to check if AttrType provides a print method.
Definition OpImplementation.h:156
virtual void printAttributeWithoutType(Attribute attr)
Print the given attribute without its type.
virtual LogicalResult printAlias(Attribute attr)
Print the alias for the given attribute, return failure if no alias could be printed.
virtual void popCyclicPrinting()
Removes the element that was last inserted with a successful call to pushCyclicPrinting.
AsmPrinter()=default
Initialize the printer with no internal implementation.
void printFunctionalType(InputRangeT &&inputs, ResultRangeT &&results)
Print the two given type ranges in a functional form.
Definition OpImplementation.h:260
virtual LogicalResult pushCyclicPrinting(const void *opaquePointer)
Pushes a new attribute or type in the form of a type erased pointer into an internal set.
virtual void printType(Type type)
virtual void printKeywordOrString(StringRef keyword)
Print the given string as a keyword, or a quoted and escaped string if it has any special or non-prin...
virtual void printSymbolName(StringRef symbolRef)
Print the given string as a symbol reference, i.e.
virtual void printString(StringRef string)
Print the given string as a quoted string, escaping any special or non-printable characters in it.
std::enable_if_t< std::is_integral_v< IntT >, void > printInteger(IntT value)
Print the given integer value.
Definition OpImplementation.h:141
FailureOr< CyclicPrintReset > tryStartCyclicPrint(AttrOrTypeT attrOrType)
Attempts to start a cyclic printing region for attrOrType.
Definition OpImplementation.h:306
void printOptionalArrowTypeList(TypeRange &&types)
Print an optional arrow followed by a type list.
Definition OpImplementation.h:241
llvm::is_detected< has_print_method, AttrOrType > detect_has_print_method
Definition OpImplementation.h:159
virtual void printAttribute(Attribute attr)
void printDimensionList(ArrayRef< int64_t > shape)
void printArrowTypeList(TypeRange &&types)
Definition OpImplementation.h:246
virtual raw_ostream & getStream() const
Return the raw output stream used by this printer.
virtual void printResourceHandle(const AsmDialectResourceHandle &resource)
Print a handle to the given dialect resource.
virtual void printFloat(const APFloat &value)
Print the given floating point value in a stabilized form that can be roundtripped through the IR.
virtual void printNamedAttribute(NamedAttribute attr)
Print the given named attribute.
void printStrippedAttrOrType(AttrOrType attrOrType)
Print the provided attribute in the context of an operation custom printer/parser: this will invoke d...
Definition OpImplementation.h:168
AsmPrinter(Impl &impl)
Initialize the printer with the given internal implementation.
Definition OpImplementation.h:127
This class is used to build resource entries for use by the printer.
Attributes are known-constant values of operations.
This class represents an argument of a Block.
Block represents an ordered list of Operations.
OpListType::iterator iterator
This class is a general helper class for creating context-global objects like types,...
detail::DialectInterfaceBase< ConcreteType, DialectInterface > Base
The base class used for all derived interface types.
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
This class represents a diagnostic that is inflight and set to be reported.
An integer set representing a conjunction of one or more affine equalities and inequalities.
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.
T * getOrLoadDialect()
Get (or create) a dialect for the given derived dialect type.
NamedAttrList is array of NamedAttributes that tracks whether it is sorted and does some basic work t...
void append(StringRef name, Attribute attr)
Add an attribute with the specified name.
NamedAttribute represents a combination of a name and an Attribute value.
virtual void buildResources(Operation *op, const SetVector< AsmDialectResourceHandle > &referencedResources, AsmResourceBuilder &builder) const
Hook for building resources to use during printing.
Definition OpImplementation.h:1833
virtual AliasResult getAlias(Attribute attr, raw_ostream &os) const
Hooks for getting an alias identifier alias for a given symbol, that is not necessarily a part of thi...
Definition OpImplementation.h:1795
OpAsmDialectInterface(Dialect *dialect)
Definition OpImplementation.h:1787
virtual AliasResult getAlias(Type type, raw_ostream &os) const
Definition OpImplementation.h:1798
OpAsmAliasResult AliasResult
Definition OpImplementation.h:1789
virtual std::string getResourceKey(const AsmDialectResourceHandle &handle) const
Return a key to use for the given resource.
Definition OpImplementation.h:1818
virtual FailureOr< AsmDialectResourceHandle > declareResource(StringRef key) const
Declare a resource with the given key, returning a handle to use for any references of this resource ...
Definition OpImplementation.h:1811
virtual LogicalResult parseResource(AsmParsedResourceEntry &entry) const
Hook for parsing resource entries.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
Definition OpImplementation.h:1514
virtual size_t getNumResults() const =0
Return the number of declared SSA results.
virtual OptionalParseResult parseOptionalAssignmentList(SmallVectorImpl< Argument > &lhs, SmallVectorImpl< UnresolvedOperand > &rhs)=0
virtual ParseResult parseRegion(Region ®ion, ArrayRef< Argument > arguments={}, bool enableNameShadowing=false)=0
Parses a region.
virtual ParseResult parseSuccessor(Block *&dest)=0
Parse a single operation successor.
virtual std::pair< StringRef, unsigned > getResultName(unsigned resultNo) const =0
Return the name of the specified result in the specified syntax, as well as the sub-element in the na...
virtual ParseResult parseArgument(Argument &result, bool allowType=false, bool allowAttrs=false)=0
Parse a single argument with the following syntax:
ParseResult parseTrailingOperandList(SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None)
Parse zero or more trailing SSA comma-separated trailing operand references with a specified surround...
Definition OpImplementation.h:1618
ParseResult resolveOperands(Operands &&operands, Type type, SMLoc loc, SmallVectorImpl< Value > &result)
Definition OpImplementation.h:1642
virtual ParseResult parseArgumentList(SmallVectorImpl< Argument > &result, Delimiter delimiter=Delimiter::None, bool allowType=false, bool allowAttrs=false)=0
Parse zero or more arguments with a specified surrounding delimiter.
virtual ParseResult parseAffineMapOfSSAIds(SmallVectorImpl< UnresolvedOperand > &operands, Attribute &map, StringRef attrName, NamedAttrList &attrs, Delimiter delimiter=Delimiter::Square)=0
Parses an affine map attribute where dims and symbols are SSA operands.
virtual OptionalParseResult parseOptionalArgument(Argument &result, bool allowType=false, bool allowAttrs=false)=0
Parse a single argument if present.
virtual ParseResult parseOptionalLocationSpecifier(std::optional< Location > &result)=0
Parse a loc(...) specifier if present, filling in result if so.
ParseResult parseAssignmentList(SmallVectorImpl< Argument > &lhs, SmallVectorImpl< UnresolvedOperand > &rhs)
Parse a list of assignments of the form (x1 = y1, x2 = y2, ...)
Definition OpImplementation.h:1767
virtual ParseResult resolveOperand(const UnresolvedOperand &operand, Type type, SmallVectorImpl< Value > &result)=0
Resolve an operand to an SSA value, emitting an error on failure.
virtual OptionalParseResult parseOptionalOperand(UnresolvedOperand &result, bool allowResultNumber=true)=0
Parse a single operand if present.
virtual FailureOr< OperationName > parseCustomOperationName()=0
Parse the name of an operation, in the custom form.
virtual ParseResult parseSuccessorAndUseList(Block *&dest, SmallVectorImpl< Value > &operands)=0
Parse a single operation successor and its operand list.
virtual OptionalParseResult parseOptionalRegion(Region ®ion, ArrayRef< Argument > arguments={}, bool enableNameShadowing=false)=0
Parses a region if present.
virtual Operation * parseGenericOperation(Block *insertBlock, Block::iterator insertPt)=0
Parse an operation in its generic form.
ParseResult parseOperandList(SmallVectorImpl< UnresolvedOperand > &result, int requiredOperandCount, Delimiter delimiter=Delimiter::None)
Parse a specified number of comma separated operands.
Definition OpImplementation.h:1606
ParseResult resolveOperands(Operands &&operands, Type type, SmallVectorImpl< Value > &result)
Resolve a list of operands to SSA values, emitting an error on failure, or appending the results to t...
Definition OpImplementation.h:1634
virtual ParseResult parseOperand(UnresolvedOperand &result, bool allowResultNumber=true)=0
Parse a single SSA value operand name along with a result number if allowResultNumber is true.
virtual ParseResult parseAffineExprOfSSAIds(SmallVectorImpl< UnresolvedOperand > &dimOperands, SmallVectorImpl< UnresolvedOperand > &symbOperands, AffineExpr &expr)=0
Parses an affine expression where dims and symbols are SSA operands.
virtual OptionalParseResult parseOptionalSuccessor(Block *&dest)=0
Parse an optional operation successor.
std::enable_if_t<!std::is_convertible< Types, Type >::value, ParseResult > resolveOperands(Operands &&operands, Types &&types, SMLoc loc, SmallVectorImpl< Value > &result)
Resolve a list of operands and a list of operand types to SSA values, emitting an error and returning...
Definition OpImplementation.h:1653
virtual ParseResult parseGenericOperationAfterOpName(OperationState &result, std::optional< ArrayRef< UnresolvedOperand > > parsedOperandType=std::nullopt, std::optional< ArrayRef< Block * > > parsedSuccessors=std::nullopt, std::optional< MutableArrayRef< std::unique_ptr< Region > > > parsedRegions=std::nullopt, std::optional< ArrayRef< NamedAttribute > > parsedAttributes=std::nullopt, std::optional< Attribute > parsedPropertiesAttribute=std::nullopt, std::optional< FunctionType > parsedFnType=std::nullopt)=0
Parse different components, viz., use-info of operand(s), successor(s), region(s),...
virtual OptionalParseResult parseOptionalRegion(std::unique_ptr< Region > ®ion, ArrayRef< Argument > arguments={}, bool enableNameShadowing=false)=0
Parses a region if present.
virtual ParseResult parseOperandList(SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None, bool allowResultNumber=true, int requiredOperandCount=-1)=0
Parse zero or more SSA comma-separated operand references with a specified surrounding delimiter,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
Definition OpImplementation.h:443
void printOperands(IteratorType it, IteratorType end)
Print a comma separated list of operands.
Definition OpImplementation.h:482
virtual void shadowRegionArgs(Region ®ion, ValueRange namesToUse)=0
Renumber the arguments for the specified region to the same names as the SSA values in namesToUse.
virtual void printNewline()=0
Print a newline and indent the printer to the start of the current operation.
virtual void increaseIndent()=0
Increase indentation.
virtual void printSuccessorAndUseList(Block *successor, ValueRange succOperands)=0
Print the successor and its operands.
void printOperands(const ContainerType &container)
Print a comma separated list of operands.
Definition OpImplementation.h:476
virtual void printOptionalAttrDictWithKeyword(ArrayRef< NamedAttribute > attrs, ArrayRef< StringRef > elidedAttrs={})=0
If the specified operation has attributes, print out an attribute dictionary prefixed with 'attribute...
virtual void printOptionalAttrDict(ArrayRef< NamedAttribute > attrs, ArrayRef< StringRef > elidedAttrs={})=0
If the specified operation has attributes, print out an attribute dictionary with their values.
virtual void printOptionalLocationSpecifier(Location loc)=0
Print a loc(...) specifier if printing debug info is enabled.
virtual void printCustomOrGenericOp(Operation *op)=0
Prints the entire operation with the custom assembly form, if available, or the generic assembly form...
virtual void decreaseIndent()=0
Decrease indentation.
virtual void printOperand(Value value, raw_ostream &os)=0
virtual void printSuccessor(Block *successor)=0
Print the given successor.
virtual void printAffineExprOfSSAIds(AffineExpr expr, ValueRange dimOperands, ValueRange symOperands)=0
Prints an affine expression of SSA ids with SSA id names used instead of dims and symbols.
void printFunctionalType(Operation *op)
Print the complete type of an operation in functional form.
virtual void printAffineMapOfSSAIds(AffineMapAttr mapAttr, ValueRange operands)=0
Prints an affine map of SSA ids, where SSA id names are used in place of dims/symbols.
virtual void printGenericOp(Operation *op, bool printOpName=true)=0
Print the entire operation with the default generic assembly form.
virtual void printRegion(Region &blocks, bool printEntryBlockArgs=true, bool printBlockTerminators=true, bool printEmptyBlock=false)=0
Prints a region.
virtual void printRegionArgument(BlockArgument arg, ArrayRef< NamedAttribute > argAttrs={}, bool omitType=false)=0
Print a block argument in the usual format of: ssaName : type {attr1=42} loc("here") where location p...
virtual void printOperand(Value value)=0
Print implementations for various things an operation contains.
AsmPrinter(Impl &impl)
Initialize the printer with the given internal implementation.
Definition OpImplementation.h:127
Operation is the basic unit of execution within MLIR.
This class implements Optional functionality for ParseResult.
bool has_value() const
Returns true if we contain a valid ParseResult value.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class provides an efficient unique identifier for a specific C++ type.
static TypeID get()
Construct a type info object for the given type T.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
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 represents an instance of an SSA value in the MLIR system, representing a computable value...
DialectInterfaceBase< ConcreteType, DialectInterface > Base
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Include the generated interface declarations.
detail::DenseArrayAttrImpl< int64_t > DenseI64ArrayAttr
ParseResult parseDimensionList(OpAsmParser &parser, DenseI64ArrayAttr &dimensions)
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)
void printDimensionList(OpAsmPrinter &printer, Operation *op, ArrayRef< int64_t > dimensions)
OpAsmAliasResult
Holds the result of OpAsm{Dialect,Attr,Type}Interface::getAlias hook call.
llvm::SetVector< T, Vector, Set, N > SetVector
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
llvm::function_ref< Fn > function_ref
static mlir::AsmDialectResourceHandle getTombstoneKey()
Definition OpImplementation.h:1864
static unsigned getHashValue(const mlir::AsmDialectResourceHandle &handle)
Definition OpImplementation.h:1868
static mlir::AsmDialectResourceHandle getEmptyKey()
Definition OpImplementation.h:1860
static bool isEqual(const mlir::AsmDialectResourceHandle &lhs, const mlir::AsmDialectResourceHandle &rhs)
Definition OpImplementation.h:1871
UnresolvedOperand ssaName
Definition OpImplementation.h:1692
Type type
Definition OpImplementation.h:1693
DictionaryAttr attrs
Definition OpImplementation.h:1694
std::optional< Location > sourceLoc
Definition OpImplementation.h:1695
This is the representation of an operand reference.
Definition OpImplementation.h:1565
SMLoc location
Definition OpImplementation.h:1566
StringRef name
Definition OpImplementation.h:1567
unsigned number
Definition OpImplementation.h:1568
This represents an operation in an abstracted form, suitable for use with the builder APIs.