platform/upstream/llvm.git
5 years ago[spirv] Add values for enum cases and generate the enum utilities
Lei Zhang [Mon, 10 Jun 2019 22:12:04 +0000 (15:12 -0700)]
[spirv] Add values for enum cases and generate the enum utilities

PiperOrigin-RevId: 252494957

5 years ago[spirv] NFC: use two spaces for indentation in gen_spirv_dialect.py
Lei Zhang [Mon, 10 Jun 2019 20:15:52 +0000 (13:15 -0700)]
[spirv] NFC: use two spaces for indentation in gen_spirv_dialect.py

PiperOrigin-RevId: 252469663

5 years agoExpose a minimal type parser to dialects.
Nicolas Vasilache [Mon, 10 Jun 2019 20:12:32 +0000 (13:12 -0700)]
Expose a minimal type parser to dialects.

This CL exposes a parseType method which allows standalone reuse of the MLIR type parsing mechanism. This is a free function for now because the underlying MLIR parser is not guaranteed to receive a StringRef which lives in the proper MemBuffer. This requires building a new MemBuffer/SourceMgr and modifying the Parser constructor to not require an mlir::Module.

The error diagnostic emitted by parseType has context limited to the local string.
For now the dialect has the additional option to emit its own extra error that has the FileLineColLoc context.

In the future, both error messages should be combined into a single error.

PiperOrigin-RevId: 252468911

5 years ago[spirv] Add array and run-time array types
Lei Zhang [Mon, 10 Jun 2019 19:21:44 +0000 (12:21 -0700)]
[spirv] Add array and run-time array types

PiperOrigin-RevId: 252458108

5 years ago[ODG] Address compiler warnings of comparing signed and unsigned integer expressions
Lei Zhang [Mon, 10 Jun 2019 18:08:52 +0000 (11:08 -0700)]
[ODG] Address compiler warnings of comparing signed and unsigned integer expressions

PiperOrigin-RevId: 252442613

5 years agoReturn dependence result enum to distiguish between dependence result and error cases...
Andy Davis [Mon, 10 Jun 2019 17:50:08 +0000 (10:50 -0700)]
Return dependence result enum to distiguish between dependence result and error cases (NFC).

PiperOrigin-RevId: 252437616

5 years ago[ODS] Support variadic operand/result verification
Lei Zhang [Sun, 9 Jun 2019 14:00:09 +0000 (07:00 -0700)]
[ODS] Support variadic operand/result verification

This CL enables verification code generation for variadic operands and results.
In verify(), we use fallback getter methods to access all the dynamic values
belonging to one static variadic operand/result to reuse the value range
calculation there.

PiperOrigin-RevId: 252288219

5 years ago[ODG] Use getODSOperands() and getODSResults() to back accessors
Lei Zhang [Sun, 9 Jun 2019 12:50:09 +0000 (05:50 -0700)]
[ODG] Use getODSOperands() and getODSResults() to back accessors

This CL added getODSOperands() and getODSResults() as fallback getter methods for
getting all the dynamic values corresponding to a static operand/result (which
can be variadic). It should provide a uniform way of calculating the value ranges.
All named getter methods are layered on top of these methods now.

PiperOrigin-RevId: 252284270

5 years ago[TableGen] Generating enum definitions and utility functions
Lei Zhang [Sat, 8 Jun 2019 15:39:07 +0000 (08:39 -0700)]
[TableGen] Generating enum definitions and utility functions

Enum attributes can be defined using `EnumAttr`, which requires all its cases
to be defined with `EnumAttrCase`. To facilitate the interaction between
`EnumAttr`s and their C++ consumers, add a new EnumsGen TableGen backend
to generate a few common utilities, including an enum class, `llvm::DenseMapInfo`
for the enum class, conversion functions from/to strings.

This is controlled via the `-gen-enum-decls` and `-gen-enum-defs` command-line
options of `mlir-tblgen`.

PiperOrigin-RevId: 252209623

5 years agoUpdate function comment, since we added FP16 support for getZeroAttr.
MLIR Team [Fri, 7 Jun 2019 20:44:09 +0000 (13:44 -0700)]
Update function comment, since we added FP16 support for getZeroAttr.

