summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Dialect.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* Remove the need for passing a location to parseAttribute/parseType.River Riddle2019-11-011-7/+7
| | | | | | | | Now that a proper parser is passed to these methods, there isn't a need to explicitly pass a source location. The source location can be recovered from the parser as necessary. This removes the need to explicitly decode an SMLoc in the case where we don't need to, which can be expensive. This requires adding some basic nesting support to the parser for supporting nested parsers to allow for remapping source locations of the nested parsers to the top level parser for accurate diagnostics. This is due to the fact that the attribute and type parsers use different source buffers than the top level parser, as they may be represented in string form. PiperOrigin-RevId: 278014858
* Add DialectAsmParser/Printer classes to simplify dialect attribute and type ↵River Riddle2019-11-011-3/+6
| | | | | | | | | | | | | | parsing. These classes are functionally similar to the OpAsmParser/Printer classes and provide hooks for parsing attributes/tokens/types/etc. This change merely sets up the base infrastructure and updates the parser hooks, followups will add hooks as needed to simplify existing handrolled dialect parsers. This has various different benefits: *) Attribute/Type parsing is much simpler to define. *) Dialect attributes/types that contain other attributes/types can now use aliases. *) It provides a 'spec' with which we may use in the future to auto-generate parsers/printers. *) Error messages emitted by attribute/type parsers can provide character exact locations rather than "beginning of the string" PiperOrigin-RevId: 278005322
* Add support for function result attributes.Sean Silva2019-10-181-0/+9
| | | | | | | | | | | | | | | | | | | | | | This allows dialect-specific attributes to be attached to func results. (or more specifically, FunctionLike ops). For example: ``` func @f() -> (i32 {my_dialect.some_attr = 3}) ``` This attaches my_dialect.some_attr with value 3 to the first result of func @f. Another more complex example: ``` func @g() -> (i32, f32 {my_dialect.some_attr = "foo", other_dialect.some_other_attr = [1,2,3]}, i1) ``` Here, the second result has two attributes attached. PiperOrigin-RevId: 275564165
* Fix typos, NFC.Christian Sigg2019-10-041-1/+1
| | | | PiperOrigin-RevId: 272851237
* Move the parser extensions for aliases currently on Dialect to a new ↵River Riddle2019-08-211-2/+5
| | | | | | | | OpAsmDialectInterface. This will allow for adding more hooks for controlling parser behavior without bloating Dialect in the common case. This cl also adds iteration support to the DialectInterfaceCollection. PiperOrigin-RevId: 264627846
* NFC: Use a DenseSet instead of a DenseMap for DialectInterfaceCollection.River Riddle2019-08-201-2/+2
| | | | | | The interfaces are looked up by dialect, which can always be retrieved from an interface instance. PiperOrigin-RevId: 264516023
* Add support for Dialect interfaces.River Riddle2019-08-141-1/+42
| | | | | | | | | | Dialect interfaces are virtual apis registered to a specific dialect instance. Dialect interfaces are generally useful for transformation passes, or analyses, that want to opaquely operate on operations within a given dialect. These interfaces generally involve wide coverage over the entire dialect. A dialect interface can be defined by inheriting from the CRTP base class DialectInterfaceBase::Base. This class provides the necessary utilities for registering an interface with the dialect so that it can be looked up later. Dialects overriding an interface may register an instance via 'Dialect::addInterfaces'. This API works very similarly to the respective addOperations/addTypes/etc. This will allow for a transformation/utility to later query the interface from an opaque dialect instance via 'getInterface<T>'. A utility class 'DialectInterfaceCollection' is also provided that will collect all of the dialects that implement a specific interface within a given module. This allows for simplifying the API of interface lookups. PiperOrigin-RevId: 263489015
* Improve support for opaque types in MLIR, allowing dialects to opt intoChris Lattner2019-08-071-1/+7
| | | | | | supporting opaque types, and providing ODS support for matching them. PiperOrigin-RevId: 262183028
* Add support for parsing/printing the trailing type of a dialect attribute.River Riddle2019-07-191-1/+2
| | | | | | | | | | This cl standardizes the printing of the type of dialect attributes to work the same as other attribute kinds. The type of dialect attributes will trail the dialect specific portion: `#` dialect-namespace `<` attr-data `>` `:` type The attribute parsing hooks on Dialect have been updated to take an optionally null expected type for the attribute. This matches the respective parseAttribute hooks in the OpAsmParser. PiperOrigin-RevId: 258661298
* Update the dialect attribute verifiers related to functions.River Riddle2019-07-121-10/+5
| | | | | | Remove the Function specific attribute verifier in favor of the general operation verifier. This also generalizes the function argument verifier to allow use for an argument attached to any region of any operation. PiperOrigin-RevId: 257689962
* NFC: Rename Function to FuncOp.River Riddle2019-07-101-2/+2
| | | | PiperOrigin-RevId: 257293379
* NFC: Refactor Function to be value typed.River Riddle2019-07-011-0/+15
| | | | | | Move the data members out of Function and into a new impl storage class 'FunctionStorage'. This allows for Function to become value typed, which will greatly simplify the transition of Function to FuncOp(given that FuncOp is also value typed). PiperOrigin-RevId: 255983022
* Move the emitError/Warning/Remark utility methods out of MLIRContext and ↵River Riddle2019-06-251-4/+4
| | | | | | | | into the mlir namespace. Now that Locations are attributes, they have direct access to the MLIR context. This allows for simplifying error emission by removing unnecessary context lookups. PiperOrigin-RevId: 255112791
* Add support for parsing/printing dialect defined attributes. This also ↵River Riddle2019-05-201-0/+7
| | | | | | | | | | | | adds support for a pretty syntax for dialects attributes that is synonymous with the pretty syntax for dialect types. This cl also adds a new attribute 'OpaqueAttr' that allows for roundtripping attributes attached to unregistered dialects. Dialect attributes have the following syntax: dialect-attribute ::= `#` dialect-namespace `<` `"` attr-data `"` `>` dialect-attribute ::= `#` alias-name pretty-dialect-sym-body? -- PiperOrigin-RevId: 248344416
* Make the Twine parameter of the current diagnostic emit functions ↵River Riddle2019-05-061-2/+2
| | | | | | | | optional. This allows for the ability to exclusively use the new diagnostic interface without breaking all of the existing usages. Several diagnostics emitted in lib/IR have been updated to make use of this functionality. -- PiperOrigin-RevId: 246546044
* Introduce a new API for emitting diagnostics with Diagnostic and ↵River Riddle2019-05-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | InFlightDiagnostic. The Diagnostic class contains all of the information necessary to report a diagnostic to the DiagnosticEngine. It should generally not be constructed directly, and instead used transitively via InFlightDiagnostic. A diagnostic is currently comprised of several different elements: * A severity level. * A source Location. * A list of DiagnosticArguments that help compose and comprise the output message. * A DiagnosticArgument represents any value that may be part of the diagnostic, e.g. string, integer, Type, Attribute, etc. * Arguments can be added to the diagnostic via the stream(<<) operator. * (In a future cl) A list of attached notes. * These are in the form of other diagnostics that provide supplemental information to the main diagnostic, but do not have context on their own. The InFlightDiagnostic class represents an RAII wrapper around a Diagnostic that is set to be reported with the diagnostic engine. This allows for the user to modify a diagnostic that is inflight. The internally wrapped diagnostic can be reported directly or automatically upon destruction. These classes allow for more natural composition of diagnostics by removing the restriction that the message of a diagnostic is comprised of a single Twine. They should also allow for nice incremental improvements to the diagnostics experience in the future, e.g. formatv style diagnostics. Simple Example: emitError(loc, "integer bitwidth is limited to " + Twine(IntegerType::kMaxWidth) + " bits"); emitError(loc) << "integer bitwidth is limited to " << IntegerType::kMaxWidth << " bits"; -- PiperOrigin-RevId: 246526439
* Add a flag to Dialect that allows for dialects to enable support for ↵River Riddle2019-04-011-1/+1
| | | | | | | | | | | | | | | | | | | unregistered operations. This flag is off by default and can be toggled via the 'allowUnknownOperations(...)' method. This means that moving forward an error will be emitted for unknown operations if the dialect does not explicitly allow it. Example: func @unknown_std_op() { %0 = "std.foo_bar_op"() : () -> index return } Will result in: error: unregistered operation 'std.foo_bar_op' found in dialect ('std') that does not allow unknown operations -- PiperOrigin-RevId: 241266009
* Rename the 'namePrefix' field in the Dialect class to 'name' and tidy ↵River Riddle2019-03-301-3/+3
| | | | | | | | some comments to make it clear that 'name' refers to the dialect namespace. -- PiperOrigin-RevId: 241103116
* Remove the MLIRContext parameter from Dialect::parseType. Dialects ↵River Riddle2019-03-291-4/+3
| | | | | | | | already have access to the context via Dialect::getContext. -- PiperOrigin-RevId: 241047077
* Validate the names of attribute, dialect, and functions during verification. ↵River Riddle2019-03-291-2/+11
| | | | | | This essentially enforces the parsing rules upon their names. PiperOrigin-RevId: 235818842
* Convert the dialect type parse/print hooks into virtual functions on the ↵River Riddle2019-03-291-0/+9
| | | | | | Dialect class. PiperOrigin-RevId: 235589945
* Use dialect hook registration for constant folding hook.Tatiana Shpeisman2019-03-291-14/+0
| | | | | | Deletes specialized mechanism for registering constant folding hook and uses dialect hooks registration mechanism instead. PiperOrigin-RevId: 235535410
* Add dialect-specific decoding for opaque constants.Tatiana Shpeisman2019-03-291-0/+18
| | | | | | | | Associates opaque constants with a particular dialect. Adds general mechanism to register dialect-specific hooks defined in external components. Adds hooks to decode opaque tensor constant and extract an element of an opaque tensor constant. This CL does not change the existing mechanism for registering constant folding hook yet. One thing at a time. PiperOrigin-RevId: 233544757
* Rename OperationPrefix to Namespace in Dialect. This is important as ↵River Riddle2019-03-291-2/+4
| | | | | | | | | | dialects will soon be able to define more than just operations. Moving forward dialect namespaces cannot contain '.' characters. This cl also standardizes that operation names must begin with the dialect namespace followed by a '.'. PiperOrigin-RevId: 227532193
* Adds ConstantFoldHook registry in MLIRContextFeng Liu2019-03-291-3/+19
| | | | | | | | | | | | | | This reverts the previous method which needs to create a new dialect with the constant fold hook from TensorFlow. This new method uses a function object in dialect to store the constant fold hook. Once a hook is registered to the dialect, this function object will be assigned when the dialect is added to the MLIRContext. For the operations which are not registered, a new method getRegisteredDialects is added to the MLIRContext to query the dialects which matches their op name prefixes. PiperOrigin-RevId: 222310149
* Falls back to dialect constant folding hookFeng Liu2019-03-291-0/+2
| | | | PiperOrigin-RevId: 220861133
* Replace the "OperationSet" abstraction with a new Dialect abstraction. This isChris Lattner2019-03-291-0/+43
a step forward because now every AbstractOperation knows which Dialect it is associated with, enabling things in the future like "constant folding hooks" which will be important for layering. This is also a bit nicer on the registration side of things. PiperOrigin-RevId: 218104230
OpenPOWER on IntegriCloud