Commit Graph

1199 Commits

Author SHA1 Message Date
Mehdi Amini bb621a5596 Using getContext() instead of getInstruction()->getContext() on Operation (NFC)
PiperOrigin-RevId: 240088209
2019-03-29 17:38:29 -07:00
River Riddle 63e8725bc2 Update some of the derived type classes to use getImpl instead of a static_cast.
PiperOrigin-RevId: 240084937
2019-03-29 17:38:14 -07:00
Chris Lattner e510de0305 Various small cleanups to the code, mostly removing const_cast's.
PiperOrigin-RevId: 240083489
2019-03-29 17:37:58 -07:00
Mehdi Amini 3c747601d2 Add a `getImpl()` utility method to the `TypeBase` class as a convenience for derived class to access their associated TypeStorage (NFC)
PiperOrigin-RevId: 240077874
2019-03-29 17:37:41 -07:00
Mehdi Amini 903342c02c 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
2019-03-29 17:37:23 -07:00
Mehdi Amini 6754968255 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
2019-03-29 17:37:08 -07:00
River Riddle 9c6e92360c NFC: Rename the 'if' operation in the AffineOps dialect to 'affine.if'.
PiperOrigin-RevId: 240071154
2019-03-29 17:36:53 -07:00
Mehdi Amini 5c8113ef80 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
2019-03-29 17:36:36 -07:00
Chris Lattner d9b5bc8f55 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
2019-03-29 17:36:21 -07:00
Jacques Pienaar 7ab37aaf02 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
2019-03-29 17:36:06 -07:00
Mehdi Amini 286bc49aca 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
2019-03-29 17:35:50 -07:00
Chris Lattner dd2b2ec542 Push a bunch of 'consts' out of the *Op structure, in prep for removing
OpPointer.

PiperOrigin-RevId: 240044712
2019-03-29 17:35:35 -07:00
Nicolas Vasilache f26c7cd792 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
2019-03-29 17:35:20 -07:00
Chris Lattner 405aa0af9e Deconst-ify MLIRContext, and detemplatize some stuff now that const is gone.
PiperOrigin-RevId: 239976764
2019-03-29 17:35:04 -07:00
Mehdi Amini 888554c0c6 Add a convenience getContext() method in OpState to reduce boilerplate on clients.
PiperOrigin-RevId: 239972907
2019-03-29 17:34:48 -07:00
Chris Lattner 986310a68f 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
2019-03-29 17:34:33 -07:00
Jacques Pienaar b236041b93 Return operand_range instead for generated variadic operands accessor.
PiperOrigin-RevId: 239959381
2019-03-29 17:34:17 -07:00
River Riddle 39fa23feca Clarify the comment on valid data during DenseElementsAttr construction.
PiperOrigin-RevId: 239958211
2019-03-29 17:34:00 -07:00
Chris Lattner 5246bceee0 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
2019-03-29 17:33:45 -07:00
Jacques Pienaar 4de7f95f7f Verify first body is not empty before testing last character.
Avoids sigabrt where body is empty.

PiperOrigin-RevId: 239942200
2019-03-29 17:33:30 -07:00
River Riddle 319915eb23 Cleanup the construction of attributes and fix a opt-mode bug in DenseElementsAttr when allocating an empty array buffer.
PiperOrigin-RevId: 239926824
2019-03-29 17:33:15 -07:00
Mehdi Amini 9a0aa4ff17 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
2019-03-29 17:32:59 -07:00
Mehdi Amini 0f5602ae3d Add a parserSourceFile function that takes a file path directly
This avoids adding boilerplate around the SourceMgr on the client.

PiperOrigin-RevId: 239918122
2019-03-29 17:32:43 -07:00
Geoffrey Martin-Noble 94764ee036 Add tablegen aliases for OpTraits ResultsAreFloatLike and SameOperandsAndResultShape
Startblock:
  cl/239891224 is submitted
