summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Parser/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Restructure the parser to support nested name scopes. This allows for ↵River Riddle2019-06-031-79/+110
| | | | | | | | | | | | | regions at the same level of nesting to have values with the same SSA name. This is a necessary step for representing functions as operations. The following is now valid IR: foo.op ... { %val = ... }, { %val = ... } PiperOrigin-RevId: 251249875
* NFC: Split up Parser::parseAttribute into multiple smaller functions to ↵River Riddle2019-06-031-286/+283
| | | | | | improve readability. PiperOrigin-RevId: 251158192
* NFC: Cleanup method definitions within Parser and add header blocks to ↵River Riddle2019-06-011-652/+712
| | | | | | | | improve readability. -- PiperOrigin-RevId: 250949195
* Abstract the internal storage of the NamedAttributeList into a new ↵River Riddle2019-06-011-0/+7
| | | | | | | | | | | attribute, DictionaryAttr. This attribute maintains a sorted list of NamedAttributes. This will allow for operations/functions to maintain sub dictionaries of attributes. The syntax is the same as top level attribute dictionaries: {sub_dictionary: {fn: @someFn, boolAttr: true}} -- PiperOrigin-RevId: 250898950
* Remove "size" property of affine maps.MLIR Team2019-06-011-39/+1
| | | | | | -- PiperOrigin-RevId: 250572818
* Change elements literal parsing to not rely on shaped type being a ↵Geoffrey Martin-Noble2019-06-011-18/+28
| | | | | | | | | | | | vector or tensor. This is in preparation for making MemRef a ShapedType. In general, a shaped type should be anything with shape, rank, and element type properties, so use sites shouldn't assume more than that. I also pulled the trailing comma parsing out the parseElementsLiteralType (new name) method. It seems weird to have the method parse the type + a trailing comma, even if all call sites currently need that. It's surprising behavior without looking at the implementation. -- PiperOrigin-RevId: 250558363
* Replace the Function reference methods from the OpAsmParser/OpAsmPrinter ↵River Riddle2019-06-011-23/+0
| | | | | | | | with usages of FunctionAttr. -- PiperOrigin-RevId: 250555680
* Tidy up a few parser functions in the ModuleParser. This also adds a ↵River Riddle2019-06-011-11/+17
| | | | | | | | missing error for attribute aliases that contain '.' characters. -- PiperOrigin-RevId: 250291646
* NFC: Cleanup a switch statement that only has a default case.River Riddle2019-06-011-8/+3
| | | | | | -- PiperOrigin-RevId: 250062529
* Replace checks for rank -1 with direct calls to hasRankGeoffrey Martin-Noble2019-06-011-4/+3
| | | | | | | | Also removed a redundant check for rank after already checking for static shape (which implies rank) -- PiperOrigin-RevId: 249927636
* Refactor FunctionAttr to hold the internal function reference by name ↵River Riddle2019-06-011-100/+3
| | | | | | | | | | | | | | | | instead of pointer. The one downside to this is that the function reference held by a FunctionAttr needs to be explicitly looked up from the parent module. This provides several benefits though: * There is no longer a need to explicitly remap function attrs. - This removes a potentially expensive call from the destructor of Function. - This will enable some interprocedural transformations to now run intraprocedurally. - This wasn't scalable and forces dialect defined attributes to override a virtual function. * Replacing a function is now a trivial operation. * This is a necessary first step to representing functions as operations. -- PiperOrigin-RevId: 249510802
* Rename VectorOrTensorType to ShapedTypeGeoffrey Martin-Noble2019-05-201-14/+13
| | | | | | | | | | | | This is in preparation for making it also support/be a parent class of MemRefType. MemRefs have similar shape/rank/element semantics and it would be useful to be able to use these same utilities for them. This CL should not change any semantics and only change variables, types, string literals, and comments. In follow-up CLs I will prepare all callers to handle MemRef types or remove their dependence on ShapedType. Discussion/Rationale in https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/cHLoyfGu8y8 -- PiperOrigin-RevId: 248476449
* Add support for parsing/printing dialect defined attributes. This also ↵River Riddle2019-05-201-71/+98
| | | | | | | | | | | | 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
* Fix lingering sign compare warnings in exposed by "ninja check-mlir".Stella Laurenzo2019-05-201-1/+2
| | | | | | -- PiperOrigin-RevId: 248050178
* Refactor NameLoc so that it also holds a child location. This removes ↵River Riddle2019-05-201-1/+24
| | | | | | | | the awkward use of CallSiteLoc as a variable usage location. -- PiperOrigin-RevId: 248014642
* Change a few errors emitted by the parser to be notes instead.River Riddle2019-05-201-7/+9
| | | | | | -- PiperOrigin-RevId: 247978922
* Add llvm_unreachable in unreachable path to silence GCC warning (NFC)Mehdi Amini2019-05-101-0/+2
| | | | | | | | | The switch is supposed to be fully covered, but GCC warns that: "control reaches end of non-void function" -- PiperOrigin-RevId: 247672430
* Remove unused method `parseIntegerSetInline` and `parseAffineMapInline` ↵Mehdi Amini2019-05-101-48/+0
| | | | | | | | | | in Parser (NFC) Fix GCC warning. -- PiperOrigin-RevId: 247672318
* Add override keyword on overidden virtual method (NFC)Mehdi Amini2019-05-101-4/+4
| | | | | | | | Fix clang warnings -- PiperOrigin-RevId: 247556495
* Add support for using the new diagnostics infrastructure in the parser. ↵River Riddle2019-05-101-47/+39
| | | | | | | | This also adds support for streaming in ranges(e.g. ArrayRef) into a diagnostic with an optional element delimiter. -- PiperOrigin-RevId: 247239436
* NFC: Make ParseResult public and update the OpAsmParser(and thus all of ↵River Riddle2019-05-101-103/+97
| | | | | | | | the custom operation parsers) to use it instead of bool. -- PiperOrigin-RevId: 246955523
* NFC: Convert the ParseResult enum into a simple struct wrapper around ↵River Riddle2019-05-101-153/+161
| | | | | | | | LogicalResult. This allows for using the existing infrastructure for LogicalResult while retaining the ability to easily chain together parse rules. This will also simplify the transition of the parser to use the new diagnostics infrastructure. -- PiperOrigin-RevId: 246955372
* Refactor the support for AffineMap and IntegerSet aliases in the parser ↵River Riddle2019-05-101-116/+47
| | | | | | | | | | | | | | | | | | | | | | | | | into more general support for attribute aliases. `#` alias `=` attribute-value This also allows for dialects to define aliases for attributes in the AsmPrinter. The printer supports two types of attribute aliases, 'direct' and 'kind'. * Direct aliases are synonymous with the current support for type aliases, i.e. this maps an alias to a specific instance of an attribute. // A direct alias ("foo_str") for the string attribute "foo". #foo_str = "foo" * Kind aliases generates unique names for all instances of a given attribute kind. The generated aliases are of the form: `alias[0-9]+`. // A kind alias ("strattr") for all string attributes could generate. #strattr0 = "foo" #strattr1 = "bar" ... #strattrN = "baz" -- PiperOrigin-RevId: 246851916
* GPU dialect: introduce custom syntax for gpu.launchAlex Zinenko2019-05-061-0/+2
| | | | | | | | | | | | This syntax removes boilerplate and verbose list of region arguments in the header of the entry block. It groups operands into segments related to GPU blocks, GPU threads as well as the operands that are forwarded to the kernel. The two former segments are also used to give names to the region arguments that are used for GPU blocks and threads inside the kernel body region. -- PiperOrigin-RevId: 246792329
* Change syntax of regions in the generic form of operationsAlex Zinenko2019-05-061-10/+14
| | | | | | | | | | | | | | | The generic form of operations currently supports optional regions to be located after the operation type. As we are going to add a type to each region in a leading position in the region syntax, similarly to functions, it becomes ambiguous to have regions immediately after the operation type. Put regions between operands the optional list of successors in the generic operation syntax and wrap them in parentheses. The effect on the exisitng IR syntax is minimal since only three operations (`affine.for`, `affine.if` and `gpu.kernel`) currently use regions. -- PiperOrigin-RevId: 246787087
* Add support for a NoneType.River Riddle2019-05-061-0/+7
| | | | | | | | | | none-type ::= `none` The `none` type is a unit type, i.e. a type with exactly one possible value, where its value does not have a defined dynamic representation. -- PiperOrigin-RevId: 245599248
* Decouple region argument parsing from their type assignmentAlex Zinenko2019-05-061-31/+45
| | | | | | | | | | | | | | | | | | | | | The parser currently expects region arguments to have a fixed, known type when the %-name of the region argument is parsed. This may not necessarily be the case, for example, if the region argument types are the same as the operand types, located at the end of the operation. Furthermore, the parser currently stores the values for region arguments internally and attaches them to the next parsed region implicitly. This makes it impossible to attach some of the arguments to one region and some other arguments to another region if the regions are not textually interleaved with operation arguments. Provide `OpAsmParser::parseRegionArgument` that parses an SSA identifier and delays its type assignment until the region is parsed, similarly to operands. Update `OpAsmParser::parseRegion` to accept a list of pre-parsed SSA identifiers and a list of types instead of using SSA identifiers stored in the parser. -- PiperOrigin-RevId: 245491133
* Add support for Unit Attributes.River Riddle2019-05-061-3/+12
| | | | | | | | | | | | | | | | | | | | | | | A unit attribute is an attribute that represents a value of `unit` type. The `unit` type allows only one value forming a singleton set. This attribute value is used to represent attributes that only have meaning from their existence. One example of such an attribute could be the `swift.self` attribute. This attribute indicates that a function parameter is the self/context parameter. It could be represented as a boolean attribute(true or false), but a value of false doesn't really bring any value. The parameter either is the self/context or it isn't. ```mlir {.mlir} // A unit attribute defined with the `unit` value specifier. func @verbose_form(i1 {unitAttr : unit}) // A unit attribute can also be defined without the `unit` value specifier. func @simple_form(i1 {unitAttr}) ``` -- PiperOrigin-RevId: 245254045
* Expand the pretty dialect type system to support arbitrary punctuation andChris Lattner2019-04-181-26/+54
| | | | | | | | | other characters within the <>'s now that we can. This will allow quantized types to use the pretty syntax (among others) after a few changes. -- PiperOrigin-RevId: 243521268
* Change the asmprinter to use pretty syntax for dialect types when it can,Chris Lattner2019-04-071-2/+3
| | | | | | | | | | | | making the IR dumps much nicer. This is part 2/3 of the path to making dialect types more nice. Part 3/3 will slightly generalize the set of characters allowed in pretty types and make it more principled. -- PiperOrigin-RevId: 242249955
* Introduce support for parsing pretty dialect types, currently with a veryChris Lattner2019-04-071-27/+94
| | | | | | | | | | | | | | restricted grammar. This will make certain common types much easier to read. This is part tensorflow/mlir#1 of 2, which allows us to accept the new syntax. Part 2 will change the asmprinter to automatically use it when appropriate, which will require updating a bunch of tests. This is motivated by the EuroLLVM tutorial and cleaning up the LLVM dialect aesthetics a bit more. -- PiperOrigin-RevId: 242234821
* Rename UnknownType to OpaqueType (NFC)Mehdi Amini2019-04-031-3/+3
| | | | | | | | | This came up in a review of the tutorial, it was suggested that "opaque" is more descriptive than "unknown" here. -- PiperOrigin-RevId: 241832927
* Introduce custom format for the LLVM IR DialectAlex Zinenko2019-04-021-1/+21
| | | | | | | | | | | Historically, the LLVM IR dialect has been using the generic form of MLIR operation syntax. It is verbose and often redundant. Introduce the custom printing and parsing for all existing operations in the LLVM IR dialect. Update the relevant documentation and tests. -- PiperOrigin-RevId: 241617393
* Update the Function and Module verifiers to return LogicalResult instead ↵River Riddle2019-04-021-1/+1
| | | | | | | | of bool. -- PiperOrigin-RevId: 241553930
* Support 0-d tensor type attributesFeng Liu2019-04-011-27/+30
| | | | | | | | This CL fixes the parser and printer to support the 0-d tensor type attributes. -- PiperOrigin-RevId: 241345329
* Implement basic IR support for a builtin complex<> type. As with tuples, weChris Lattner2019-03-301-0/+24
| | | | | | | | | have no standard ops for working with these yet, this is simply enough to represent and round trip them in the printer and parser. -- PiperOrigin-RevId: 241102728
* Remove the MLIRContext parameter from Dialect::parseType. Dialects ↵River Riddle2019-03-291-1/+1
| | | | | | | | already have access to the context via Dialect::getContext. -- PiperOrigin-RevId: 241047077
* Tidy up a few comments and error messages related to parsing multi-result ↵River Riddle2019-03-291-5/+5
| | | | | | operations. PiperOrigin-RevId: 240876306
* Change the muli-return syntax for operations. The name of the operation ↵River Riddle2019-03-291-9/+58
| | | | | | | | | | | | | | | result now contains the number of results that it refers to if the number of results is greater than 1. Example: %call:2 = call @multi_return() : () -> (f32, i32) use(%calltensorflow/mlir#0, %calltensorflow/mlir#1) This cl also adds parser support for uniquely named result values. This means that a test writer can now write something like: %foo, %bar = call @multi_return() : () -> (f32, i32) use(%foo, %bar) Note: The printer will still print the collapsed form. PiperOrigin-RevId: 240860058
* Replace remaining usages of the Instruction class with Operation.River Riddle2019-03-291-15/+15
| | | | PiperOrigin-RevId: 240777521
* Replace usages of Instruction with Operation in the /IR directory.River Riddle2019-03-291-2/+2
| | | | | | This is step 2/N to renaming Instruction to Operation. PiperOrigin-RevId: 240459216
* Allow creating standalone RegionsAlex Zinenko2019-03-291-61/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, regions can only be constructed by passing in a `Function` or an `Instruction` pointer referencing the parent object, unlike `Function`s or `Instruction`s themselves that can be created without a parent. It leads to a rather complex flow in operation construction where one has to create the operation first before being able to work with its regions. It may be necessary to work with the regions before the operation is created. In particular, in `build` and `parse` functions that are executed _before_ the operation is created in cases where boilerplate region manipulation is required (for example, inserting the hypothetical default terminator in affine regions). Allow creating standalone regions. Such regions are meant to own a list of blocks and transfer them to other regions on demand. Each instruction stores a fixed number of regions as trailing objects and has ownership of them. This decreases the size of the Instruction object for the common case of instructions without regions. Keep this behavior intact. To allow some flexibility in construction, make OperationState store an owning vector of regions. When the Builder creates an Instruction from OperationState, the bodies of the regions are transferred into the instruction-owned regions to minimize copying. Thus, it becomes possible to fill standalone regions with blocks and move them to an operation when it is constructed, or move blocks from a region to an operation region, e.g., for inlining. PiperOrigin-RevId: 240368183
* At missing mlir:: namespace qualifier in front of function definitionMehdi Amini2019-03-291-1/+1
| | | | | | This was defining a function in the global namespace instead of the mlir one. PiperOrigin-RevId: 239918509
* Add a parserSourceFile function that takes a file path directlyMehdi Amini2019-03-291-0/+17
| | | | | | This avoids adding boilerplate around the SourceMgr on the client. PiperOrigin-RevId: 239918122
* Add support for a standard TupleType. Though this is a standard type, it ↵River Riddle2019-03-291-0/+28
| | | | | | | | | | | | | | | | | | | | merely provides a common mechanism for representing tuples in MLIR. It is up to dialect authors to provides operations for manipulating them, e.g. extract_tuple_element. TupleType has the following form: tuple-type ::= `tuple` `<` (type (`,` type)*)? `>` Example: // Empty tuple. tuple<> // Single element. tuple<i32> // Multi element. tuple<i32, tuple<f32>, i16> PiperOrigin-RevId: 239226021
* Add support for parsing true/false inside of a splat tensor literal.River Riddle2019-03-291-0/+2
| | | | PiperOrigin-RevId: 239052061
* Add an 'Instruction::create' overload that accepts an existing ↵River Riddle2019-03-291-1/+1
| | | | | | NamedAttributeList. This avoids the need to unique an attribute list if one already exists, e.g. when cloning an existing instruction. PiperOrigin-RevId: 238512499
* Rename BlockList into RegionAlex Zinenko2019-03-291-59/+55
| | | | | | NFC. This is step 1/n to specifying regions as parts of any operation. PiperOrigin-RevId: 238472370
* Introduce the notion of dialect attributes and dependent attributes. A ↵River Riddle2019-03-291-8/+2
| | | | | | | | | | | | | | | dialect attribute derives its context from a specific dialect, whereas a dependent attribute derives context from what it is attached to. Following this, we now enforce that functions and function arguments may only contain dialect specific attributes. These are generic entities and cannot provide any specific context for a dependent attribute. Dialect attributes are defined as: dialect-namespace `.` attr-name `:` attribute-value Dialects can override any of the following hooks to verify the validity of a given attribute: * verifyFunctionAttribute * verifyFunctionArgAttribute * verifyInstructionAttribute PiperOrigin-RevId: 236507970
* Set the namespace of the StandardOps dialect to "std", but add a special ↵River Riddle2019-03-291-1/+10
| | | | | | case to the parser to allow parsing standard operations without the "std" prefix. This will now allow for the standard dialect to be looked up dynamically by name. PiperOrigin-RevId: 236493865
OpenPOWER on IntegriCloud