summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Operation.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-111-12/+12
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* [mlir] Rewrite the internal representation of OpResult to be optimized for ↵River Riddle2020-01-021-30/+41
| | | | | | | | | | | | | | memory. Summary: This changes the implementation of OpResult to have some of the results be represented inline in Value, via a pointer int pair of Operation*+result number, and the rest being trailing objects on the main operation. The full details of the new representation is detailed in the proposal here: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ The only difference between here and the above proposal is that we only steal 2-bits for the Value kind instead of 3. This means that we can only fit 2-results inline instead of 6. This allows for other users to steal the final bit for PointerUnion/etc. If necessary, we can always steal this bit back in the future to save more space if 3-6 results are common enough. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D72020
* [mlir] Refactor operation results to use a single use list for all results ↵River Riddle2019-12-301-57/+1
| | | | | | | | | | of the operation. Summary: A new class is added, IRMultiObjectWithUseList, that allows for representing an IR use list that holds multiple sub values(used in this case for OpResults). This class provides all of the same functionality as the base IRObjectWithUseList, but for specific sub-values. This saves a word per operation result and is a necessary step in optimizing the layout of operation results. For now the use list is placed on the operation itself, so zero-result operations grow by a word. When the work for optimizing layout is finished, this can be moved back to being a trailing object based on memory/runtime benchmarking. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D71955
* [mlir] Merge the successor operand count into BlockOperand.River Riddle2019-12-271-52/+15
| | | | | | | | Summary: The successor operand counts are directly tied to block operands anyways, and this simplifies the trailing objects of Operation(i.e. one less computation to perform). Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D71949
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-10/+10
| | | | | | ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
* Resubmit: ReImplement the Value classes as value-typed objects wrapping an ↵River Riddle2019-12-231-10/+16
| | | | | | | | internal pointer storage. This will enable future commits to reimplement the internal implementation of OpResult without needing to change all of the existing users. This is part of a chain of commits optimizing the size of operation results. PiperOrigin-RevId: 286930047
* Automated rollback of commit f603a50109107b447b835dac11f0eb541288393eMLIR Team2019-12-231-16/+10
| | | | PiperOrigin-RevId: 286924059
* ReImplement the Value classes as value-typed objects wrapping an internal ↵River Riddle2019-12-231-10/+16
| | | | | | | | pointer storage. This will enable future commits to reimplement the internal implementation of OpResult without needing to change all of the existing users. This is part of a chain of commits optimizing the size of operation results. PiperOrigin-RevId: 286919966
* 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-13/+13
| | | | | | | | | | 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
* NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle2019-12-181-1/+1
| | | | | | | | in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
* Refactor the various operand/result/type iterators to use ↵River Riddle2019-12-101-50/+9
| | | | | | | | | | | | | | indexed_accessor_range. This has several benefits: * The implementation is much cleaner and more efficient. * The ranges now have support for many useful operations: operator[], slice, drop_front, size, etc. * Value ranges can now directly query a range for their types via 'getTypes()': e.g: void foo(Operation::operand_range operands) { auto operandTypes = operands.getTypes(); } PiperOrigin-RevId: 284834912
* Add new indexed_accessor_range_base and indexed_accessor_range classes that ↵River Riddle2019-12-091-38/+19
| | | | | | | | simplify defining index-able ranges. Many ranges want similar functionality from a range type(e.g. slice/drop_front/operator[]/etc.), so these classes provide a generic implementation that may be used by many different types of ranges. This removes some code duplication, and also empowers many of the existing range types in MLIR(e.g. result type ranges, operand ranges, ElementsAttr ranges, etc.). This change only updates RegionRange and ValueRange, more ranges will be updated in followup commits. PiperOrigin-RevId: 284615679
* Add RegionRange for when need to abstract over different region iterationJacques Pienaar2019-12-091-2/+1
| | | | | | | | | | | | Follows ValueRange in representing a generic abstraction over the different ways to represent a range of Regions. This wrapper is not as ValueRange and only considers the current cases of interest: MutableArrayRef<Region> and ArrayRef<std::unique_ptr<Region>> as occurs during op construction vs op region querying. Note: ArrayRef<std::unique_ptr<Region>> allows for unset regions, so this range returns a pointer to a Region instead of a Region. PiperOrigin-RevId: 284563229
* Update the builder API to take ValueRange instead of ArrayRef<Value *>River Riddle2019-12-071-0/+32
| | | | | | This allows for users to provide operand_range and result_range in builder.create<> calls, instead of requiring an explicit copy into a separate data structure like SmallVector/std::vector. PiperOrigin-RevId: 284360710
* Add a new ValueRange class.River Riddle2019-12-061-0/+36
| | | | | | | | This class represents a generic abstraction over the different ways to represent a range of Values: ArrayRef<Value *>, operand_range, result_range. This class will allow for removing the many instances of explicit SmallVector<Value *, N> construction. It has the same memory cost as ArrayRef, and only suffers cost from indexing(if+elsing the different underlying representations). This change only updates a few of the existing usages, with more to be changed in followups; e.g. 'build' API. PiperOrigin-RevId: 284307996
* minor spelling tweaksKazuaki Ishizaki2019-12-061-1/+1
| | | | | | | Closes tensorflow/mlir#290 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/290 from kiszk:spelling_tweaks_201912 9d9afd16a723dd65754a04698b3976f150a6054a PiperOrigin-RevId: 284169681
* Optimize operation ordering to support non-congruent indices.River Riddle2019-12-041-5/+73
| | | | | | This change adds support for non-congruent indices in the operation ordering within a basic block. This effect of this is that insertions are less likely to cause an invalidation of the ordering within a block. This has a big effect on modules that have very large basic blocks. PiperOrigin-RevId: 283858136
* Verifier: Better error message in case of successor operand mismatch.Sean Silva2019-12-031-6/+9
| | | | | | In particular, print the successor number in the diagnostic. PiperOrigin-RevId: 283585084
* Fix redundant convert and use NamedAttributeList as valueJacques Pienaar2019-11-291-6/+6
| | | | | | | | * Had leftover call that would result in converting to dictionary attr before being implicitedly converted back to NamedAttributeList; * NamedAttributeList is value typed, so don't use const reference; PiperOrigin-RevId: 283072576
* Add create method that takes equivalent of OperationState with ↵Jacques Pienaar2019-11-261-6/+19
| | | | | | | | | | | | | NamedAttributeList This method is close to creating an OperationState first and then unpacking it but avoids creating the OperationState and takes a NamedAttributeList for attributes rather than array of NamedAttribute (to enable reusing an already created NamedAttributeList). Reuse this new method via create that takes OperationState. I'll update inferReturnTypes in follow up to also take NamedAttributeList and so a build method that uses both inferReturnTypes and create can reuse the same list. PiperOrigin-RevId: 282651642
* Add support for AttrSizedOperandSegments/AttrSizedResultSegmentsLei Zhang2019-11-251-0/+41
| | | | | | | | | | | | | | | | | Certain operations can have multiple variadic operands and their size relationship is not always known statically. For such cases, we need a per-op-instance specification to divide the operands into logical groups or segments. This can be modeled by attributes. This CL introduces C++ trait AttrSizedOperandSegments for operands and AttrSizedResultSegments for results. The C++ trait just guarantees such size attribute has the correct type (1D vector) and values (non-negative), etc. It serves as the basis for ODS sugaring that with ODS argument declarations we can further verify the number of elements match the number of ODS-declared operands and we can generate handy getter methods. PiperOrigin-RevId: 282467075
* Add multi-level DCE pass.Sean Silva2019-11-201-0/+15
| | | | | | | | | This is a simple multi-level DCE pass that operates pretty generically on the IR. Its key feature compared to the existing peephole dead op folding that happens during canonicalization is being able to delete recursively dead cycles of the use-def graph, including block arguments. PiperOrigin-RevId: 281568202
* Add an option to print an operation if a diagnostic is emitted on itRiver Riddle2019-11-121-6/+40
| | | | | | It is often helpful to inspect the operation that the error/warning/remark/etc. originated from, especially in the context of debugging or in the case of a verifier failure. This change adds an option 'mlir-print-op-on-diagnostic' that attaches the operation as a note to any diagnostic that is emitted on it via Operation::emit(Error|Warning|Remark). In the case of an error, the operation is printed in the generic form. PiperOrigin-RevId: 280021438
* Replace some remnant uses of "inst" with "op".Sean Silva2019-11-061-7/+7
| | | | PiperOrigin-RevId: 278961676
* NFC: Rename parseOptionalAttributeDict -> parseOptionalAttrDict to match the ↵River Riddle2019-11-051-2/+2
| | | | | | name of the print method. PiperOrigin-RevId: 278696668
* Allow dynamic but ranked types in ops with SameOperandsAndResultShape and ↵Smit Hinsu2019-10-081-25/+8
| | | | | | | | | | SameOperandsAndResultType traits Currently SameOperandsAndResultShape trait allows operands to have tensor<*xf32> and tensor<2xf32> but doesn't allow tensor<?xf32> and tensor<10xf32>. Also, use the updated shape compatibility helper function in TensorCastOp::areCastCompatible method. PiperOrigin-RevId: 273658336
* Allow element type traits to operate on scalarsGeoffrey Martin-Noble2019-10-051-22/+8
| | | | | | | | This allows confirming that a scalar argument has the same element type as a shaped one. It's easy to validate a type is shaped on its own if that's desirable, so this shouldn't make that use case harder. This matches the behavior of other traits that operate on element type (e.g. AllElementTypesMatch). Also this makes the code simpler because now we just use getElementTypeOrSelf. Verified that all uses in core already check the type is shaped in another way. PiperOrigin-RevId: 273068507
* Generalize parse/printBinaryOp to parse/printOneResultOp.Christian Sigg2019-10-031-9/+10
| | | | PiperOrigin-RevId: 272722539
* Add verification error message for ops that require at least one operand or ↵Christian Sigg2019-10-011-5/+8
| | | | | | result. PiperOrigin-RevId: 272153634
* Switch explicit create methods to match generated build's orderJacques Pienaar2019-09-281-6/+6
| | | | | | 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
* NFC: Pass OpAsmPrinter by reference instead of by pointer.River Riddle2019-09-201-12/+11
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270401378
* NFC: Pass OperationState by reference instead of by pointer.River Riddle2019-09-201-15/+15
| | | | | | 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-15/+15
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270315612
* Fix nested dominance relationship between parent results and child operations.River Riddle2019-09-181-0/+9
| | | | | | This modifies DominanceInfo::properlyDominates(Value *value, Operation *op) to return false if the value is defined by a parent operation of 'op'. This prevents using values defined by the parent operation from within any child regions. PiperOrigin-RevId: 269934920
* Add pass generate per block in a function a GraphViz Dot graph with ops as nodesJacques Pienaar2019-09-091-0/+43
| | | | | | | | | | | * Add GraphTraits that treat a block as a graph, Operation* as node and use-relationship for edges; - Just basic graph output; * Add use iterator to iterate over all uses of an Operation; * Add testing pass to generate op graph; This does not support arbitrary operations other than function nor nested regions yet. PiperOrigin-RevId: 268121782
* Refactor the 'walk' methods for operations.River Riddle2019-08-291-13/+0
| | | | | | | | | | | | This change refactors and cleans up the implementation of the operation walk methods. After this refactoring is that the explicit template parameter for the operation type is no longer needed for the explicit op walks. For example: op->walk<AffineForOp>([](AffineForOp op) { ... }); is now accomplished via: op->walk([](AffineForOp op) { ... }); PiperOrigin-RevId: 266209552
* Add implementation for tensor_load and tensor_store operations.Stephan Herhut2019-08-281-0/+32
| | | | | | This change adds definitions, parsing and verification for both ops. PiperOrigin-RevId: 265954051
* NFC: Remove the explicit context from Operation::create and OperationState.River Riddle2019-08-261-11/+10
| | | | | | The context can easily be recovered from the Location in these situations. PiperOrigin-RevId: 265578574
* NFC: Standardize the terminology used for parent ops/regions/etc.River Riddle2019-08-091-3/+3
| | | | | | There are currently several different terms used to refer to a parent IR unit in 'get' methods: getParent/getEnclosing/getContaining. This cl standardizes all of these methods to use 'getParent*'. PiperOrigin-RevId: 262680287
* FuncOp::eraseBody: drop all references before erasing blocksAlex Zinenko2019-07-121-2/+1
| | | | | | | | | | Operations in a block can use a value defined in a dominating block. When a block, and therefore all its operations, is deleted, the operations are not allowed to have any remaining uses. Drop all uses of values in all blocks before deleting them in FuncOp::eraseBody to avoid deleting an operation before deleting the users of its results. PiperOrigin-RevId: 257628002
* NFC: Remove the various "::getFunction" methods.River Riddle2019-07-081-4/+0
| | | | | | These methods assume that a function is a valid builtin top-level operation, and removing these methods allows for decoupling FuncOp and IR/. Utility "getParentOfType" methods have been added to Operation/OpState to allow for querying the first parent operation of a given type. PiperOrigin-RevId: 257018913
* Replace the implementation of Function and Module with FuncOp and ModuleOp.River Riddle2019-07-031-2/+4
| | | | | | 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
* NFC: Update the Operation 'walk' methods to use llvm::function_ref instead ↵River Riddle2019-07-021-1/+1
| | | | | | of std::function. PiperOrigin-RevId: 256099638
* NFC: Refactor Function to be value typed.River Riddle2019-07-011-4/+5
| | | | | | 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
* Cleanup the 'clone' methods and remove the need to explicitly pass in the ↵River Riddle2019-06-271-11/+9
| | | | | | | | context. This also adds a new 'Region::cloneInto' method that accepts an insertion position. PiperOrigin-RevId: 255504640
* 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
* NFC: Simplify Operation::getContext to use the context within the location.River Riddle2019-06-241-13/+1
| | | | PiperOrigin-RevId: 254771979
* Define a ModuleOp that represents a Module as an Operation.River Riddle2019-06-221-0/+21
| | | | | | | | | | | | | | | | | | The ModuleOp contains a single region that must contain a single block. This block must be terminated by a new pseudo operation 'module_terminator'. The syntax for this operations is as follows: `module` (`attributes` attr-dict)? region Example: module { ... } module attributes { ... } { ... } PiperOrigin-RevId: 254513752
* Refactor generic op printing: extract a public printFunctionalType() on ↵Mehdi Amini2019-06-191-1/+2
| | | | | | OpAsmPrinter (NFC) PiperOrigin-RevId: 253674584
OpenPOWER on IntegriCloud