PiperOrigin-RevId: 252110998

5 years agoNFC: Cleanup the grouping of DenseElementsAttr 'get' methods, and move the bit write...
River Riddle [Fri, 7 Jun 2019 19:08:36 +0000 (12:08 -0700)]
NFC: Cleanup the grouping of DenseElementsAttr 'get' methods, and move the bit write/read functions to static functions in Attributes.cpp.

PiperOrigin-RevId: 252094145

5 years agoRemove the ability to directly construct a DenseElementsAttr with a raw character...
River Riddle [Fri, 7 Jun 2019 16:57:29 +0000 (09:57 -0700)]
Remove the ability to directly construct a DenseElementsAttr with a raw character buffer. This made assumptions about how DenseElementsAttr structured its internal storage, which may change in the future. To replace the existing use cases, a few utility methods have been added:

* 'get' methods that allow constructing from an ArrayRef of integer or floating point values.
* A 'reshape' method to allow for changing the shape without changing the underlying data.

PiperOrigin-RevId: 252067898

5 years agoNFC: Cleanup FuncVerifier and refactor it into a general OperationVerifier. The funct...
River Riddle [Fri, 7 Jun 2019 16:46:13 +0000 (09:46 -0700)]
NFC: Cleanup FuncVerifier and refactor it into a general OperationVerifier. The function specific verification has been moved into Function::verify. This is in preparation for adding a general Operation::verify method.

PiperOrigin-RevId: 252065646

5 years agoRemove unnecessary StandardOps dependency
Geoffrey Martin-Noble [Fri, 7 Jun 2019 12:30:35 +0000 (05:30 -0700)]
Remove unnecessary StandardOps dependency

PiperOrigin-RevId: 252032386

5 years agoAdd a convenient getDialect() accessor on Op<> class
Mehdi Amini [Fri, 7 Jun 2019 04:50:13 +0000 (21:50 -0700)]
Add a convenient getDialect() accessor on Op<> class

PiperOrigin-RevId: 251988464

5 years agoNFC: Replace typelist_contains with llvm::is_one_of. This should also fix weird build...
River Riddle [Fri, 7 Jun 2019 04:39:36 +0000 (21:39 -0700)]
NFC: Replace typelist_contains with llvm::is_one_of. This should also fix weird build failures on MSVC related to typelist_contains for missing template arguments.

PiperOrigin-RevId: 251987621

5 years agoAdd free standing getElementTypeOrSelf member.
Jacques Pienaar [Fri, 7 Jun 2019 02:53:49 +0000 (19:53 -0700)]
Add free standing getElementTypeOrSelf member.

This function returns the element type of the underlying type or the input type itself. This removes some of the casting and code from ODS and into C++ code.

I've not converted all the call sites (as this requires a new include and target) and wanted to run it past folks first.

PiperOrigin-RevId: 251978156

5 years agoInternal change
Mehdi Amini [Fri, 7 Jun 2019 01:52:29 +0000 (18:52 -0700)]
Internal change

PiperOrigin-RevId: 251972430

5 years agoAdd the getDialectNamespace static utility method to the Linalg dialect.
MLIR Team [Thu, 6 Jun 2019 23:42:36 +0000 (16:42 -0700)]
Add the getDialectNamespace static utility method to the Linalg dialect.

PiperOrigin-RevId: 251953766

5 years agoRemove the explicit attribute kinds for DenseIntElementsAttr and DenseFPElementsAttr...
River Riddle [Thu, 6 Jun 2019 23:15:42 +0000 (16:15 -0700)]
Remove the explicit attribute kinds for DenseIntElementsAttr and DenseFPElementsAttr in favor of just one DenseElementsAttr. Now that attribute has the ability to define 'classof(Attribute attr)' methods, these derived classes can just be specializations of the main attribute class.

PiperOrigin-RevId: 251948820

5 years agoAdding utility to parse optional colon-type-lists.
Ben Vanik [Thu, 6 Jun 2019 22:58:47 +0000 (15:58 -0700)]
Adding utility to parse optional colon-type-lists.

