platform/upstream/llvm.git
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

5 years ago Rename Float/Integer to AnyFloat/AnyInteger
Geoffrey Martin-Noble [Thu, 23 May 2019 21:41:32 +0000 (14:41 -0700)]
Rename Float/Integer to AnyFloat/AnyInteger

    This emphasizes that it is potentially less constrained than you might desire (especially dialects will frequently not support all bit widths), and better matches the other type names, especially the container types.

--

PiperOrigin-RevId: 249718409

5 years ago Fix Linalg tiling for the partial tile case.
Nicolas Vasilache [Thu, 23 May 2019 20:00:16 +0000 (13:00 -0700)]
Fix Linalg tiling for the partial tile case.

    This CL prepares for mixing lowering of tiled linalg operations to loops with load and store operations. In particular it is necessary to capture partial tile information in views. This CL makes slice ops during Linalg tiling properly stop at partial tile boundaries by implementing `min` with a `cmpi` and `select` over values of index type.

    To be consistent with lowering to loops, the implementation of tiling also drops specifics of accessing values via ranges and instead uses ranges of the form
    `[0, dim(view), 1]` for creating view slices. This simplifies the code for the implementation of tiling and utils.

    This also allows removing restrictions around needing a View or SliceOp defined in the current function context (as well as all it RangeOps). The restriction removal is tested by making the dot test operate directly on views.

    The above is still subject to folding of the linalg.dim operation left for a future CL.

    At this time, mixing tiling and lowering to loops all the way to execution is not yet functional because affine.for does not allow arbitrarily defined values of index type as its operands.

    The previously introduced linalg.range_intersection was not sufficient to capture the necessary information and still required dealing with max quantities.
    A followup CL will remove linalg.range_intersection.

--

PiperOrigin-RevId: 249698823

5 years ago Remove a stale declaration in FunctionAttr.
River Riddle [Thu, 23 May 2019 19:51:13 +0000 (12:51 -0700)]
Remove a stale declaration in FunctionAttr.

--

PiperOrigin-RevId: 249697345

5 years ago Added the ability to run a mapping function across the values of an elements
Rob Suderman [Thu, 23 May 2019 18:22:13 +0000 (11:22 -0700)]
Added the ability to run a mapping function across the values of an elements
    attr. This supports both the SplatElementsAttr and DenseElementsAttr for both
    float and integer inputs / outputs.

--

PiperOrigin-RevId: 249681056

5 years ago Apply operation rewrites before updating arguments.
River Riddle [Thu, 23 May 2019 18:11:18 +0000 (11:11 -0700)]
Apply operation rewrites before updating arguments.

--

PiperOrigin-RevId: 249678839

5 years ago Decouple running a conversion from the DialectConversion class. The DialectConver...
River Riddle [Thu, 23 May 2019 16:23:33 +0000 (09:23 -0700)]
Decouple running a conversion from the DialectConversion class. The DialectConversion class is only necessary for type signature changes(block arguments or function arguments). This isn't always desired when performing a dialect conversion. This allows for those conversions without this need to run per function instead of per module.

--

PiperOrigin-RevId: 249657549

5 years ago Fix Linalg lowering to loops
Nicolas Vasilache [Thu, 23 May 2019 14:00:18 +0000 (07:00 -0700)]
Fix Linalg lowering to loops

    This CL makes lowering to loops always be a:
    ```
    %D = linalg.dim %view, constant : !linalg.view<...>
    affine.for %ix = %c0 to %D {
      ...
    }
    ```

    This form composes correctly with tiling and is also the proper way to emit loops from views that across function boundaries.
    The previous version that would extract the range_min/max/step was composing incorrectly with tiling (i.e. would shift by range_min both in the loop bounds and in the slice) and would not work across function boundaries.

    The relevant tests are updated and a new test `dot_view`---which lowers to loops from views passed as function parameters---is added.

    When additional context is available, the linalg.dim operations should be folded away but this is left for a future CL.

--

PiperOrigin-RevId: 249634712

5 years ago Automated rollback of changelist 247713812.
Thomas Joerg [Thu, 23 May 2019 09:16:18 +0000 (02:16 -0700)]
Automated rollback of changelist 247713812.

PiperOrigin-RevId: 249605627

5 years ago Add LLVM::IntToPtrOp and LLVM::PtrToIntOp to LLVM dialect.
Stephan Herhut [Thu, 23 May 2019 09:03:14 +0000 (02:03 -0700)]
Add LLVM::IntToPtrOp and LLVM::PtrToIntOp to LLVM dialect.

