platform/upstream/llvm.git
5 years agoInitialize std::atomic directly.
Jacques Pienaar [Wed, 27 Mar 2019 19:36:57 +0000 (12:36 -0700)]
Initialize std::atomic directly.

Avoids error in OSS build:
error: copying variable of type 'std::atomic<unsigned int>' invokes deleted constructor
PiperOrigin-RevId: 240618765

5 years agoAdd a method to swap the type of a function in-place
Mehdi Amini [Wed, 27 Mar 2019 19:20:51 +0000 (12:20 -0700)]
Add a method to swap the type of a function in-place

This is motivated by the need to translate function across dialect which
requires morphing their type, as well as the Toy tutorial part on interprocedural
shape inference.

The alternative is cloning the function, but it is heavy and it seems like an
arbitrary restriction to forbid morphing the function type.

PiperOrigin-RevId: 240615755

5 years agoUse dereference instead of implicit conversion for IndexedValue to Value*.
Jacques Pienaar [Wed, 27 Mar 2019 18:36:36 +0000 (11:36 -0700)]
Use dereference instead of implicit conversion for IndexedValue to Value*.

Avoids ambiguous constructor error on some compilers.

PiperOrigin-RevId: 240606838

5 years agoAdd missing numeric header for std::accumulate.
Jacques Pienaar [Wed, 27 Mar 2019 17:38:23 +0000 (10:38 -0700)]
Add missing numeric header for std::accumulate.

PiperOrigin-RevId: 240593135

5 years agoLLVM IR Conversion: support zero-dimensional memrefs
Alex Zinenko [Wed, 27 Mar 2019 16:39:31 +0000 (09:39 -0700)]
LLVM IR Conversion: support zero-dimensional memrefs

The spec allows zero-dimensional memrefs to exist and treats them essentially
as single-element buffers.  Unlike single-dimensional memrefs of static shape
<1xTy>, zero-dimensional memrefs do not require indices to access the only
element they store.  Add support of zero-dimensional memrefs to the LLVM IR
conversion.  In particular, such memrefs are converted into bare pointers, and
accesses to them are converted to bare loads and stores, without the overhead
of `getelementptr %buffer, 0`.

PiperOrigin-RevId: 240579456

5 years agoLLVM IR Conversion: keep LLVM dialect types as is during conversion
Alex Zinenko [Wed, 27 Mar 2019 16:16:27 +0000 (09:16 -0700)]
LLVM IR Conversion: keep LLVM dialect types as is during conversion

When converting to the LLVM IR Dialect, it is possible for the input IR to
contain LLVM IR Dialect operation and/or types, for example, some functions may
have been coverted to the LLVM IR Dialect already, or may have been created
using this dialect directly.  Make sure that type conversion keeps LLVM IR
Dialect types unmodified and does not error out.  Operations are already kept
as is.

PiperOrigin-RevId: 240574972

5 years agoReplace usages of Instruction with Operation in the /Analysis directory.
River Riddle [Wed, 27 Mar 2019 15:55:17 +0000 (08:55 -0700)]
Replace usages of Instruction with Operation in the /Analysis directory.

PiperOrigin-RevId: 240569775

5 years agoPort api-test::tile_2d to the edsc::Builder API
Nicolas Vasilache [Wed, 27 Mar 2019 13:45:18 +0000 (06:45 -0700)]
Port api-test::tile_2d to the edsc::Builder API

The AST-based EDSCs implementation will be retired soon, this test was missing from the builders API.

PiperOrigin-RevId: 240547453

5 years agoIntroduce affine terminator
Alex Zinenko [Wed, 27 Mar 2019 12:11:58 +0000 (05:11 -0700)]
Introduce affine terminator

Due to legacy reasons (ML/CFG function separation), regions in affine control
flow operations require contained blocks not to have terminators.  This is
inconsistent with the notion of the block and may complicate code motion
between regions of affine control operations and other regions.

Introduce `affine.terminator`, a special terminator operation that must be used
to terminate blocks inside affine operations and transfers the control back to
he region enclosing the affine operation.  For brevity and readability reasons,
allow `affine.for` and `affine.if` to omit the `affine.terminator` in their
regions when using custom printing and parsing format.  The custom parser
injects the `affine.terminator` if it is missing so as to always have it
present in constructed operations.

Update transformations to account for the presence of terminator.  In
particular, most code motion transformation between loops should leave the
terminator in place, and code motion between loops and non-affine blocks should
drop the terminator.

PiperOrigin-RevId: 240536998

5 years agoAdd experimental support for multi-threading the pass manager. This adds support...
River Riddle [Wed, 27 Mar 2019 04:15:54 +0000 (21:15 -0700)]
Add experimental support for multi-threading the pass manager. This adds support for running function pipelines on functions across multiple threads, and is guarded by an off-by-default flag 'experimental-mt-pm'. There are still quite a few things that need to be done before multi-threading is ready for general use(e.g. pass-timing), but this allows for those things to be tested in a multi-threaded environment.

PiperOrigin-RevId: 240489002

