Commit Graph

1334 Commits

Author SHA1 Message Date
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
Jacques Pienaar a8ed2ca8fd 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
2019-03-29 17:25:24 -07:00
River Riddle 30e68230bd 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
2019-03-29 17:25:09 -07:00
Jacques Pienaar 57270a9a99 Remove some statements that required >C++11, add includes and qualify names. NFC.
PiperOrigin-RevId: 239197784
2019-03-29 17:24:53 -07:00
Dimitrios Vytiniotis ee4cfefca8 Avoiding allocations during argument attribute conversion.
PiperOrigin-RevId: 239144675
2019-03-29 17:24:38 -07:00
Jacques Pienaar 52b10474a7 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
2019-03-29 17:24:24 -07:00
River Riddle 6d6ff7298a Add support for parsing true/false inside of a splat tensor literal.
PiperOrigin-RevId: 239052061
2019-03-29 17:24:09 -07:00
River Riddle 6e983ae8df Give PassInstrumentor a SmartMutex to lock access to the held instrumentations.
PiperOrigin-RevId: 239031524
2019-03-29 17:23:53 -07:00
Jacques Pienaar 81d25bb894 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
2019-03-29 17:23:38 -07:00
Jacques Pienaar 1156b2df35 Cleanups for OSS build.
PiperOrigin-RevId: 238999629
2019-03-29 17:23:23 -07:00
Nicolas Vasilache c3b0c6a0dc Cleanups Vectorize and SliceAnalysis - NFC
This CL cleans up and refactors super-vectorization and slice analysis.

PiperOrigin-RevId: 238986866
2019-03-29 17:23:07 -07:00
Jacques Pienaar 509cd739bf 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
2019-03-29 17:22:51 -07:00
Nicolas Vasilache a89d8c0a1a Port Tablegen'd reference implementation of Add to declarative builders.
PiperOrigin-RevId: 238977252
2019-03-29 17:22:36 -07:00
Nicolas Vasilache 3a12bc5041 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
2019-03-29 17:22:20 -07:00
Nicolas Vasilache f43388e4ce 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
2019-03-29 17:22:06 -07:00
River Riddle 6810c8bdc1 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
2019-03-29 17:21:50 -07:00