aboutsummaryrefslogtreecommitdiff
path: root/mlir/unittests/IR/OperationSupportTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
8 days[mlir][NFC] update `mlir/Dialect` create APIs (30/n) (#150643)Maksim Levental1-6/+6
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-07-18[mlir] Deprecate NamedAttrList(std::nullopt_t) (NFC) (#149544)Kazu Hirata1-2/+2
This patch deprecates NamedAttrList(std::nullopt_t) to avoid use of std::nullopt outside the context of std::optional.
2025-06-26[mlir] Migrate away from std::nullopt (NFC) (#145842)Kazu Hirata1-12/+11
ArrayRef has a constructor that accepts std::nullopt. This constructor dates back to the days when we still had llvm::Optional. Since the use of std::nullopt outside the context of std::optional is kind of abuse and not intuitive to new comers, I would like to move away from the constructor and eventually remove it. This patch replaces {} with std::nullopt.
2025-06-24[mlir] Migrate away from {TypeRange,ValueRange}(std::nullopt) (NFC) (#145445)Kazu Hirata1-3/+3
ArrayRef has a constructor that accepts std::nullopt. This constructor dates back to the days when we still had llvm::Optional. Since the use of std::nullopt outside the context of std::optional is kind of abuse and not intuitive to new comers, I would like to move away from the constructor and eventually remove it. This patch migrates away from TypeRagne(std::nullopt) and ValueRange(std::nullopt).
2025-06-20[mlir] Migrate away from ArrayRef(std::nullopt) (NFC) (#144989)Kazu Hirata1-3/+2
ArrayRef has a constructor that accepts std::nullopt. This constructor dates back to the days when we still had llvm::Optional. Since the use of std::nullopt outside the context of std::optional is kind of abuse and not intuitive to new comers, I would like to move away from the constructor and eventually remove it. This patch takes care of the mlir side of the migration, starting with straightforward places where I see ArrayRef or ValueRange nearby. Note that ValueRange has a constructor that forwards arguments to an ArrayRef constructor.
2025-06-04[mlir]: Added properties/attributes ignore flags to OperationEquivalence ↵Aviad Cohen1-0/+25
(#142623) Those flags are useful for cases and operation which we may consider equivalent even when their attributes/properties are not the same.
2025-06-01Revert "[mlir]: Added properties/attributes ignore flags to ↵Vitaly Buka1-25/+0
OperationEquivalence" (#142319) Reverts llvm/llvm-project#141664 See https://github.com/llvm/llvm-project/pull/141664#issuecomment-2927867604
2025-06-01Revert "Fixed wrong check OperationEquivalenceTest.HashWorksWithFlags" (#142318)Vitaly Buka1-2/+2
Reverts llvm/llvm-project#142210 This is not enough, see #141664
2025-05-30Fixed wrong check OperationEquivalenceTest.HashWorksWithFlags (#142210)Aviad Cohen1-2/+2
The check was meant to check `IgnoreProperties` works as expected but operated on the wrong operation. Co-authored-by: Aviad Cohen <aviad.cohen2@mobileye.com>
2025-05-30[mlir]: Added properties/attributes ignore flags to OperationEquivalence ↵Aviad Cohen1-0/+25
(#141664) Those flags are useful for cases and operation which we may consider equivalent even when their attributes/properties are not the same.
2025-03-03[mlir] Add use nameloc to OpPrintingFlags (#129584)Jacques Pienaar1-0/+20
2025-01-16Revert "[mlir] Make single value `ValueRange`s memory safer" (#123187)Emilio Cota1-17/+0
Reverts llvm/llvm-project#121996 because it broke an emscripten build with `--target=wasm32-unknown-emscripten`: ``` llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:172:17: error: static assertion failed due to requirement '3U <= PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>::NumLowBitsAvailable': PointerIntPair with integer size too large for pointer 172 | static_assert(IntBits <= PtrTraits::NumLowBitsAvailable, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:111:13: note: in instantiation of template class 'llvm::PointerIntPairInfo<void *, 3, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>' requested here 111 | Value = Info::updateInt(Info::updatePointer(0, PtrVal), | ^ llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:89:5: note: in instantiation of member function 'llvm::PointerIntPair<void *, 3, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>::setPointerAndInt' requested here 89 | setPointerAndInt(PtrVal, IntVal); | ^ llvm/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:77:16: note: in instantiation of member function 'llvm::PointerIntPair<void *, 3, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>::PointerIntPair' requested here 77 | : Base(ValTy(const_cast<void *>( | ^ llvm/llvm-project/mlir/include/mlir/IR/TypeRange.h:49:36: note: in instantiation of member function 'llvm::pointer_union_detail::PointerUnionMembers<llvm::PointerUnion<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>, llvm::PointerIntPair<void *, 3, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>, 4, mlir::Type>::PointerUnionMembers' requested here 49 | TypeRange(Type type) : TypeRange(type, /*count=*/1) {} | ^ llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:172:25: note: expression evaluates to '3 <= 2' 172 | static_assert(IntBits <= PtrTraits::NumLowBitsAvailable, | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. ```
2025-01-15[mlir] Make single value `ValueRange`s memory safer (#121996)Markus Böck1-0/+17
A very common mistake users (and yours truly) make when using `ValueRange`s is assigning a temporary `Value` to it. Example: ```cpp ValueRange values = op.getOperand(); apiThatUsesValueRange(values); ``` The issue is caused by the implicit `const Value&` constructor: As per C++ rules a const reference can be constructed from a temporary and the address of it taken. After the statement, the temporary goes out of scope and `stack-use-after-free` error occurs. This PR fixes that issue by making `ValueRange` capable of owning a single `Value` instance for that case specifically. While technically a departure from the other owner types that are non-owning, I'd argue that this behavior is more intuitive for the majority of users that usually don't need to care about the lifetime of `Value` instances. `TypeRange` has similarly been adopted to accept a single `Type` instance to implement `getTypes`.
2024-04-22[mlir][test] Reorganize the test dialect (#89424)Jeff Niu1-0/+1
This PR massively reorganizes the Test dialect's source files. It moves manually-written op hooks into `TestOpDefs.cpp`, moves format custom directive parsers and printers into `TestFormatUtils`, adds missing comment blocks, and moves around where generated source files are included for types, attributes, enums, etc. into their own source file. This will hopefully help navigate the test dialect source code, but also speeds up compile time of the test dialect by putting generated source files into separate compilation units. This also sets up the test dialect to shard its op definitions, done in the next PR.
2024-02-21Apply clang-tidy fixes for llvm-qualified-auto in OperationSupportTest.cpp (NFC)Mehdi Amini1-2/+2
2023-09-12Update some uses of `getAttr()` to be explicit about Inherent vs Discardable ↵Mehdi Amini1-1/+1
(NFC)
2023-06-28[mlir][IR] Combine location hash if required in ↵Hideto Ueno1-0/+22
OperationEquivalence::computeHash This fixes a bug that `OperationEquivalence::computeHash` doesn't combine hash of operation locations even when `IgnoreLocations` is false. Added a unit test which fails at the current trunk. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D154015
2023-05-01Introduce MLIR Op PropertiesMehdi Amini1-3/+3
This new features enabled to dedicate custom storage inline within operations. This storage can be used as an alternative to attributes to store data that is specific to an operation. Attribute can also be stored inside the properties storage if desired, but any kind of data can be present as well. This offers a way to store and mutate data without uniquing in the Context like Attribute. See the OpPropertiesTest.cpp for an example where a struct with a std::vector<> is attached to an operation and mutated in-place: struct TestProperties { int a = -1; float b = -1.; std::vector<int64_t> array = {-33}; }; More complex scheme (including reference-counting) are also possible. The only constraint to enable storing a C++ object as "properties" on an operation is to implement three functions: - convert from the candidate object to an Attribute - convert from the Attribute to the candidate object - hash the object Optional the parsing and printing can also be customized with 2 extra functions. A new options is introduced to ODS to allow dialects to specify: let usePropertiesForAttributes = 1; When set to true, the inherent attributes for all the ops in this dialect will be using properties instead of being stored alongside discardable attributes. The TestDialect showcases this feature. Another change is that we introduce new APIs on the Operation class to access separately the inherent attributes from the discardable ones. We envision deprecating and removing the `getAttr()`, `getAttrsDictionary()`, and other similar method which don't make the distinction explicit, leading to an entirely separate namespace for discardable attributes. Recommit d572cd1b067f after fixing python bindings build. Differential Revision: https://reviews.llvm.org/D141742
2023-05-01Revert "Introduce MLIR Op Properties"Mehdi Amini1-3/+3
This reverts commit d572cd1b067f1177a981a4711bf2e501eaa8117b. Some bots are broken and investigation is needed before relanding.
2023-05-01Introduce MLIR Op PropertiesMehdi Amini1-3/+3
This new features enabled to dedicate custom storage inline within operations. This storage can be used as an alternative to attributes to store data that is specific to an operation. Attribute can also be stored inside the properties storage if desired, but any kind of data can be present as well. This offers a way to store and mutate data without uniquing in the Context like Attribute. See the OpPropertiesTest.cpp for an example where a struct with a std::vector<> is attached to an operation and mutated in-place: struct TestProperties { int a = -1; float b = -1.; std::vector<int64_t> array = {-33}; }; More complex scheme (including reference-counting) are also possible. The only constraint to enable storing a C++ object as "properties" on an operation is to implement three functions: - convert from the candidate object to an Attribute - convert from the Attribute to the candidate object - hash the object Optional the parsing and printing can also be customized with 2 extra functions. A new options is introduced to ODS to allow dialects to specify: let usePropertiesForAttributes = 1; When set to true, the inherent attributes for all the ops in this dialect will be using properties instead of being stored alongside discardable attributes. The TestDialect showcases this feature. Another change is that we introduce new APIs on the Operation class to access separately the inherent attributes from the discardable ones. We envision deprecating and removing the `getAttr()`, `getAttrsDictionary()`, and other similar method which don't make the distinction explicit, leading to an entirely separate namespace for discardable attributes. Differential Revision: https://reviews.llvm.org/D141742
2022-12-03[mlir/unittests] Use std::nullopt instead of None (NFC)Kazu Hirata1-13/+14
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-08-22[mlir] Populate default attributes on op creationJacques Pienaar1-2/+1
Default attributes were only handled by ODS accessors generated with the intention that these behave as if set attributes. This addresses the long standing TODO to address this inconsistency. Moving the initialization to construction vs every access. Removing need for duplicated default attribute population in python bindings. Switch some of the OpenMP ones to optional attribute with default as the currently set default values are not legal. May need to dig more there. Switched LinAlg generated ones to optional attribute with default as its quite widely used and unclear where it falls on two different interpretations. Differential Revision: https://reviews.llvm.org/D130916
2022-07-13[mlir] Use has_value instead of hasValue (NFC)Kazu Hirata1-2/+2
2022-07-08[mlir] Add method to populate default attributesJacques Pienaar1-0/+19
Previously default attributes were only usable by way of the ODS generated accessors, but this was undesirable as 1. The ODS getters could construct Attribute each get request; 2. For non-C++ uses this would require either duplicating some of tee default attribute generating or generating additional bindings to generate methods; 3. Accessing op.getAttr("foo") and op.getFoo() would return different results; Generate method to populate default attributes that can be used to address these. This merely adds this facility but does not employ by default on any path. Differential Revision: https://reviews.llvm.org/D128962
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-2/+2
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
2022-02-17[mlir] NFC NamedAttrList append with StringAttrMogball1-1/+1
NamedAttrList.append(StringAttr, StringAttr) fails to compile because it is matched to the IteratorT append. Fixes the method to only match if the type is an iterator.
2022-01-26[mlir][NFC] Add a using for llvm::BitVector to LLVM.hRiver Riddle1-1/+1
BitVector is becoming widespread enough that we should add a proper using. Differential Revision: https://reviews.llvm.org/D118290
2021-12-20Fix clang-tidy issues in mlir/ (NFC)Mehdi Amini1-2/+2
Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D115956
2021-12-08Adjust "end namespace" comment in MLIR to match new agree'd coding styleMehdi Amini1-1/+1
See D115115 and this mailing list discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html Differential Revision: https://reviews.llvm.org/D115309
2021-11-18[mlir] Convert NamedAttribute to be a classRiver Riddle1-8/+8
NamedAttribute is currently represented as an std::pair, but this creates an extremely clunky .first/.second API. This commit converts it to a class, with better accessors (getName/getValue) and also opens the door for more convenient API in the future. Differential Revision: https://reviews.llvm.org/D113956
2021-11-16[mlir][NFC] Replace references to Identifier with StringAttrRiver Riddle1-4/+4
This is part of the replacement of Identifier with StringAttr. Differential Revision: https://reviews.llvm.org/D113953
2021-10-29[mlir][NFC] Fix leak in unit testVladislav Vinogradov1-0/+2
Destroy operation created in `OperationFormatPrintTest.CanUseVariadicFormat` test.
2021-10-19[mlir] fix bugs with NamedAttrListMogball1-0/+44
- `assign` with ArrayRef was calling `append` - `assign` with empty ArrayRef was not clearing storage Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D112043
2021-10-12[mlir] Allow to use vformat utility with MLIR classesVladislav Vinogradov1-0/+11
Make `raw_ostream operator<<` follow const correctness semantic, since it is a requirement of FormatVariadic implementation. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D111547
2021-03-09[mlir][IR] Add an Operation::eraseOperands that supports batch erasureRiver Riddle1-0/+32
This method allows for removing multiple disjoint operands at once, reducing the need to erase operands individually (which results in shifting the operand list). Differential Revision: https://reviews.llvm.org/D98290
2020-12-03[mlir][Types][NFC] Move all of the builtin Type classes to BuiltinTypes.hRiver Riddle1-1/+1
This is part of a larger refactoring the better congregates the builtin structures under the BuiltinDialect. This also removes the problematic "standard" naming that clashes with the "standard" dialect, which is not defined within IR/. A temporary forward is placed in StandardTypes.h to allow time for downstream users to replaced references. Differential Revision: https://reviews.llvm.org/D92435
2020-10-24Remove global dialect registrationMehdi Amini1-5/+5
This has been deprecated for >1month now and removal was announced in: https://llvm.discourse.group/t/rfc-revamp-dialect-registration/1559/11 Differential Revision: https://reviews.llvm.org/D86356
2020-10-23Revert "Remove global dialect registration"Mehdi Amini1-5/+5
This reverts commit b22e2e4c6e420b78a8a4c307f0cf002f51af9590. Investigating broken builds
2020-10-23Remove global dialect registrationMehdi Amini1-5/+5
This has been deprecated for >1month now and removal was announced in: https://llvm.discourse.group/t/rfc-revamp-dialect-registration/1559/11 Differential Revision: https://reviews.llvm.org/D86356
2020-10-09[mlir] Fix bug in computing operation orderJames Molloy1-2/+35
When attempting to compute a differential orderIndex we were calculating the bailout condition correctly, but then an errant "+ 1" meant the orderIndex we created was invalid. Added test. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D89115
2020-08-19Separate the Registration from Loading dialects in the ContextMehdi Amini1-4/+4
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand: - the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context. - Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline. This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled. To adjust to this change, stop using the existing dialect registration: the global registry will be removed soon. 1) For passes, you need to override the method: virtual void getDependentDialects(DialectRegistry &registry) const {} and registery on the provided registry any dialect that this pass can produce. Passes defined in TableGen can provide this list in the dependentDialects list field. 2) For dialects, on construction you can register dependent dialects using the provided MLIRContext: `context.getOrLoadDialect<DialectName>()` This is useful if a dialect may canonicalize or have interfaces involving another dialect. 3) For loading IR, dialect that can be in the input file must be explicitly registered with the context. `MlirOptMain()` is taking an explicit registry for this purpose. See how the standalone-opt.cpp example is setup: mlir::DialectRegistry registry; registry.insert<mlir::standalone::StandaloneDialect>(); registry.insert<mlir::StandardOpsDialect>(); Only operations from these two dialects can be in the input file. To include all of the dialects in MLIR Core, you can populate the registry this way: mlir::registerAllDialects(registry); 4) For `mlir-translate` callback, as well as frontend, Dialects can be loaded in the context before emitting the IR: context.getOrLoadDialect<ToyDialect>() Differential Revision: https://reviews.llvm.org/D85622
2020-08-19Revert "Separate the Registration from Loading dialects in the Context"Mehdi Amini1-4/+4
This reverts commit d14cf45735b0d09d7d3caf0824779520dd20ef10. The build is broken with GCC-5.
2020-08-18Separate the Registration from Loading dialects in the ContextMehdi Amini1-4/+4
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand: - the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context. - Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline. This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled. To adjust to this change, stop using the existing dialect registration: the global registry will be removed soon. 1) For passes, you need to override the method: virtual void getDependentDialects(DialectRegistry &registry) const {} and registery on the provided registry any dialect that this pass can produce. Passes defined in TableGen can provide this list in the dependentDialects list field. 2) For dialects, on construction you can register dependent dialects using the provided MLIRContext: `context.getOrLoadDialect<DialectName>()` This is useful if a dialect may canonicalize or have interfaces involving another dialect. 3) For loading IR, dialect that can be in the input file must be explicitly registered with the context. `MlirOptMain()` is taking an explicit registry for this purpose. See how the standalone-opt.cpp example is setup: mlir::DialectRegistry registry; registry.insert<mlir::standalone::StandaloneDialect>(); registry.insert<mlir::StandardOpsDialect>(); Only operations from these two dialects can be in the input file. To include all of the dialects in MLIR Core, you can populate the registry this way: mlir::registerAllDialects(registry); 4) For `mlir-translate` callback, as well as frontend, Dialects can be loaded in the context before emitting the IR: context.getOrLoadDialect<ToyDialect>() Differential Revision: https://reviews.llvm.org/D85622
2020-08-18Revert "Separate the Registration from Loading dialects in the Context"Mehdi Amini1-4/+4
This reverts commit e1de2b75501e5eaf8777bd5248382a7c55a44fd6. Broke a build bot.
2020-08-18Separate the Registration from Loading dialects in the ContextMehdi Amini1-4/+4
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand: - the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context. - Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline. This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled. To adjust to this change, stop using the existing dialect registration: the global registry will be removed soon. 1) For passes, you need to override the method: virtual void getDependentDialects(DialectRegistry &registry) const {} and registery on the provided registry any dialect that this pass can produce. Passes defined in TableGen can provide this list in the dependentDialects list field. 2) For dialects, on construction you can register dependent dialects using the provided MLIRContext: `context.getOrLoadDialect<DialectName>()` This is useful if a dialect may canonicalize or have interfaces involving another dialect. 3) For loading IR, dialect that can be in the input file must be explicitly registered with the context. `MlirOptMain()` is taking an explicit registry for this purpose. See how the standalone-opt.cpp example is setup: mlir::DialectRegistry registry; mlir::registerDialect<mlir::standalone::StandaloneDialect>(); mlir::registerDialect<mlir::StandardOpsDialect>(); Only operations from these two dialects can be in the input file. To include all of the dialects in MLIR Core, you can populate the registry this way: mlir::registerAllDialects(registry); 4) For `mlir-translate` callback, as well as frontend, Dialects can be loaded in the context before emitting the IR: context.getOrLoadDialect<ToyDialect>()
2020-08-15Revert "Separate the Registration from Loading dialects in the Context"Mehdi Amini1-4/+4
This reverts commit 20563933875a9396c8ace9c9770ecf6a988c4ea6. Build is broken on a few bots
2020-08-15Separate the Registration from Loading dialects in the ContextMehdi Amini1-4/+4
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand: - the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context. - Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline. This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled. Differential Revision: https://reviews.llvm.org/D85622
2020-08-15Revert "Separate the Registration from Loading dialects in the Context"Mehdi Amini1-4/+4
This was landed by accident, will reland with the right comments addressed from the reviews. Also revert dependent build fixes.
2020-08-14Separate the Registration from Loading dialects in the ContextMehdi Amini1-4/+4
This changes the behavior of constructing MLIRContext to no longer load globally registered dialects on construction. Instead Dialects are only loaded explicitly on demand: - the Parser is lazily loading Dialects in the context as it encounters them during parsing. This is the only purpose for registering dialects and not load them in the context. - Passes are expected to declare the dialects they will create entity from (Operations, Attributes, or Types), and the PassManager is loading Dialects into the Context when starting a pipeline. This changes simplifies the configuration of the registration: a compiler only need to load the dialect for the IR it will emit, and the optimizer is self-contained and load the required Dialects. For example in the Toy tutorial, the compiler only needs to load the Toy dialect in the Context, all the others (linalg, affine, std, LLVM, ...) are automatically loaded depending on the optimization pipeline enabled.