5 years agoInclude numeric header for std::accumulate.
Jacques Pienaar [Wed, 27 Mar 2019 00:28:18 +0000 (17:28 -0700)]
Include numeric header for std::accumulate.

PiperOrigin-RevId: 240462910

5 years agoReplace usages of Instruction with Operation in the /IR directory.
River Riddle [Wed, 27 Mar 2019 00:05:09 +0000 (17:05 -0700)]
Replace usages of Instruction with Operation in the /IR directory.

This is step 2/N to renaming Instruction to Operation.

PiperOrigin-RevId: 240459216

5 years agoUpdate header notices.
Jacques Pienaar [Tue, 26 Mar 2019 23:58:43 +0000 (16:58 -0700)]
Update header notices.

PiperOrigin-RevId: 240457737

5 years agoAdd a trait to set the result type by attribute
Feng Liu [Tue, 26 Mar 2019 22:31:15 +0000 (15:31 -0700)]
Add a trait to set the result type by attribute

Before this CL, the result type of the pattern match results need to be as same
as the first operand type, operand broadcast type or a generic tensor type.
This CL adds a new trait to set the result type by attribute. For example, the
TFL_ConstOp can use this to set the output type to its value attribute.

PiperOrigin-RevId: 240441249

5 years agoRename the Instruction class to Operation. This just renames the class, usages of...
River Riddle [Tue, 26 Mar 2019 21:45:38 +0000 (14:45 -0700)]
Rename the Instruction class to Operation. This just renames the class, usages of Instruction will still refer to a typedef in the interim.

This is step 1/N to renaming Instruction to Operation.

PiperOrigin-RevId: 240431520

5 years agoAdd a getContext() utility to the Module/FunctionPass class (NFC)
Mehdi Amini [Tue, 26 Mar 2019 19:49:08 +0000 (12:49 -0700)]
Add a getContext() utility to the Module/FunctionPass class (NFC)

This is just a convenience for reducing boilerplate when writing a pass.

PiperOrigin-RevId: 240407564

5 years agoAdd a utility Instruction::getDialect method to return the dialect an operation is...
River Riddle [Tue, 26 Mar 2019 19:22:52 +0000 (12:22 -0700)]
Add a utility Instruction::getDialect method to return the dialect an operation is associated with, or nullptr if the associated dialect has not been registered.

PiperOrigin-RevId: 240402300

5 years agoUpdate the canonicalization patterns for AffineApply and AffineForOp to use matchAndR...
River Riddle [Tue, 26 Mar 2019 19:02:04 +0000 (12:02 -0700)]
Update the canonicalization patterns for AffineApply and AffineForOp to use matchAndRewrite.

PiperOrigin-RevId: 240398220

5 years agoFix createAffineComputationSlice comments
Nicolas Vasilache [Tue, 26 Mar 2019 18:03:16 +0000 (11:03 -0700)]
Fix createAffineComputationSlice comments

PiperOrigin-RevId: 240384796

5 years agoTablegen changes to add support for tuples.
Rob Suderman [Tue, 26 Mar 2019 17:48:24 +0000 (10:48 -0700)]
Tablegen changes to add support for tuples.

PiperOrigin-RevId: 240380512

5 years agoAdd an IndexedValue::operator Value*
Nicolas Vasilache [Tue, 26 Mar 2019 17:06:49 +0000 (10:06 -0700)]
Add an IndexedValue::operator Value*

This avoids the need to explicitly convert to a ValueHandle when using an Indexed where a Value* is expected.

PiperOrigin-RevId: 240371014

5 years agoAllow creating standalone Regions
Alex Zinenko [Tue, 26 Mar 2019 16:55:06 +0000 (09:55 -0700)]
Allow creating standalone Regions

Currently, regions can only be constructed by passing in a `Function` or an
`Instruction` pointer referencing the parent object, unlike `Function`s or
`Instruction`s themselves that can be created without a parent.  It leads to a
rather complex flow in operation construction where one has to create the
operation first before being able to work with its regions.  It may be
necessary to work with the regions before the operation is created.  In
particular, in `build` and `parse` functions that are executed _before_ the
operation is created in cases where boilerplate region manipulation is required
(for example, inserting the hypothetical default terminator in affine regions).
Allow creating standalone regions.  Such regions are meant to own a list of
blocks and transfer them to other regions on demand.

Each instruction stores a fixed number of regions as trailing objects and has
ownership of them.  This decreases the size of the Instruction object for the
common case of instructions without regions.  Keep this behavior intact.  To
allow some flexibility in construction, make OperationState store an owning
vector of regions.  When the Builder creates an Instruction from
OperationState, the bodies of the regions are transferred into the
instruction-owned regions to minimize copying.  Thus, it becomes possible to
fill standalone regions with blocks and move them to an operation when it is
constructed, or move blocks from a region to an operation region, e.g., for
inlining.

PiperOrigin-RevId: 240368183