PiperOrigin-RevId: 251945512

5 years agoSimplify DenseElementsAttr by rounding up the storage of odd bit widths to 8-bits...
River Riddle [Thu, 6 Jun 2019 22:55:17 +0000 (15:55 -0700)]
Simplify DenseElementsAttr by rounding up the storage of odd bit widths to 8-bits. This removes the requirement that the underlying buffer be aligned to 64 bits which opens the door for several optimizations in the future, e.g. detecting splat.

PiperOrigin-RevId: 251944922

5 years agoAdd support to ConversionTarget for storing legalization actions for entire dialects...
River Riddle [Thu, 6 Jun 2019 22:48:14 +0000 (15:48 -0700)]
Add support to ConversionTarget for storing legalization actions for entire dialects as opposed to individual operations. This allows for better support of unregistered operations, as well as removing the need to collect all of the operations for a given dialect(which may be very expensive).

PiperOrigin-RevId: 251943590

5 years agoAdd support for matchAndRewrite to the DialectConversion patterns. This also drops...
River Riddle [Thu, 6 Jun 2019 22:38:08 +0000 (15:38 -0700)]
Add support for matchAndRewrite to the DialectConversion patterns. This also drops the default "always succeed" match override to better align with RewritePattern.

PiperOrigin-RevId: 251941625

5 years agoAdd a general operation property 'IsolatedFromAbove' that guarantees that all regions...
River Riddle [Thu, 6 Jun 2019 21:28:13 +0000 (14:28 -0700)]
Add a general operation property 'IsolatedFromAbove' that guarantees that all regions of a given operation are explicit capture only and will not reference values defined above the enclosing operation. This trait will be useful for applying some of the properties currently attached to Functions to operations, e.g. verifying dominance within a specific operation, enabling multi-threading of certain transformations between different instances, etc.

PiperOrigin-RevId: 251927466

5 years agoSupport constructing DominanceInfo with an Operation. This computes the dominance...
River Riddle [Thu, 6 Jun 2019 18:54:14 +0000 (11:54 -0700)]
Support constructing DominanceInfo with an Operation. This computes the dominance information for any nested regions within the operation.

PiperOrigin-RevId: 251896520

5 years agoSupport FP16 in getZeroAttr.
MLIR Team [Thu, 6 Jun 2019 05:02:22 +0000 (22:02 -0700)]
Support FP16 in getZeroAttr.

PiperOrigin-RevId: 251783931

5 years agoAdd a verify method to FuncOp and check that the type signature matches the signature...
River Riddle [Thu, 6 Jun 2019 01:12:16 +0000 (18:12 -0700)]
Add a verify method to FuncOp and check that the type signature matches the signature of the entry block.

PiperOrigin-RevId: 251759848

5 years agoNFC: Rename FunctionParser to OperationParser. There is nothing specific to functions...
River Riddle [Thu, 6 Jun 2019 00:04:37 +0000 (17:04 -0700)]
NFC: Rename FunctionParser to OperationParser. There is nothing specific to functions about this parser and provides general parser support for operations, and regions of operations.

PiperOrigin-RevId: 251749622

5 years agoMinor change to Linalg Tablegen file to not include OpBase.td if already included...
MLIR Team [Wed, 5 Jun 2019 21:57:20 +0000 (14:57 -0700)]
Minor change to Linalg Tablegen file to not include OpBase.td if already included by another include

PiperOrigin-RevId: 251725376

5 years agoNFC: Cleanup the definitions of OpAsmParser and CustomOpAsmParser by adding comments...
River Riddle [Wed, 5 Jun 2019 21:49:52 +0000 (14:49 -0700)]
NFC: Cleanup the definitions of OpAsmParser and CustomOpAsmParser by adding comments, grouping similar functionality, and adding header blocks.

PiperOrigin-RevId: 251723883

5 years agoAdd utility 'create' methods to OperationFolder that will create an operation with...
River Riddle [Wed, 5 Jun 2019 21:15:05 +0000 (14:15 -0700)]
Add utility 'create' methods to OperationFolder that will create an operation with a given OpBuilder and automatically try to fold it, similarly to OpBuilder::createOrFold. The difference here is that these methods enable folding to constants in addition to existing values. This functionality is then used to replace linalg::FunctionConstants.

