summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
...
* Update the PatternRewriter constructor to take a context instead of a region.River Riddle2019-07-122-6/+6
| | | | | | This will allow for cleanly using a rewriter for multiple different regions. PiperOrigin-RevId: 257845371
* Remove the 'region' field from OpBuilder.River Riddle2019-07-121-5/+5
| | | | | | This field wasn't updated as the insertion point changed, making it potentially dangerous given the multi-level of MLIR(e.g. 'createBlock' would always insert the new block in 'region'). This also allows for building an OpBuilder with just a context. PiperOrigin-RevId: 257829135
* Fix a bug in the canonicalizer when replacing constants via patterns.River Riddle2019-07-121-3/+6
| | | | | | The GreedyPatternRewriteDriver currently does not notify the OperationFolder when constants are removed as part of a pattern match. This materializes in a nasty bug where a different operation may be allocated to the same address. This causes an assertion in the OperationFolder when it gets notified of the new operations removal. PiperOrigin-RevId: 257817627
* Lower affine control flow to std control flow to LLVM dialectNicolas Vasilache2019-07-122-233/+32
| | | | | | | | | | | | | This CL splits the lowering of affine to LLVM into 2 parts: 1. affine -> std 2. std -> LLVM The conversions mostly consists of splitting concerns between the affine and non-affine worlds from existing conversions. Short-circuiting of affine `if` conditions was never tested or exercised and is removed in the process, it can be reintroduced later if needed. LoopParametricTiling.cpp is updated to reflect the newly added ForOp::build. PiperOrigin-RevId: 257794436
* Rename FunctionAttr to SymbolRefAttr.River Riddle2019-07-124-0/+4
| | | | | | This allows for the attribute to hold symbolic references to other operations than FuncOp. This also allows for removing the dependence on FuncOp from the base Builder. PiperOrigin-RevId: 257650017
* EDSC: use affine.load/store instead of std.load/storeAlex Zinenko2019-07-121-2/+2
| | | | | | | | | | | Standard load and store operations are evolving to be separated from the Affine constructs. Special affine.load/store have been introduced to uphold the restrictions of the Affine control flow constructs on their operands. EDSC-produced loads and stores were originally intended to uphold those restrictions as well so they should use affine.load/store instead of std.load/store. PiperOrigin-RevId: 257443307
* NFC: Rename Module to ModuleOp.River Riddle2019-07-101-1/+1
| | | | | | Module is a legacy name that only exists as a typedef of ModuleOp. PiperOrigin-RevId: 257427248
* NFC: Rename Function to FuncOp.River Riddle2019-07-1013-24/+24
| | | | PiperOrigin-RevId: 257293379
* Fix a test broken on some systems due to a mis-rebase.Alex Zinenko2019-07-093-2/+2
| | | | PiperOrigin-RevId: 257190161
* Implement parametric tiling on standard for loopsAlex Zinenko2019-07-092-8/+238
| | | | | | | | | | | | | | | | | | Parametric tiling can be used to extract outer loops with fixed number of iterations. This in turn enables mapping to GPU kernels on a fixed grid independently of the range of the original loops, which may be unknown statically, making the kernel adaptable to different sizes. Provide a utility function that also computes the parametric tile size given the range of the loop. Exercise the utility function through a simple pass that applies it to all top-level loop nests. Permutability or parallelism checks must be performed before calling this utility function in actual passes. Note that parametric tiling cannot be implemented in a purely affine way, although it can be encoded using semi-affine maps. The choice to implement it on standard loops is guided by them being the common representation between Affine loops, Linalg and GPU kernels. PiperOrigin-RevId: 257180251
* NFC: Remove `Module::getFunctions` in favor of a general `getOps<T>`.River Riddle2019-07-081-1/+1
| | | | | | Modules can now contain more than just Functions, this just updates the iteration API to reflect that. The 'begin'/'end' methods have also been updated to iterate over opaque Operations. PiperOrigin-RevId: 257099084
* NFC: Remove the various "::getFunction" methods.River Riddle2019-07-085-15/+12
| | | | | | 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
* NFC: Remove Region::getContainingFunction as Functions are now Operations.River Riddle2019-07-042-4/+3
| | | | PiperOrigin-RevId: 256579717
* Globally change load/store/dma_start/dma_wait operations over to ↵Andy Davis2019-07-038-130/+253
| | | | | | | | | | | affine.load/store/dma_start/dma_wait. In most places, this is just a name change (with the exception of affine.dma_start swapping the operand positions of its tag memref and num_elements operands). Significant code changes occur here: *) Vectorization: LoopAnalysis.cpp, Vectorize.cpp *) Affine Transforms: Transforms/Utils/Utils.cpp PiperOrigin-RevId: 256395088
* NFC: Refactor Module to be value typed.River Riddle2019-07-021-1/+1
| | | | | | As with Functions, Module will soon become an operation, which are value-typed. This eases the transition from Module to ModuleOp. A new class, OwningModuleRef is provided to allow for owning a reference to a Module, and will auto-delete the held module on destruction. PiperOrigin-RevId: 256196193
* Generalize the CFG graph printing for Functions to work on Regions instead.River Riddle2019-07-012-18/+19
| | | | PiperOrigin-RevId: 256029944
* Standardize the definition and usage of getAllArgAttrs between FuncOp and ↵River Riddle2019-07-011-2/+5
| | | | | | Function. PiperOrigin-RevId: 255988352
* NFC: Refactor Function to be value typed.River Riddle2019-07-0114-71/+49
| | | | | | 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
* TypeConversion: do not materialize conversion of the type to itselfAlex Zinenko2019-07-011-0/+9
| | | | | | | | | | Type conversion does not necessarily affect all types, some of them may remain untouched. The type conversion tool from the dialect conversion framework will unconditionally insert a temporary cast operation from the type to itself anyway, and will try to materialize it to a real conversion operation if there are remaining uses. Simply use the original value instead. PiperOrigin-RevId: 255975450
* Add affine-to-standard lowerings for affine.load/store/dma_start/dma_wait.Andy Davis2019-07-011-1/+130
| | | | PiperOrigin-RevId: 255960171
* Add a folder-based EDSC intrinsics constructor (NFC)Nicolas Vasilache2019-07-012-7/+22
| | | | PiperOrigin-RevId: 255908660
* Refactor DialectConversion to use 'materializeConversion' when a type ↵River Riddle2019-06-281-63/+43
| | | | | | | | conversion must persist after the conversion has finished. During conversion, if a type conversion has dangling uses a type conversion must persist after conversion has finished to maintain valid IR. In these cases, we now query the TypeConverter to materialize a conversion for us. This allows for the default case of a full conversion to continue working as expected, but also handle the degenerate cases more robustly. PiperOrigin-RevId: 255637171
* Move the emitError/Warning/Remark utility methods out of MLIRContext and ↵River Riddle2019-06-252-15/+10
| | | | | | | | 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: Uniformize the return of the LocationAttr 'get' methods to 'Location'.River Riddle2019-06-252-2/+2
| | | | PiperOrigin-RevId: 255078768
* Update the OperationFolder to find a valid insertion point when ↵River Riddle2019-06-252-44/+59
| | | | | | | | materializing constants. The OperationFolder currently just inserts into the entry block of a Function, but regions may be isolated above, i.e. explicit capture only, and blindly inserting constants may break the invariants of these regions. PiperOrigin-RevId: 254987796
* NFC: Move the ArgConverter methods out-of-line to improve readability.River Riddle2019-06-241-182/+217
| | | | PiperOrigin-RevId: 254872695
* Fix OSS buildNicolas Vasilache2019-06-241-1/+0
| | | | PiperOrigin-RevId: 254847773
* Split test-specific passes out of mlir-optNicolas Vasilache2019-06-244-559/+0
| | | | | | Instead put their impl in test/lib and link them into mlir-test-opt PiperOrigin-RevId: 254837439
* Update CSE to respect nested regions that are isolated from above. This cl ↵River Riddle2019-06-241-28/+40
| | | | | | also removes the unused 'NthRegionIsIsolatedFromAbove' trait as it was replaced with a more general 'IsIsolatedFromAbove'. PiperOrigin-RevId: 254709704
* Add a new dialect hook 'materializeConstant' to create a constant operation ↵River Riddle2019-06-223-87/+129
| | | | | | that materializes an attribute value with the given type. This effectively adds support for dialect specific constant values that have different invariants than std.constant. 'OperationFolder' is updated to use this new hook, or attempt to default to std.constant when legal. PiperOrigin-RevId: 254570153
* NFC: Remove the 'context' parameter from OperationState.River Riddle2019-06-223-10/+7
| | | | | | Now that Locations are Attributes they contain a direct reference to the MLIRContext, i.e. the context can be directly accessed from the given location instead of being explicitly passed in. PiperOrigin-RevId: 254568329
* Add support for 1->N type mappings in the dialect conversion infrastructure. ↵River Riddle2019-06-221-14/+49
| | | | | | To support these mappings a hook must be overridden on the type converter: 'materializeConversion' :to generate a cast operation from the new types to the old type. This operation is automatically erased if all uses are removed, otherwise it remains in the IR for the user to handle. PiperOrigin-RevId: 254411383
* Add an overload to 'PatternRewriter::inlineRegionBefore' that accepts a ↵River Riddle2019-06-222-7/+6
| | | | | | parent region for the insertion position. This allows for inlining the given region into the end of another region. PiperOrigin-RevId: 254367375
* Uniformize usage of OpBuilder& (NFC)Nicolas Vasilache2019-06-226-61/+60
| | | | | | | Historically the pointer-based version of builders was used. This CL uniformizes to OpBuilder & PiperOrigin-RevId: 254280885
* Rename ConversionTarget::isLegal to isDynamicallyLegal to better represent ↵River Riddle2019-06-221-1/+1
| | | | | | what the function is actually checking. PiperOrigin-RevId: 254141073
* Refactor the TypeConverter to support more robust type conversions:River Riddle2019-06-191-117/+324
| | | | | | | | | | | | * 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
* Simplify usages of SplatElementsAttr now that it inherits from ↵River Riddle2019-06-191-1/+1
| | | | | | DenseElementsAttr. PiperOrigin-RevId: 253910543
* Factor fusion compute cost calculation out of LoopFusion and into ↵Andy Davis2019-06-192-221/+244
| | | | | | LoopFusionUtils (NFC). PiperOrigin-RevId: 253797886
* Factor Region::getUsedValuesDefinedAbove into Transforms/RegionUtilsAlex Zinenko2019-06-191-0/+24
| | | | | | | | Arguably, this function is only useful for transformations and should not pollute the main IR. Also make sure it accepts a the resulting container by-reference instead of returning it. PiperOrigin-RevId: 253622981
* LoopFusion: adds support for computing forward computation slices, which ↵Andy Davis2019-06-193-34/+105
| | | | | | will enable fusion of consumer loop nests into their producers in subsequent CLs. PiperOrigin-RevId: 253601994
* Convert a nest affine loops to a GPU kernelAlex Zinenko2019-06-193-23/+70
| | | | | | | | | 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
* Refactor SplatElementsAttr to inherit from DenseElementsAttr as opposed to ↵River Riddle2019-06-192-11/+11
| | | | | | being a separate Attribute type. DenseElementsAttr provides a better internal representation for splat values as well as better API for accessing elements. PiperOrigin-RevId: 253138287
* Add basic cost modeling to the dialect conversion infrastructure. This ↵River Riddle2019-06-191-0/+84
| | | | | | | | | | | | initial cost model favors specific patterns based upon two criteria: 1) Lowest minimum pattern stack depth when legalizing. - This leads the system to favor patterns that have lower legalization stacks, i.e. represent a more direct mapping to the target. 2) Pattern benefit. - When considering multiple patterns with the same legalization depth, this favors patterns with a larger specified benefit. PiperOrigin-RevId: 252713470
* NFC: Cleanup the naming scheme for registering legalization actions to be ↵River Riddle2019-06-112-1/+32
| | | | | | consistent, and move a file functions to the source file. PiperOrigin-RevId: 252639629
* Use DialectConversion to lower the Affine dialect to the Standard dialectAlex Zinenko2019-06-112-281/+375
| | | | | | | | | | | | | | | | | | | | | 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
* Return dependence result enum to distiguish between dependence result and ↵Andy Davis2019-06-112-6/+8
| | | | | | error cases (NFC). PiperOrigin-RevId: 252437616
* Add support to ConversionTarget for storing legalization actions for entire ↵River Riddle2019-06-091-62/+23
| | | | | | dialects as opposed to individual operations. This allows for better support of unregistered operations, as well as removing the need to collect all of the operations for a given dialect(which may be very expensive). PiperOrigin-RevId: 251943590
* Add support for matchAndRewrite to the DialectConversion patterns. This also ↵River Riddle2019-06-091-11/+10
| | | | | | drops the default "always succeed" match override to better align with RewritePattern. PiperOrigin-RevId: 251941625
* Add utility 'create' methods to OperationFolder that will create an ↵River Riddle2019-06-091-1/+1
| | | | | | operation with a given OpBuilder and automatically try to fold it, similarly to OpBuilder::createOrFold. The difference here is that these methods enable folding to constants in addition to existing values. This functionality is then used to replace linalg::FunctionConstants. PiperOrigin-RevId: 251716247
* Always remap results when replacing an operation. This prevents a crash when ↵River Riddle2019-06-091-4/+7
| | | | | | lowering identity(passthrough) operations to the same resultant type as the original operation. PiperOrigin-RevId: 251665492
OpenPOWER on IntegriCloud