5 years agoMake FunctionPass::getFunction() return a reference to the function, instead of
Chris Lattner [Tue, 26 Mar 2019 01:02:49 +0000 (18:02 -0700)]
Make FunctionPass::getFunction() return a reference to the function, instead of
a pointer.  This makes it consistent with all the other methods in
FunctionPass, as well as with ModulePass::getModule().  NFC.

PiperOrigin-RevId: 240257910

5 years agoReplace remaining usages of "Op::operator->" with "." and remove it.
River Riddle [Mon, 25 Mar 2019 20:49:45 +0000 (13:49 -0700)]
Replace remaining usages of "Op::operator->" with "." and remove it.

PiperOrigin-RevId: 240210336

5 years agoReplace usages of "Op::operator->" with ".".
River Riddle [Mon, 25 Mar 2019 20:02:06 +0000 (13:02 -0700)]
Replace usages of "Op::operator->" with ".".

This is step 2/N of removing the temporary operator-> method as part of the de-const transition.

PiperOrigin-RevId: 240200792

5 years agoQualify string in OpDefinitionsGen. NFC.
Jacques Pienaar [Mon, 25 Mar 2019 18:54:37 +0000 (11:54 -0700)]
Qualify string in OpDefinitionsGen. NFC.

PiperOrigin-RevId: 240188138

5 years agoRefactor the Pattern framework to allow for combined match/rewrite patterns. This...
River Riddle [Mon, 25 Mar 2019 18:53:03 +0000 (11:53 -0700)]
Refactor the Pattern framework to allow for combined match/rewrite patterns. This is done by adding a new 'matchAndRewrite' function to RewritePattern that performs the match and rewrite in one step. The default behavior simply calls into the existing 'match' and 'rewrite' functions. The 'PatternMatcher' class has now been specialized for RewritePatterns and has been rewritten to make use of the new matchAndRewrite functionality.

This combined match/rewrite functionality allows simplifying the majority of existing RewritePatterns, as they do not benefit from separate match and rewrite functions.

Some of the existing canonicalization patterns in StandardOps have been modified to take advantage of this functionality.

PiperOrigin-RevId: 240187856

5 years agoReplace usages of "operator->" with "." for the AffineOps.
River Riddle [Mon, 25 Mar 2019 18:13:31 +0000 (11:13 -0700)]
Replace usages of "operator->" with "." for the AffineOps.

Note: The "operator->" method is a temporary helper for the de-const transition and is gradually being phased out.
PiperOrigin-RevId: 240179439

5 years agoNFC: Rename the 'for' operation in the AffineOps dialect to 'affine.for' and set...
River Riddle [Mon, 25 Mar 2019 17:14:34 +0000 (10:14 -0700)]
NFC: Rename the 'for' operation in the AffineOps dialect to 'affine.for' and set the namespace of the AffineOps dialect to 'affine'.

PiperOrigin-RevId: 240165792

5 years ago[TableGen] Consolidate constraint related concepts
Lei Zhang [Mon, 25 Mar 2019 13:09:26 +0000 (06:09 -0700)]
[TableGen] Consolidate constraint related concepts

Previously we have multiple mechanisms to specify op definition and match constraints:
TypeConstraint, AttributeConstraint, Type, Attr, mAttr, mAttrAnyOf, mPat. These variants
are not added because there are so many distinct cases we need to model; essentially,
they are all carrying a predicate. It's just an artifact of implementation.

It's quite confusing for users to grasp these variants and choose among them. Instead,
as the OpBase TableGen file, we need to strike to provide an unified mechanism. Each
dialect has the flexibility to define its own aliases if wanted.

This CL removes mAttr, mAttrAnyOf, mPat. A new base class, Constraint, is added. Now
TypeConstraint and AttrConstraint derive from Constraint. Type and Attr further derive
from TypeConstraint and AttrConstraint, respectively.

Comments are revised and examples are added to make it clear how to use constraints.

PiperOrigin-RevId: 240125076

5 years agoUsing getContext() instead of getInstruction()->getContext() on Operation (NFC)
Mehdi Amini [Mon, 25 Mar 2019 07:29:00 +0000 (00:29 -0700)]
Using getContext() instead of getInstruction()->getContext() on Operation (NFC)

PiperOrigin-RevId: 240088209

5 years agoUpdate some of the derived type classes to use getImpl instead of a static_cast.
River Riddle [Mon, 25 Mar 2019 06:51:05 +0000 (23:51 -0700)]
Update some of the derived type classes to use getImpl instead of a static_cast.

PiperOrigin-RevId: 240084937

5 years agoVarious small cleanups to the code, mostly removing const_cast's.
Chris Lattner [Mon, 25 Mar 2019 06:26:39 +0000 (23:26 -0700)]
Various small cleanups to the code, mostly removing const_cast's.

PiperOrigin-RevId: 240083489

5 years agoAdd a `getImpl()` utility method to the `TypeBase` class as a convenience for derived...
Mehdi Amini [Mon, 25 Mar 2019 05:09:41 +0000 (22:09 -0700)]
Add a `getImpl()` utility method to the `TypeBase` class as a convenience for derived class to access their associated TypeStorage (NFC)

PiperOrigin-RevId: 240077874

