summaryrefslogtreecommitdiffstats
path: root/mlir/test/lib/TestDialect/TestDialect.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle2020-01-111-6/+6
| | | | | | | | | | properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
* NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle2019-12-231-4/+4
| | | | | | ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
* 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-4/+4
| | | | | | | | | | 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
* Allow dialect to create friendly names for region argumentsFrank Laub2019-12-191-0/+14
| | | | | | | | | This is the block argument equivalent of the existing `getAsmResultNames` hook. Closes tensorflow/mlir#329 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/329 from plaidml:flaub-region-arg-names fc7876f2d1335024e441083cd25263fd6247eb7d PiperOrigin-RevId: 286523299
* Add RegionRange for when need to abstract over different region iterationJacques Pienaar2019-12-091-1/+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-1/+1
| | | | | | 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
* Change inferReturnTypes to return LogicalResult and valuesJacques Pienaar2019-12-061-8/+8
| | | | | | | | Previously the error case was using a sentinel in the error case which was bad. Also make the one `build` invoke the other `build` to reuse verification there. And follow up on suggestion to use formatv which I missed during previous review. PiperOrigin-RevId: 284265762
* De-duplicate EnumAttr overrides by defining defaultsLei Zhang2019-11-251-0/+3
| | | | | | | EnumAttr should provide meaningful defaults so concrete instances do not need to duplicate the fields. PiperOrigin-RevId: 282398431
* Add support for using the ODS result names as the Asm result names for ↵River Riddle2019-11-211-15/+0
| | | | | | | | | | | | | | | multi-result operations. This changes changes the OpDefinitionsGen to automatically add the OpAsmOpInterface for operations with multiple result groups using the provided ODS names. We currently just limit the generation to multi-result ops as most single result operations don't have an interesting name(result/output/etc.). An example is shown below: // The following operation: def MyOp : ... { let results = (outs AnyType:$first, Variadic<AnyType>:$middle, AnyType); } // May now be printed as: %first, %middle:2, %0 = "my.op" ... PiperOrigin-RevId: 281834156
* Add a new OpAsmOpInterface to allow for ops to directly hook into the ↵River Riddle2019-11-201-1/+30
| | | | | | | | | | | | | | | | | | | | | | | AsmPrinter. This interface provides more fine-grained hooks into the AsmPrinter than the dialect interface, allowing for operations to define the asm name to use for results directly on the operations themselves. The hook is also expanded to enable defining named result "groups". Get a special name to use when printing the results of this operation. The given callback is invoked with a specific result value that starts a result "pack", and the name to give this result pack. To signal that a result pack should use the default naming scheme, a None can be passed in instead of the name. For example, if you have an operation that has four results and you want to split these into three distinct groups you could do the following: setNameFn(getResult(0), "first_result"); setNameFn(getResult(1), "middle_results"); setNameFn(getResult(3), ""); // use the default numbering. This would print the operation as follows: %first_result, %middle_results:2, %0 = "my.op" ... PiperOrigin-RevId: 281546873
* Add an option to print an operation if a diagnostic is emitted on itRiver Riddle2019-11-121-0/+7
| | | | | | 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
* Add compatible query method to infer type interfaceJacques Pienaar2019-11-071-3/+8
| | | | | | | | A return type that differs from the inferred return type need not indicate that an operation is invalid (e.g., tensor<*xf32> vs tensor<10xf32>) but they should be compatible for the operation to be considered valid. Add method to query if inferred type is compatible with return type. Also add InferTypeOpIntefaceDefault trait that considers equality and compatibility as the same. Currently an op has to opt in to using it explicitly. PiperOrigin-RevId: 279085639
* Add ReferToOp attribute constraint for SymbolRefAttrLei Zhang2019-11-011-0/+2
| | | | | | | This constraint can be used to limit a SymbolRefAttr to point to a specific kind of op in the closest parent with a symbol table. PiperOrigin-RevId: 278001364
* Parse locations in parseGenericOperationSean Silva2019-10-281-1/+5
| | | | | | | | | For ops that recursively re-enter the parser to parse an operation (such as ops with a "wraps" pretty form), this ensures that the wrapped op will parse its location, which can then be used for the locations of the wrapping op and any other implicit ops. PiperOrigin-RevId: 277152636
* Add support for function result attributes.Sean Silva2019-10-181-0/+18
| | | | | | | | | | | | | | | | | | | | | | This allows dialect-specific attributes to be attached to func results. (or more specifically, FunctionLike ops). For example: ``` func @f() -> (i32 {my_dialect.some_attr = 3}) ``` This attaches my_dialect.some_attr with value 3 to the first result of func @f. Another more complex example: ``` func @g() -> (i32, f32 {my_dialect.some_attr = "foo", other_dialect.some_other_attr = [1,2,3]}, i1) ``` Here, the second result has two attributes attached. PiperOrigin-RevId: 275564165
* Add support for PatternRewriter::eraseOp.River Riddle2019-10-161-1/+1
| | | | | | This hook is useful when an operation is known to be dead, and no replacement values make sense. PiperOrigin-RevId: 275052756
* Add test for fix to tablegen for custom folders for ops that return a singleParker Schuh2019-10-091-0/+8
| | | | | | | | | variadic result. Add missing test for single line fix to `void OpEmitter::genFolderDecls()` entitled "Fold away reduction over 0 dimensions." PiperOrigin-RevId: 273880337
* Add support for inlining calls with different arg/result types from the ↵River Riddle2019-10-031-1/+16
| | | | | | | | callable. Some dialects have implicit conversions inherent in their modeling, meaning that a call may have a different type that the type that the callable expects. To support this, a hook is added to the dialect interface that allows for materializing conversion operations during inlining when there is a mismatch. A hook is also added to the callable interface to allow for introspecting the expected result types. PiperOrigin-RevId: 272814379
* Update the Inliner pass to work on SCCs of the CallGraph.River Riddle2019-10-031-0/+4
| | | | | | This allows for the inliner to work on arbitrary call operations. The updated inliner will also work bottom-up through the callgraph enabling support for multiple levels of inlining. PiperOrigin-RevId: 272813876
* Add InferTypeOpTrait & enable generating its member function definitionJacques Pienaar2019-09-291-0/+8
| | | | | | | | | | Use OpInterfaces to add an interface for ops defining a return type function. This change does not use this trait in any meaningful way, I'll use it in a follow up to generalize and unify some of the op type traits/constraints. Also, currently the infer type function can only be manually specified in C++, that should rather be the fallback in future. PiperOrigin-RevId: 271883746
* Fix a number of Clang-Tidy warnings.Christian Sigg2019-09-231-1/+1
| | | | PiperOrigin-RevId: 270632324
* NFC: Pass OpAsmPrinter by reference instead of by pointer.River Riddle2019-09-201-10/+10
| | | | | | 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-12/+12
| | | | | | 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-17/+17
| | | | | | MLIR follows the LLVM style of pass-by-reference. PiperOrigin-RevId: 270315612
* Add support to OpAsmParser for parsing unknown keywords.River Riddle2019-09-171-2/+18
| | | | | | This is useful in several cases, for example a user may want to sugar the syntax of a string(as we do with custom operation syntax), or avoid many nested ifs for parsing a set of known keywords. PiperOrigin-RevId: 269695451
* Add `parseGenericOperation()` to the OpAsmParserMehdi Amini2019-09-081-0/+36
| | | | | | | | | This method parses an operation in its generic form, from the current parser state. This is the symmetric of OpAsmPrinter::printGenericOp(). An immediate use case is illustrated in the test dialect, where an operation wraps another one in its region and makes use of a single-line pretty-print form. PiperOrigin-RevId: 267930869
* Use "final" instead of marking method virtual in override (NFC)Mehdi Amini2019-09-071-1/+1
| | | | | | | | This is the only example for overriding this interface in the repo, let's try to make it right as it may be taken as a reference when implemented in other dialects PiperOrigin-RevId: 267811123
* Add the initial inlining infrastructure.River Riddle2019-09-051-1/+42
| | | | | | | | | | | | | | | | | | This defines a set of initial utilities for inlining a region(or a FuncOp), and defines a simple inliner pass for testing purposes. A new dialect interface is defined, DialectInlinerInterface, that allows for dialects to override hooks controlling inlining legality. The interface currently provides the following hooks, but these are just premilinary and should be changed/added to/modified as necessary: * isLegalToInline - Determine if a region can be inlined into one of this dialect, *or* if an operation of this dialect can be inlined into a given region. * shouldAnalyzeRecursively - Determine if an operation with regions should be analyzed recursively for legality. This allows for child operations to be closed off from the legality checks for operations like lambdas. * handleTerminator - Process a terminator that has been inlined. This cl adds support for inlining StandardOps, but other dialects will be added in followups as necessary. PiperOrigin-RevId: 267426759
* Add a new dialect interface for the OperationFolder `OpFolderDialectInterface`.River Riddle2019-09-011-0/+20
| | | | | | This interface will allow for providing hooks to interrop with operation folding. The first hook, 'shouldMaterializeInto', will allow for controlling which region to insert materialized constants into. The folder will generally materialize constants into the top-level isolated region, this allows for materializing into a lower level ancestor region if it is more profitable/correct. PiperOrigin-RevId: 266702972
* Support folding of ops with inner ops in GreedyPatternRewriteDriver.Andy Ly2019-08-261-4/+9
| | | | | | This fixes a bug when folding ops with inner ops and inner ops are still being visited. PiperOrigin-RevId: 265475780
* Introduce the ability for "isolated from above" ops to introduce shadowingChris Lattner2019-08-231-0/+7
| | | | | | names for the basic block arguments in their body. PiperOrigin-RevId: 265084627
* Allow isolated regions to form isolated SSA name scopes in the printer.River Riddle2019-08-191-5/+22
| | | | | | | | | | | This will allow for naming values the same as existing SSA values for regions attached to operations that are isolated from above. This fits in with how the system already allows separate name scopes for sibling regions. This name shadowing can be enabled in the custom parser of operations by setting the 'enableNameShadowing' flag to true when calling 'parseRegion'. %arg = constant 10 : i32 foo.op { %arg = constant 10 : i32 } PiperOrigin-RevId: 264255999
* Remove ops in regions/blocks from worklist when parent op is being removed ↵Andy Ly2019-08-061-0/+21
| | | | | | | | via GreedyPatternRewriteDriver::replaceOp. This fixes a bug where ops inside the parent op are visited even though the parent op has been removed. PiperOrigin-RevId: 261953580
* Introduce parser library method to parse list of region argumentsUday Bondhugula2019-07-221-0/+19
| | | | | | | | | | | | | | | | | - introduce parseRegionArgumentList (similar to parseOperandList) to parse a list of region arguments with a delimiter - allows defining custom parse for op's with multiple/variadic number of region arguments - use this on the gpu.launch op (although the latter has a fixed number of region arguments) - add a test dialect op to test region argument list parsing (with the no delimiter case) Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#40 PiperOrigin-RevId: 259442536
* Merge TypeUtilities library into the IR libraryAlex Zinenko2019-07-201-1/+1
| | | | | | | | | | The TypeUtilities.{cpp,h}, currently living in {lib,include/mlir}/Support, do not belong to the Support library. Instead, they form a separate utility library that depends on the IR library. The operations it provides relate to standard types (tensors, memrefs) as well as to operation manipulation, making them a better fit for the main IR library. PiperOrigin-RevId: 259108314
* Split test-specific passes out of mlir-optNicolas Vasilache2019-06-241-0/+41
Instead put their impl in test/lib and link them into mlir-test-opt PiperOrigin-RevId: 254837439
OpenPOWER on IntegriCloud