--

PiperOrigin-RevId: 249604199

5 years ago Automated rollback of changelist 249538085.
Rob Suderman [Thu, 23 May 2019 00:03:18 +0000 (17:03 -0700)]
Automated rollback of changelist 249538085.

PiperOrigin-RevId: 249550805

5 years ago Added the ability to run a mapping function across the values of an elements
Rob Suderman [Wed, 22 May 2019 22:55:17 +0000 (15:55 -0700)]
Added the ability to run a mapping function across the values of an elements
    attr. This supports both the SplatElementsAttr and DenseElementsAttr for both
    float and integer inputs / outputs.

--

PiperOrigin-RevId: 249538085

5 years ago Add thread-safe utilities to LLVMType to allow constructing llvm types in a multi...
River Riddle [Wed, 22 May 2019 21:56:07 +0000 (14:56 -0700)]
Add thread-safe utilities to LLVMType to allow constructing llvm types in a multi-threaded environment. The LLVMContext is not thread-safe and directly constructing a raw llvm::Type can create situations where the LLVMContext is modified by multiple threads at the same time.

--

PiperOrigin-RevId: 249526233

5 years ago Refactor FunctionAttr to hold the internal function reference by name instead...
River Riddle [Wed, 22 May 2019 20:41:23 +0000 (13:41 -0700)]
Refactor FunctionAttr to hold the internal function reference by name instead of pointer. The one downside to this is that the function reference held by a FunctionAttr needs to be explicitly looked up from the parent module. This provides several benefits though:
    * There is no longer a need to explicitly remap function attrs.
      - This removes a potentially expensive call from the destructor of Function.
      - This will enable some interprocedural transformations to now run intraprocedurally.
      - This wasn't scalable and forces dialect defined attributes to override
        a virtual function.
    * Replacing a function is now a trivial operation.
    * This is a necessary first step to representing functions as operations.

--

PiperOrigin-RevId: 249510802

5 years ago Return nullptr on Region::getContainingOperation()/getContainingFunction() instea...
Mehdi Amini [Wed, 22 May 2019 19:22:51 +0000 (12:22 -0700)]
Return nullptr on Region::getContainingOperation()/getContainingFunction() instead of asserting

    This avoids crashing when trying to dump an operation nested in a region that isn't yet attached to an operation, which is quite useful when debugging.

    This alone won't be enough to print an unlink Operation, it'll display `<<UNLINKED INSTRUCTION>>`.

--

PiperOrigin-RevId: 249496388

5 years ago Make EDSC builder test more robust to the order of evaluation
Alex Zinenko [Wed, 22 May 2019 19:13:54 +0000 (12:13 -0700)]
Make EDSC builder test more robust to the order of evaluation

    EDSC builder test uses FileCheck to match the IR produced by EDSC in the
    textual order.  For mathematical operations, EDSC relies on overloaded
    operators.  Since they are essentially function calls, the order of evaluation
    of their operands is unspecified and differs between compilers.  Do not rely on
    a specific order of operands and just check they are all emitted before the
    last operation.  Give names to matched SSA values in order to make sure the
    right operands are used in relevant places.

--

PiperOrigin-RevId: 249494995

5 years ago Refactor DialectConversion to operate on functions in-place *without* any cloning...
River Riddle [Wed, 22 May 2019 18:49:04 +0000 (11:49 -0700)]
Refactor DialectConversion to operate on functions in-place *without* any cloning. This works by caching all of the requested pattern rewrite operations, e.g. replace operation, and only applying them on a completely successful conversion.

--

PiperOrigin-RevId: 249490306

5 years ago Update Attribute::getDialect/Type::getDialect to return a non-const dialect refer...
River Riddle [Wed, 22 May 2019 16:56:11 +0000 (09:56 -0700)]
Update Attribute::getDialect/Type::getDialect to return a non-const dialect reference.

--

PiperOrigin-RevId: 249467245

5 years ago NFC: Fix the name of a comment header block in Diagnostics.cpp.
River Riddle [Wed, 22 May 2019 16:52:47 +0000 (09:52 -0700)]
NFC: Fix the name of a comment header block in Diagnostics.cpp.

--

PiperOrigin-RevId: 249466645

5 years ago Add a new interleaveComma that allows specifying a unary function for the contain...
River Riddle [Tue, 21 May 2019 23:30:55 +0000 (16:30 -0700)]
Add a new interleaveComma that allows specifying a unary function for the container elements.