5 years agoChange TypeStorage from a struct into a class (NFC)
Mehdi Amini [Mon, 25 Mar 2019 04:52:49 +0000 (21:52 -0700)]
Change TypeStorage from a struct into a class (NFC)

By coding standard, we try to keep struct as pure storage without method or other logic attached to it.

PiperOrigin-RevId: 240076419

5 years agoMove TypeStorage out of the detail namespace
Mehdi Amini [Mon, 25 Mar 2019 04:41:36 +0000 (21:41 -0700)]
Move TypeStorage out of the detail namespace

Dialect implementer are expected to inherit from this class when implementing their types. It does not seems right when using MLIR "from the outside" to use directly something from `mlir::detail::`.

PiperOrigin-RevId: 240075769

5 years agoNFC: Rename the 'if' operation in the AffineOps dialect to 'affine.if'.
River Riddle [Mon, 25 Mar 2019 03:35:07 +0000 (20:35 -0700)]
NFC: Rename the 'if' operation in the AffineOps dialect to 'affine.if'.

PiperOrigin-RevId: 240071154

5 years agoRemove `alignas(8) from TypeStorage class
Mehdi Amini [Mon, 25 Mar 2019 03:34:16 +0000 (20:34 -0700)]
Remove `alignas(8) from TypeStorage class

This is here from history at a time where it was bit-packed and storage was dependent on this.

PiperOrigin-RevId: 240071093

5 years agoRemove OpPointer, cleaning up a ton of code. This also moves Ops to using
Chris Lattner [Mon, 25 Mar 2019 02:53:05 +0000 (19:53 -0700)]
Remove OpPointer, cleaning up a ton of code.  This also moves Ops to using
inherited constructors, which is cleaner and means you can now use DimOp()
to get a null op, instead of having to use Instruction::getNull<DimOp>().

This removes another 200 lines of code.

PiperOrigin-RevId: 240068113

5 years agoFix missing parenthesis around negation.
Jacques Pienaar [Mon, 25 Mar 2019 02:35:20 +0000 (19:35 -0700)]
Fix missing parenthesis around negation.

This should probably be changed to instead use the negated form (e.g., get predicate + negate it + get resulting template), but this fixes it locally.

PiperOrigin-RevId: 240067116

5 years agoAdd a routine to allow registering a dialect without relying on global constructors.
Mehdi Amini [Mon, 25 Mar 2019 01:48:21 +0000 (18:48 -0700)]
Add a routine to allow registering a dialect without relying on global constructors.

Using global constructors should not be mandatory when possible, clients should be able to register a dialect explicitly when they want.

PiperOrigin-RevId: 240064244

5 years agoPush a bunch of 'consts' out of the *Op structure, in prep for removing
Chris Lattner [Sun, 24 Mar 2019 20:02:43 +0000 (13:02 -0700)]
Push a bunch of 'consts' out of the *Op structure, in prep for removing
OpPointer.

PiperOrigin-RevId: 240044712

5 years agoCleanup ValueHandleArray
Nicolas Vasilache [Sun, 24 Mar 2019 17:45:22 +0000 (10:45 -0700)]
Cleanup ValueHandleArray

We just need a way to unpack ArrayRef<ValueHandle> to ArrayRef<Value*>.
No need to expose this to the user.

This reduces the cognitive overhead for the tutorial.

PiperOrigin-RevId: 240037425

5 years agoDeconst-ify MLIRContext, and detemplatize some stuff now that const is gone.
Chris Lattner [Sat, 23 Mar 2019 23:42:01 +0000 (16:42 -0700)]
Deconst-ify MLIRContext, and detemplatize some stuff now that const is gone.

PiperOrigin-RevId: 239976764

5 years agoAdd a convenience getContext() method in OpState to reduce boilerplate on clients.
Mehdi Amini [Sat, 23 Mar 2019 22:19:51 +0000 (15:19 -0700)]
Add a convenience getContext() method in OpState to reduce boilerplate on clients.

PiperOrigin-RevId: 239972907

5 years agoRemove const from Value, Instruction, Argument, and the various methods on the
Chris Lattner [Sat, 23 Mar 2019 22:09:06 +0000 (15:09 -0700)]
Remove const from Value, Instruction, Argument, and the various methods on the
*Op classes.  This is a net reduction by almost 400LOC.

PiperOrigin-RevId: 239972443

5 years agoReturn operand_range instead for generated variadic operands accessor.
Jacques Pienaar [Sat, 23 Mar 2019 17:36:55 +0000 (10:36 -0700)]
Return operand_range instead for generated variadic operands accessor.

PiperOrigin-RevId: 239959381

5 years agoClarify the comment on valid data during DenseElementsAttr construction.
River Riddle [Sat, 23 Mar 2019 17:12:31 +0000 (10:12 -0700)]
Clarify the comment on valid data during DenseElementsAttr construction.

PiperOrigin-RevId: 239958211

