summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Parser/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] Use double format when parsing bfloat16 hexadecimal valuesRiver Riddle2020-01-141-7/+8
| | | | | | | | Summary: bfloat16 doesn't have a valid APFloat format, so we have to use double semantics when storing it. This change makes sure that hexadecimal values can be round-tripped properly given this fact. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D72667
* [mlir] Change the syntax of AffineMapAttr and IntegerSetAttr to avoid ↵River Riddle2020-01-131-7/+57
| | | | | | | | | | conflicts with function types. Summary: The current syntax for AffineMapAttr and IntegerSetAttr conflict with function types, making it currently impossible to round-trip function types(and e.g. FuncOp) in the IR. This revision changes the syntax for the attributes by wrapping them in a keyword. AffineMapAttr is wrapped with `affine_map<>` and IntegerSetAttr is wrapped with `affine_set<>`. Reviewed By: nicolasvasilache, ftynse Differential Revision: https://reviews.llvm.org/D72429
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-111-7/+7
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* [mlir] Fix -Wrange-loo-analysis warningsFangrui Song2020-01-011-2/+2
| | | | | | | | | | | | for (const auto &x : llvm::zip(..., ...)) -> for (auto x : llvm::zip(..., ...)) The return type of zip() is a wrapper that wraps a tuple of references. > warning: loop variable 'p' is always a copy because the range of type 'detail::zippy<detail::zip_shortest, ArrayRef<long> &, ArrayRef<long> &>' does not return a reference [-Wrange-loop-analysis]
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-31/+28
| | | | | | ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle2019-12-221-32/+33
| | | | | | | | | | Value being value-typed. This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics. PiperOrigin-RevId: 286844725
* Introduce prefetch op: affine -> std -> llvm intrinsicUday Bondhugula2019-12-181-0/+10
| | | | | | | | | | | | | | | | | | | Introduce affine.prefetch: op to prefetch using a multi-dimensional subscript on a memref; similar to affine.load but has no effect on semantics, but only on performance. Provide lowering through std.prefetch, llvm.prefetch and map to llvm's prefetch instrinsic. All attributes reflected through the lowering - locality hint, rw, and instr/data cache. affine.prefetch %0[%i, %j + 5], false, 3, true : memref<400x400xi32> Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#225 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/225 from bondhugula:prefetch 4c3b4e93bc64d9a5719504e6d6e1657818a2ead0 PiperOrigin-RevId: 286212997
* NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle2019-12-181-27/+24
| | | | | | | | in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
* Add UnrankedMemRef Typenmostafa2019-12-051-4/+26
| | | | | | | Closes tensorflow/mlir#261 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/261 from nmostafa:nmostafa/unranked 96b6e918f6ed64496f7573b2db33c0b02658ca45 PiperOrigin-RevId: 284037040
* NFC: Fix mismatches between LangRef.md and actual parser implementation.River Riddle2019-12-041-5/+9
| | | | PiperOrigin-RevId: 283805832
* Correctly parse empty affine maps.MLIR Team2019-11-201-3/+7
| | | | | | Previously the test case crashes / produces an error. PiperOrigin-RevId: 281630540
* Add '*' and '?' and optional brace parse calls to the ParserEric Schweitz2019-11-191-0/+20
| | | | | | Closes tensorflow/mlir#245 PiperOrigin-RevId: 281321459
* Rename the current parseSymbolName to parseOptionalSymbolNameRiver Riddle2019-11-131-7/+9
| | | | | | The current implementation silently fails if the '@' identifier isn't present, making it similar to the 'optional' parse methods. This change renames the current implementation to 'Optional' and adds a new 'parseSymbolName' that emits an error. PiperOrigin-RevId: 280214610
* Add support for nested symbol references.River Riddle2019-11-111-2/+26
| | | | | | | | | | | | | | | | | | This change allows for adding additional nested references to a SymbolRefAttr to allow for further resolving a symbol if that symbol also defines a SymbolTable. If a referenced symbol also defines a symbol table, a nested reference can be used to refer to a symbol within that table. Nested references are printed after the main reference in the following form: symbol-ref-attribute ::= symbol-ref-id (`::` symbol-ref-id)* Example: module @reference { func @nested_reference() } my_reference_op @reference::@nested_reference Given that SymbolRefAttr is now more general, the existing functionality centered around a single reference is moved to a derived class FlatSymbolRefAttr. Followup commits will add support to lookups, rauw, etc. for scoped references. PiperOrigin-RevId: 279860501
* Add (parse|print)OptionalAttrDictWithKeyword hooks to simplify parsing ↵River Riddle2019-11-051-1/+10
| | | | | | | | attribute dictionaries with regions. Many operations with regions add an additional 'attributes' prefix when printing the attribute dictionary to differentiate it from the region body. This leads to duplicated logic for detecting when to actually print the attribute dictionary. PiperOrigin-RevId: 278747681
* NFC: Rename parseOptionalAttributeDict -> parseOptionalAttrDict to match the ↵River Riddle2019-11-051-1/+1
| | | | | | name of the print method. PiperOrigin-RevId: 278696668
* Update the SPV dialect type parser to use the methods on DialectAsmParser ↵River Riddle2019-11-011-3/+11
| | | | | | | | directly. This simplifies the implementation quite a bit, and removes the need for explicit string munging. One change is made to some of the enum elements of SPV_DimAttr to ensure that they are proper identifiers; The string form is now prefixed with 'Dim'. PiperOrigin-RevId: 278027132
* Refactor LinalgDialect::parseType to use the DialectAsmParser methods directly.River Riddle2019-11-011-0/+5
| | | | | | This simplifies the implementation, and removes the need to do explicit string manipulation. A utility method 'parseDimensionList' is added to the DialectAsmParser to simplify defining types and attributes that contain shapes. PiperOrigin-RevId: 278020604
* Refactor QuantOps TypeParser to use the DialectAsmParser methods directly.River Riddle2019-11-011-0/+188
| | | | | | This greatly simplifies the implementation and removes custom parser functionality. The necessary methods are added to the DialectAsmParser. PiperOrigin-RevId: 278015983
* Remove the need for passing a location to parseAttribute/parseType.River Riddle2019-11-011-34/+91
| | | | | | | | 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-49/+148
| | | | | | | | | | | | | | 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
* Parse locations in parseGenericOperationSean Silva2019-10-281-7/+10
| | | | | | | | | For ops that recursively re-enter the parser to parse an operation (such as ops with a "wraps" pretty form), this ensures that the wrapped op will parse its location, which can then be used for the locations of the wrapping op and any other implicit ops. PiperOrigin-RevId: 277152636
* Add support for parsing multiple result name groups.River Riddle2019-10-251-47/+39
| | | | | | | | | | | | This allows for parsing things like: %name_1, %name_2:5, %name_3:2 = "my.op" ... This is useful for operations that have groups of variadic result values. The total number of results is expected to match the number of results defined by the operation. PiperOrigin-RevId: 276703280
* NFC: Add support for parsing attributes programmatically via ↵River Riddle2019-10-211-9/+41
| | | | | | | | mlir::parseAttribute. This matches the behavior of the public mlir::parseType, and even uses the internal implementation. PiperOrigin-RevId: 275989777
* Fix minor spelling tweaks (NFC)Kazuaki Ishizaki2019-10-201-5/+5
| | | | | | Closes tensorflow/mlir#177 PiperOrigin-RevId: 275692653
* NFC: Remove trivial builder get methods.River Riddle2019-10-171-10/+10
| | | | | | These don't add any value, and some are even more restrictive than the respective static 'get' method. PiperOrigin-RevId: 275391240
* Add support for parsing/printing non bare-identifier SymbolRefs.River Riddle2019-10-081-4/+18
| | | | | | The restriction that symbols can only have identifier names is arbitrary, and artificially limits the names that a symbol may have. This change adds support for parsing and printing symbols that don't fit in the 'bare-identifier' grammar by printing the reference in quotes, e.g. @"0_my_reference" can now be used as a symbol name. PiperOrigin-RevId: 273644768
* Replace constexpr MemRefType::kDynamicStrideOrOffset by a ↵Nicolas Vasilache2019-10-041-2/+2
| | | | | | | | | | MemRefType:;getDynamicStrideOrOffset() method - NFC This fixes global ODR-use issues, some of which manifest in Parser.cpp. Fixes tensorflow/mlir#167. PiperOrigin-RevId: 272886347
* Add syntactic sugar for strided memref parsing.Nicolas Vasilache2019-10-031-12/+95
| | | | | | | | | | | | | | | This CL implements the last remaining bit of the [strided memref proposal](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). The syntax is a bit more explicit than what was originally proposed and resembles: `memref<?x?xf32, offset: 0 strides: [?, 1]>` Nonnegative strides and offsets are currently supported. Future extensions will include negative strides. This also gives a concrete example of syntactic sugar for the ([RFC] Proposed Changes to MemRef and Tensor MLIR Types)[https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/-wKHANzDNTg]. The underlying implementation still uses AffineMap layout. PiperOrigin-RevId: 272717437
* Switch explicit create methods to match generated build's orderJacques Pienaar2019-09-281-1/+1
| | | | | | The generated build methods have result type before the arguments (operands and attributes, which are also now adjacent in the explicit create method). This also results in changing the create method's ordering to match most build method's ordering. PiperOrigin-RevId: 271755054
* Use constant's location for reporting errors in parsing of hex constantJacques Pienaar2019-09-231-12/+19
| | | | | | Before this the line following the error would be reported in some cases. PiperOrigin-RevId: 270778722
* Simplify the way spirv::StructTypes are parsed.Mahesh Ravishankar2019-09-231-8/+9
| | | | | | | | | | | | | The existing logic to parse spirv::StructTypes is very brittle. This change simplifies the parsing logic a lot. The simplification also allows for memberdecorations to be separated by commas instead of spaces (which was an artifact of the existing parsing logic). The change also needs a modification to mlir::parseType to return the number of chars parsed. Adding a new parseType method to do so. Also allow specification of spirv::StructType with no members. PiperOrigin-RevId: 270739672
* Fix a number of Clang-Tidy warnings.Christian Sigg2019-09-231-1/+1
| | | | PiperOrigin-RevId: 270632324
* NFC: Pass OperationState by reference instead of by pointer.River Riddle2019-09-201-2/+2
| | | | | | MLIR follows the LLVM convention of passing by reference instead of by pointer. PiperOrigin-RevId: 270396945
* NFC: Pass OpAsmParser by reference instead of by pointer.River Riddle2019-09-201-1/+1
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270315612
* Add support to OpAsmParser for parsing unknown keywords.River Riddle2019-09-171-14/+26
| | | | | | This is useful in several cases, for example a user may want to sugar the syntax of a string(as we do with custom operation syntax), or avoid many nested ifs for parsing a set of known keywords. PiperOrigin-RevId: 269695451
* Add `parseGenericOperation()` to the OpAsmParserMehdi Amini2019-09-081-0/+17
| | | | | | | | | This method parses an operation in its generic form, from the current parser state. This is the symmetric of OpAsmPrinter::printGenericOp(). An immediate use case is illustrated in the test dialect, where an operation wraps another one in its region and makes use of a single-line pretty-print form. PiperOrigin-RevId: 267930869
* Change the parseSource* methods to return OwningModuleRef instead of ModuleOp.River Riddle2019-08-291-7/+10
| | | | | | This avoids potential memory leaks from misuse of the API. PiperOrigin-RevId: 266305750
* Tweak to the pretty type parser to recognize that `->` is a special token.Eric Schweitz2019-08-281-0/+6
| | | | | | | | | | | Tweak to the pretty type parser to recognize that `->` is a special token that shouldn't be split into two characters. This change allows dialect types to wrap function types as in `!my.ptr_type<(i32) -> i32>`. Closes tensorflow/mlir#105 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/105 from schweitzpgi:parse-arrow 8b2d768053f419daae5a1a864121a44c4319acbe PiperOrigin-RevId: 265986240
* NFC: Remove the explicit context from Operation::create and OperationState.River Riddle2019-08-261-1/+1
| | | | | | The context can easily be recovered from the Location in these situations. PiperOrigin-RevId: 265578574
* NFC: Remove unnecessary context parameters from several Location getters.River Riddle2019-08-261-4/+2
| | | | | | The context can be recovered by other means in these methods and doesn't need to be passed explicitly. PiperOrigin-RevId: 265532956
* NFC: Update in-code documentation. Make the two grammar definitions of ↵MLIR Team2019-08-231-3/+5
| | | | | | static-dimension-list consistent. PiperOrigin-RevId: 265084348
* Split out parsing location into separate functions per instanceJacques Pienaar2019-08-221-107/+127
| | | | | | Split out method into specialized instances + add an early exit. Should be NFC, but simplifies reading the logic slightly IMHO. PiperOrigin-RevId: 264855529
* NFC: Update in-code documentation for type.MLIR Team2019-08-211-3/+3
| | | | PiperOrigin-RevId: 264734014
* NFC: Update in-code documentation for function-type.MLIR Team2019-08-211-1/+1
| | | | PiperOrigin-RevId: 264723462
* Allow isolated regions to form isolated SSA name scopes in the printer.River Riddle2019-08-191-73/+110
| | | | | | | | | | | This will allow for naming values the same as existing SSA values for regions attached to operations that are isolated from above. This fits in with how the system already allows separate name scopes for sibling regions. This name shadowing can be enabled in the custom parser of operations by setting the 'enableNameShadowing' flag to true when calling 'parseRegion'. %arg = constant 10 : i32 foo.op { %arg = constant 10 : i32 } PiperOrigin-RevId: 264255999
* LLVM Dialect: introduce llvm.globalAlex Zinenko2019-08-091-0/+16
| | | | | | | | | | | Introduce an operation that defines global constants and variables in the LLVM dialect, to reflect the corresponding LLVM IR capability. This operation is expected to live in the top-level module and behaves similarly to llvm.constant. It currently does not model many of the attributes supported by the LLVM IR for global values (memory space, alignment, thread-local, linkage) and will be extended as the relevant use cases appear. PiperOrigin-RevId: 262539445
* FunctionSupport: wrap around bool to have a more semantic callback typeAlex Zinenko2019-08-081-5/+5
| | | | | | | | | | | | This changes the type of the function type-building callback from (ArrayRef<Type>, ArrayRef<Type>, bool, string &) to (ArrayRef<Type>, ArrayRef<Type>, VariadicFlag, String &) to make the intended use clear from the callback signature alone. Also rearrange type definitions in Parser.cpp to make them more sorted alphabetically. PiperOrigin-RevId: 262405851
* Introduce support for variadic function signatures for the LLVM dialectAlex Zinenko2019-08-081-0/+5
| | | | | | | | | | | | | LLVM function type has first-class support for variadic functions. In the current lowering pipeline, it is emulated using an attribute on functions of standard function type. In LLVMFuncOp that has LLVM function type, this can be modeled directly. Introduce parsing support for variadic arguments to the function and use it to support variadic function declarations in LLVMFuncOp. Function definitions are currently not supported as that would require modeling va_start/va_end LLVM intrinsics in the dialect and we don't yet have a consistent story for LLVM intrinsics. PiperOrigin-RevId: 262372651
OpenPOWER on IntegriCloud