--

PiperOrigin-RevId: 249349269

5 years ago Make static shape tensor container match other container types
Geoffrey Martin-Noble [Tue, 21 May 2019 22:45:25 +0000 (15:45 -0700)]
Make static shape tensor container match other container types

    Suffix with Of and take a list of types. Also give a better description that includes the element type information.

--

PiperOrigin-RevId: 249341159

5 years ago Simplify container type definitions
Geoffrey Martin-Noble [Tue, 21 May 2019 22:44:17 +0000 (15:44 -0700)]
Simplify container type definitions

    The passed element type description is usually unnecessary, and it's just as valid to want to pass a description for the entire container. In either case there's an alternative (Separate element type def or a TypeAlias) and we don't need to pollute the main API.

    To allow for this, I cleaned up the TF op definitions and added some additional utilities.

--

PiperOrigin-RevId: 249340979

5 years ago Make the ParallelDiagnosticHandler used by the pass manager publicly available...
River Riddle [Tue, 21 May 2019 21:29:20 +0000 (14:29 -0700)]
Make the ParallelDiagnosticHandler used by the pass manager publicly available in Diagnostics.h. This provides a common utility for deterministically handling diagnostics in a multi-threaded environment.

--

PiperOrigin-RevId: 249325937

5 years ago Fix a bug in toy LateLowering where a type conversion was using 'cast' instead...
River Riddle [Tue, 21 May 2019 21:24:48 +0000 (14:24 -0700)]
Fix a bug in toy LateLowering where a type conversion was using 'cast' instead of 'dyn_cast'.

--

PiperOrigin-RevId: 249325111

5 years ago Clean up container type names in OpBase
Geoffrey Martin-Noble [Tue, 21 May 2019 17:45:30 +0000 (10:45 -0700)]
Clean up container type names in OpBase

    Establish the following convention:
    1. Container class types end in "Of" (e.g. TensorOf) and take a list of allowed types.
    2. An X container where only a single type is allowed is called TypeX (e.g. I32Tensor).
    3. An X container where any type is allowed is called AnyX (e.g. AnyTensor).

--

PiperOrigin-RevId: 249281018

5 years ago CMake build: force-link SDBM lib into SDBM unit tests
Alex Zinenko [Tue, 21 May 2019 15:56:38 +0000 (08:56 -0700)]
CMake build: force-link SDBM lib into SDBM unit tests

    Otherwise, GCC < 7 does not link in the dialect registration, fails to look up
    the dialect in the context and cannot construct SDBM objects.

--

PiperOrigin-RevId: 249259758

5 years ago Move SDBM uniquer into the SDBM dialect
Alex Zinenko [Tue, 21 May 2019 14:25:55 +0000 (07:25 -0700)]
Move SDBM uniquer into the SDBM dialect

    MLIRContext does not have to be aware of the SDBM unique data structures
    directly.  Move the SDBM storage uniquer from MLIRContext to the SDBM dialect
    instance.  Expressions that previously required a context to be constructed now
    require an instance of the dialect in order to access the uniquer.  While they
    could look up the dialect in the context, it would have introduced a rather
    expensive lookup into each construction.  Instead, the caller is expected to
    obtain the dialect instance and cache it.

--

PiperOrigin-RevId: 249245199

5 years ago Move SDBM infrastructure into a new SDBM dialect
Alex Zinenko [Tue, 21 May 2019 14:22:35 +0000 (07:22 -0700)]
Move SDBM infrastructure into a new SDBM dialect

    We now have sufficient extensibility in dialects to move attribute components
    such as SDBM out of the core IR into a dedicated dialect and make them
    optional.  Introduce an SDBM dialect and move the code.  This is a mostly
    non-functional change.

--

PiperOrigin-RevId: 249244802

5 years ago SDBMExpr: factor uniqu'ing out of MLIRContext.cpp
Alex Zinenko [Tue, 21 May 2019 14:22:00 +0000 (07:22 -0700)]
SDBMExpr: factor uniqu'ing out of MLIRContext.cpp

    SDBM expressions are designed as components of an attribute, similarly to
    affine expressions.  As such, they need to be unique'd in the MLIRContext.
    When SDBM expressions were implemented, uniqu'ing objects in a context required
    to modify MLIRContext implementation.  This is no longer the case as generic
    StorageUniquer has been introduced.  Port the SDBMExpr uniqu'ing to use a newly
    introduced uniquer and remove SDBM construction from MLIRContext.cpp.