5 years agoNow that ConstOpPointer is gone, we can change the various methods generated by
Chris Lattner [Sat, 23 Mar 2019 16:03:07 +0000 (09:03 -0700)]
Now that ConstOpPointer is gone, we can change the various methods generated by
tblgen be non-const.  This requires introducing some const_cast's at the
moment, but those (and lots more stuff) will disappear in subsequent patches.

This significantly simplifies those patches because the various tblgen op emitters
get adjusted.

PiperOrigin-RevId: 239954566

5 years agoVerify first body is not empty before testing last character.
Jacques Pienaar [Sat, 23 Mar 2019 12:05:20 +0000 (05:05 -0700)]
Verify first body is not empty before testing last character.

Avoids sigabrt where body is empty.

PiperOrigin-RevId: 239942200

5 years agoCleanup the construction of attributes and fix a opt-mode bug in DenseElementsAttr...
River Riddle [Sat, 23 Mar 2019 07:40:25 +0000 (00:40 -0700)]
Cleanup the construction of attributes and fix a opt-mode bug in DenseElementsAttr when allocating an empty array buffer.

PiperOrigin-RevId: 239926824

5 years agoAt missing mlir:: namespace qualifier in front of function definition
Mehdi Amini [Sat, 23 Mar 2019 05:26:01 +0000 (22:26 -0700)]
At missing mlir:: namespace qualifier in front of function definition

This was defining a function in the global namespace instead of the mlir one.

PiperOrigin-RevId: 239918509

5 years agoAdd a parserSourceFile function that takes a file path directly
Mehdi Amini [Sat, 23 Mar 2019 05:17:10 +0000 (22:17 -0700)]
Add a parserSourceFile function that takes a file path directly

This avoids adding boilerplate around the SourceMgr on the client.

PiperOrigin-RevId: 239918122

5 years agoAdd tablegen aliases for OpTraits ResultsAreFloatLike and SameOperandsAndResultShape
Geoffrey Martin-Noble [Sat, 23 Mar 2019 01:03:58 +0000 (18:03 -0700)]
Add tablegen aliases for OpTraits ResultsAreFloatLike and SameOperandsAndResultShape

Startblock:
  cl/239891224 is submitted
PiperOrigin-RevId: 239899356

5 years agoRemove "<label>" from the llvm basic block CHECK names.
River Riddle [Sat, 23 Mar 2019 00:54:26 +0000 (17:54 -0700)]
Remove "<label>" from the llvm basic block CHECK names.

PiperOrigin-RevId: 239898185

5 years agoStart elemental type constraint specification modelling.
Jacques Pienaar [Fri, 22 Mar 2019 22:26:05 +0000 (15:26 -0700)]
Start elemental type constraint specification modelling.

Enable users specifying operand type constraint combinations (e.g., considering multiple operands). Some of these will be refactored (particularly the OpBase change and that should also not be needed to be done by most users), but the focus is more on user side (shown in test). The generated code for this does not take any known facts into account or perform any simplification.

Start with 2 primities to specify 1) whether an operand has a specific element type, and 2) whether an operand's element type matches another operands element type.

PiperOrigin-RevId: 239875712

5 years agoDefine the base class for attributes containing types
Feng Liu [Fri, 22 Mar 2019 18:22:20 +0000 (11:22 -0700)]
Define the base class for attributes containing types

This attribute has checks for verifying it is an mlir::TypeAttr and the
subclass can specify the mlir::Type as the value.

PiperOrigin-RevId: 239830412

5 years agoRename edsc::EDSCxxxBuilder to edsc::xxxBuilder - NFC
Nicolas Vasilache [Fri, 22 Mar 2019 16:10:01 +0000 (09:10 -0700)]
Rename edsc::EDSCxxxBuilder to edsc::xxxBuilder - NFC

PiperOrigin-RevId: 239805692

5 years agoSupport composition of symbols in AffineApplyOp
Nicolas Vasilache [Fri, 22 Mar 2019 14:31:00 +0000 (07:31 -0700)]
Support composition of symbols in AffineApplyOp

This CL revisits the composition of AffineApplyOp for the special case where a symbol
itself comes from an AffineApplyOp.
This is achieved by rewriting such symbols into dims to allow composition to occur mathematically.
The implementation is also refactored to improve readability.

Rationale for locally rewriting symbols as dims:
================================================
The mathematical composition of AffineMap must always concatenate symbols
because it does not have enough information to do otherwise. For example,
composing `(d0)[s0] -> (d0 + s0)` with itself must produce
`(d0)[s0, s1] -> (d0 + s0 + s1)`.

The result is only equivalent to `(d0)[s0] -> (d0 + 2 * s0)` when
applied to the same mlir::Value* for both s0 and s1.
As a consequence mathematical composition of AffineMap always concatenates
symbols.

When AffineMaps are used in AffineApplyOp however, they may specify
composition via symbols, which is ambiguous mathematically. This corner case
is handled by locally rewriting such symbols that come from AffineApplyOp
into dims and composing through dims.

PiperOrigin-RevId: 239791597