PiperOrigin-RevId: 239899356
2019-03-29 17:32:27 -07:00
River Riddle fdef161592 Remove "<label>" from the llvm basic block CHECK names.
PiperOrigin-RevId: 239898185
2019-03-29 17:32:06 -07:00
Jacques Pienaar 5546733ec4 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
2019-03-29 17:31:50 -07:00
Feng Liu b899ec16a2 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
2019-03-29 17:31:34 -07:00
Nicolas Vasilache 9021349c58 Rename edsc::EDSCxxxBuilder to edsc::xxxBuilder - NFC
PiperOrigin-RevId: 239805692
2019-03-29 17:31:15 -07:00
Nicolas Vasilache 071ca8da91 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
2019-03-29 17:30:59 -07:00
Mehdi Amini 9e210f9884 Remove declaration and unused reference to non-existent type `TensorTypeStorage` (NFC)
PiperOrigin-RevId: 239743070
2019-03-29 17:30:45 -07:00
Chris Lattner 3d6c74fff5 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
2019-03-29 17:30:30 -07:00
Chris Lattner 6ab2984b23 Remove const support from mlir::Region
PiperOrigin-RevId: 239642194
2019-03-29 17:30:14 -07:00
Chris Lattner 88e9f418f5 Continue pushing const out of the core IR types - in this case, remove const
from Function.

PiperOrigin-RevId: 239638635
2019-03-29 17:29:58 -07:00
River Riddle f0b38058b1 Add support for building a DenseIntElementsAttr with ArrayRef<int64_t> values.
PiperOrigin-RevId: 239616595
2019-03-29 17:29:42 -07:00
Nicolas Vasilache a19f22163d Better document TemplatedIndexedValue
PiperOrigin-RevId: 239615534
2019-03-29 17:29:26 -07:00
Nicolas Vasilache 028530271e 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
2019-03-29 17:29:12 -07:00
Mehdi Amini 8a761881a0 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
2019-03-29 17:28:56 -07:00
Nicolas Vasilache 053870f148 Reserve type range for the Linalg dialect
PiperOrigin-RevId: 239599147
2019-03-29 17:28:41 -07:00
Mehdi Amini de81d65e9d Fix class description for Attributes: the instance of the class aren't uniqued, the class has reference semantics.
PiperOrigin-RevId: 239598522
2019-03-29 17:28:27 -07:00
Nicolas Vasilache e21c101037 Add intrinsics for constants
PiperOrigin-RevId: 239596595
2019-03-29 17:28:12 -07:00
Nicolas Vasilache fc5bbdd6c8 Improve comment for `augmentMapAndBounds`
Followup from a previous CL.

PiperOrigin-RevId: 239591775
2019-03-29 17:27:57 -07:00
Mehdi Amini 1eb38ecdb7 Add comment describing what IREE (IR Execution Engine) stands for in the dialect registration.
PiperOrigin-RevId: 239539263
2019-03-29 17:27:41 -07:00
Chris Lattner 8d526ef173 Continue pushing const out of the IR types - removing the notion of a 'const
Module'.  NFC.

PiperOrigin-RevId: 239532885
2019-03-29 17:27:26 -07:00
Jacques Pienaar 2be78730b0 Add contributing file.
Initially no external contributions will be accepted (until post dev meeting at
least).

PiperOrigin-RevId: 239528594
2019-03-29 17:27:11 -07:00
Chris Lattner 589df37142 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
2019-03-29 17:26:56 -07:00
Chris Lattner ee1c726bfa Add a nice quote from Bjarke to summarize the const situation.
PiperOrigin-RevId: 239510578
2019-03-29 17:26:41 -07:00
Lei Zhang a09dc8a491 [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
2019-03-29 17:26:26 -07:00
Chris Lattner 3f1a5e4cf4 Add a "Usage of Const in MLIR" doc, explaining the rationale for the design
point we're moving the compiler to.

PiperOrigin-RevId: 239462779
2019-03-29 17:26:10 -07:00
Nicolas Vasilache d6c650cfb5 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
2019-03-29 17:25:53 -07:00
Lei Zhang eeadfbc170 Change getBroadcastedShape() to return result shape via parameter
This is a more efficient way than returning SmallVector directly.

PiperOrigin-RevId: 239407024
2019-03-29 17:25:38 -07:00