--

PiperOrigin-RevId: 249244739

5 years ago Fix -Wsign-compare in OperationSupportTest.cpp
Alex Zinenko [Tue, 21 May 2019 14:07:17 +0000 (07:07 -0700)]
Fix -Wsign-compare in OperationSupportTest.cpp

    A couple of warnings was produced when compiling this test due to comaprisons
    with a signed literal.  Used unsigned literals instead.

--

PiperOrigin-RevId: 249242970

5 years ago Linalg: avoid deriving from MultiOperandTraitBase multiple times
Lei Zhang [Tue, 21 May 2019 11:42:04 +0000 (04:42 -0700)]
Linalg: avoid deriving from MultiOperandTraitBase multiple times

    The Op Definition Generator will automatically insert the VariadicOperands
    trait if an op has variadic operands or results. It already derives from
    MultiOperandTraitBase.

--

PiperOrigin-RevId: 249227268

5 years ago Small cleanup.
Thomas Joerg [Tue, 21 May 2019 08:38:53 +0000 (01:38 -0700)]
Small cleanup.
    * Use `cast` rather than `dyn_cast` to get an assertion failure rather than a segfault in case of a type mismatch.
    * Use stream operators to `emitOpError`s.

--

PiperOrigin-RevId: 249208135

5 years ago AffineExpr: factor uniqu'ing out of MLIRContext.cpp
Alex Zinenko [Tue, 21 May 2019 08:34:13 +0000 (01:34 -0700)]
AffineExpr: factor uniqu'ing out of MLIRContext.cpp

    Affine expressions are designed as components of an attribute and are unique'd
    in the MLIRContext.  When affine expressions were implemented, uniqu'ing
    objects in a context required to modify MLIRContext implementation.  This is no
    longer the case as generic StorageUniquer has been introduced.  Port the
    AffineExpr construction to use the new infrastructure by introducing an
    affineUniquer into the MLIRContext.

--

PiperOrigin-RevId: 249207539

5 years ago Drop AffineExpr::Null
Alex Zinenko [Tue, 21 May 2019 08:33:53 +0000 (01:33 -0700)]
Drop AffineExpr::Null

    Similarly to other value-type wrappers, the default constructor of AffineExpr
    constructs a null object and removes the need for an explicit ::Null
    constructor.  Drop it and remove the only user which can trivially rely on the
    default constructor.

--

PiperOrigin-RevId: 249207502

5 years ago Change getParent() to be a const function. This is only necessary because ilist_n...
Youlong Cheng [Tue, 21 May 2019 06:10:10 +0000 (23:10 -0700)]
Change getParent() to be a const function. This is only necessary because ilist_node_with_parent specifically requires a 'getParent() const' method. If/When ilist_node removes this constraint we should drop the const to fit the rest of the MLIR const model.

--

PiperOrigin-RevId: 249193257

5 years ago Upstream the Quantizer tool (part 4).
Stella Laurenzo [Tue, 21 May 2019 01:27:38 +0000 (18:27 -0700)]
Upstream the Quantizer tool (part 4).

    This adds the basic passes needed and ties them into mlir-opt. Also adds two specific unit tests that exercise them.

    Next step is a standalone quantizer tool and additional cleanup.
    Tested:
      ninja check-mlir

--

PiperOrigin-RevId: 249167690

5 years ago When changing the type of a Function, also update the type of the respective...
River Riddle [Mon, 20 May 2019 22:21:22 +0000 (15:21 -0700)]
When changing the type of a Function, also update the type of the respective FunctionAttr.

--

PiperOrigin-RevId: 249137558

5 years ago [LoopFusion] Don't count terminator op in compute cost.
MLIR Team [Mon, 20 May 2019 21:18:43 +0000 (14:18 -0700)]
[LoopFusion] Don't count terminator op in compute cost.

--

PiperOrigin-RevId: 249124895

5 years ago Use lambdas for nesting edsc constructs.
Nicolas Vasilache [Mon, 20 May 2019 20:32:35 +0000 (13:32 -0700)]
Use lambdas for nesting edsc constructs.

    Using ArrayRef introduces issues with the order of evaluation between a constructor and
    the arguments of the subsequent calls to the `operator()`.
    As a consequence the order of captures is not well-defined can go wrong with certain compilers (e.g. gcc-6.4).
    This CL fixes the issue by using lambdas in lieu of ArrayRef.