5 years agoRemove declaration and unused reference to non-existent type `TensorTypeStorage`...
Mehdi Amini [Fri, 22 Mar 2019 06:18:11 +0000 (23:18 -0700)]
Remove declaration and unused reference to non-existent type `TensorTypeStorage` (NFC)

PiperOrigin-RevId: 239743070

5 years agoRemove const from mlir::Block.
Chris Lattner [Fri, 22 Mar 2019 00:53:00 +0000 (17:53 -0700)]
Remove const from mlir::Block.

This also eliminates some incorrect reinterpret_cast logic working around it, and numerous const-incorrect issues (like block argument iteration).

PiperOrigin-RevId: 239712029

5 years agoRemove const support from mlir::Region
Chris Lattner [Thu, 21 Mar 2019 18:57:14 +0000 (11:57 -0700)]
Remove const support from mlir::Region

PiperOrigin-RevId: 239642194

5 years agoContinue pushing const out of the core IR types - in this case, remove const
Chris Lattner [Thu, 21 Mar 2019 18:39:22 +0000 (11:39 -0700)]
Continue pushing const out of the core IR types - in this case, remove const
from Function.

PiperOrigin-RevId: 239638635

5 years agoAdd support for building a DenseIntElementsAttr with ArrayRef<int64_t> values.
River Riddle [Thu, 21 Mar 2019 17:03:40 +0000 (10:03 -0700)]
Add support for building a DenseIntElementsAttr with ArrayRef<int64_t> values.

PiperOrigin-RevId: 239616595

5 years agoBetter document TemplatedIndexedValue
Nicolas Vasilache [Thu, 21 Mar 2019 16:59:57 +0000 (09:59 -0700)]
Better document TemplatedIndexedValue

PiperOrigin-RevId: 239615534

5 years agoMake edsc::IndexedValue templated - NFC
Nicolas Vasilache [Thu, 21 Mar 2019 15:44:20 +0000 (08:44 -0700)]
Make edsc::IndexedValue templated - NFC

This allows the indexing sugar to just work naturally with other type of load and store ops than the affine ones we currently have.
This is needed for the EuroLLVM tutorial.

PiperOrigin-RevId: 239602257

5 years agoAdd 10 "private" kind ranges for MLIR type kind.
Mehdi Amini [Thu, 21 Mar 2019 15:42:06 +0000 (08:42 -0700)]
Add 10 "private" kind ranges for MLIR type kind.

This is useful when developing one or multiple dialects in a private context without having to register them with MLIR Core.

PiperOrigin-RevId: 239601844

5 years agoReserve type range for the Linalg dialect
Nicolas Vasilache [Thu, 21 Mar 2019 15:25:51 +0000 (08:25 -0700)]
Reserve type range for the Linalg dialect

PiperOrigin-RevId: 239599147

5 years agoFix class description for Attributes: the instance of the class aren't uniqued, the...
Mehdi Amini [Thu, 21 Mar 2019 15:21:21 +0000 (08:21 -0700)]
Fix class description for Attributes: the instance of the class aren't uniqued, the class has reference semantics.

PiperOrigin-RevId: 239598522

5 years agoAdd intrinsics for constants
Nicolas Vasilache [Thu, 21 Mar 2019 15:07:15 +0000 (08:07 -0700)]
Add intrinsics for constants

PiperOrigin-RevId: 239596595

5 years agoImprove comment for `augmentMapAndBounds`
Nicolas Vasilache [Thu, 21 Mar 2019 14:32:51 +0000 (07:32 -0700)]
Improve comment for `augmentMapAndBounds`

Followup from a previous CL.

PiperOrigin-RevId: 239591775

5 years agoAdd comment describing what IREE (IR Execution Engine) stands for in the dialect...
Mehdi Amini [Thu, 21 Mar 2019 05:34:49 +0000 (22:34 -0700)]
Add comment describing what IREE (IR Execution Engine) stands for in the dialect registration.

PiperOrigin-RevId: 239539263

5 years agoContinue pushing const out of the IR types - removing the notion of a 'const
Chris Lattner [Thu, 21 Mar 2019 04:14:59 +0000 (21:14 -0700)]
Continue pushing const out of the IR types - removing the notion of a 'const
Module'.  NFC.

PiperOrigin-RevId: 239532885

5 years agoAdd contributing file.
Jacques Pienaar [Thu, 21 Mar 2019 03:28:58 +0000 (20:28 -0700)]
Add contributing file.

Initially no external contributions will be accepted (until post dev meeting at
least).

PiperOrigin-RevId: 239528594

5 years agoMove to new `const` model, part 1: remove ConstOpPointer.
Chris Lattner [Thu, 21 Mar 2019 00:48:43 +0000 (17:48 -0700)]
Move to new `const` model, part 1: remove ConstOpPointer.

This eliminate ConstOpPointer (but keeps OpPointer for now) by making OpPointer
implicitly launder const in a const incorrect way.  It will eventually go away
entirely, this is a progressive step towards the new const model.

PiperOrigin-RevId: 239512640

5 years agoAdd a nice quote from Bjarke to summarize the const situation.
Chris Lattner [Thu, 21 Mar 2019 00:32:52 +0000 (17:32 -0700)]
Add a nice quote from Bjarke to summarize the const situation.