PiperOrigin-RevId: 251716247

5 years agoNFC: Rename FunctionParser::builder to opBuilder. This allows for removing the clang...
River Riddle [Wed, 5 Jun 2019 20:59:28 +0000 (13:59 -0700)]
NFC: Rename FunctionParser::builder to opBuilder. This allows for removing the clang specific pragmas for ignoring field shadowing warnings.

PiperOrigin-RevId: 251712823

5 years agoFix a warning for missing parentheses around '||' inside of an assert.
River Riddle [Wed, 5 Jun 2019 20:56:01 +0000 (13:56 -0700)]
Fix a warning for missing parentheses around '||' inside of an assert.

PiperOrigin-RevId: 251712106

5 years agoNFC: Cleanup FunctionParser by removing dead methods, adding header blocks, and group...
River Riddle [Wed, 5 Jun 2019 18:57:37 +0000 (11:57 -0700)]
NFC: Cleanup FunctionParser by removing dead methods, adding header blocks, and grouping related pieces of functionality.

PiperOrigin-RevId: 251688578

5 years agoFix a typo in error message.
MLIR Team [Wed, 5 Jun 2019 18:24:19 +0000 (11:24 -0700)]
Fix a typo in error message.

PiperOrigin-RevId: 251681475

5 years agoAdd new 'createOrFold' methods to FuncBuilder to immediately try to fold an operation...
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

5 years agoAlways remap results when replacing an operation. This prevents a crash when lowering...
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

5 years agoWhen cleaning up after a failed legalization pattern, make sure to remove any newly...
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

5 years agoAdd a few utility overloads for OpAsmParser methods:
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

5 years agoODG: Always deference operand/result when using named arg/result.
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

5 years agoNFC: Rename FuncBuilder to OpBuilder and refactor to take a top level region instead...
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

5 years agoAdd support to AffineApplyOp::fold for folding dim and symbol expression results.
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

5 years ago[spirv] Basic validity of SPV_ModuleOp
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

5 years agoAdd a utility function to Op that allows for checking if an operation has a specific...
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

5 years agoNFC: Rename FoldHelper to OperationFolder and split a large function in two.
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

5 years agoAdding additional dialect parsing utilities, conversion wrappers, and traversal helpers.
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

5 years agoMake it explicit that the IR printing instrumentation should not be used when multi...
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

5 years agoAdd support to FuncOp for managing argument attributes. The syntax for argument attri...
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

5 years ago[ODG] Add iterators for results in Operator
Lei Zhang [Tue, 4 Jun 2019 12:03:42 +0000 (05:03 -0700)]
[ODG] Add iterators for results in Operator

PiperOrigin-RevId: 251417085

5 years agoAlign NVVM operation names with names from GPU dialect.
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

5 years agoAdd a utility function to OperationName for extracting the dialect name.
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

5 years ago[ODS] Add support for TypeArrayAttr
Lei Zhang [Mon, 3 Jun 2019 21:52:56 +0000 (14:52 -0700)]
[ODS] Add support for TypeArrayAttr

PiperOrigin-RevId: 251314203

5 years agoReplace comments referring to "vector or tensor" with "shaped" where appropriate
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

5 years agoMake MemRefOf tablegen type subclass ShapedContainerType
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

5 years agoRefactor the dialect conversion framework to support multi-level conversions. Multi...
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

5 years agoSupport type casting Type to itself
Lei Zhang [Mon, 3 Jun 2019 19:38:22 +0000 (12:38 -0700)]
Support type casting Type to itself

PiperOrigin-RevId: 251287045

5 years agoStart defining a new operation 'FuncOp' that replicates all of the functionality...
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

5 years agoAdd Windows build instructions.
Jacques Pienaar [Mon, 3 Jun 2019 18:09:02 +0000 (11:09 -0700)]
Add Windows build instructions.

PiperOrigin-RevId: 251269521

5 years agoSDBM: fix the order of variables in the stripe-induced inequalities
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

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