summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/PatternMatch.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
* Change the `notifyRootUpdated` API to be transaction based.River Riddle2019-12-231-17/+0
| | | | | | 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
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-231-13/+4
| | | | PiperOrigin-RevId: 286906740
* Add a new ValueRange class.River Riddle2019-12-061-10/+7
| | | | | | | | 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
* Add a PatternRewriter hook to merge blocks, and use it to support for ↵River Riddle2019-11-051-0/+29
| | | | | | | | | | | | | | | | | | | folding branches. A pattern rewriter hook, mergeBlock, is added that allows for merging the operations of one block into the end of another. This is used to support a canonicalization pattern for branch operations that folds the branch when the successor has a single predecessor(the branch block). Example: ^bb0: %c0_i32 = constant 0 : i32 br ^bb1(%c0_i32 : i32) ^bb1(%x : i32): return %x : i32 becomes: ^bb0: %c0_i32 = constant 0 : i32 return %c0_i32 : i32 PiperOrigin-RevId: 278677825
* Add support for PatternRewriter::eraseOp.River Riddle2019-10-161-0/+8
| | | | | | This hook is useful when an operation is known to be dead, and no replacement values make sense. PiperOrigin-RevId: 275052756
* Add a PatternRewriter hook for cloning a region into another.River Riddle2019-10-081-0/+19
| | | | | | This is similar to the `inlineRegionBefore` hook, except the original blocks are unchanged. The region to be cloned *must* not have been modified during the conversion process at the point of cloning, i.e. it must belong an operation that has yet to be converted, or the operation that is currently being converted. PiperOrigin-RevId: 273622533
* NFC: Update pattern rewrite API to pass OwningRewritePatternList by const ↵River Riddle2019-08-111-1/+1
| | | | | | | | reference. The pattern list is not modified by any of these APIs and should thus be passed with const. PiperOrigin-RevId: 262844002
* Add utility 'replaceAllUsesWith' methods to Operation.River Riddle2019-08-071-2/+1
| | | | | | These methods will allow replacing the uses of results with an existing operation, with the same number of results, or a range of values. This removes a number of hand-rolled result replacement loops and simplifies replacement for operations with multiple results. PiperOrigin-RevId: 262206600
* NFC: Implement OwningRewritePatternList as a class instead of a using directive.River Riddle2019-08-051-5/+6
| | | | | | This allows for proper forward declaration, as opposed to leaking the internal implementation via a using directive. This also allows for all pattern building to go through 'insert' methods on the OwningRewritePatternList, replacing uses of 'push_back' and 'RewriteListBuilder'. PiperOrigin-RevId: 261816316
* Add an overload to 'PatternRewriter::inlineRegionBefore' that accepts a ↵River Riddle2019-06-221-2/+5
| | | | | | parent region for the insertion position. This allows for inlining the given region into the end of another region. PiperOrigin-RevId: 254367375
* Use DialectConversion to lower the Affine dialect to the Standard dialectAlex Zinenko2019-06-111-0/+9
| | | | | | | | | | | | | | | | | | | | | This introduces the support for region-containing operations to the dialect conversion framework in order to support the conversion of affine control-flow operations into the standard control flow with branches. Regions that belong to an operation are converted before the operation itself. The DialectConversionPattern can therefore access the converted regions of the original operation and process them further if necessary. In particular, the conversion is allowed to move the blocks from the original region to other regions and to split blocks into multiple blocks. All block manipulations must be performed through the PatternRewriter to ensure they will be undone if the conversion fails. Port the pass converting from the affine dialect (loops and ifs with bodies as regions) to the standard dialect (branch-based cfg) to use DialectConversion in order to exercise this new functionality. The modification to the lowering functions are minor and are focused on using the PatterRewriter instead of directly modifying the IR. PiperOrigin-RevId: 252625169
* Add support to RewritePattern for specifying the potential operations ↵River Riddle2019-06-011-0/+14
| | | | | | | | that can be generated during a rewrite. This will enable analyses to start understanding the possible effects of applying a rewrite pattern. -- PiperOrigin-RevId: 249936309
* Rewrite the DialectOpConversion patterns to inherit from RewritePattern ↵River Riddle2019-05-201-3/+4
| | | | | | | | instead of Pattern. This simplifies the infrastructure a bit by being able to reuse PatternRewriter and the RewritePatternMatcher, but also starts to lay the groundwork for a more generalized legalization framework that can operate on DialectOpConversions as well as normal RewritePatterns. -- PiperOrigin-RevId: 248836492
* Apply patterns repeatly if the function is modifiedFeng Liu2019-04-231-2/+3
| | | | | | | | | | | | | | | | | | During the pattern rewrite, if the function is changed, i.e. ops created, deleted or swapped, the pattern rewriter needs to re-scan the function entirely and apply the patterns again, so the patterns whose root ops have been popped out from the working list nor an immediate users of the changed ops can be reconsidered. A command line flag is added to set the max number of iterations rescanning the function for pattern match. If the rewrite doesn' converge after this number, this compiling will continue and the result can be sub-optimal. One unit test is updated because this change fixed the missing optimization opportunities. -- PiperOrigin-RevId: 244754190
* Replace usages of Instruction with Operation in the /IR directory.River Riddle2019-03-291-10/+8
| | | | | | 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
* 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
* Remove remaining references to OperationInst in all directories except for ↵River Riddle2019-03-291-7/+6
| | | | | | lib/Transforms. PiperOrigin-RevId: 232322771
* Fold the functionality of OperationInst into Instruction. OperationInst ↵River Riddle2019-03-291-1/+1
| | | | | | still exists as a forward declaration and will be removed incrementally in a set of followup cleanup patches. PiperOrigin-RevId: 232198540
* Standardize naming of statements -> instructions, revisting the code base to beChris Lattner2019-03-291-1/+1
| | | | | | | | | consistent and moving the using declarations over. Hopefully this is the last truly massive patch in this refactoring. This is step 21/n towards merging instructions and statements, NFC. PiperOrigin-RevId: 227178245
* Merge Operation into OperationInst and standardize nomenclature aroundChris Lattner2019-03-291-6/+9
| | | | | | | | OperationInst. This is a big mechanical patch. This is step 16/n towards merging instructions and statements, NFC. PiperOrigin-RevId: 227093712
* Merge SSAValue, CFGValue, and MLValue together into a single Value class, whichChris Lattner2019-03-291-8/+7
| | | | | | | | | is the new base of the SSA value hierarchy. This CL also standardizes all the nomenclature and comments to use 'Value' where appropriate. This also eliminates a large number of cast<MLValue>(x)'s, which is very soothing. This is step 11/n towards merging instructions and statements, NFC. PiperOrigin-RevId: 227064624
* Split "rewrite" functionality out of Pattern into a new RewritePattern derivedChris Lattner2019-03-291-7/+10
| | | | | | | | class. This change is NFC, but allows for new kinds of patterns, specifically LegalizationPatterns which will be allowed to change the types of things they rewrite. PiperOrigin-RevId: 223243783
* Tidy up the replaceOp hooks in PatternMatch, generalizing them to support anyChris Lattner2019-03-291-24/+19
| | | | | | number of result ops. Among other things, this results in shorter names PiperOrigin-RevId: 222685039
* Minimal patch to allow patterns to rewrite multi-result instructions, ↵Chris Lattner2019-03-291-0/+23
| | | | | | related to b/119877155 PiperOrigin-RevId: 222597798
* - Simplify PatternMatch to *require* static benefits at pattern constructionChris Lattner2019-03-291-55/+13
| | | | | | | | | | | time. The "Fast and Flexible Instruction Selection With Constraints" paper from CC2018 makes a credible argument that dynamic costs aren't actually necessary/important, and we are not using them. - Check in my "MLIR Generic DAG Rewriter Infrastructure" design doc into the source tree. PiperOrigin-RevId: 221017546
* Refactor all of the canonicalization patterns out of the Canonicalize pass, andChris Lattner2019-03-291-0/+195
make operations provide a list of canonicalizations that can be applied to them. This allows canonicalization to be general to any IR definition. As part of this, sink PatternMatch.h/cpp down to the IR library to fix a layering problem. PiperOrigin-RevId: 218773981
OpenPOWER on IntegriCloud