PiperOrigin-RevId: 239510578

5 years ago[TableGen] Generate op declaration and definition into different files
Lei Zhang [Thu, 21 Mar 2019 00:25:34 +0000 (17:25 -0700)]
[TableGen] Generate op declaration and definition into different files

Previously we emit both op declaration and definition into one file and include it
in *Ops.h. That pulls in lots of implementation details in the header file and we
cannot hide symbols local to implementation. This CL splits them to provide a cleaner
interface.

The way how we define custom builders in TableGen is changed accordingly because now
we need to distinguish signatures and implementation logic. Some custom builders with
complicated logic now can be moved to be implemented in .cpp entirely.

PiperOrigin-RevId: 239509594

5 years agoAdd a "Usage of Const in MLIR" doc, explaining the rationale for the design
Chris Lattner [Wed, 20 Mar 2019 20:32:39 +0000 (13:32 -0700)]
Add a "Usage of Const in MLIR" doc, explaining the rationale for the design
point we're moving the compiler to.

PiperOrigin-RevId: 239462779

5 years agoProperly propagate induction variable in tiling
Nicolas Vasilache [Wed, 20 Mar 2019 17:23:04 +0000 (10:23 -0700)]
Properly propagate induction variable in tiling

This CL fixes an issue where cloned loop induction variables were not properly
propagated and beefs up the corresponding test.

PiperOrigin-RevId: 239422961

5 years agoChange getBroadcastedShape() to return result shape via parameter
Lei Zhang [Wed, 20 Mar 2019 16:01:58 +0000 (09:01 -0700)]
Change getBroadcastedShape() to return result shape via parameter

This is a more efficient way than returning SmallVector directly.

PiperOrigin-RevId: 239407024

5 years agoCleanup for changes failing with std=c++11
Jacques Pienaar [Tue, 19 Mar 2019 19:05:11 +0000 (12:05 -0700)]
Cleanup for changes failing with std=c++11

The static constexpr were failing with undefined reference due to lacking definition at namespace scope.

PiperOrigin-RevId: 239241157

5 years agoAdd support for a standard TupleType. Though this is a standard type, it merely provi...
River Riddle [Tue, 19 Mar 2019 17:59:02 +0000 (10:59 -0700)]
Add support for a standard TupleType. Though this is a standard type, it merely provides a common mechanism for representing tuples in MLIR. It is up to dialect authors to provides operations for manipulating them, e.g. extract_tuple_element.

TupleType has the following form:
   tuple-type ::= `tuple` `<` (type (`,` type)*)? `>`

Example:

// Empty tuple.
tuple<>

// Single element.
tuple<i32>

// Multi element.
tuple<i32, tuple<f32>, i16>

PiperOrigin-RevId: 239226021

5 years agoRemove some statements that required >C++11, add includes and qualify names. NFC.
Jacques Pienaar [Tue, 19 Mar 2019 15:45:06 +0000 (08:45 -0700)]
Remove some statements that required >C++11, add includes and qualify names. NFC.

PiperOrigin-RevId: 239197784

5 years agoAvoiding allocations during argument attribute conversion.
Dimitrios Vytiniotis [Tue, 19 Mar 2019 08:19:01 +0000 (01:19 -0700)]
Avoiding allocations during argument attribute conversion.

PiperOrigin-RevId: 239144675

5 years agoRemove index free function
Jacques Pienaar [Tue, 19 Mar 2019 02:26:04 +0000 (19:26 -0700)]
Remove index free function

Avoids including function in C++ side that resulted in OSS C++ errors:

include/mlir-c/Core.h:228:16: error: functions that differ only in their
return type cannot be overloaded
edsc_indexed_t index(edsc_indexed_t indexed, edsc_expr_list_t indices);
~~~~~~~~~~~~~~ ^
/usr/include/string.h:484:14: note: previous declaration is here
extern char *index (const char *__s, int __c)

And as these are going away soon, just removing the function requires the least changes.

PiperOrigin-RevId: 239110470

5 years agoAdd support for parsing true/false inside of a splat tensor literal.
River Riddle [Mon, 18 Mar 2019 20:42:55 +0000 (13:42 -0700)]
Add support for parsing true/false inside of a splat tensor literal.

PiperOrigin-RevId: 239052061

5 years agoGive PassInstrumentor a SmartMutex to lock access to the held instrumentations.
River Riddle [Mon, 18 Mar 2019 18:56:18 +0000 (11:56 -0700)]
Give PassInstrumentor a SmartMutex to lock access to the held instrumentations.

PiperOrigin-RevId: 239031524

5 years agoChange trait verification to support older clang & gcc.
Jacques Pienaar [Mon, 18 Mar 2019 17:21:57 +0000 (10:21 -0700)]
Change trait verification to support older clang & gcc.

This was resulting in an error:
 explicit specialization of 'BaseProperties' in class scope
pre clang-7.0 (C++ DR 275).

PiperOrigin-RevId: 239010696