--

PiperOrigin-RevId: 249114775

5 years ago Fix MacOS test: use %shlibext in lit command line to expand to .dylib on MacOS...
Mehdi Amini [Mon, 20 May 2019 20:25:35 +0000 (13:25 -0700)]
Fix MacOS test: use %shlibext in lit command line to expand to .dylib on MacOS and .so on Linux

--

PiperOrigin-RevId: 249113478

5 years ago Define a string join tablegen utility
Geoffrey Martin-Noble [Mon, 20 May 2019 18:00:24 +0000 (11:00 -0700)]
Define a string join tablegen utility

--

PiperOrigin-RevId: 249083600

5 years ago Add CMakeLists.txt entry for Linalg/Transforms/LowerToLoops
Nicolas Vasilache [Mon, 20 May 2019 17:49:27 +0000 (10:49 -0700)]
Add CMakeLists.txt entry for Linalg/Transforms/LowerToLoops

--

PiperOrigin-RevId: 249080647

5 years ago Fix automatic description for AnyTypeOf
Geoffrey Martin-Noble [Mon, 20 May 2019 17:32:55 +0000 (10:32 -0700)]
Fix automatic description for AnyTypeOf

    Unfortunately, this now gives a segfault if you pass it an empty list, similar to stringify. Given how fiddly this is, we should probably have a string join helper. I'll fix both of these using better tablegen helpers in a follow-up.

--

PiperOrigin-RevId: 249076849

5 years ago Rename "AnyOf" and "AllOf" combined predicates to "Or" and "And", respectively.
Geoffrey Martin-Noble [Mon, 20 May 2019 17:31:32 +0000 (10:31 -0700)]
Rename "AnyOf" and "AllOf" combined predicates to "Or" and "And", respectively.

    This reduces conflict between these and other type names, where we're moving towards "Of" indicating a container type containing certain types. It also better matches the "Neg" predicate modifier and generally is pretty understandable/readable for predicates.

--

PiperOrigin-RevId: 249076508

5 years ago Delete IntegerBase and FloatBase tablegen classes
Geoffrey Martin-Noble [Mon, 20 May 2019 17:19:38 +0000 (10:19 -0700)]
Delete IntegerBase and FloatBase tablegen classes

    These don't have any behavior and just delegate to Type. The only references are in OpBase.td Since the tablegen type hierarchy is not realized in the generated C++ these also aren't providing value for examining the type hierarchy

--

PiperOrigin-RevId: 249073939

5 years ago [ODS] Allow dialect to specify C++ namespaces
Lei Zhang [Mon, 20 May 2019 16:33:10 +0000 (09:33 -0700)]
[ODS] Allow dialect to specify C++ namespaces

    Previously we force the C++ namespaces to be `NS` if `SomeOp` is defined as
    `NS_SomeOp`. This is too rigid as it does not support nested namespaces
    well. This CL adds a "namespace" field into the Dialect class to allow
    flexible namespaces.

--

PiperOrigin-RevId: 249064981

5 years ago Fix Linalg/llvm_ir test
Nicolas Vasilache [Mon, 20 May 2019 15:48:25 +0000 (08:48 -0700)]
Fix Linalg/llvm_ir test

--

PiperOrigin-RevId: 249057043

5 years ago Fix stride computation bug when lowering linalg.view to llvm
Nicolas Vasilache [Mon, 20 May 2019 15:26:11 +0000 (08:26 -0700)]
Fix stride computation bug when lowering linalg.view to llvm

--

PiperOrigin-RevId: 249053115

5 years ago Add lowering of LinalgLibraryOps to linalg.load + linalg.store.
Nicolas Vasilache [Mon, 20 May 2019 15:04:40 +0000 (08:04 -0700)]
Add lowering of LinalgLibraryOps to linalg.load + linalg.store.

    This CL adds a pass to lower out of dot,matvec,matmul etc and into a combination of affine.for, linalg.load and linalg.store operations.
    Such operations can then later lowered to LLVM.
    This CL essentially performs op expansion using EDSCs and factors out a few common utils from Tiling.cpp.

--

PiperOrigin-RevId: 249049518

5 years ago Use FileCheck to test SDBM
Alex Zinenko [Mon, 20 May 2019 08:44:37 +0000 (01:44 -0700)]
Use FileCheck to test SDBM

    SDBM has an output format representing the unterlying matrix and stripe
    expressions.  Move the SDBM tests from unit testing framework to
    FileCheck-based tests, printing them to the standard output and using FileCheck
    to test the output.  Tests that check the API proper (e.g. that SDBM
    expressions have a specific subtype) and that rely on non-syntatic properties
    (equality of the set of constraints) are not ported.

