summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Parser/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Parser: treat implicit top-level module as an SSA name scopeAlex Zinenko2019-08-081-1/+5
| | | | | | | | | | Now that modules are also operations, nothing prevents one from defining SSA values in the module. Doing so in an implicit top-level module, i.e. outside of a `module` operation, was leading to a crash because the implicit module was not associated with an SSA name scope. Create a name scope before parsing the top-level module to fix this. PiperOrigin-RevId: 262366891
* Support hexadecimal floats in tensor literalsAlex Zinenko2019-07-301-114/+94
| | | | | | | | | | | | | | | Extend the recently introduced support for hexadecimal float literals to tensor literals, which may also contain special floating point values such as infinities and NaNs. Modify TensorLiteralParser to store the list of tokens representing values until the type is parsed instead of trying to guess the tensor element type from the token kinds (hexadecimal values can be either integers or floats, and can be mixed with both). Maintain the error reports as close as possible to the existing implementation to avoid disturbing the tests. They can be improved in a separate clean-up if deemed necessary. PiperOrigin-RevId: 260794716
* Add support for hexadecimal float literalsAlex Zinenko2019-07-301-11/+50
| | | | | | | | | | | | | | | | | | | | MLIR does not have support for parsing special floating point values such as infinities and NaNs. If programmatically constructed, these values are printed as NaN and (+-)Inf and cannot be parsed back. Add parser support for hexadecimal literals in float attributes, following LLVM IR. The literal corresponds to the in-memory representation of the floating point value. IEEE 754 defines a range of possible values for NaNs, storing the bitwise representation allows MLIR to properly roundtrip NaNs with different bit values of significands. The initial version of this commit was missing support for float literals that used to be printed in decimal notation as a fallback, but ended up being printed in hexadecimal format which became the fallback for special values. The decimal fallback behavior was not exercised by tests. It is currently reinstated and tested by the newly added test @f32_potential_precision_loss in parser.mlir. PiperOrigin-RevId: 260790900
* Automated rollback of commit fc194a4f22fe53f46729821d9c4a993fe200facfMehdi Amini2019-07-251-50/+11
| | | | PiperOrigin-RevId: 260037115
* Add support for hexadecimal float literalsAlex Zinenko2019-07-251-11/+50
| | | | | | | | | | | | | MLIR does not have support for parsing special floating point values such as infinities and NaNs. If programmatically constructed, these values are printed as NaN and (+-)Inf and cannot be parsed back. Add parser support for hexadecimal literals in float attributes, following LLVM IR. The literal corresponds to the in-memory representation of the floating point value. IEEE 754 defines a range of possible values for NaNs, storing the bitwise representation allows MLIR to properly roundtrip NaNs with different bit values of significands. PiperOrigin-RevId: 260018802
* Introduce parser library method to parse list of region argumentsUday Bondhugula2019-07-221-3/+22
| | | | | | | | | | | | | | | | | - introduce parseRegionArgumentList (similar to parseOperandList) to parse a list of region arguments with a delimiter - allows defining custom parse for op's with multiple/variadic number of region arguments - use this on the gpu.launch op (although the latter has a fixed number of region arguments) - add a test dialect op to test region argument list parsing (with the no delimiter case) Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#40 PiperOrigin-RevId: 259442536
* Emit an error for missing '[' when parsing an AffineMapOfSSAIds.River Riddle2019-07-221-1/+1
| | | | | | Fixes tensorflow/mlir#51 PiperOrigin-RevId: 259415034
* Add support for parsing/printing the trailing type of a dialect attribute.River Riddle2019-07-191-3/+8
| | | | | | | | | | 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
* Rename FunctionAttr to SymbolRefAttr.River Riddle2019-07-121-8/+8
| | | | | | This allows for the attribute to hold symbolic references to other operations than FuncOp. This also allows for removing the dependence on FuncOp from the base Builder. PiperOrigin-RevId: 257650017
* Refactor the parsing/printing of the top-level module.River Riddle2019-07-121-2/+24
| | | | | | | | | | This changes the top-level module parser to handle the case where the top-level module is defined with the module operation syntax, i.e: module ... { } The printer is also updated to always print the top-level module in this form. This allows for cleanly round-tripping the location and attributes of the top-level module. PiperOrigin-RevId: 257492069
* NFC: Rename Module to ModuleOp.River Riddle2019-07-101-7/+7
| | | | | | Module is a legacy name that only exists as a typedef of ModuleOp. PiperOrigin-RevId: 257427248
* Update ModuleOp::create(...) to take a Location instead of a context.River Riddle2019-07-101-1/+3
| | | | | | This allows for giving a Module a more interesting location than 'Unknown'. PiperOrigin-RevId: 257310117
* Add missing overrides.Jacques Pienaar2019-07-081-5/+5
| | | | PiperOrigin-RevId: 256995548
* Replace the implementation of Function and Module with FuncOp and ModuleOp.River Riddle2019-07-031-191/+23
| | | | | | This is an important step in allowing for the top-level of the IR to be extensible. FuncOp and ModuleOp contain all of the necessary functionality, while using the existing operation infrastructure. As an interim step, many of the usages of Function and Module, including the name, will remain the same. In the future, many of these will be relaxed to allow for many different types of top-level operations to co-exist. PiperOrigin-RevId: 256427100
* Globally change load/store/dma_start/dma_wait operations over to ↵Andy Davis2019-07-031-6/+14
| | | | | | | | | | | affine.load/store/dma_start/dma_wait. In most places, this is just a name change (with the exception of affine.dma_start swapping the operand positions of its tag memref and num_elements operands). Significant code changes occur here: *) Vectorization: LoopAnalysis.cpp, Vectorize.cpp *) Affine Transforms: Transforms/Utils/Utils.cpp PiperOrigin-RevId: 256395088
* NFC: Move the Function/Module/Operation::verify methods out-of-line.River Riddle2019-07-021-1/+2
| | | | | | As Functions/Modules becomes operations, these methods will conflict with the 'verify' hook already on derived operation types. PiperOrigin-RevId: 256246112
* NFC: Refactor Module to be value typed.River Riddle2019-07-021-14/+13
| | | | | | As with Functions, Module will soon become an operation, which are value-typed. This eases the transition from Module to ModuleOp. A new class, OwningModuleRef is provided to allow for owning a reference to a Module, and will auto-delete the held module on destruction. PiperOrigin-RevId: 256196193
* Resolving buffer operand of linalg.view doesnt have the informationMahesh Ravishankar2019-07-021-0/+10
| | | | | | | | | | | about the buffer size. This is needed to resolve the operand correctly. Add that information to view op serialization/deserialization Also modify the parsing of buffer type by splitting at 'x' to side-step issues with StringRef number parsing. PiperOrigin-RevId: 256188319
* NFC: Refactor Function to be value typed.River Riddle2019-07-011-14/+14
| | | | | | 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
* Extract the automatic function renaming and symbol table out of Module.River Riddle2019-07-011-4/+0
| | | | | | This functionality is now moved to a new class, ModuleManager. This class allows for inserting functions into a module, and will auto-rename them on insert to ensure a unique name. This now means that users adding new functions to a module must ensure that the function name is unique, as the Module will no longer do it automatically. This also means that Module::getNamedFunction now operates in O(N) instead of the O(c) time it did before. This simplifies the move of Modules to Operations as the ModuleOp will not be able to have this functionality. PiperOrigin-RevId: 255846088
* Respect the user provided type when parsing StringAttr.River Riddle2019-06-271-6/+5
| | | | PiperOrigin-RevId: 255532918
* Return an error when parseType doesnt parse the entire string passedMahesh Ravishankar2019-06-271-1/+15
| | | | PiperOrigin-RevId: 255505300
* Allow attaching a type to StringAttr.River Riddle2019-06-271-1/+8
| | | | | | Some dialects allow for string types, and this allows for reusing StringAttr for constants of these types. PiperOrigin-RevId: 255413948
* Support parsing MLIR source from stdin.MLIR Team2019-06-261-1/+1
| | | | PiperOrigin-RevId: 255316118
* Split out TranslateClParser and add new parse method that reuses SourceMgr.Jacques Pienaar2019-06-261-4/+19
| | | | | | | | Split out class to command line parser for translate methods into standalone class. Similar to splitting up mlir-opt to reuse functionality with different initialization. PiperOrigin-RevId: 255225790
* Move the emitError/Warning/Remark utility methods out of MLIRContext and ↵River Riddle2019-06-251-3/+3
| | | | | | | | 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
* Change the attribute dictionary syntax to separate name and value with '='.River Riddle2019-06-251-4/+4
| | | | | | | | | | | The current syntax separates the name and value with ':', but ':' is already overloaded by several other things(e.g. trailing types). This makes the syntax difficult to parse in some situtations: Old: "foo: 10 : i32" New: "foo = 10 : i32" PiperOrigin-RevId: 255097928
* Modify the syntax of the the ElementsAttrs to print the type as a colon type.River Riddle2019-06-251-87/+238
| | | | | | | | | This is the standard syntax for types on operations, and is also already used by IntegerAttr and FloatAttr. Example: dense<5> : tensor<i32> dense<[3]> : tensor<1xi32> PiperOrigin-RevId: 255069157
* Print both type in diagnostic emitted on mismatch between def/use of SSA ↵Mehdi Amini2019-06-251-1/+3
| | | | | | | | | | Values (NFC) The error would look like: path/filename.mlir:32:23: error: use of value '%28' expects different type than prior uses: ''i32'' vs ''!_tf.control'' PiperOrigin-RevId: 254874859
* Add SPIR-V Load/Store operations. Currently this only support memoryMahesh Ravishankar2019-06-241-0/+10
| | | | | | operands being None, Volatile, Aligned and Nontemporal PiperOrigin-RevId: 254792353
* Add parsing/printing for new affine.load and affine.store operations.Andy Davis2019-06-241-1/+127
| | | | | | | The new operations affine.load and affine.store will take composed affine maps by construction. These operations will eventually replace load and store operations currently used in affine regions and operated on by affine transformation and analysis passes. PiperOrigin-RevId: 254754048
* Allow converting Diagnostic to LogicalResult::Failure. This matches the ↵River Riddle2019-06-241-2/+1
| | | | | | behavior of InFlightDiagnostic and enables notes to be converted to failure. PiperOrigin-RevId: 254579098
* NFC: Remove the 'context' parameter from OperationState.River Riddle2019-06-221-2/+2
| | | | | | Now that Locations are Attributes they contain a direct reference to the MLIRContext, i.e. the context can be directly accessed from the given location instead of being explicitly passed in. PiperOrigin-RevId: 254568329
* Refactor the location classes to be attributes instead of separate IR classes.River Riddle2019-06-221-43/+37
| | | | | | This will allow for locations to be used in the same contexts as attributes. Given that attributes are nullable types, the 'Location' class now represents a non-nullable wrapper around a 'LocationAttr'. This preserves the desired semantics we have for non-optional locations. PiperOrigin-RevId: 254505278
* NFC: Drop the unnecessary dependence on TransformsUtils from Parser. This is ↵River Riddle2019-06-221-1/+1
| | | | | | a historical dependency that is no longer needed. PiperOrigin-RevId: 254460518
* Add missing override on overridden virtual method (NFC)Mehdi Amini2019-06-221-1/+2
| | | | PiperOrigin-RevId: 254349019
* Replace usages of 'UniquedFilename' with 'Identifier' and remove it. ↵River Riddle2019-06-191-3/+4
| | | | | | Identifier already contains all of the necessary functionality/verification, so having a separate class for filenames is unnecessary. PiperOrigin-RevId: 253855505
* Refactor SplatElementsAttr to inherit from DenseElementsAttr as opposed to ↵River Riddle2019-06-191-61/+8
| | | | | | being a separate Attribute type. DenseElementsAttr provides a better internal representation for splat values as well as better API for accessing elements. PiperOrigin-RevId: 253138287
* Update the Parser to support parsing/printing DenseElementAttrs with a splat ↵River Riddle2019-06-191-80/+79
| | | | | | | | | value. The syntax for this is the same as 0-D tensors: dense<tensor<100x100x100xi32>, 10> dense<tensor<1x1x1xi64>, -5> PiperOrigin-RevId: 252907880
* Change a call to FloatAttr::getChecked to FloatAttr::get inside of ↵River Riddle2019-06-111-4/+1
| | | | | | 'parseFloatAttr'. The invariants of FloatAttr are already checked before construction. This also removes an unnecessary materialization of a mlir::Location which becomes expensive when parsing dense element literals. PiperOrigin-RevId: 252545776
* Expose a minimal type parser to dialects.Nicolas Vasilache2019-06-111-15/+20
| | | | | | | | | | | This CL exposes a parseType method which allows standalone reuse of the MLIR type parsing mechanism. This is a free function for now because the underlying MLIR parser is not guaranteed to receive a StringRef which lives in the proper MemBuffer. This requires building a new MemBuffer/SourceMgr and modifying the Parser constructor to not require an mlir::Module. The error diagnostic emitted by parseType has context limited to the local string. For now the dialect has the additional option to emit its own extra error that has the FileLineColLoc context. In the future, both error messages should be combined into a single error. PiperOrigin-RevId: 252468911
* Adding utility to parse optional colon-type-lists.Ben Vanik2019-06-091-0/+9
| | | | PiperOrigin-RevId: 251945512
* NFC: Rename FunctionParser to OperationParser. There is nothing specific to ↵River Riddle2019-06-091-46/+47
| | | | | | functions about this parser and provides general parser support for operations, and regions of operations. PiperOrigin-RevId: 251749622
* NFC: Cleanup the definitions of OpAsmParser and CustomOpAsmParser by adding ↵River Riddle2019-06-091-94/+136
| | | | | | comments, grouping similar functionality, and adding header blocks. PiperOrigin-RevId: 251723883
* NFC: Rename FunctionParser::builder to opBuilder. This allows for removing ↵River Riddle2019-06-091-13/+9
| | | | | | the clang specific pragmas for ignoring field shadowing warnings. PiperOrigin-RevId: 251712823
* NFC: Cleanup FunctionParser by removing dead methods, adding header blocks, ↵River Riddle2019-06-091-429/+445
| | | | | | and grouping related pieces of functionality. PiperOrigin-RevId: 251688578
* Add a few utility overloads for OpAsmParser methods:River Riddle2019-06-091-3/+2
| | | | | | | * Add a getCurrentLocation that returns the location directly. * Add parseOperandList/parseTrailingOperandList overloads without the required operand count. PiperOrigin-RevId: 251585488
* NFC: Rename FuncBuilder to OpBuilder and refactor to take a top level region ↵River Riddle2019-06-091-2/+2
| | | | | | instead of a function. PiperOrigin-RevId: 251563898
* Adding additional dialect parsing utilities, conversion wrappers, and ↵Ben Vanik2019-06-091-4/+16
| | | | | | | | | | traversal helpers. - added a typed walk to Block (matching the equivalent on Function) - added token parsers (incl optional variants) for : and ( - added applyConversionPatterns that takes a list of functions to apply patterns to PiperOrigin-RevId: 251481608
* Start defining a new operation 'FuncOp' that replicates all of the ↵River Riddle2019-06-031-8/+33
| | | | | | functionality of 'Function', but with an operation. The pretty syntax for the operation is exactly the same as that of Function. This operation is currently builtin, but should hopefully be moved to a different dialect when it has been completely decoupled from IR/. This is the first patch in a large series that refactors Functions to be represented as operations. PiperOrigin-RevId: 251281612
OpenPOWER on IntegriCloud