MLIR Team [Wed, 5 Jun 2019 18:24:19 +0000 (11:24 -0700)]
Fix a typo in error message.
PiperOrigin-RevId:
251681475
River Riddle [Wed, 5 Jun 2019 17:50:10 +0000 (10:50 -0700)]
Add new 'createOrFold' methods to FuncBuilder to immediately try to fold an operation after creating it. This can be used to remove operations that are likely to be trivially folded later. Note, these functions only fold operations if all of the folded results are existing values.
PiperOrigin-RevId:
251674299
River Riddle [Wed, 5 Jun 2019 17:08:47 +0000 (10:08 -0700)]
Always remap results when replacing an operation. This prevents a crash when lowering identity(passthrough) operations to the same resultant type as the original operation.
PiperOrigin-RevId:
251665492
River Riddle [Wed, 5 Jun 2019 16:36:32 +0000 (09:36 -0700)]
When cleaning up after a failed legalization pattern, make sure to remove any newly created value mappings.
PiperOrigin-RevId:
251658984
River Riddle [Wed, 5 Jun 2019 06:33:18 +0000 (23:33 -0700)]
Add a few utility overloads for OpAsmParser methods:
* Add a getCurrentLocation that returns the location directly.
* Add parseOperandList/parseTrailingOperandList overloads without the required operand count.
PiperOrigin-RevId:
251585488
Jacques Pienaar [Wed, 5 Jun 2019 02:31:30 +0000 (19:31 -0700)]
ODG: Always deference operand/result when using named arg/result.
Considered adding more placeholders to designate types in the replacement pattern, but convinced for now sticking to simpler approach. This should at least enable specifying constraints across operands/results/attributes and we can start getting rid of the special cases.
PiperOrigin-RevId:
251564893
River Riddle [Wed, 5 Jun 2019 02:18:23 +0000 (19:18 -0700)]
NFC: Rename FuncBuilder to OpBuilder and refactor to take a top level region instead of a function.
PiperOrigin-RevId:
251563898
River Riddle [Tue, 4 Jun 2019 21:12:40 +0000 (14:12 -0700)]
Add support to AffineApplyOp::fold for folding dim and symbol expression results.
PiperOrigin-RevId:
251512700
Lei Zhang [Tue, 4 Jun 2019 21:03:30 +0000 (14:03 -0700)]
[spirv] Basic validity of SPV_ModuleOp
This CL adds SPV_ModuleEndOp for terminating the only block inside a
SPV_ModuleOp's only region. Verification now enforces a spv.module only
contains func or spv.* ops and no external or nested functions are
present. Because of the structural requirement of a block, spv.Return
is also added in this CL.
PiperOrigin-RevId:
251510706
River Riddle [Tue, 4 Jun 2019 19:14:43 +0000 (12:14 -0700)]
Add a utility function to Op that allows for checking if an operation has a specific trait.
PiperOrigin-RevId:
251489498
River Riddle [Tue, 4 Jun 2019 18:56:43 +0000 (11:56 -0700)]
NFC: Rename FoldHelper to OperationFolder and split a large function in two.
PiperOrigin-RevId:
251485843
Ben Vanik [Tue, 4 Jun 2019 18:35:21 +0000 (11:35 -0700)]
Adding additional dialect parsing utilities, conversion wrappers, and traversal helpers.
- added a typed walk to Block (matching the equivalent on Function)
- added token parsers (incl optional variants) for : and (
- added applyConversionPatterns that takes a list of functions to apply patterns to
PiperOrigin-RevId:
251481608
River Riddle [Tue, 4 Jun 2019 18:21:11 +0000 (11:21 -0700)]
Make it explicit that the IR printing instrumentation should not be used when multi-threading is enabled.
PiperOrigin-RevId:
251478399
River Riddle [Tue, 4 Jun 2019 18:01:32 +0000 (11:01 -0700)]
Add support to FuncOp for managing argument attributes. The syntax for argument attributes is the same as Function:
func @foo(i1 {dialect.attr: 10 : i64})
func @foo(%arg0: i1 {dialect.attr: 10 : i64}) {
return
}
PiperOrigin-RevId:
251473338
Lei Zhang [Tue, 4 Jun 2019 12:03:42 +0000 (05:03 -0700)]
[ODG] Add iterators for results in Operator
PiperOrigin-RevId:
251417085
Stephan Herhut [Tue, 4 Jun 2019 07:58:19 +0000 (00:58 -0700)]
Align NVVM operation names with names from GPU dialect.
Currently, we use different names for block and grid dimensions in the GPU vs. NVVM dialect, which is confusing. With this change, the NVVM names match the ones from the GPU dialect. The NVVM intrinsics use different names anyway, so it does not add new confusion.
PiperOrigin-RevId:
251389281
River Riddle [Mon, 3 Jun 2019 23:32:25 +0000 (16:32 -0700)]
Add a utility function to OperationName for extracting the dialect name.
PiperOrigin-RevId:
251333376
Lei Zhang [Mon, 3 Jun 2019 21:52:56 +0000 (14:52 -0700)]
[ODS] Add support for TypeArrayAttr
PiperOrigin-RevId:
251314203
Geoffrey Martin-Noble [Mon, 3 Jun 2019 21:19:04 +0000 (14:19 -0700)]
Replace comments referring to "vector or tensor" with "shaped" where appropriate
PiperOrigin-RevId:
251306752
Geoffrey Martin-Noble [Mon, 3 Jun 2019 20:07:51 +0000 (13:07 -0700)]
Make MemRefOf tablegen type subclass ShapedContainerType
Possible now because MemRef subclasses ShapedType
PiperOrigin-RevId:
251292951
River Riddle [Mon, 3 Jun 2019 19:49:55 +0000 (12:49 -0700)]
Refactor the dialect conversion framework to support multi-level conversions. Multi-level conversions are those that require multiple patterns to be applied before an operation is completely legalized. This essentially means that conversion patterns do not have to directly generate legal operations, and may be chained together to produce legal code.
To accomplish this, moving forward users will need to provide a legalization target that defines what operations are legal for the conversion. A target can mark an operation as legal by providing a specific legalization action. The initial actions are:
* Legal
- This action signals that every instance of the given operation is legal,
i.e. any combination of attributes, operands, types, etc. is valid.
* Dynamic
- This action signals that only some instances of a given operation are legal. This
allows for defining fine-tune constraints, like say std.add is only legal when
operating on 32-bit integers.
An example target is shown below:
struct MyTarget : public ConversionTarget {
MyTarget(MLIRContext &ctx) : ConversionTarget(ctx) {
// All operations in the LLVM dialect are legal.
addLegalDialect<LLVMDialect>();
// std.constant op is always legal on this target.
addLegalOp<ConstantOp>();
// std.return op has dynamic legality constraints.
addDynamicallyLegalOp<ReturnOp>();
}
/// Implement the custom legalization handler to handle
/// std.return.
bool isLegal(Operation *op) override {
// Process the dynamic handling for a std.return op (and any others that were
// marked "dynamic").
...
}
};
PiperOrigin-RevId:
251289374
Lei Zhang [Mon, 3 Jun 2019 19:38:22 +0000 (12:38 -0700)]
Support type casting Type to itself
PiperOrigin-RevId:
251287045
River Riddle [Mon, 3 Jun 2019 19:08:22 +0000 (12:08 -0700)]
Start defining a new operation 'FuncOp' that replicates all of the functionality of 'Function', but with an operation. The pretty syntax for the operation is exactly the same as that of Function. This operation is currently builtin, but should hopefully be moved to a different dialect when it has been completely decoupled from IR/. This is the first patch in a large series that refactors Functions to be represented as operations.
PiperOrigin-RevId:
251281612
Jacques Pienaar [Mon, 3 Jun 2019 18:09:02 +0000 (11:09 -0700)]
Add Windows build instructions.
PiperOrigin-RevId:
251269521
Alex Zinenko [Mon, 3 Jun 2019 17:00:16 +0000 (10:00 -0700)]
SDBM: fix the order of variables in the stripe-induced inequalities
The initial implementation of SDBM mistakenly swapped the order of variables in
the inequalities induced by a stripe equality: y = x # B actually implies
y - x <= 0 and x - y <= B - 1 rather than x - y <= 0 and y - x <= B - 1 as
implemented. Textual comments in the test files were correct but did not
correspond to the emitted IR. Round-tripping between SDBM and expression lists
was not affected because the wrong order was used in both directions of the
conversion. Use the correct order.
PiperOrigin-RevId:
251252980
River Riddle [Mon, 3 Jun 2019 16:43:22 +0000 (09:43 -0700)]
Restructure the parser to support nested name scopes. This allows for regions at the same level of nesting to have values with the same SSA name. This is a necessary step for representing functions as operations.
The following is now valid IR:
foo.op ... {
%val = ...
}, {
%val = ...
}
PiperOrigin-RevId:
251249875
Alex Zinenko [Mon, 3 Jun 2019 15:03:20 +0000 (08:03 -0700)]
Introduce OpOperandAdaptors and emit them from ODS
When manipulating generic operations, such as in dialect conversion /
rewriting, it is often necessary to view a list of Values as operands to an
operation without creating the operation itself. The absence of such view
makes dialect conversion patterns, among others, to use magic numbers to obtain
specific operands from a list of rewritten values when converting an operation.
Introduce XOpOperandAdaptor classes that wrap an ArrayRef<Value *> and provide
accessor functions identical to those available in XOp. This makes it possible
for conversions to use these adaptors to address the operands with names rather
than rely on their position in the list. The adaptors are generated from ODS
together with the actual operation definitions.
This is another step towards making dialect conversion patterns specific for a
given operation.
Illustrate the approach on conversion patterns in the standard to LLVM dialect
conversion.
PiperOrigin-RevId:
251232899
River Riddle [Mon, 3 Jun 2019 14:03:54 +0000 (07:03 -0700)]
Cleanup the Linalg trait ViewRanks.
* Fix a miscompile on older clang versions when initializing an ArrayRef with an unsigned variadic template argument.
* Update the errors to use the streaming interface instead of Twine.
PiperOrigin-RevId:
251223929
River Riddle [Mon, 3 Jun 2019 03:33:29 +0000 (20:33 -0700)]
NFC: Split up Parser::parseAttribute into multiple smaller functions to improve readability.
PiperOrigin-RevId:
251158192
Jacques Pienaar [Sat, 1 Jun 2019 17:10:24 +0000 (10:10 -0700)]
Allow constant of unit type.
--
PiperOrigin-RevId:
251053682
Jacques Pienaar [Sat, 1 Jun 2019 15:37:50 +0000 (08:37 -0700)]
Avoid failure due to incomplete type specification.
--
PiperOrigin-RevId:
251048081
Lei Zhang [Sat, 1 Jun 2019 13:34:18 +0000 (06:34 -0700)]
[spirv] Add a script to update SPIRVBase.td with new enum attributes
This script parses the SPIR-V JSON grammar to extract operand kinds that
are enums and generate TableGen definitions for them.
Also added a shell script to point to the correct relative file location
to simplify command invocation.
--
PiperOrigin-RevId:
251041084
Mehdi Amini [Sat, 1 Jun 2019 02:52:18 +0000 (19:52 -0700)]
Move NamedAttributeList::get() method out-of-line (fix CMake build due to missing include)
--
PiperOrigin-RevId:
251000296
Geoffrey Martin-Noble [Sat, 1 Jun 2019 00:19:24 +0000 (17:19 -0700)]
Use size_t for tuple type size
This is more consistent with standard containers.
--
PiperOrigin-RevId:
250985851
Geoffrey Martin-Noble [Sat, 1 Jun 2019 00:18:59 +0000 (17:18 -0700)]
Consistently use int64_t for shape-related values in shaped types
We want to support 64-bit shapes (even when the compiler is on a 32-bit architecture). Using int64_t consistently allows us to sidestep the bugginess of unsigned arithmetic.
Still unsigned: kind, memory space, and bit width. The first two are basically enums. We could have a discussion about the last one, but it's basically just a very large enum as well and we're not doing any math on it, I think.
--
PiperOrigin-RevId:
250985791
Geoffrey Martin-Noble [Fri, 31 May 2019 23:41:21 +0000 (16:41 -0700)]
Static cast size_t -> int64_t instead of vice versa for equals comparisons
These were just introduced by a previous CL moving MemRef getRank to return int64_t. size_t could be smaller than 64 bits and in equals comparisons, signed vs unsigned doesn't matter. In these cases, we know right now that the particular int64_t is not larger than max size_t (because it currently comes directly from a size() call), the alternative cast plus equals comparison is always safe, so we might as well do it that way and no longer require reasoning deeper into the callstack.
We are already assuming that size() calls fit into int64_t in a number of other cases like the aforementioned getRank() (since exabytes of RAM are rare). If we want to avoid this assumption we will have to come up with a principled way to do it throughout.
--
PiperOrigin-RevId:
250980297
River Riddle [Fri, 31 May 2019 23:03:26 +0000 (16:03 -0700)]
Add support for providing an output stream to the SourceMgrDiagnosticHandlers.
--
PiperOrigin-RevId:
250974331
Amit Sabne [Fri, 31 May 2019 20:56:47 +0000 (13:56 -0700)]
Loop invariant code motion - remove reliance on getForwardSlice. Add more tests.
--
PiperOrigin-RevId:
250950703
River Riddle [Fri, 31 May 2019 20:48:43 +0000 (13:48 -0700)]
NFC: Cleanup method definitions within Parser and add header blocks to improve readability.
--
PiperOrigin-RevId:
250949195
Mehdi Amini [Fri, 31 May 2019 20:46:23 +0000 (13:46 -0700)]
Fix CMake builds: sources not used in every targets must be marked with LLVM_OPTIONAL_SOURCES
--
PiperOrigin-RevId:
250948796
Geoffrey Martin-Noble [Fri, 31 May 2019 20:28:37 +0000 (13:28 -0700)]
Get rid of separate getRank() on MemRef now that it subclasses ShapedType
We are moving towards int64_t for these shape/dimension -related values to avoid buginess with unsigned arithmetic
--
PiperOrigin-RevId:
250945322
Geoffrey Martin-Noble [Fri, 31 May 2019 20:28:19 +0000 (13:28 -0700)]
Some cleanup of ShapedType now that MemRef subclasses it.
Extract common methods into ShapedType.
Simplify methods.
Remove some extraneous asserts.
Replace sentinel value with a helper method to check the same.
--
PiperOrigin-RevId:
250945261
Geoffrey Martin-Noble [Fri, 31 May 2019 20:28:01 +0000 (13:28 -0700)]
Make MemRefType subclass ShapedType
MemRefs have the same notion of shape, rank, and fixed element type. This allows us to reuse utilities based on shape for memref.
All dyn_cast and isa calls for ShapedType have been checked and either modified to explicitly check for vector or tensor, or confirmed to not depend on the result being a vector or tensor.
Discussion in https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/cHLoyfGu8y8
--
PiperOrigin-RevId:
250945184
Geoffrey Martin-Noble [Fri, 31 May 2019 20:01:45 +0000 (13:01 -0700)]
Don't use ShapedType to indicate vector or tensor type
MemRefType may soon subclass ShapedType. ShapedType only guarantees that something has a shape (possibly dynamic), rank (or explicitly unranked), and fixed element type.
--
PiperOrigin-RevId:
250940537
River Riddle [Fri, 31 May 2019 19:53:22 +0000 (12:53 -0700)]
Fix an msan warning for use of an uninitialized variable.
--
PiperOrigin-RevId:
250939301
River Riddle [Fri, 31 May 2019 16:27:52 +0000 (09:27 -0700)]
Remove the newline from the mlir-opt 'split-input-file' flag marker. This fixes support for DOS style new lines(/r/n).
--
PiperOrigin-RevId:
250899420
River Riddle [Fri, 31 May 2019 16:24:48 +0000 (09:24 -0700)]
Abstract the internal storage of the NamedAttributeList into a new attribute, DictionaryAttr. This attribute maintains a sorted list of NamedAttributes. This will allow for operations/functions to maintain sub dictionaries of attributes.
The syntax is the same as top level attribute dictionaries:
{sub_dictionary: {fn: @someFn, boolAttr: true}}
--
PiperOrigin-RevId:
250898950
Jacques Pienaar [Fri, 31 May 2019 01:42:16 +0000 (18:42 -0700)]
Disable named attribute in ODG for ArgOrResultElementTypeIs as was taking address of r-value.
--
PiperOrigin-RevId:
250805965
Lei Zhang [Thu, 30 May 2019 23:50:16 +0000 (16:50 -0700)]
[ODS] Support region names and constraints
Similar to arguments and results, now we require region definition in ops to
be specified as a DAG expression with the 'region' operator. This way we can
specify the constraints for each region and optionally give the region a name.
Two kinds of region constraints are added, one allowing any region, and the
other requires a certain number of blocks.
--
PiperOrigin-RevId:
250790211
Geoffrey Martin-Noble [Thu, 30 May 2019 23:02:49 +0000 (16:02 -0700)]
Replace checks against numDynamicDims with hasStaticShape
--
PiperOrigin-RevId:
250782165
River Riddle [Thu, 30 May 2019 21:58:28 +0000 (14:58 -0700)]
Replace a usage of std::vector with SmallVector to allow constructing with non-constant iterators on MSVC.
--
PiperOrigin-RevId:
250769027
Geoffrey Martin-Noble [Thu, 30 May 2019 18:01:17 +0000 (11:01 -0700)]
Make getRank abort for unranked type
This better matches the other methods in ShapedType which only make sense for ranked types. There's now an explicit hasRank for checking the rank. Actual call sites rarely used the "-1" sentinel to combine checking for rankedness and checking that rank is a certain value. And in most cases they should actually be checking for rankedness at a higher level using type predicates. Using an explicit method is clearer than a sentinel anyway.
--
PiperOrigin-RevId:
250720853
Jacques Pienaar [Thu, 30 May 2019 17:57:23 +0000 (10:57 -0700)]
Allow argument and result names replacement in predicates.
This allow specifying $x to refer to an operand's named argument (operand or attribute) or result. Skip variadic operands/results for now pending autogenerated discussion of their accessors.
This adds a new predicate, following feedback on the naming but does not remove the old one. Post feedback I'll do that, potentially in follow up.
--
PiperOrigin-RevId:
250720003
Jacques Pienaar [Thu, 30 May 2019 17:02:57 +0000 (10:02 -0700)]
Avoid unspecified files error by explicitly including for now.
--
PiperOrigin-RevId:
250708336
Jacques Pienaar [Thu, 30 May 2019 16:42:17 +0000 (09:42 -0700)]
Add keywords in target_link_libraries post add_llvm_executable.
--
PiperOrigin-RevId:
250704528
River Riddle [Thu, 30 May 2019 15:23:49 +0000 (08:23 -0700)]
Replace usages of 'add_executable' with 'add_llvm_executable'.
--
PiperOrigin-RevId:
250691487
Jacques Pienaar [Thu, 30 May 2019 04:15:43 +0000 (21:15 -0700)]
Fix 5 ClangTidy - Readability findings.
* the 'empty' method should be used to check for emptiness instead of 'size'
* using decl 'CapturableHandle' is unused
* redundant get() call on smart pointer
* using decl 'apply' is unused
* using decl 'ScopeGuard' is unused
--
PiperOrigin-RevId:
250623863
River Riddle [Thu, 30 May 2019 03:31:12 +0000 (20:31 -0700)]
NFC: Inline toString as operations can be streamed directly into raw_ostream.
--
PiperOrigin-RevId:
250619765
Geoffrey Martin-Noble [Thu, 30 May 2019 00:15:51 +0000 (17:15 -0700)]
Use hasRank instead of comparing rank to -1
--
PiperOrigin-RevId:
250598252
River Riddle [Wed, 29 May 2019 23:46:17 +0000 (16:46 -0700)]
Move CondBranchOp to the ODG framework.
--
PiperOrigin-RevId:
250593367
Geoffrey Martin-Noble [Wed, 29 May 2019 23:07:17 +0000 (16:07 -0700)]
Exclude all ShapedType subclasses other than TensorType subclasses from having non-scalar elements.
The current logic assumes that ShapedType indicates a vector or tensor, which will not be true soon when MemRef subclasses ShapedType
--
PiperOrigin-RevId:
250586364
Geoffrey Martin-Noble [Wed, 29 May 2019 23:06:49 +0000 (16:06 -0700)]
Check for Vector or Tensor Type rather than ShapedType when matching constant splat
Only vectors or tensors can be constant splats (or element attrs). This is in preparation for making MemRef subclass ShapedType
--
PiperOrigin-RevId:
250586281
Geoffrey Martin-Noble [Wed, 29 May 2019 22:51:17 +0000 (15:51 -0700)]
Avoid dyn_cast to ShapedType
ShapedType just indicates shape/rank/element semantics. It's generally not useful for other type checking. This check already checks for vector or tensor type, so we can use a direct cast if we check those first.
Related to making MemRefType a subclass of ShapedType
--
PiperOrigin-RevId:
250583231
Geoffrey Martin-Noble [Wed, 29 May 2019 22:34:50 +0000 (15:34 -0700)]
Make it clear that ElementsAttr is only for static shaped vectors or tensors.
This is in preparation for making MemRef a subclass of ShapedType, but also UnrankedTensor should already be excluded.
--
PiperOrigin-RevId:
250580197
MLIR Team [Wed, 29 May 2019 21:56:41 +0000 (14:56 -0700)]
Remove "size" property of affine maps.
--
PiperOrigin-RevId:
250572818
Andy Davis [Wed, 29 May 2019 21:02:14 +0000 (14:02 -0700)]
LoopFusionUtils CL 2/n: Factor out and generalize slice union computation.
*) Factors slice union computation out of LoopFusion into Analysis/Utils (where other iteration slice utilities exist).
*) Generalizes slice union computation to take the union of slices computed on all loads/stores pairs between source and destination loop nests.
*) Fixes a bug in FlatAffineConstraints::addSliceBounds where redundant constraints were added.
*) Takes care of a TODO to expose FlatAffineConstraints::mergeAndAlignIds as a public method.
--
PiperOrigin-RevId:
250561529
Geoffrey Martin-Noble [Wed, 29 May 2019 20:58:10 +0000 (13:58 -0700)]
Change "may never" to "must never"
"may never" indicates that it's allowed to never hold a value. I believe the intent here is that it is not allowed to ever hold a value.
--
PiperOrigin-RevId:
250560623
River Riddle [Wed, 29 May 2019 20:47:24 +0000 (13:47 -0700)]
Add whole_archive_link support for MSVC.
This issue was discovered by @loic-joly-sonarsource with a proposed fix
in https://github.com/tensorflow/mlir/pull/22.
--
PiperOrigin-RevId:
250558504
Geoffrey Martin-Noble [Wed, 29 May 2019 20:46:41 +0000 (13:46 -0700)]
Change elements literal parsing to not rely on shaped type being a vector or tensor.
This is in preparation for making MemRef a ShapedType. In general, a shaped type should be anything with shape, rank, and element type properties, so use sites shouldn't assume more than that.
I also pulled the trailing comma parsing out the parseElementsLiteralType (new name) method. It seems weird to have the method parse the type + a trailing comma, even if all call sites currently need that. It's surprising behavior without looking at the implementation.
--
PiperOrigin-RevId:
250558363
River Riddle [Wed, 29 May 2019 20:35:44 +0000 (13:35 -0700)]
Disable the mlir-cpu-runner tests on win32. llvm orc does not support the COFF rtld.
--
PiperOrigin-RevId:
250556116
River Riddle [Wed, 29 May 2019 20:33:22 +0000 (13:33 -0700)]
Replace the Function reference methods from the OpAsmParser/OpAsmPrinter with usages of FunctionAttr.
--
PiperOrigin-RevId:
250555680
River Riddle [Wed, 29 May 2019 20:23:47 +0000 (13:23 -0700)]
Add an example of accessing the impl storage to the 'DefiningAttributesAndTypes' document.
--
PiperOrigin-RevId:
250553898
River Riddle [Wed, 29 May 2019 20:00:14 +0000 (13:00 -0700)]
Remove the Toy/* file path from the location check lines. This assumes a specific file path format that breaks on MSVC.
--
PiperOrigin-RevId:
250549223
River Riddle [Wed, 29 May 2019 18:59:26 +0000 (11:59 -0700)]
NFC: Switch std::vector to SmallVector. This fixes a compiler error on MSVC as the StringMap key dereference method is non-const.
--
PiperOrigin-RevId:
250538085
Ben Vanik [Wed, 29 May 2019 18:40:05 +0000 (11:40 -0700)]
[TableGen] Making printer support $cppClass substitution (similar to parser).
--
PiperOrigin-RevId:
250534216
Lei Zhang [Wed, 29 May 2019 17:47:16 +0000 (10:47 -0700)]
[spirv] Add ModuleOp
This op defines a SPIR-V module using a MLIR region. The region contains
one block. Module-level operations, including functions definitions,
are all placed in this block.
This CL extracts common definitions from SPIRVOps.td into SPIRVBase.td.
The new op is placed in SPIRVStructureOps.td.
--
PiperOrigin-RevId:
250522320
Rasmus Munk Larsen [Wed, 29 May 2019 16:59:21 +0000 (09:59 -0700)]
Get rid of redundant verifier, which is implied by the type traits.
--
PiperOrigin-RevId:
250511694
Rasmus Munk Larsen [Wed, 29 May 2019 16:22:30 +0000 (09:22 -0700)]
Add a rank op to MLIR. Example:
%1 = rank %0 : index
--
PiperOrigin-RevId:
250505411
Nicolas Vasilache [Wed, 29 May 2019 16:12:47 +0000 (09:12 -0700)]
Add lowering linalg.for to LLVM IR
This CL adds lowering of linalg.for to LLVM IR and adds an IR test.
This also replaces the usage of affine.for with linalg.for and enables the LLVM IR path in the integration test.
--
PiperOrigin-RevId:
250503798
Alex Zinenko [Wed, 29 May 2019 12:47:15 +0000 (05:47 -0700)]
EDSC: use llvm::function_ref instead of std::function
Region body constructors in EDSC now take a callback to the function that fills
in the body. This callback is called immediately and not stored, so it is
sufficient to pass a reference to it and avoid a potentially expensive copy.
--
PiperOrigin-RevId:
250473793
Nicolas Vasilache [Tue, 28 May 2019 22:05:51 +0000 (15:05 -0700)]
Add a linalg.for operation to support non-affine loop constructs
The affine.for operation has restrictions that make it suitable for dependence analysis. The Linalg dialect aims at being more general.
This CL introduces linalg.for, and its associated terminator, along with a simple roundtripping test.
A `linalg.for` only takes one value of index type for lower bound, upper bound and step.
Example usage:
```
linalg.for %iv = %lb to %ub step %step {
... // body
}
```
--
PiperOrigin-RevId:
250369722
Lei Zhang [Tue, 28 May 2019 19:14:26 +0000 (12:14 -0700)]
Remove unused IsSingleResult template
--
PiperOrigin-RevId:
250335025
River Riddle [Tue, 28 May 2019 17:23:06 +0000 (10:23 -0700)]
NFC: Replace Function::args_iterator with Block::args_iterator.
--
PiperOrigin-RevId:
250311059
Jacques Pienaar [Tue, 28 May 2019 17:21:25 +0000 (10:21 -0700)]
Fix mismatched-tags warning.
--
PiperOrigin-RevId:
250310618
River Riddle [Tue, 28 May 2019 15:57:38 +0000 (08:57 -0700)]
Tidy up a few parser functions in the ModuleParser. This also adds a missing error for attribute aliases that contain '.' characters.
--
PiperOrigin-RevId:
250291646
Lei Zhang [Tue, 28 May 2019 15:03:46 +0000 (08:03 -0700)]
[ODS] Support numRegions in Op definition
--
PiperOrigin-RevId:
250282024
Alex Zinenko [Tue, 28 May 2019 14:41:17 +0000 (07:41 -0700)]
Do not assume Blocks belong to Functions
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
Stephan Herhut [Tue, 28 May 2019 11:45:50 +0000 (04:45 -0700)]
Fix translation of NVVM special registers to intrinsics.
The original implementation did not map the return value of the intrinsics
call to the result value of the special register op. Uses of the result
value hence hit a nullpointer.
--
PiperOrigin-RevId:
250255436
Alex Zinenko [Tue, 28 May 2019 07:49:23 +0000 (00:49 -0700)]
Decouple affine->standard lowering from the pass
The lowering from the Affine dialect to the Standard dialect was originally
implemented as a standalone pass. However, it may be used by other passes
willing to lower away some of the affine constructs as a part of their
operation. Decouple the transformation functions from the pass infrastructure
and expose the entry point for the lowering.
Also update the lowering functions to use `LogicalResult` instead of bool for
return values.
--
PiperOrigin-RevId:
250229198
Jacques Pienaar [Tue, 28 May 2019 04:18:19 +0000 (21:18 -0700)]
Fix correspondence between trait names in ODS and C++ class names.
Make the correspondence between the ODS and C++ side clearer.
--
PiperOrigin-RevId:
250211194
Jacques Pienaar [Tue, 28 May 2019 03:04:56 +0000 (20:04 -0700)]
Change pattern test to use TestDialect instead.
Verify pattern specification, added benefit, named pattern and location recording using TestDialect. Naming is verified via explicitly adding named pattern to TestPatternDriver pass. Refactoring test to verify the desired functionality rather than generated code.
--
PiperOrigin-RevId:
250205618
Jacques Pienaar [Tue, 28 May 2019 00:13:55 +0000 (17:13 -0700)]
Use SourceMgrDiagnosticHandler in mlir-translate for translations from MLIR input.
Report errors using the file and line location using SourceMgr's diagnostic reporting. Reduce some horizontal white spacing too.
--
PiperOrigin-RevId:
250193646
River Riddle [Mon, 27 May 2019 16:05:17 +0000 (09:05 -0700)]
Move the 'is_detected' utility out of StorageUniquer and into STLExtras to allow reuse throughout the codebase.
--
PiperOrigin-RevId:
250160508
Jacques Pienaar [Mon, 27 May 2019 07:51:27 +0000 (00:51 -0700)]
Avoid unused variable warning.
--
PiperOrigin-RevId:
250109802
River Riddle [Mon, 27 May 2019 02:49:57 +0000 (19:49 -0700)]
NFC: Add a missing include for std::isalnum and std::digit.
--
PiperOrigin-RevId:
250085298
River Riddle [Sun, 26 May 2019 20:01:39 +0000 (13:01 -0700)]
NFC: Cleanup a switch statement that only has a default case.
--
PiperOrigin-RevId:
250062529
River Riddle [Sun, 26 May 2019 15:28:28 +0000 (08:28 -0700)]
Add a 'getDialectNamespace' utility to a few dialects.
--
PiperOrigin-RevId:
250049416
Lei Zhang [Sun, 26 May 2019 12:43:20 +0000 (05:43 -0700)]
[spirv] Start the SPIR-V dialect
This CL sets up the basic structure for a SPIR-V dialect: operation
definition specification, dialect registration, testing, etc.
A single op, FMul, is defined and tested to showcase.
The SPIR-V dialect aims to be a simple proxy for the SPIR-V binary format
to enable straightforward and lightweight conversion from/to the binary
format. Ops in this dialect should stay as the same semantic level and
try to be a mechanical mapping to the corresponding SPIR-V instructions;
but they can deviate representationally to allow using MLIR mechanisms.
--
PiperOrigin-RevId:
250040830
River Riddle [Sun, 26 May 2019 00:22:27 +0000 (17:22 -0700)]
Add a templated wrapper around RewritePattern that allows for defining match/rewrite methods with an instance of the source op instead of a raw Operation*.
--
PiperOrigin-RevId:
250003405
Jacques Pienaar [Sat, 25 May 2019 18:03:51 +0000 (11:03 -0700)]
Use fused location for rewritten ops in generated rewrites.
This does tracks the location by recording all the ops in the source pattern and using the fused location for the transformed op. Track the locations via the rewrite state which is a bit heavy weight, in follow up to change to matchAndRewrite this will be addressed (and need for extra array go away).
--
PiperOrigin-RevId:
249986555