5 years agoCleanups for OSS build.
Jacques Pienaar [Mon, 18 Mar 2019 16:26:20 +0000 (09:26 -0700)]
Cleanups for OSS build.

PiperOrigin-RevId: 238999629

5 years agoCleanups Vectorize and SliceAnalysis - NFC
Nicolas Vasilache [Mon, 18 Mar 2019 15:07:19 +0000 (08:07 -0700)]
Cleanups Vectorize and SliceAnalysis - NFC

This CL cleans up and refactors super-vectorization and slice analysis.

PiperOrigin-RevId: 238986866

5 years agoChange Value to NamedTypeConstraint and use TypeConstraint.
Jacques Pienaar [Mon, 18 Mar 2019 14:54:20 +0000 (07:54 -0700)]
Change Value to NamedTypeConstraint and use TypeConstraint.

Previously Value was a pair of name & Type, but for operands/result a TypeConstraint rather then a Type is specified. Update C++ side to match declarative side.

PiperOrigin-RevId: 238984799

5 years agoPort Tablegen'd reference implementation of Add to declarative builders.
Nicolas Vasilache [Mon, 18 Mar 2019 13:52:23 +0000 (06:52 -0700)]
Port Tablegen'd reference implementation of Add to declarative builders.

PiperOrigin-RevId: 238977252

5 years agoRemove LOAD/STORE/RETURN boilerplate in declarative builders.
Nicolas Vasilache [Mon, 18 Mar 2019 13:26:05 +0000 (06:26 -0700)]
Remove LOAD/STORE/RETURN boilerplate in declarative builders.

This CL introduces a ValueArrayHandle helper to manage the implicit conversion
of ArrayRef<ValueHandle> -> ArrayRef<Value*> by converting first to ValueArrayHandle.
Without this, boilerplate operations that take ArrayRef<Value*> cannot be removed easily.

This all seems to boil down to decoupling Value from Type.
Alternative solutions exist (e.g. MLIR using Value by value everywhere) but they would be very intrusive. This seems to be the lowest impedance change.

Intrinsics are also lowercased by popular demand.

PiperOrigin-RevId: 238974125

5 years agoPort LowerVectorTransfers from EDSC + AST to declarative builders
Nicolas Vasilache [Mon, 18 Mar 2019 13:03:00 +0000 (06:03 -0700)]
Port LowerVectorTransfers from EDSC + AST to declarative builders

This CL removes the dependency of LowerVectorTransfers on the AST version of EDSCs which will be retired.

This exhibited a pretty fundamental staging difference in AST-based vs declarative based emission.

Since the delayed creation with an AST was staged, the loop order came into existence after the clipping expressions were computed.
This now changes as the loops first need to be created declaratively in fixed order and then the clipping expressions are created.
Also, due to lack of staging, coalescing cannot be done on the fly anymore and
needs to be done either as a pre-pass (current implementation) or as a local transformation on the generated IR (future work).

Tests are updated accordingly.

PiperOrigin-RevId: 238971631

5 years agoMoving the IR printing and execution timing options out of mlir-opt and into lib...
River Riddle [Sun, 17 Mar 2019 03:34:23 +0000 (20:34 -0700)]
Moving the IR printing and execution timing options out of mlir-opt and into lib/Pass. We now expose two methods: registerPassManagerCLOptions and applyPassManagerCLOptions; to allow for multiple different users (mlir-opt, etc.) to opt-in to this common functionality.

PiperOrigin-RevId: 238836911

5 years agoReplace the usages of llvm::Timer in PassTiming in favor of a simple nested Timer...
River Riddle [Sat, 16 Mar 2019 22:07:08 +0000 (15:07 -0700)]
Replace the usages of llvm::Timer in PassTiming in favor of a simple nested Timer. The output view is simplified to just display the Wall Time. This new infrastructure will greatly simplify the amount of work needed to support multi-threaded execution timing.

PiperOrigin-RevId: 238819218

5 years agoMove getSuccessorOperandIndex out of line.
Jacques Pienaar [Sat, 16 Mar 2019 20:49:57 +0000 (13:49 -0700)]
Move getSuccessorOperandIndex out of line.

PiperOrigin-RevId: 238814769

5 years agoAdd numeric include for using std::accumulate
Jacques Pienaar [Fri, 15 Mar 2019 17:20:03 +0000 (10:20 -0700)]
Add numeric include for using std::accumulate

PiperOrigin-RevId: 238664219

5 years agoCache the simplified attributes in SimplifyAffineStructures to avoid redundant simpli...
River Riddle [Fri, 15 Mar 2019 16:24:05 +0000 (09:24 -0700)]
Cache the simplified attributes in SimplifyAffineStructures to avoid redundant simplifications, as well as unnecessary accesses to the MLIRContext.

PiperOrigin-RevId: 238654325

5 years agoQualify DenseMap in AnalysisManager.
Jacques Pienaar [Fri, 15 Mar 2019 15:55:35 +0000 (08:55 -0700)]
Qualify DenseMap in AnalysisManager.

PiperOrigin-RevId: 238649794