River Riddle [Mon, 1 Apr 2019 17:03:18 +0000 (10:03 -0700)]
Rewrite ResultTypeIterator to be a mapped_iterator instead of an IndexedAccessorIterator. IndexedAccessorIterator makes some assumptions about the element type that do not hold for the result type, i.e. pointer elements. A mapped_iterator also better models the behavior of a ResultTypeIterator.
--
PiperOrigin-RevId:
241345949
Feng Liu [Mon, 1 Apr 2019 17:01:47 +0000 (10:01 -0700)]
Support 0-d tensor type attributes
This CL fixes the parser and printer to support the 0-d tensor type attributes.
--
PiperOrigin-RevId:
241345329
Feng Liu [Mon, 1 Apr 2019 16:39:59 +0000 (09:39 -0700)]
Minor fixes on the typo/naming/style in the Pattern.cpp file
--
PiperOrigin-RevId:
241341334
Lei Zhang [Mon, 1 Apr 2019 15:58:53 +0000 (08:58 -0700)]
[TableGen] Add EnumAttrCase and EnumAttr
This CL adds EnumAttr as a general mechanism for modelling enum attributes. Right now
it is using StringAttr under the hood since MLIR does not have native support for enum
attributes.
--
PiperOrigin-RevId:
241334043
River Riddle [Mon, 1 Apr 2019 06:30:22 +0000 (23:30 -0700)]
Add a flag to Dialect that allows for dialects to enable support for unregistered operations. This flag is off by default and can be toggled via the 'allowUnknownOperations(...)' method. This means that moving forward an error will be emitted for unknown operations if the dialect does not explicitly allow it.
Example:
func @unknown_std_op() {
%0 = "std.foo_bar_op"() : () -> index
return
}
Will result in:
error: unregistered operation 'std.foo_bar_op' found in dialect ('std') that does not allow unknown operations
--
PiperOrigin-RevId:
241266009
River Riddle [Mon, 1 Apr 2019 05:08:12 +0000 (22:08 -0700)]
Update variable in PassTiming to refer to system_clock instead of high_resolution_clock.
--
PiperOrigin-RevId:
241260071
River Riddle [Sat, 30 Mar 2019 05:30:54 +0000 (22:30 -0700)]
Rename the 'namePrefix' field in the Dialect class to 'name' and tidy some comments to make it clear that 'name' refers to the dialect namespace.
--
PiperOrigin-RevId:
241103116
Chris Lattner [Sat, 30 Mar 2019 05:23:34 +0000 (22:23 -0700)]
Implement basic IR support for a builtin complex<> type. As with tuples, we
have no standard ops for working with these yet, this is simply enough to
represent and round trip them in the printer and parser.
--
PiperOrigin-RevId:
241102728
Jacques Pienaar [Sat, 30 Mar 2019 05:10:12 +0000 (22:10 -0700)]
Add build files and update README.
* Add initial version of build files;
* Update README with instructions to download and build MLIR from github;
--
PiperOrigin-RevId:
241102092
River Riddle [Fri, 29 Mar 2019 21:18:08 +0000 (14:18 -0700)]
Assert that registered dialects have unique names. This creates a guarantee that the namespace of a dialect can be used a unique key.
--
PiperOrigin-RevId:
241049578
River Riddle [Fri, 29 Mar 2019 21:06:51 +0000 (14:06 -0700)]
Remove the MLIRContext parameter from Dialect::parseType. Dialects already have access to the context via Dialect::getContext.
--
PiperOrigin-RevId:
241047077
River Riddle [Fri, 29 Mar 2019 20:59:28 +0000 (13:59 -0700)]
Update TypeBase::verifyConstructionInvariants to use a LogicalResult return instead of bool.
--
PiperOrigin-RevId:
241045568
River Riddle [Fri, 29 Mar 2019 20:15:06 +0000 (13:15 -0700)]
Replace usages of instruction with operation in the g3 documents.
PiperOrigin-RevId:
241037784
Nicolas Vasilache [Fri, 29 Mar 2019 18:48:20 +0000 (11:48 -0700)]
Cleanup SuperVectorization dialect printing and parsing.
On the read side,
```
%3 = vector_transfer_read %arg0, %i2, %i1, %i0 {permutation_map: (d0, d1, d2)->(d2, d0)} : (memref<?x?x?xf32>, index, index, index) -> vector<32x256xf32>
```
becomes:
```
%3 = vector_transfer_read %arg0[%i2, %i1, %i0] {permutation_map: (d0, d1, d2)->(d2, d0)} : memref<?x?x?xf32>, vector<32x256xf32>
```
On the write side,
```
vector_transfer_write %0, %arg0, %c3, %c3 {permutation_map: (d0, d1)->(d0)} : vector<128xf32>, memref<?x?xf32>, index, index
```
becomes
```
vector_transfer_write %0, %arg0[%c3, %c3] {permutation_map: (d0, d1)->(d0)} : vector<128xf32>, memref<?x?xf32>
```
Documentation will be cleaned up in a followup commit that also extracts a proper .md from the top of the file comments.
PiperOrigin-RevId:
241021879
Feng Liu [Fri, 29 Mar 2019 16:54:11 +0000 (09:54 -0700)]
remove the const quantifier before temp variable
PiperOrigin-RevId:
240997262
Nicolas Vasilache [Fri, 29 Mar 2019 16:47:30 +0000 (09:47 -0700)]
Make createMaterializeVectorsPass take a vectorSize parameter - NFC
This CL allows the programmatic control of the target hardware vector size when creating a MaterializeVectorsPass.
This is useful for registering passes for the tutorial.
PiperOrigin-RevId:
240996136
Feng Liu [Fri, 29 Mar 2019 16:36:09 +0000 (09:36 -0700)]
[TableGen] Support benefit score in pattern definition.
A integer number can be specified in the pattern definition and used as the
adjustment to the default benefit score in the generated rewrite pattern C++
definition.
PiperOrigin-RevId:
240994192
Nicolas Vasilache [Fri, 29 Mar 2019 16:34:06 +0000 (09:34 -0700)]
Refactor vectorization patterns
This CL removes the reliance of the vectorize pass on the specification of a `fastestVaryingDim` parameter. This parameter is a restriction meant to more easily target a particular loop/memref combination for vectorization and is mainly used for testing.
This also had the side-effect of restricting vectorization patterns to only the ones in which all memrefs were contiguous along the same loop dimension. This simple restriction prevented matmul to vectorize in 2-D.
this CL removes the restriction and adds the matmul test which vectorizes in 2-D along the parallel loops. Support for reduction loops is left for future work.
PiperOrigin-RevId:
240993827
River Riddle [Fri, 29 Mar 2019 16:18:45 +0000 (09:18 -0700)]
Slight rewording of TupleType rationale.
PiperOrigin-RevId:
240991400
River Riddle [Fri, 29 Mar 2019 15:59:20 +0000 (08:59 -0700)]
Update the QuickstartRewrites document to include information about the new 'matchAndRewrite' functionality in RewritePatterns.
PiperOrigin-RevId:
240987764
River Riddle [Fri, 29 Mar 2019 15:52:06 +0000 (08:52 -0700)]
[PassManager] Add a utility class, PrettyStackTraceParallelDiagnosticEntry, to emit any queued up diagnostics in the event of a crash when multi-threading.
PiperOrigin-RevId:
240986566
MLIR Team [Fri, 29 Mar 2019 15:06:25 +0000 (08:06 -0700)]
Enable input-reuse fusion to search function arguments for fusion candidates (takes care of a TODO, enables another tutorial test case).
PiperOrigin-RevId:
240979894
River Riddle [Fri, 29 Mar 2019 02:53:02 +0000 (19:53 -0700)]
Change the vectorizer test pass to output via diagnostics instead of llvm::outs. This allows for the output to be deterministic when multi-threading is enabled.
PiperOrigin-RevId:
240905858
MLIR Team [Fri, 29 Mar 2019 02:49:31 +0000 (19:49 -0700)]
Support for type constraints across operand and results
--
PiperOrigin-RevId:
240905555
Tatiana Shpeisman [Fri, 29 Mar 2019 01:28:14 +0000 (18:28 -0700)]
Fixed a few instances of inconsistent grammar.
PiperOrigin-RevId:
240896336
Jacques Pienaar [Fri, 29 Mar 2019 01:00:57 +0000 (18:00 -0700)]
Address some errors from g++
These fail with:
could not convert ‘module’ from ‘llvm::orc::ThreadSafeModule’ to
‘llvm::Expected<llvm::orc::ThreadSafeModule>’
PiperOrigin-RevId:
240892583
Jacques Pienaar [Fri, 29 Mar 2019 00:37:29 +0000 (17:37 -0700)]
Add README file for MLIR.
PiperOrigin-RevId:
240889350
River Riddle [Fri, 29 Mar 2019 00:36:06 +0000 (17:36 -0700)]
Remove the LowerEDSCTestPass.
Most of the tests have been ported to be unit-tests and this pass is problematic in the way it depends on TableGen-generated files. This pass is also non-deterministic during multi-threading and a blocker to turning it on by default.
PiperOrigin-RevId:
240889154
River Riddle [Thu, 28 Mar 2019 23:18:52 +0000 (16:18 -0700)]
Tidy up a few comments and error messages related to parsing multi-result operations.
PiperOrigin-RevId:
240876306
Jacques Pienaar [Thu, 28 Mar 2019 23:13:32 +0000 (16:13 -0700)]
Remove extra qualification
PiperOrigin-RevId:
240875432
Alex Zinenko [Thu, 28 Mar 2019 23:10:07 +0000 (16:10 -0700)]
LLVM IR Dialect: separate the conversion tool from the conversion pass
Originally, the conversion to the LLVM IR dialect had been implemented as pass.
The common conversion infrastructure was factored into DialectConversion from
which the conversion pass inherited. The conversion being a pass is
undesirable for callers that only need the conversion done, for example as a
part of sequence of conversions or outside the pass manager infrastructure.
Split the LLVM IR Dialect conversion into the conversion proper and the
conversion pass, where the latter contains the former instead of inheriting.
NFC.
PiperOrigin-RevId:
240874740
Alex Zinenko [Thu, 28 Mar 2019 22:58:53 +0000 (15:58 -0700)]
Dialect Conversion: convert regions of operations when cloning them
Dialect conversion currently clones the operations that did not match any
pattern. This includes cloning any regions that belong to these operations.
Instead, apply conversion recursively to the nested regions.
Note that if an operation matched one of the conversion patterns, it is up to
the pattern rewriter to fill in the regions of the converted operation. This
may require calling back to the converter and is left for future work.
PiperOrigin-RevId:
240872410
Nicolas Vasilache [Thu, 28 Mar 2019 22:12:18 +0000 (15:12 -0700)]
NFC - Handle IndexedValue corner case
Implicit conversion don't play nicely in expressions such as:
`C() = A(i) * B(i)`.
Make `C()` return an IndexedValue instead of casting to ValueHandle.
This prevents double capture errors and is useful for the tutorial.
PiperOrigin-RevId:
240863223
River Riddle [Thu, 28 Mar 2019 21:58:52 +0000 (14:58 -0700)]
Change the muli-return syntax for operations. The name of the operation result now contains the number of results that it refers to if the number of results is greater than 1.
Example:
%call:2 = call @multi_return() : () -> (f32, i32)
use(%calltensorflow/mlir#0, %calltensorflow/mlir#1)
This cl also adds parser support for uniquely named result values. This means that a test writer can now write something like:
%foo, %bar = call @multi_return() : () -> (f32, i32)
use(%foo, %bar)
Note: The printer will still print the collapsed form.
PiperOrigin-RevId:
240860058
MLIR Team [Thu, 28 Mar 2019 21:54:49 +0000 (14:54 -0700)]
Remove overly conservative check in LoopFusion pass (enables fusion in tutorial example).
PiperOrigin-RevId:
240859227
River Riddle [Thu, 28 Mar 2019 18:40:17 +0000 (11:40 -0700)]
[PassManager] Define a ParallelDiagnosticHandler to ensure that diagnostics are still produced in a deterministic order when multi-threading.
PiperOrigin-RevId:
240817922
River Riddle [Thu, 28 Mar 2019 18:25:19 +0000 (11:25 -0700)]
Rename InstOperand to OpOperand.
PiperOrigin-RevId:
240814651
Dimitrios Vytiniotis [Thu, 28 Mar 2019 16:20:13 +0000 (09:20 -0700)]
Remove global LLVM CLI variables from library code
Plus move parsing code into the MLIR CPU runner binary.
PiperOrigin-RevId:
240786709
River Riddle [Thu, 28 Mar 2019 15:24:38 +0000 (08:24 -0700)]
Replace remaining usages of the Instruction class with Operation.
PiperOrigin-RevId:
240777521
Nicolas Vasilache [Thu, 28 Mar 2019 01:04:19 +0000 (18:04 -0700)]
Cleanup vectorize_1d.mlir test - NFC
This CL splits a large monolithic test function into smaller ones that are each CHECK-LABEL'd
PiperOrigin-RevId:
240684979
Nicolas Vasilache [Thu, 28 Mar 2019 00:50:34 +0000 (17:50 -0700)]
Make vectorization aware of loop semantics
Now that we have a dependence analysis, we can check that loops are indeed parallel and make vectorization correct.
PiperOrigin-RevId:
240682727
River Riddle [Thu, 28 Mar 2019 00:43:08 +0000 (17:43 -0700)]
Update the multi-threaded pass timing to not assume that total time will be different from user time.
PiperOrigin-RevId:
240681618
Jacques Pienaar [Thu, 28 Mar 2019 00:33:40 +0000 (17:33 -0700)]
Move test of trait using dialect ops, to dialects of ops.
PiperOrigin-RevId:
240680010
MLIR Team [Wed, 27 Mar 2019 23:16:15 +0000 (16:16 -0700)]
Small edit for clarity. ("Zero dimensions" reads to me as "rank of zero.")
PiperOrigin-RevId:
240664300
Jacques Pienaar [Wed, 27 Mar 2019 21:52:34 +0000 (14:52 -0700)]
Move TF dialect test to dialect.
PiperOrigin-RevId:
240646586
Nicolas Vasilache [Wed, 27 Mar 2019 21:12:01 +0000 (14:12 -0700)]
Give the Vectorize pass a virtualVectorSize argument.
This CL allows vectorization to be called and configured in other ways than just via command line arguments.
This allows triggering vectorization programmatically.
PiperOrigin-RevId:
240638208
Lei Zhang [Wed, 27 Mar 2019 21:09:19 +0000 (14:09 -0700)]
[TableGen] Change names for Builder* and OperationState* parameters to avoid collision
The `Builder*` parameter is unused in both generated build() methods so that we can
leave it unnamed. Changed stand-alone parameter build() to take `_tblgen_state` instead
of `result` to allow `result` to avoid having name collisions with op operand,
attribute, or result.
PiperOrigin-RevId:
240637700
River Riddle [Wed, 27 Mar 2019 21:02:26 +0000 (14:02 -0700)]
Add support for multi-threaded pass timing.
When multi-threading is enabled in the pass manager the meaning of the display
slightly changes. First, a new timing column is added, `User Time`, that
displays the total time spent across all threads. Secondly, the `Wall Time`
column displays the longest individual time spent amongst all of the threads.
This means that the `Wall Time` column will continue to give an indicator on the
perceived time, or clock time, whereas the `User Time` will display the total
cpu time.
Example:
$ mlir-opt foo.mlir -experimental-mt-pm -cse -canonicalize -convert-to-llvmir -pass-timing
===-------------------------------------------------------------------------===
... Pass execution timing report ...
===-------------------------------------------------------------------------===
Total Execution Time: 0.0078 seconds
---User Time--- ---Wall Time--- --- Name ---
0.0175 ( 88.3%) 0.0055 ( 70.4%) Function Pipeline
0.0018 ( 9.3%) 0.0006 ( 8.1%) CSE
0.0013 ( 6.3%) 0.0004 ( 5.8%) (A) DominanceInfo
0.0017 ( 8.7%) 0.0006 ( 7.1%) FunctionVerifier
0.0128 ( 64.6%) 0.0039 ( 50.5%) Canonicalizer
0.0011 ( 5.7%) 0.0004 ( 4.7%) FunctionVerifier
0.0004 ( 2.1%) 0.0004 ( 5.2%) ModuleVerifier
0.0010 ( 5.3%) 0.0010 ( 13.4%) LLVMLowering
0.0009 ( 4.3%) 0.0009 ( 11.0%) ModuleVerifier
0.0198 (100.0%) 0.0078 (100.0%) Total
PiperOrigin-RevId:
240636269
River Riddle [Wed, 27 Mar 2019 21:02:02 +0000 (14:02 -0700)]
Replace usages of Instruction with Operation in the Transforms/ directory.
PiperOrigin-RevId:
240636130
Mehdi Amini [Wed, 27 Mar 2019 20:57:02 +0000 (13:57 -0700)]
Simplify API uses of `getContext()` (NFC)
The Pass base class is providing a convenience getContext() accessor.
PiperOrigin-RevId:
240634961
Mehdi Amini [Wed, 27 Mar 2019 20:38:48 +0000 (13:38 -0700)]
Allow to mutate the type of MLIR Value in-place
This avoid trashing memory by cloning and replaceAllUseswith when
performing type inference.
PiperOrigin-RevId:
240631137
Jacques Pienaar [Wed, 27 Mar 2019 20:24:05 +0000 (13:24 -0700)]
Fix include path in test pass.
PiperOrigin-RevId:
240628260
Jacques Pienaar [Wed, 27 Mar 2019 19:36:57 +0000 (12:36 -0700)]
Initialize std::atomic directly.
Avoids error in OSS build:
error: copying variable of type 'std::atomic<unsigned int>' invokes deleted constructor
PiperOrigin-RevId:
240618765
Mehdi Amini [Wed, 27 Mar 2019 19:20:51 +0000 (12:20 -0700)]
Add a method to swap the type of a function in-place
This is motivated by the need to translate function across dialect which
requires morphing their type, as well as the Toy tutorial part on interprocedural
shape inference.
The alternative is cloning the function, but it is heavy and it seems like an
arbitrary restriction to forbid morphing the function type.
PiperOrigin-RevId:
240615755
Jacques Pienaar [Wed, 27 Mar 2019 18:36:36 +0000 (11:36 -0700)]
Use dereference instead of implicit conversion for IndexedValue to Value*.
Avoids ambiguous constructor error on some compilers.
PiperOrigin-RevId:
240606838
Jacques Pienaar [Wed, 27 Mar 2019 17:38:23 +0000 (10:38 -0700)]
Add missing numeric header for std::accumulate.
PiperOrigin-RevId:
240593135
Alex Zinenko [Wed, 27 Mar 2019 16:39:31 +0000 (09:39 -0700)]
LLVM IR Conversion: support zero-dimensional memrefs
The spec allows zero-dimensional memrefs to exist and treats them essentially
as single-element buffers. Unlike single-dimensional memrefs of static shape
<1xTy>, zero-dimensional memrefs do not require indices to access the only
element they store. Add support of zero-dimensional memrefs to the LLVM IR
conversion. In particular, such memrefs are converted into bare pointers, and
accesses to them are converted to bare loads and stores, without the overhead
of `getelementptr %buffer, 0`.
PiperOrigin-RevId:
240579456
Alex Zinenko [Wed, 27 Mar 2019 16:16:27 +0000 (09:16 -0700)]
LLVM IR Conversion: keep LLVM dialect types as is during conversion
When converting to the LLVM IR Dialect, it is possible for the input IR to
contain LLVM IR Dialect operation and/or types, for example, some functions may
have been coverted to the LLVM IR Dialect already, or may have been created
using this dialect directly. Make sure that type conversion keeps LLVM IR
Dialect types unmodified and does not error out. Operations are already kept
as is.
PiperOrigin-RevId:
240574972
River Riddle [Wed, 27 Mar 2019 15:55:17 +0000 (08:55 -0700)]
Replace usages of Instruction with Operation in the /Analysis directory.
PiperOrigin-RevId:
240569775
Nicolas Vasilache [Wed, 27 Mar 2019 13:45:18 +0000 (06:45 -0700)]
Port api-test::tile_2d to the edsc::Builder API
The AST-based EDSCs implementation will be retired soon, this test was missing from the builders API.
PiperOrigin-RevId:
240547453
Alex Zinenko [Wed, 27 Mar 2019 12:11:58 +0000 (05:11 -0700)]
Introduce affine terminator
Due to legacy reasons (ML/CFG function separation), regions in affine control
flow operations require contained blocks not to have terminators. This is
inconsistent with the notion of the block and may complicate code motion
between regions of affine control operations and other regions.
Introduce `affine.terminator`, a special terminator operation that must be used
to terminate blocks inside affine operations and transfers the control back to
he region enclosing the affine operation. For brevity and readability reasons,
allow `affine.for` and `affine.if` to omit the `affine.terminator` in their
regions when using custom printing and parsing format. The custom parser
injects the `affine.terminator` if it is missing so as to always have it
present in constructed operations.
Update transformations to account for the presence of terminator. In
particular, most code motion transformation between loops should leave the
terminator in place, and code motion between loops and non-affine blocks should
drop the terminator.
PiperOrigin-RevId:
240536998
River Riddle [Wed, 27 Mar 2019 04:15:54 +0000 (21:15 -0700)]
Add experimental support for multi-threading the pass manager. This adds support for running function pipelines on functions across multiple threads, and is guarded by an off-by-default flag 'experimental-mt-pm'. There are still quite a few things that need to be done before multi-threading is ready for general use(e.g. pass-timing), but this allows for those things to be tested in a multi-threaded environment.
PiperOrigin-RevId:
240489002
Jacques Pienaar [Wed, 27 Mar 2019 00:28:18 +0000 (17:28 -0700)]
Include numeric header for std::accumulate.
PiperOrigin-RevId:
240462910
River Riddle [Wed, 27 Mar 2019 00:05:09 +0000 (17:05 -0700)]
Replace usages of Instruction with Operation in the /IR directory.
This is step 2/N to renaming Instruction to Operation.
PiperOrigin-RevId:
240459216
Jacques Pienaar [Tue, 26 Mar 2019 23:58:43 +0000 (16:58 -0700)]
Update header notices.
PiperOrigin-RevId:
240457737
Feng Liu [Tue, 26 Mar 2019 22:31:15 +0000 (15:31 -0700)]
Add a trait to set the result type by attribute
Before this CL, the result type of the pattern match results need to be as same
as the first operand type, operand broadcast type or a generic tensor type.
This CL adds a new trait to set the result type by attribute. For example, the
TFL_ConstOp can use this to set the output type to its value attribute.
PiperOrigin-RevId:
240441249
River Riddle [Tue, 26 Mar 2019 21:45:38 +0000 (14:45 -0700)]
Rename the Instruction class to Operation. This just renames the class, 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
Mehdi Amini [Tue, 26 Mar 2019 19:49:08 +0000 (12:49 -0700)]
Add a getContext() utility to the Module/FunctionPass class (NFC)
This is just a convenience for reducing boilerplate when writing a pass.
PiperOrigin-RevId:
240407564
River Riddle [Tue, 26 Mar 2019 19:22:52 +0000 (12:22 -0700)]
Add a utility Instruction::getDialect method to return the dialect an operation is associated with, or nullptr if the associated dialect has not been registered.
PiperOrigin-RevId:
240402300
River Riddle [Tue, 26 Mar 2019 19:02:04 +0000 (12:02 -0700)]
Update the canonicalization patterns for AffineApply and AffineForOp to use matchAndRewrite.
PiperOrigin-RevId:
240398220
Nicolas Vasilache [Tue, 26 Mar 2019 18:03:16 +0000 (11:03 -0700)]
Fix createAffineComputationSlice comments
PiperOrigin-RevId:
240384796
Rob Suderman [Tue, 26 Mar 2019 17:48:24 +0000 (10:48 -0700)]
Tablegen changes to add support for tuples.
PiperOrigin-RevId:
240380512
Nicolas Vasilache [Tue, 26 Mar 2019 17:06:49 +0000 (10:06 -0700)]
Add an IndexedValue::operator Value*
This avoids the need to explicitly convert to a ValueHandle when using an Indexed where a Value* is expected.
PiperOrigin-RevId:
240371014
Alex Zinenko [Tue, 26 Mar 2019 16:55:06 +0000 (09:55 -0700)]
Allow creating standalone Regions
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
Chris Lattner [Tue, 26 Mar 2019 01:02:49 +0000 (18:02 -0700)]
Make FunctionPass::getFunction() return a reference to the function, instead of
a pointer. This makes it consistent with all the other methods in
FunctionPass, as well as with ModulePass::getModule(). NFC.
PiperOrigin-RevId:
240257910
River Riddle [Mon, 25 Mar 2019 20:49:45 +0000 (13:49 -0700)]
Replace remaining usages of "Op::operator->" with "." and remove it.
PiperOrigin-RevId:
240210336
River Riddle [Mon, 25 Mar 2019 20:02:06 +0000 (13:02 -0700)]
Replace usages of "Op::operator->" with ".".
This is step 2/N of removing the temporary operator-> method as part of the de-const transition.
PiperOrigin-RevId:
240200792
Jacques Pienaar [Mon, 25 Mar 2019 18:54:37 +0000 (11:54 -0700)]
Qualify string in OpDefinitionsGen. NFC.
PiperOrigin-RevId:
240188138
River Riddle [Mon, 25 Mar 2019 18:53:03 +0000 (11:53 -0700)]
Refactor the Pattern framework to allow for combined match/rewrite patterns. 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
River Riddle [Mon, 25 Mar 2019 18:13:31 +0000 (11:13 -0700)]
Replace usages of "operator->" with "." for the AffineOps.
Note: The "operator->" method is a temporary helper for the de-const transition and is gradually being phased out.
PiperOrigin-RevId:
240179439
River Riddle [Mon, 25 Mar 2019 17:14:34 +0000 (10:14 -0700)]
NFC: Rename the 'for' operation in the AffineOps dialect to 'affine.for' and set the namespace of the AffineOps dialect to 'affine'.
PiperOrigin-RevId:
240165792
Lei Zhang [Mon, 25 Mar 2019 13:09:26 +0000 (06:09 -0700)]
[TableGen] Consolidate constraint related concepts
Previously we have multiple mechanisms to specify op definition and match constraints:
TypeConstraint, AttributeConstraint, Type, Attr, mAttr, mAttrAnyOf, mPat. These variants
are not added because there are so many distinct cases we need to model; essentially,
they are all carrying a predicate. It's just an artifact of implementation.
It's quite confusing for users to grasp these variants and choose among them. Instead,
as the OpBase TableGen file, we need to strike to provide an unified mechanism. Each
dialect has the flexibility to define its own aliases if wanted.
This CL removes mAttr, mAttrAnyOf, mPat. A new base class, Constraint, is added. Now
TypeConstraint and AttrConstraint derive from Constraint. Type and Attr further derive
from TypeConstraint and AttrConstraint, respectively.
Comments are revised and examples are added to make it clear how to use constraints.
PiperOrigin-RevId:
240125076
Mehdi Amini [Mon, 25 Mar 2019 07:29:00 +0000 (00:29 -0700)]
Using getContext() instead of getInstruction()->getContext() on Operation (NFC)
PiperOrigin-RevId:
240088209
River Riddle [Mon, 25 Mar 2019 06:51:05 +0000 (23:51 -0700)]
Update some of the derived type classes to use getImpl instead of a static_cast.
PiperOrigin-RevId:
240084937
Chris Lattner [Mon, 25 Mar 2019 06:26:39 +0000 (23:26 -0700)]
Various small cleanups to the code, mostly removing const_cast's.
PiperOrigin-RevId:
240083489
Mehdi Amini [Mon, 25 Mar 2019 05:09:41 +0000 (22:09 -0700)]
Add a `getImpl()` utility method to the `TypeBase` class as a convenience for derived class to access their associated TypeStorage (NFC)
PiperOrigin-RevId:
240077874
Mehdi Amini [Mon, 25 Mar 2019 04:52:49 +0000 (21:52 -0700)]
Change TypeStorage from a struct into a class (NFC)
By coding standard, we try to keep struct as pure storage without method or other logic attached to it.
PiperOrigin-RevId:
240076419
Mehdi Amini [Mon, 25 Mar 2019 04:41:36 +0000 (21:41 -0700)]
Move TypeStorage out of the detail namespace
Dialect implementer are expected to inherit from this class when implementing their types. It does not seems right when using MLIR "from the outside" to use directly something from `mlir::detail::`.
PiperOrigin-RevId:
240075769
River Riddle [Mon, 25 Mar 2019 03:35:07 +0000 (20:35 -0700)]
NFC: Rename the 'if' operation in the AffineOps dialect to 'affine.if'.
PiperOrigin-RevId:
240071154
Mehdi Amini [Mon, 25 Mar 2019 03:34:16 +0000 (20:34 -0700)]
Remove `alignas(8) from TypeStorage class
This is here from history at a time where it was bit-packed and storage was dependent on this.
PiperOrigin-RevId:
240071093
Chris Lattner [Mon, 25 Mar 2019 02:53:05 +0000 (19:53 -0700)]
Remove OpPointer, cleaning up a ton of code. This also moves Ops to using
inherited constructors, which is cleaner and means you can now use DimOp()
to get a null op, instead of having to use Instruction::getNull<DimOp>().
This removes another 200 lines of code.
PiperOrigin-RevId:
240068113
Jacques Pienaar [Mon, 25 Mar 2019 02:35:20 +0000 (19:35 -0700)]
Fix missing parenthesis around negation.
This should probably be changed to instead use the negated form (e.g., get predicate + negate it + get resulting template), but this fixes it locally.
PiperOrigin-RevId:
240067116
Mehdi Amini [Mon, 25 Mar 2019 01:48:21 +0000 (18:48 -0700)]
Add a routine to allow registering a dialect without relying on global constructors.
Using global constructors should not be mandatory when possible, clients should be able to register a dialect explicitly when they want.
PiperOrigin-RevId:
240064244
Chris Lattner [Sun, 24 Mar 2019 20:02:43 +0000 (13:02 -0700)]
Push a bunch of 'consts' out of the *Op structure, in prep for removing
OpPointer.
PiperOrigin-RevId:
240044712
Nicolas Vasilache [Sun, 24 Mar 2019 17:45:22 +0000 (10:45 -0700)]
Cleanup ValueHandleArray
We just need a way to unpack ArrayRef<ValueHandle> to ArrayRef<Value*>.
No need to expose this to the user.
This reduces the cognitive overhead for the tutorial.
PiperOrigin-RevId:
240037425
Chris Lattner [Sat, 23 Mar 2019 23:42:01 +0000 (16:42 -0700)]
Deconst-ify MLIRContext, and detemplatize some stuff now that const is gone.
PiperOrigin-RevId:
239976764
Mehdi Amini [Sat, 23 Mar 2019 22:19:51 +0000 (15:19 -0700)]
Add a convenience getContext() method in OpState to reduce boilerplate on clients.
PiperOrigin-RevId:
239972907
Chris Lattner [Sat, 23 Mar 2019 22:09:06 +0000 (15:09 -0700)]
Remove const from Value, Instruction, Argument, and the various methods on the
*Op classes. This is a net reduction by almost 400LOC.
PiperOrigin-RevId:
239972443
Jacques Pienaar [Sat, 23 Mar 2019 17:36:55 +0000 (10:36 -0700)]
Return operand_range instead for generated variadic operands accessor.
PiperOrigin-RevId:
239959381
River Riddle [Sat, 23 Mar 2019 17:12:31 +0000 (10:12 -0700)]
Clarify the comment on valid data during DenseElementsAttr construction.
PiperOrigin-RevId:
239958211