summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Block.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-111-1/+1
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* [mlir][GPU] introduce utilities for promotion to workgroup memoryAlex Zinenko2020-01-091-0/+14
| | | | | | | | | | | | | | | | | | | Introduce a set of function that promote a memref argument of a `gpu.func` to workgroup memory using memory attribution. The promotion boils down to additional loops performing the copy from the original argument to the attributed memory in the beginning of the function, and back at the end of the function using all available threads. The loop bounds are specified so as to adapt to any size of the workgroup. These utilities are intended to compose with other existing utilities (loop coalescing and tiling) in cases where the distribution of work across threads is uneven, e.g. copying a 2D memref with only the threads along the "x" dimension. Similarly, specialization of the kernel to specific launch sizes should be implemented as a separate pass combining constant propagation and canonicalization. Introduce a simple attribute-driven pass to test the promotion transformation since we don't have a heuristic at the moment. Differential revision: https://reviews.llvm.org/D71904
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-1/+1
| | | | | | ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
* Change the `notifyRootUpdated` API to be transaction based.River Riddle2019-12-231-0/+5
| | | | | | This means that in-place, or root, updates need to use explicit calls to `startRootUpdate`, `finalizeRootUpdate`, and `cancelRootUpdate`. The major benefit of this change is that it enables in-place updates in DialectConversion, which simplifies the FuncOp pattern for example. The major downside to this is that the cases that *may* modify an operation in-place will need an explicit cancel on the failure branches(assuming that they started an update before attempting the transformation). PiperOrigin-RevId: 286933674
* Resubmit: ReImplement the Value classes as value-typed objects wrapping an ↵River Riddle2019-12-231-5/+6
| | | | | | | | 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-6/+5
| | | | PiperOrigin-RevId: 286924059
* ReImplement the Value classes as value-typed objects wrapping an internal ↵River Riddle2019-12-231-5/+6
| | | | | | | | 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-2/+2
| | | | | | | | | | 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
* Insert signature-converted blocks into a region with a parent operation.River Riddle2019-12-161-1/+9
| | | | | | This keeps the IR valid and consistent as it is expected that each block should have a valid parent region/operation. Previously, converted blocks were kept floating without a valid parent region. PiperOrigin-RevId: 285821687
* Refactor the Block support classes.River Riddle2019-12-091-0/+10
| | | | | | Each of the support classes for Block are now moved into a new header BlockSupport.h. The successor iterator class is also reimplemented as an indexed_accessor_range. This makes the class more efficient, and expands on its available functionality. PiperOrigin-RevId: 284646792
* Optimize operation ordering to support non-congruent indices.River Riddle2019-12-041-4/+3
| | | | | | 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
* Replace some remnant uses of "inst" with "op".Sean Silva2019-11-061-19/+17
| | | | PiperOrigin-RevId: 278961676
* Change Block::getParent() to be a const function. This is only necessary ↵Christian Sigg2019-10-071-1/+3
| | | | | | because ilist_node_with_parent specifically requires a 'getParent() const' method. If/When ilist_node removes this constraint we should drop the const to fit the rest of the MLIR const model. PiperOrigin-RevId: 273316153
* NFC: Remove stray logging from ~Block().River Riddle2019-09-181-5/+0
| | | | PiperOrigin-RevId: 269941815
* Refactor the 'walk' methods for operations.River Riddle2019-08-291-16/+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
* 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
* Refactor the conversion of block argument types in DialectConversion.River Riddle2019-07-191-0/+7
| | | | | | | | This cl begins a large refactoring over how signature types are converted in the DialectConversion infrastructure. The signatures of blocks are now converted on-demand when an operation held by that block is being converted. This allows for handling the case where a region is created as part of a pattern, something that wasn't possible previously. This cl also generalizes the region signature conversion used by FuncOp to work on any region of any operation. This generalization allows for removing the 'apply*Conversion' functions that were specific to FuncOp/ModuleOp. The implementation currently uses a new hook on TypeConverter, 'convertRegionSignature', but this should ideally be removed in favor of using Patterns. That depends on adding support to the PatternRewriter used by ConversionPattern to allow applying signature conversions to regions, which should be coming in a followup. PiperOrigin-RevId: 258645733
* NFC: Remove the various "::getFunction" methods.River Riddle2019-07-081-9/+4
| | | | | | 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-10/+3
| | | | | | 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-2/+2
| | | | | | of std::function. PiperOrigin-RevId: 256099638
* NFC: Refactor Function to be value typed.River Riddle2019-07-011-1/+1
| | | | | | 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
* Simplify PredecessorIterator by using mapped_iterator.River Riddle2019-06-221-11/+13
| | | | PiperOrigin-RevId: 254495164
* Refactor the TypeConverter to support more robust type conversions:River Riddle2019-06-191-1/+5
| | | | | | | | | | | | * Support for 1->0 type mappings, i.e. when the argument is being removed. * Reordering types when converting a type signature. * Adding new inputs when converting a type signature. This cl also lays down the initial foundation for supporting 1->N type mappings, but full support will come in a followup. Moving forward, function signature changes will be driven by populating a SignatureConversion instance. This class contains all of the necessary information for adding/removing/remapping function signatures; e.g. addInputs, addResults, remapInputs, etc. PiperOrigin-RevId: 254064665
* Move the Region type out to its own .h/.cpp file instead of putting it intoChris Lattner2019-06-191-201/+14
| | | | | | | | Block.h/cpp. This doesn't change much but makes it easier to find. PiperOrigin-RevId: 253423041
* Convert a nest affine loops to a GPU kernelAlex Zinenko2019-06-191-11/+24
| | | | | | | | | This converts entire loops into threads/blocks. No check on the size of the block or grid, or on the validity of parallelization is performed, it is under the responsibility of the caller to strip-mine the loops and to perform the dependence analysis before calling the conversion. PiperOrigin-RevId: 253189268
* Add a general operation property 'IsolatedFromAbove' that guarantees that ↵River Riddle2019-06-091-1/+1
| | | | | | all regions of a given operation are explicit capture only and will not reference values defined above the enclosing operation. This trait will be useful for applying some of the properties currently attached to Functions to operations, e.g. verifying dominance within a specific operation, enabling multi-threading of certain transformations between different instances, etc. PiperOrigin-RevId: 251927466
* NFC: Rename FuncBuilder to OpBuilder and refactor to take a top level region ↵River Riddle2019-06-091-0/+18
| | | | | | instead of a function. PiperOrigin-RevId: 251563898
* Do not assume Blocks belong to FunctionsAlex Zinenko2019-06-011-4/+4
| | | | | | | | | | | | | | | Fix Block::splitBlock and Block::eraseFromFunction that erronously assume blocks belong to functions. They now belong to regions. When splitting, new blocks should be created in the same region as the existing block. When erasing a block, it should be removed from the region rather than from the function body that transitively contains the region. Also rename Block::eraseFromFunction to Block::erase for consistency with other IR containers. -- PiperOrigin-RevId: 250278272
* Return nullptr on ↵Mehdi Amini2019-06-011-2/+0
| | | | | | | | | | | | Region::getContainingOperation()/getContainingFunction() instead of asserting This avoids crashing when trying to dump an operation nested in a region that isn't yet attached to an operation, which is quite useful when debugging. This alone won't be enough to print an unlink Operation, it'll display `<<UNLINKED INSTRUCTION>>`. -- PiperOrigin-RevId: 249496388
* Add the ability to attach notes to Diagnostic/InFlightDiagnostic.River Riddle2019-05-061-15/+14
| | | | | | | | | | | | | Notes are a way to add additional context to a diagnostic, but don't really make sense as standalone diagnostics. Moving forward, notes will no longer be able to be constructed directly and must be attached to a parent Diagnostic. Notes can be attached via `attachNote`: auto diag = ...; diag.attachNote() << "This is a note"; -- PiperOrigin-RevId: 246545971
* Start GPU DialectAlex Zinenko2019-05-061-0/+49
| | | | | | | | | | | | | Define a new dialect related to GPU kernels. Currently, it only contains a single operation for launching a kernel on a three-dimensional grid of thread blocks, following a model similar to that of CUDA. In particular, the body of the kernel contains operations executed by each thread and uses region arguments to accept thread and block identifiers (similar to how the loop body region accepts the induction value). -- PiperOrigin-RevId: 245713728
* Introduce functionality for defining region ancestor relationAlex Zinenko2019-05-061-0/+17
| | | | | | | | | | | | Add member functions for Regions to query if another Region is a ancestor. The implementation is naive and traverses all parent regions performing one-to-one comparisons. As a side effect, this introduces `getContainingRegion` function for Operations and Values to return the Region in which they are defined, and for Regions to return the "parent" region if any. -- PiperOrigin-RevId: 245057980
* Remove the non-postorder walk functions from Function/Block/Instruction ↵River Riddle2019-04-051-14/+2
| | | | | | | | and rename walkPostOrder to walk. -- PiperOrigin-RevId: 241965239
* Rename InstOperand to OpOperand.River Riddle2019-03-291-3/+3
| | | | PiperOrigin-RevId: 240814651
* Replace usages of Instruction with Operation in the /Analysis directory.River Riddle2019-03-291-1/+1
| | | | PiperOrigin-RevId: 240569775
* Replace usages of Instruction with Operation in the /IR directory.River Riddle2019-03-291-60/+59
| | | | | | 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
* Allow creating standalone RegionsAlex Zinenko2019-03-291-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Various small cleanups to the code, mostly removing const_cast's.Chris Lattner2019-03-291-1/+1
| | | | PiperOrigin-RevId: 240083489
* Remove const from Value, Instruction, Argument, and the various methods on theChris Lattner2019-03-291-5/+5
| | | | | | *Op classes. This is a net reduction by almost 400LOC. PiperOrigin-RevId: 239972443
* Remove const from mlir::Block.Chris Lattner2019-03-291-8/+19
| | | | | | 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-2/+2
| | | | PiperOrigin-RevId: 239642194
* Continue pushing const out of the core IR types - in this case, remove constChris Lattner2019-03-291-3/+3
| | | | | | from Function. PiperOrigin-RevId: 239638635
* Rename BlockList into RegionAlex Zinenko2019-03-291-23/+22
| | | | | | NFC. This is step 1/n to specifying regions as parts of any operation. PiperOrigin-RevId: 238472370
* Remove the restriction that only registered terminator operations may ↵River Riddle2019-03-291-16/+9
| | | | | | 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
* Automated rollback of changelist 232728977.Uday Bondhugula2019-03-291-1/+1
| | | | PiperOrigin-RevId: 232944889
* Automated rollback of changelist 232717775.Uday Bondhugula2019-03-291-1/+1
| | | | PiperOrigin-RevId: 232807986
* Rename the 'if' operation in the AffineOps dialect to 'affine.if' and namespaceRiver Riddle2019-03-291-1/+1
| | | | | | the AffineOps dialect with 'affine'. PiperOrigin-RevId: 232728977
OpenPOWER on IntegriCloud