summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/AsmPrinter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify and enable pretty-parsing/printing of the uniform quantized types.Stella Laurenzo2019-04-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | The per-layer format is now like: !quant.uniform<i8<-8:7>:f32, 9.987200e-01:127> and per-axis is: !quant.uniform<i8:f32:1, {2.0e+2,0.99872:120}> I used the following sed script to update the unit tests (invoked with commands like `sed -i -r -f fix_quant.sed $(find . -name '*.mlir')`). --- # Per-layer s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2, \3>|g s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3, \4>|g # Per-axis s|\!quant<"uniform\[([iu][0-9]+):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1:\2\3, {\4}>|g s|\!quant<"uniform\[([iu][0-9]+)\(([^\)]+)\):([fb]+[0-9]+)(:[0-9]+)?\]\{([^\}]+)\}\s*">|!quant.uniform<\1<\2>:\3\4, {\5}>|g --- I fixed up the one file of error cases manually. Since this is a one time syntax fix, I am not persisting the script anywhere. -- PiperOrigin-RevId: 244425331
* Add NewLine for Attribute dump()MLIR Team2019-04-181-1/+4
| | | | | | -- PiperOrigin-RevId: 243904869
* Expand the pretty dialect type system to support arbitrary punctuation andChris Lattner2019-04-181-21/+35
| | | | | | | | | 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-5/+77
| | | | | | | | | | | | 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
* Rename UnknownType to OpaqueType (NFC)Mehdi Amini2019-04-031-4/+4
| | | | | | | | | This came up in a review of the tutorial, it was suggested that "opaque" is more descriptive than "unknown" here. -- PiperOrigin-RevId: 241832927
* Support 0-d tensor type attributesFeng Liu2019-04-011-0/+6
| | | | | | | | 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/+5
| | | | | | | | | 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
* Change the muli-return syntax for operations. The name of the operation ↵River Riddle2019-03-291-6/+3
| | | | | | | | | | | | | | | 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-23/+23
| | | | PiperOrigin-RevId: 240777521
* Introduce affine terminatorAlex Zinenko2019-03-291-8/+16
| | | | | | | | | | | | | | | | | | | | | | Due to legacy reasons (ML/CFG function separation), regions in affine control flow operations require contained blocks not to have terminators. This is inconsistent with the notion of the block and may complicate code motion between regions of affine control operations and other regions. Introduce `affine.terminator`, a special terminator operation that must be used to terminate blocks inside affine operations and transfers the control back to he region enclosing the affine operation. For brevity and readability reasons, allow `affine.for` and `affine.if` to omit the `affine.terminator` in their regions when using custom printing and parsing format. The custom parser injects the `affine.terminator` if it is missing so as to always have it present in constructed operations. Update transformations to account for the presence of terminator. In particular, most code motion transformation between loops should leave the terminator in place, and code motion between loops and non-affine blocks should drop the terminator. PiperOrigin-RevId: 240536998
* Replace usages of Instruction with Operation in the /IR directory.River Riddle2019-03-291-20/+20
| | | | | | This is step 2/N to renaming Instruction to Operation. PiperOrigin-RevId: 240459216
* Rename the Instruction class to Operation. This just renames the class, ↵River Riddle2019-03-291-1/+1
| | | | | | | | usages of Instruction will still refer to a typedef in the interim. This is step 1/N to renaming Instruction to Operation. PiperOrigin-RevId: 240431520
* Various small cleanups to the code, mostly removing const_cast's.Chris Lattner2019-03-291-4/+3
| | | | PiperOrigin-RevId: 240083489
* Remove const from Value, Instruction, Argument, and the various methods on theChris Lattner2019-03-291-32/+28
| | | | | | *Op classes. This is a net reduction by almost 400LOC. PiperOrigin-RevId: 239972443
* Now that ConstOpPointer is gone, we can change the various methods generated byChris Lattner2019-03-291-1/+1
| | | | | | | | | | tblgen be non-const. This requires introducing some const_cast's at the moment, but those (and lots more stuff) will disappear in subsequent patches. This significantly simplifies those patches because the various tblgen op emitters get adjusted. PiperOrigin-RevId: 239954566
* Remove const from mlir::Block.Chris Lattner2019-03-291-13/+13
| | | | | | This also eliminates some incorrect reinterpret_cast logic working around it, and numerous const-incorrect issues (like block argument iteration). PiperOrigin-RevId: 239712029
* Remove const support from mlir::RegionChris Lattner2019-03-291-1/+1
| | | | PiperOrigin-RevId: 239642194
* Continue pushing const out of the core IR types - in this case, remove constChris Lattner2019-03-291-13/+11
| | | | | | from Function. PiperOrigin-RevId: 239638635
* Continue pushing const out of the IR types - removing the notion of a 'constChris Lattner2019-03-291-10/+9
| | | | | | Module'. NFC. PiperOrigin-RevId: 239532885
* Add support for a standard TupleType. Though this is a standard type, it ↵River Riddle2019-03-291-0/+7
| | | | | | | | | | | | | | | | | | | | 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
* Rename BlockList into RegionAlex Zinenko2019-03-291-13/+14
| | | | | | 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-18/+4
| | | | | | | | | | | | | | | 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
* NFC. Move all of the remaining operations left in BuiltinOps to StandardOps. ↵River Riddle2019-03-291-13/+17
| | | | | | The only thing left in BuiltinOps are the core MLIR types. The standard types can't be moved because they are referenced within the IR directory, e.g. in things like Builder. PiperOrigin-RevId: 236403665
* Add support for parsing and printing affine.if and affine.for attributes. ↵River Riddle2019-03-291-5/+5
| | | | | | | | | | | | | | | | | | | | The attribute dictionaries are printed after the final block list for both operations: for %i = 0 to 10 { ... } {some_attr: true} if () : () () { ... } {some_attr: true} if () : () () { ... } else { ... } {some_attr: true} PiperOrigin-RevId: 236346983
* Add support for named function argument attributes. The attribute dictionary ↵River Riddle2019-03-291-11/+12
| | | | | | | | | | is printed after the argument type: func @arg_attrs(i32 {arg_attr: 10}) func @arg_attrs(%arg0: i32 {arg_attr: 10}) PiperOrigin-RevId: 236136830
* Add parser support for internal named attributes. These are attributes with ↵River Riddle2019-03-291-2/+2
| | | | | | names starting with ':'. PiperOrigin-RevId: 235774810
* Add a Function::isExternal utility to simplify checks for external functions.River Riddle2019-03-291-1/+1
| | | | PiperOrigin-RevId: 235746553
* Convert the dialect type parse/print hooks into virtual functions on the ↵River Riddle2019-03-291-2/+1
| | | | | | Dialect class. PiperOrigin-RevId: 235589945
* Adding -mlir-print-internal-attributes to print attributes with ':' prefixes.Ben Vanik2019-03-291-1/+7
| | | | | | This enables lit testing of passes that add internal attributes. PiperOrigin-RevId: 234809949
* Make IndexType a standard type instead of a builtin. This also cleans up ↵River Riddle2019-03-291-1/+1
| | | | | | some unnecessary factory methods on the Type class. PiperOrigin-RevId: 233640730
* Add dialect-specific decoding for opaque constants.Tatiana Shpeisman2019-03-291-0/+1
| | | | | | | | 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
* Remove the restriction that only registered terminator operations may ↵River Riddle2019-03-291-1/+1
| | | | | | terminate a block and have block operands. This allows for any operation to hold block operands. It also introduces the notion that unregistered operations may terminate a block. As such, the 'isTerminator' api on Instruction has been split into 'isKnownTerminator' and 'isKnownNonTerminator'. PiperOrigin-RevId: 233076831
* Print parens around the return type of a function if it is also a function typeAlex Zinenko2019-03-291-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | Existing type syntax contains the following productions: function-type ::= type-list-parens `->` type-list type-list ::= type | type-list-parens type ::= <..> | function-type Due to these rules, when the parser sees `->` followed by `(`, it cannot disambiguate if `(` starts a parenthesized list of function result types, or a parenthesized list of operands of another function type, returned from the current function. We would need an unknown amount of lookahead to try to find the `->` at the right level of function nesting to differentiate between type lists and singular function types. Instead, require the result type of the function that is a function type itself to be always parenthesized, at the syntax level. Update the spec and the parser to correspond to the production rule names used in the spec (although it would have worked without modifications). Fix the function type parsing bug in the process, as it used to accept the non-parenthesized list of types for arguments, disallowed by the spec. PiperOrigin-RevId: 232528361
* Print non-default attribute types in optional attr dictionaryAlex Zinenko2019-03-291-5/+28
| | | | | | | | | | | | | | | In optional attribute dictionary used, among others, in the generic form of the ops, attribute types for integers and floats are omitted. This could lead to inconsistencies when round-tripping the IR, in particular the attributes are created with incorrect types after parsing (integers default to i64, floats default to f64). Provide API to emit a trailing type after the attribute for integers and floats. Use it while printing the optional attribute dictionary. Omitting types for i64 and f64 is a pragmatic decision that minimizes changes in tests. We may want to reconsider in the future and always print types of attributes in the generic form. PiperOrigin-RevId: 232480116
* Remove InstWalker and move all instruction walking to the api facilities on ↵River Riddle2019-03-291-1/+0
| | | | | | Function/Block/Instruction. PiperOrigin-RevId: 232388113
* Add option print functions with the generic form.Jacques Pienaar2019-03-291-0/+10
| | | | | | | | The generic form may be more desirable even when there is a custom form specified so add option to enable emitting it. This also exposes a current bug when round tripping constant with function attribute. PiperOrigin-RevId: 232350712
* Replace the walkOps/visitOperationInst variants from the InstWalkers with ↵River Riddle2019-03-291-1/+1
| | | | | | the Instruction variants. PiperOrigin-RevId: 232322030
* Begin the process of fully removing OperationInst. This patch cleans up ↵River Riddle2019-03-291-29/+15
| | | | | | references to OperationInst in the /include, /AffineOps, and lib/Analysis. PiperOrigin-RevId: 232199262
* Fold the functionality of OperationInst into Instruction. OperationInst ↵River Riddle2019-03-291-9/+1
| | | | | | still exists as a forward declaration and will be removed incrementally in a set of followup cleanup patches. PiperOrigin-RevId: 232198540
* Define the AffineForOp and replace ForInst with it. This patch is largely ↵River Riddle2019-03-291-114/+2
| | | | | | mechanical, i.e. changing usages of ForInst to OpPointer<AffineForOp>. An important difference is that upon construction an AffineForOp no longer automatically creates the body and induction variable. To generate the body/iv, 'createBody' can be called on an AffineForOp with no body. PiperOrigin-RevId: 232060516
* Recommit: Define a AffineOps dialect as well as an AffineIfOp operation. ↵River Riddle2019-03-291-34/+4
| | | | | | Replace all instances of IfInst with AffineIfOp and delete IfInst. PiperOrigin-RevId: 231342063
* Automated rollback of changelist 231318632.Nicolas Vasilache2019-03-291-4/+34
| | | | PiperOrigin-RevId: 231327161
* Define a AffineOps dialect as well as an AffineIfOp operation. Replace all ↵River Riddle2019-03-291-34/+4
| | | | | | instances of IfInst with AffineIfOp and delete IfInst. PiperOrigin-RevId: 231318632
* Change the ForInst induction variable to be a block argument of the body ↵River Riddle2019-03-291-50/+34
| | | | | | instead of the ForInst itself. This is a necessary step in converting ForInst into an operation. PiperOrigin-RevId: 231064139
* Add an option to improve the readibility of the printed MLIR debuginfoFeng Liu2019-03-291-16/+45
| | | | | | | Use `-mlir-pretty-debuginfo` if the user wants line breaks between different callsite lines. The print results before and after this CL are shown in the tests. PiperOrigin-RevId: 231013812
* Allow operations to hold a blocklist and add support for parsing/printing a ↵River Riddle2019-03-291-0/+15
| | | | | | block list for verbose printing. PiperOrigin-RevId: 230951462
* Change trailing locations printing to also print unknown locations. This ↵River Riddle2019-03-291-5/+2
| | | | | | will allow for truly round tripping debug locations given that we assign locations while parsing IR. PiperOrigin-RevId: 230627191
* Add asmparser/printer support for locations to make them round-trippable. ↵River Riddle2019-03-291-38/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Location printing is currently behind a command line flag "mlir-print-debuginfo", we can rethink this when we have a pass for stripping debug info or when we have support for printer flags. Example inline notation: trailing-location ::= 'loc' '(' location ')' // FileLineCol Location. %1 = "foo"() : () -> i1 loc("mysource.cc":10:8) // Name Location return loc("foo") // CallSite Location return loc(callsite("foo" at "mysource.cc":19:9)) // Fused Location /// Without metadata func @inline_notation() loc(fused["foo", "mysource.cc":10:8]) /// With metadata return loc(fused<"myPass">["foo", "foo2"]) // Unknown location. return loc(unknown) Locations are currently only printed with inline notation at the line of each instruction. Further work is needed to allow for reference notation, e.g: ... return loc 1 } ... loc 1 = "source.cc":10:1 PiperOrigin-RevId: 230587621
* Unify terms regarding assembly form to use generic vs. customLei Zhang2019-03-291-11/+11
| | | | | | | | | | | | This CL just changes various docs and comments to use the term "generic" and "custom" when mentioning assembly forms. To be consist, several methods are also renamed: * FunctionParser::parseVerboseOperation() -> parseGenericOperation() * ModuleState::hasShorthandForm() -> hasCustomForm() * OpAsmPrinter::printDefaultOp() -> printGenericOp() PiperOrigin-RevId: 230568819
* AffineExpr pretty print - add missing handling to print expr * - 1 as -exprUday Bondhugula2019-03-291-11/+20
| | | | | | | | - print multiplication by -1 as unary negate; expressions like s0 * -1, d0 * -1 + d1 will now appear as -s0, -d0 + d1 resp. - a minor cleanup while on printAffineExprInternal PiperOrigin-RevId: 230222151
OpenPOWER on IntegriCloud