platform/upstream/llvm.git
5 years agoRestructure the parser to support nested name scopes. This allows for regions at...
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

5 years agoIntroduce OpOperandAdaptors and emit them from ODS
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

5 years agoCleanup the Linalg trait ViewRanks.
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

5 years agoNFC: Split up Parser::parseAttribute into multiple smaller functions to improve reada...
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

5 years ago Allow constant of unit type.
Jacques Pienaar [Sat, 1 Jun 2019 17:10:24 +0000 (10:10 -0700)]
Allow constant of unit type.

--

PiperOrigin-RevId: 251053682

5 years ago Avoid failure due to incomplete type specification.
Jacques Pienaar [Sat, 1 Jun 2019 15:37:50 +0000 (08:37 -0700)]
Avoid failure due to incomplete type specification.

--

PiperOrigin-RevId: 251048081

5 years ago [spirv] Add a script to update SPIRVBase.td with new enum attributes
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

5 years ago Move NamedAttributeList::get() method out-of-line (fix CMake build due to missing...
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

5 years ago Use size_t for tuple type size
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

5 years ago Consistently use int64_t for shape-related values in shaped types
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

5 years ago Static cast size_t -> int64_t instead of vice versa for equals comparisons
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

5 years ago Add support for providing an output stream to the SourceMgrDiagnosticHandlers.
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

5 years ago Loop invariant code motion - remove reliance on getForwardSlice. Add more tests.
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

5 years ago NFC: Cleanup method definitions within Parser and add header blocks to improve...
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

5 years ago Fix CMake builds: sources not used in every targets must be marked with LLVM_OPTI...
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

5 years ago Get rid of separate getRank() on MemRef now that it subclasses ShapedType
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

5 years ago Some cleanup of ShapedType now that MemRef subclasses it.
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

5 years ago Make MemRefType subclass ShapedType
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

5 years ago Don't use ShapedType to indicate vector or tensor type
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

5 years ago Fix an msan warning for use of an uninitialized variable.
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

5 years ago Remove the newline from the mlir-opt 'split-input-file' flag marker. This fixes...
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

5 years ago Abstract the internal storage of the NamedAttributeList into a new attribute...
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

5 years ago Disable named attribute in ODG for ArgOrResultElementTypeIs as was taking address...
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

5 years ago [ODS] Support region names and constraints
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

5 years ago Replace checks against numDynamicDims with hasStaticShape
Geoffrey Martin-Noble [Thu, 30 May 2019 23:02:49 +0000 (16:02 -0700)]
Replace checks against numDynamicDims with hasStaticShape

--

PiperOrigin-RevId: 250782165

5 years ago Replace a usage of std::vector with SmallVector to allow constructing with non...
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

5 years ago Make getRank abort for unranked type
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

5 years ago Allow argument and result names replacement in predicates.
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

5 years ago Avoid unspecified files error by explicitly including for now.
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

5 years ago Add keywords in target_link_libraries post add_llvm_executable.
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

5 years ago Replace usages of 'add_executable' with 'add_llvm_executable'.
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

5 years ago Fix 5 ClangTidy - Readability findings.
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

5 years ago NFC: Inline toString as operations can be streamed directly into raw_ostream.
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

5 years ago Use hasRank instead of comparing rank to -1
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

5 years ago Move CondBranchOp to the ODG framework.
River Riddle [Wed, 29 May 2019 23:46:17 +0000 (16:46 -0700)]
Move CondBranchOp to the ODG framework.

--

PiperOrigin-RevId: 250593367

5 years ago Exclude all ShapedType subclasses other than TensorType subclasses from having...
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

5 years ago Check for Vector or Tensor Type rather than ShapedType when matching constant...
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

5 years ago Avoid dyn_cast to ShapedType
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

5 years ago Make it clear that ElementsAttr is only for static shaped vectors or tensors.
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

5 years ago Remove "size" property of affine maps.
MLIR Team [Wed, 29 May 2019 21:56:41 +0000 (14:56 -0700)]
Remove "size" property of affine maps.

--

PiperOrigin-RevId: 250572818

5 years ago LoopFusionUtils CL 2/n: Factor out and generalize slice union computation.
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

5 years ago Change "may never" to "must never"
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

5 years ago Add whole_archive_link support for MSVC.
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

5 years ago Change elements literal parsing to not rely on shaped type being a vector or...
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

5 years ago Disable the mlir-cpu-runner tests on win32. llvm orc does not support the COFF...
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

5 years ago Replace the Function reference methods from the OpAsmParser/OpAsmPrinter with...
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

5 years ago Add an example of accessing the impl storage to the 'DefiningAttributesAndTypes...
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

5 years ago Remove the Toy/* file path from the location check lines. This assumes a specific...
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

5 years ago NFC: Switch std::vector to SmallVector. This fixes a compiler error on MSVC as...
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

5 years ago [TableGen] Making printer support $cppClass substitution (similar to parser).
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

5 years ago [spirv] Add ModuleOp
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

5 years ago Get rid of redundant verifier, which is implied by the type traits.
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

5 years ago Add a rank op to MLIR. Example:
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

5 years ago Add lowering linalg.for to LLVM IR
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

5 years ago EDSC: use llvm::function_ref instead of std::function
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

5 years ago Add a linalg.for operation to support non-affine loop constructs
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

5 years ago Remove unused IsSingleResult template
Lei Zhang [Tue, 28 May 2019 19:14:26 +0000 (12:14 -0700)]
Remove unused IsSingleResult template

--

PiperOrigin-RevId: 250335025

5 years ago NFC: Replace Function::args_iterator with Block::args_iterator.
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

5 years ago Fix mismatched-tags warning.
Jacques Pienaar [Tue, 28 May 2019 17:21:25 +0000 (10:21 -0700)]
Fix mismatched-tags warning.

--

PiperOrigin-RevId: 250310618

5 years ago Tidy up a few parser functions in the ModuleParser. This also adds a missing...
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

5 years ago [ODS] Support numRegions in Op definition
Lei Zhang [Tue, 28 May 2019 15:03:46 +0000 (08:03 -0700)]
[ODS] Support numRegions in Op definition

--

PiperOrigin-RevId: 250282024

5 years ago Do not assume Blocks belong to Functions
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

5 years ago Fix translation of NVVM special registers to intrinsics.
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

5 years ago Decouple affine->standard lowering from the pass
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

5 years ago Fix correspondence between trait names in ODS and C++ class names.
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

5 years ago Change pattern test to use TestDialect instead.
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

5 years ago Use SourceMgrDiagnosticHandler in mlir-translate for translations from MLIR input.
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

5 years ago Move the 'is_detected' utility out of StorageUniquer and into STLExtras to allow...
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

5 years ago Avoid unused variable warning.
Jacques Pienaar [Mon, 27 May 2019 07:51:27 +0000 (00:51 -0700)]
Avoid unused variable warning.

--

PiperOrigin-RevId: 250109802

5 years ago NFC: Add a missing include for std::isalnum and std::digit.
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

5 years ago NFC: Cleanup a switch statement that only has a default case.
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

5 years ago Add a 'getDialectNamespace' utility to a few dialects.
River Riddle [Sun, 26 May 2019 15:28:28 +0000 (08:28 -0700)]
Add a 'getDialectNamespace' utility to a few dialects.

--

PiperOrigin-RevId: 250049416

5 years ago [spirv] Start the SPIR-V dialect
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

5 years ago Add a templated wrapper around RewritePattern that allows for defining match...
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

5 years ago Use fused location for rewritten ops in generated rewrites.
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

5 years ago Make scope explicit to avoid misleading-indentation warnings.
Jacques Pienaar [Sat, 25 May 2019 18:03:25 +0000 (11:03 -0700)]
Make scope explicit to avoid misleading-indentation warnings.

--

PiperOrigin-RevId: 249986537

5 years ago Address some build warnings.
Jacques Pienaar [Sat, 25 May 2019 17:55:20 +0000 (10:55 -0700)]
Address some build warnings.

--

PiperOrigin-RevId: 249986120

5 years ago Add support to RewritePattern for specifying the potential operations that can...
River Riddle [Sat, 25 May 2019 02:35:23 +0000 (19:35 -0700)]
Add support to RewritePattern for specifying the potential operations that can be generated during a rewrite. This will enable analyses to start understanding the possible effects of applying a rewrite pattern.

--

PiperOrigin-RevId: 249936309

5 years ago Fix incorrect result type inference for nested tuples & remove hacky const case.
Jacques Pienaar [Sat, 25 May 2019 02:31:09 +0000 (19:31 -0700)]
Fix incorrect result type inference for nested tuples & remove hacky const case.

    Builders can be further refined but wanted to address bug where the result type was used beyond the first depth.

--

PiperOrigin-RevId: 249936004

5 years ago Update the type printer for Diagnostic to automatically wrap the type with ''.
River Riddle [Sat, 25 May 2019 02:22:00 +0000 (19:22 -0700)]
Update the type printer for Diagnostic to automatically wrap the type with ''.

--

PiperOrigin-RevId: 249935489

5 years ago Update the m_Constant matcher to enable matching derived attribute types.
River Riddle [Sat, 25 May 2019 01:49:45 +0000 (18:49 -0700)]
Update the m_Constant matcher to enable matching derived attribute types.

--

PiperOrigin-RevId: 249933184

5 years ago Rename DialectConversion to TypeConverter and split out pattern construction...
River Riddle [Sat, 25 May 2019 01:17:50 +0000 (18:17 -0700)]
Rename DialectConversion to TypeConverter and split out pattern construction. This simplifies building the conversion pattern list from multiple sources.

--

PiperOrigin-RevId: 249930583

5 years ago Move the definitions of LoadOp and StoreOp to the ODG framework.
River Riddle [Sat, 25 May 2019 01:01:38 +0000 (18:01 -0700)]
Move the definitions of LoadOp and StoreOp to the ODG framework.

--

PiperOrigin-RevId: 249928980

5 years ago Move the definitions of CmpIOp, CmpFOp, and SelectOp to the ODG framework.
River Riddle [Sat, 25 May 2019 01:01:20 +0000 (18:01 -0700)]
Move the definitions of CmpIOp, CmpFOp, and SelectOp to the ODG framework.

--

PiperOrigin-RevId: 249928953

5 years ago Replace checks for rank -1 with direct calls to hasRank
Geoffrey Martin-Noble [Sat, 25 May 2019 00:46:58 +0000 (17:46 -0700)]
Replace checks for rank -1 with direct calls to hasRank

    Also removed a redundant check for rank after already checking for static shape (which implies rank)

--

PiperOrigin-RevId: 249927636

5 years ago Limit the number of places where shaped type has to explicitly reference its...
Geoffrey Martin-Noble [Sat, 25 May 2019 00:44:21 +0000 (17:44 -0700)]
Limit the number of places where shaped type has to explicitly reference its base classes.

    Introduces a hasRank() method to make checking for rank a bit easier.

    This is partially to make it easier to make MemRef subclass ShapedType

--

PiperOrigin-RevId: 249927442

5 years ago Use TestDialect to test traits instead of unittest.
Jacques Pienaar [Fri, 24 May 2019 23:17:52 +0000 (16:17 -0700)]
Use TestDialect to test traits instead of unittest.

--

PiperOrigin-RevId: 249916947

5 years ago Add a type-constrained nested tuple type.
Geoffrey Martin-Noble [Fri, 24 May 2019 22:31:53 +0000 (15:31 -0700)]
Add a type-constrained nested tuple type.

    This is useful for dialects that use tuples but only support a subset of types.

--

PiperOrigin-RevId: 249910133

5 years ago Add TestLoopFusion.cpp to CMakeLists.txt
Lei Zhang [Fri, 24 May 2019 21:39:05 +0000 (14:39 -0700)]
Add TestLoopFusion.cpp to CMakeLists.txt

--

PiperOrigin-RevId: 249901490

5 years ago Add operand type iterators to Operation and cleanup usages of operand->getType...
River Riddle [Fri, 24 May 2019 20:28:55 +0000 (13:28 -0700)]
Add operand type iterators to Operation and cleanup usages of operand->getType. This also simplifies some lingering usages of result->getType.

--

PiperOrigin-RevId: 249889174

5 years ago Add LoopFusionUtils.cpp to CMakeLists.
Andy Davis [Fri, 24 May 2019 20:17:44 +0000 (13:17 -0700)]
Add LoopFusionUtils.cpp to CMakeLists.

--

PiperOrigin-RevId: 249887371

5 years ago Affine Loop Fusion Utility Module (1/n).
Andy Davis [Fri, 24 May 2019 17:54:22 +0000 (10:54 -0700)]
Affine Loop Fusion Utility Module (1/n).
    *) Adds LoopFusionUtils which will expose a set of loop fusion utilities (e.g. dependence checks, fusion cost/storage reduction, loop fusion transformation) for use by loop fusion algorithms. Support for checking block-level fusion-preventing dependences is added in this CL (additional loop fusion utilities will be added in subsequent CLs).
    *) Adds TestLoopFusion test pass for testing LoopFusionUtils at a fine granularity.
    *) Adds unit test for testing dependence check for block-level fusion-preventing dependences.

--

PiperOrigin-RevId: 249861071

5 years ago NFC: Rename DialectConversionPattern to ConversionPattern.
River Riddle [Fri, 24 May 2019 17:36:16 +0000 (10:36 -0700)]
NFC: Rename DialectConversionPattern to ConversionPattern.

--

PiperOrigin-RevId: 249857277

5 years ago Detemplatize convertRegion in DialectConversion
Alex Zinenko [Fri, 24 May 2019 14:00:29 +0000 (07:00 -0700)]
Detemplatize convertRegion in DialectConversion

    Originally, FunctionConverter::convertRegion in the DialectConversion framework
    was implemented as a function template because it was creating a new region in
    the parent object, which could have been an op or a function.  Since
    DialectConversion now operates in place, new region is no longer created so
    there is no need for convertRegion to be aware of the parent, only of the error
    reporting location.

--

PiperOrigin-RevId: 249826392

5 years ago Add support for llvm.constant with StringAttr as value.
Stephan Herhut [Fri, 24 May 2019 11:49:56 +0000 (04:49 -0700)]
Add support for llvm.constant with StringAttr as value.

    These are translated to an llvm::ConstantDataArray on translation to llvm IR
    proper.

--

PiperOrigin-RevId: 249813111

5 years ago Move explicit calls to Module::getNamedFunction outside of the operations that...
River Riddle [Fri, 24 May 2019 00:01:16 +0000 (17:01 -0700)]
Move explicit calls to Module::getNamedFunction outside of the operations that contain FunctionAttr. It is up to the users of operations to query the module for a specific function referenced by a FunctionAttr.

--

PiperOrigin-RevId: 249743109

5 years ago Introduce a new common diagnostic handler ScopedDiagnosticHandler to simplify...
River Riddle [Thu, 23 May 2019 23:16:34 +0000 (16:16 -0700)]
Introduce a new common diagnostic handler ScopedDiagnosticHandler to simplify saving and restoring the currently registered handler.

--

PiperOrigin-RevId: 249735912

5 years ago Add pattern file location to generated code to trace origin of pattern.
Jacques Pienaar [Thu, 23 May 2019 23:08:52 +0000 (16:08 -0700)]
Add pattern file location to generated code to trace origin of pattern.

--

PiperOrigin-RevId: 249734666

5 years ago Make TupleOf take a list of allowed types.
Geoffrey Martin-Noble [Thu, 23 May 2019 22:43:11 +0000 (15:43 -0700)]
Make TupleOf take a list of allowed types.

    This better matches other container types. Seems better to do that, even though tuples are a little different, since they don't have a single element type.

    Also fixed its description to mention the element type.

--

PiperOrigin-RevId: 249730341

5 years ago Add a new TestDialect directory in tests/. This directory defines a fake 'TestDia...
River Riddle [Thu, 23 May 2019 22:11:19 +0000 (15:11 -0700)]
Add a new TestDialect directory in tests/. This directory defines a fake 'TestDialect' that allows for the use of FileCheck to test things that aren't currently used anywhere else in tree. As a first order, this should simplify the tests used for tablegen components revolving around operation constraints/patterns.

--

PiperOrigin-RevId: 249724328