--

PiperOrigin-RevId: 249006055

5 years ago ExecutionEngine: drop PassManager integration
Alex Zinenko [Mon, 20 May 2019 08:31:29 +0000 (01:31 -0700)]
ExecutionEngine: drop PassManager integration

    Originally, ExecutionEngine was created before MLIR had a proper pass
    management infrastructure or an LLVM IR dialect (using the LLVM target
    directly).  It has been running a bunch of lowering passes to convert the input
    IR from Standard+Affine dialects to LLVM IR and, later, to the LLVM IR dialect.
    This is no longer necessary and is even undesirable for compilation flows that
    perform their own conversion to the LLVM IR dialect.  Drop this integration and
    make ExecutionEngine accept only the LLVM IR dialect.  Users of the
    ExecutionEngine can call the relevant passes themselves.

--

PiperOrigin-RevId: 249004676

5 years ago Fix debug build: static constexpr data member must have a definition (until C...
Mehdi Amini [Mon, 20 May 2019 06:09:29 +0000 (23:09 -0700)]
Fix debug build: static constexpr data member must have a definition (until C++17)

--

PiperOrigin-RevId: 248990338

5 years ago Add support for streaming an OperationName into a Diagnostic.
River Riddle [Mon, 20 May 2019 05:35:01 +0000 (22:35 -0700)]
Add support for streaming an OperationName into a Diagnostic.

--

PiperOrigin-RevId: 248987646

5 years ago NFC: Tidy up DialectConversion.cpp and rename DialectOpConversion to DialectConv...
River Riddle [Mon, 20 May 2019 03:54:13 +0000 (20:54 -0700)]
NFC: Tidy up DialectConversion.cpp and rename DialectOpConversion to  DialectConversionPattern.

--

PiperOrigin-RevId: 248980810

5 years ago Refactor the DialectConversion process to clone each function and then operate...
River Riddle [Mon, 20 May 2019 00:56:32 +0000 (17:56 -0700)]
Refactor the DialectConversion process to clone each function and then operate in-place, as opposed to incrementally constructing a new function. This is crucial to allowing the use of non type-conversion patterns(normal RewritePatterns) as part of the conversion process.

    The converter now works by inserting fake producer operations when replacing the results of an existing operation with values of a different, now legal, type. These fake operations are guaranteed to never escape the converter.

--

PiperOrigin-RevId: 248969130

5 years ago Allow a function to take the name of another existing function.
River Riddle [Mon, 20 May 2019 00:41:19 +0000 (17:41 -0700)]
Allow a function to take the name of another existing function.

--

PiperOrigin-RevId: 248968285

5 years ago Add support for streaming Operations into Diagnostics.
River Riddle [Mon, 20 May 2019 00:29:51 +0000 (17:29 -0700)]
Add support for streaming Operations into Diagnostics.

--

PiperOrigin-RevId: 248967563

5 years ago Update the rewrite methods of each of the DialectConversion patterns to notify...
River Riddle [Sun, 19 May 2019 23:43:08 +0000 (16:43 -0700)]
Update the rewrite methods of each of the DialectConversion patterns to notify the PatternRewriter that the operation is being replaced.

--

PiperOrigin-RevId: 248965082

5 years ago Add a utility function 'Operation::replaceUsesOfWith' to replace uses of a value...
River Riddle [Sun, 19 May 2019 22:42:49 +0000 (15:42 -0700)]
Add a utility function 'Operation::replaceUsesOfWith' to replace uses of a value within a single operation.

--

PiperOrigin-RevId: 248961779

5 years ago Move the ConversionListBuilder utility to PatternMatch.h and rename it to Rewrite...
River Riddle [Sat, 18 May 2019 20:23:38 +0000 (13:23 -0700)]
Move the ConversionListBuilder utility to PatternMatch.h and rename it to RewriteListBuilder. It has no specific functionality for DialectOpConversion patterns and can be useful for RewritePatterns in general.

--

PiperOrigin-RevId: 248884466

5 years ago Add user iterators to IRObjects, i.e. Values.
River Riddle [Sat, 18 May 2019 18:09:07 +0000 (11:09 -0700)]
Add user iterators to IRObjects, i.e. Values.

--

PiperOrigin-RevId: 248877752