summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Add iterator support to DenseIntElementsAttr and DenseFPElementsAttr. ↵River Riddle2019-04-071-52/+100
| | | | | | | | This avoids the need to load all of the values from a DenseElementsAttr inorder to process them. -- PiperOrigin-RevId: 242212741
* Add methods for building array attributes in BuilderLei Zhang2019-04-071-0/+31
| | | | | | | | | I32/I64/F32/F64/Str array attributes are commonly used in ops. It helps to have handy methods for them. -- PiperOrigin-RevId: 242170569
* NFC: Fix a few typos in the tutorials and one in the comment of ↵River Riddle2019-04-051-1/+1
| | | | | | | | FunctionAttr::dropFunctionReference. -- PiperOrigin-RevId: 242050934
* NFC: Replace usages of iterator_range<operand_iterator> with operand_range.River Riddle2019-04-051-3/+2
| | | | | | -- PiperOrigin-RevId: 242031201
* Remove the non-postorder walk functions from Function/Block/Instruction ↵River Riddle2019-04-053-31/+2
| | | | | | | | and rename walkPostOrder to walk. -- PiperOrigin-RevId: 241965239
* Rename UnknownType to OpaqueType (NFC)Mehdi Amini2019-04-034-26/+26
| | | | | | | | | This came up in a review of the tutorial, it was suggested that "opaque" is more descriptive than "unknown" here. -- PiperOrigin-RevId: 241832927
* Fix the alignment issue in the DenseElementsAttr buffer allocationFeng Liu2019-04-031-1/+6
| | | | | | | | | | | | Currently, we only make the initial address aligned with 64-bit address but allocate the buffer with the real size. This can cause issue when we extract the value by the `readBits` method, which needs to read the memory in the granularity of APINT_WORD_SIZE. In this CL, we rounded the allocation size to the multiplies of APINT_WORD_SIZE to fix the issue. -- PiperOrigin-RevId: 241816656
* Update the dialect attribute verification hooks to return LogicalResult ↵River Riddle2019-04-021-4/+4
| | | | | | | | instead of bool. This updates Function::emitError to return LogicalResult as well. -- PiperOrigin-RevId: 241598892
* Rewrite the verify hooks on operations to use LogicalResult instead of ↵River Riddle2019-04-021-62/+63
| | | | | | | | bool. This also changes the return of Operation::emitError/emitOpError to LogicalResult as well. -- PiperOrigin-RevId: 241588075
* Add a getLoc() method on mlir::Value that returns the loc of the ↵Mehdi Amini2019-04-011-0/+7
| | | | | | | | defining Operations if any, otherwise an unknown location -- PiperOrigin-RevId: 241354085
* 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
* 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-302-7/+7
| | | | | | | | some comments to make it clear that 'name' refers to the dialect namespace. -- PiperOrigin-RevId: 241103116
* Implement basic IR support for a builtin complex<> type. As with tuples, weChris Lattner2019-03-304-13/+80
| | | | | | | | | 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
* Add build files and update README.Jacques Pienaar2019-03-301-0/+9
| | | | | | | | | * Add initial version of build files; * Update README with instructions to download and build MLIR from github; -- PiperOrigin-RevId: 241102092
* Assert that registered dialects have unique names. This creates a ↵River Riddle2019-03-291-1/+6
| | | | | | | | guarantee that the namespace of a dialect can be used a unique key. -- PiperOrigin-RevId: 241049578
* 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
* Update TypeBase::verifyConstructionInvariants to use a LogicalResult ↵River Riddle2019-03-292-28/+25
| | | | | | | | return instead of bool. -- PiperOrigin-RevId: 241045568
* Dialect Conversion: convert regions of operations when cloning themAlex Zinenko2019-03-291-10/+26
| | | | | | | | | | | | Dialect conversion currently clones the operations that did not match any pattern. This includes cloning any regions that belong to these operations. Instead, apply conversion recursively to the nested regions. Note that if an operation matched one of the conversion patterns, it is up to the pattern rewriter to fill in the regions of the converted operation. This may require calling back to the converter and is left for future work. PiperOrigin-RevId: 240872410
* 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
* Rename InstOperand to OpOperand.River Riddle2019-03-293-24/+24
| | | | PiperOrigin-RevId: 240814651
* Replace remaining usages of the Instruction class with Operation.River Riddle2019-03-292-28/+28
| | | | PiperOrigin-RevId: 240777521
* Simplify API uses of `getContext()` (NFC)Mehdi Amini2019-03-291-1/+1
| | | | | | The Pass base class is providing a convenience getContext() accessor. PiperOrigin-RevId: 240634961
* Replace usages of Instruction with Operation in the /Analysis directory.River Riddle2019-03-292-4/+4
| | | | PiperOrigin-RevId: 240569775
* Introduce affine terminatorAlex Zinenko2019-03-293-18/+29
| | | | | | | | | | | | | | | | | | | | | | 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
* Include numeric header for std::accumulate.Jacques Pienaar2019-03-291-0/+1
| | | | PiperOrigin-RevId: 240462910
* Replace usages of Instruction with Operation in the /IR directory.River Riddle2019-03-298-128/+123
| | | | | | 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-297-696/+664
| | | | | | | | 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
* Add a utility Instruction::getDialect method to return the dialect an ↵River Riddle2019-03-291-0/+13
| | | | | | operation is associated with, or nullptr if the associated dialect has not been registered. PiperOrigin-RevId: 240402300
* Allow creating standalone RegionsAlex Zinenko2019-03-295-6/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Refactor the Pattern framework to allow for combined match/rewrite patterns. ↵River Riddle2019-03-291-49/+25
| | | | | | | | | | This is done by adding a new 'matchAndRewrite' function to RewritePattern that performs the match and rewrite in one step. The default behavior simply calls into the existing 'match' and 'rewrite' functions. The 'PatternMatcher' class has now been specialized for RewritePatterns and has been rewritten to make use of the new matchAndRewrite functionality. This combined match/rewrite functionality allows simplifying the majority of existing RewritePatterns, as they do not benefit from separate match and rewrite functions. Some of the existing canonicalization patterns in StandardOps have been modified to take advantage of this functionality. PiperOrigin-RevId: 240187856
* Update some of the derived type classes to use getImpl instead of a static_cast.River Riddle2019-03-292-26/+14
| | | | PiperOrigin-RevId: 240084937
* Various small cleanups to the code, mostly removing const_cast's.Chris Lattner2019-03-292-5/+4
| | | | PiperOrigin-RevId: 240083489
* Push a bunch of 'consts' out of the *Op structure, in prep for removingChris Lattner2019-03-291-4/+4
| | | | | | OpPointer. PiperOrigin-RevId: 240044712
* Deconst-ify MLIRContext, and detemplatize some stuff now that const is gone.Chris Lattner2019-03-291-8/+7
| | | | PiperOrigin-RevId: 239976764
* Remove const from Value, Instruction, Argument, and the various methods on theChris Lattner2019-03-295-105/+82
| | | | | | *Op classes. This is a net reduction by almost 400LOC. PiperOrigin-RevId: 239972443
* Clarify the comment on valid data during DenseElementsAttr construction.River Riddle2019-03-291-1/+1
| | | | PiperOrigin-RevId: 239958211
* Now that ConstOpPointer is gone, we can change the various methods generated byChris Lattner2019-03-293-7/+7
| | | | | | | | | | 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
* Cleanup the construction of attributes and fix a opt-mode bug in ↵River Riddle2019-03-292-88/+65
| | | | | | DenseElementsAttr when allocating an empty array buffer. PiperOrigin-RevId: 239926824
* Remove const from mlir::Block.Chris Lattner2019-03-293-23/+34
| | | | | | 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-292-3/+3
| | | | PiperOrigin-RevId: 239642194
* Continue pushing const out of the core IR types - in this case, remove constChris Lattner2019-03-297-29/+27
| | | | | | from Function. PiperOrigin-RevId: 239638635
* Add support for building a DenseIntElementsAttr with ArrayRef<int64_t> values.River Riddle2019-03-292-3/+24
| | | | PiperOrigin-RevId: 239616595
* 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-295-1/+65
| | | | | | | | | | | | | | | | | | | | 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
* Remove some statements that required >C++11, add includes and qualify names. ↵Jacques Pienaar2019-03-292-0/+37
| | | | | | NFC. PiperOrigin-RevId: 239197784
* Move getSuccessorOperandIndex out of line.Jacques Pienaar2019-03-291-0/+17
| | | | PiperOrigin-RevId: 238814769
* Rename allocator to identifierAllocator and add an identifierMutex to make ↵River Riddle2019-03-291-13/+64
| | | | | | identifier uniquing thread safe. This also adds a general purpose 'contextMutex' to protect access to the rest of the miscellaneous parts of the MLIRContext, e.g. diagnostics, dialect registration, etc. This is step 5/5 of making the MLIRContext thread-safe. PiperOrigin-RevId: 238516697
* Give the Location classes their own SmartRWMutex and make sure that they are ↵River Riddle2019-03-292-60/+62
| | | | | | using the locationAllocator. This is step 4/N to making MLIRContext thread-safe. PiperOrigin-RevId: 238516646
OpenPOWER on IntegriCloud