summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR
Commit message (Collapse)AuthorAgeFilesLines
...
* Give the affine structures, AffineMap/AffineExpr/IntegerSet/etc, their own ↵River Riddle2019-03-291-67/+96
| | | | | | BumpPtrAllocator and SmartMutex to make them thread-safe. This is step 3/N to making MLIRContext thread-safe. PiperOrigin-RevId: 238516596
* Give Attributes their own BumpPtrAllocator and SmartRWMutex to make them ↵River Riddle2019-03-291-234/+280
| | | | | | thread-safe. This is step 2/N to making the MLIRContext thread-safe. PiperOrigin-RevId: 238516542
* Add an 'Instruction::create' overload that accepts an existing ↵River Riddle2019-03-291-3/+17
| | | | | | NamedAttributeList. This avoids the need to unique an attribute list if one already exists, e.g. when cloning an existing instruction. PiperOrigin-RevId: 238512499
* Optimize the implementation of AffineExprConstantFolder to avoid the ↵River Riddle2019-03-291-22/+29
| | | | | | redundant creation of IntegerAttrs and IndexType. This becomes a much bigger performance issue when MLIRContext is thread-safe; as each unnecessary call may need to lock a mutex. PiperOrigin-RevId: 238484632
* Rename BlockList into RegionAlex Zinenko2019-03-295-74/+74
| | | | | | NFC. This is step 1/n to specifying regions as parts of any operation. PiperOrigin-RevId: 238472370
* Give the TypeUniquer its own BumpPtrAllocator and a SmartRWMutex to make it ↵River Riddle2019-03-291-7/+137
| | | | | | thread-safe. This is step 1/N to making the MLIRContext thread-safe. PiperOrigin-RevId: 238037814
* Update the constantFold/fold API to use LogicalResult instead of bool.River Riddle2019-03-292-17/+19
| | | | PiperOrigin-RevId: 237719658
* Introduce a TypeID class to provide unique identifiers for derived type ↵River Riddle2019-03-293-20/+7
| | | | | | classes. This removes the need for derived types to define a static typeID field. PiperOrigin-RevId: 237482890
* Change assert message to mention `nullptr` instead of `sentinel`: this is ↵Mehdi Amini2019-03-291-6/+6
| | | | | | likely more helpful to the user when it fires PiperOrigin-RevId: 237170067
* Supporting conversion of argument attributes along their types.Dimitrios Vytiniotis2019-03-291-0/+7
| | | | | | | | | | | | | | | | | This fixes a bug: previously, during conversion function argument attributes were neither beings passed through nor converted. This fix extends DialectConversion to allow for simultaneous conversion of the function type and the argument attributes. This was important when lowering MLIR to LLVM where attribute information (e.g. noalias) needs to be preserved in MLIR(LLVMDialect). Longer run it seems reasonable that we want to convert both the function attribute and its type and the argument attributes, but that requires a small refactoring in Function.h to aggregate these three fields in an inner struct, which will require some discussion. PiperOrigin-RevId: 236709409
* Introduce the notion of dialect attributes and dependent attributes. A ↵River Riddle2019-03-291-18/+4
| | | | | | | | | | | | | | | dialect attribute derives its context from a specific dialect, whereas a dependent attribute derives context from what it is attached to. Following this, we now enforce that functions and function arguments may only contain dialect specific attributes. These are generic entities and cannot provide any specific context for a dependent attribute. Dialect attributes are defined as: dialect-namespace `.` attr-name `:` attribute-value Dialects can override any of the following hooks to verify the validity of a given attribute: * verifyFunctionAttribute * verifyFunctionArgAttribute * verifyInstructionAttribute PiperOrigin-RevId: 236507970
* Add an assertion on the builder to ensure that a block is set before ↵Mehdi Amini2019-03-291-0/+1
| | | | | | | | creating an operation This is more friendly for the user than a raw segfault PiperOrigin-RevId: 236504102
* NFC. Move all of the remaining operations left in BuiltinOps to StandardOps. ↵River Riddle2019-03-294-471/+28
| | | | | | The only thing left in BuiltinOps are the core MLIR types. The standard types can't be moved because they are referenced within the IR directory, e.g. in things like Builder. PiperOrigin-RevId: 236403665
* Add support for parsing and printing affine.if and affine.for attributes. ↵River Riddle2019-03-292-6/+6
| | | | | | | | | | | | | | | | | | | | The attribute dictionaries are printed after the final block list for both operations: for %i = 0 to 10 { ... } {some_attr: true} if () : () () { ... } {some_attr: true} if () : () () { ... } else { ... } {some_attr: true} PiperOrigin-RevId: 236346983
* Provide a Builder::getNamedAttr and ↵River Riddle2019-03-291-0/+4
| | | | | | (Instruction|Function)::setAttr(StringRef, Attribute) to simplify attribute manipulation. PiperOrigin-RevId: 236222504
* Add support for named function argument attributes. The attribute dictionary ↵River Riddle2019-03-293-15/+28
| | | | | | | | | | is printed after the argument type: func @arg_attrs(i32 {arg_attr: 10}) func @arg_attrs(%arg0: i32 {arg_attr: 10}) PiperOrigin-RevId: 236136830
* Add a generic getValue to ElementsAttr for accessing a value at a given index.River Riddle2019-03-291-0/+18
| | | | PiperOrigin-RevId: 236013669
* Add a new class NamedAttributeList to deduplicate named attribute handling ↵River Riddle2019-03-296-128/+111
| | | | | | between Function and Instruction. PiperOrigin-RevId: 235830304
* Validate the names of attribute, dialect, and functions during verification. ↵River Riddle2019-03-292-2/+31
| | | | | | This essentially enforces the parsing rules upon their names. PiperOrigin-RevId: 235818842
* Add parser support for internal named attributes. These are attributes with ↵River Riddle2019-03-291-2/+2
| | | | | | names starting with ':'. PiperOrigin-RevId: 235774810
* Add a Function::isExternal utility to simplify checks for external functions.River Riddle2019-03-291-1/+1
| | | | PiperOrigin-RevId: 235746553
* Cleanup post cl/235283610 - NFCUday Bondhugula2019-03-291-7/+7
| | | | | | | - remove stale comments + cleanup - drop MLIRContext * field from expr flattener PiperOrigin-RevId: 235621178
* Convert the dialect type parse/print hooks into virtual functions on the ↵River Riddle2019-03-292-2/+10
| | | | | | Dialect class. PiperOrigin-RevId: 235589945
* Add support for constructing DenseIntElementsAttr with an array of APInt andRiver Riddle2019-03-292-6/+46
| | | | | | DenseFPElementsAttr with an array of APFloat. PiperOrigin-RevId: 235581794
* Use dialect hook registration for constant folding hook.Tatiana Shpeisman2019-03-291-14/+0
| | | | | | Deletes specialized mechanism for registering constant folding hook and uses dialect hooks registration mechanism instead. PiperOrigin-RevId: 235535410
* Add constant folding for ExtractElementOp when the aggregate is an ↵River Riddle2019-03-291-0/+8
| | | | | | OpaqueElementsAttr. PiperOrigin-RevId: 235533283
* Refactor AffineExprFlattener and move FlatAffineConstraints out of IR intoUday Bondhugula2019-03-292-2610/+186
| | | | | | | | | | | | | | | | | Analysis - NFC - refactor AffineExprFlattener (-> SimpleAffineExprFlattener) so that it doesn't depend on FlatAffineConstraints, and so that FlatAffineConstraints could be moved out of IR/; the simplification that the IR needs for AffineExpr's doesn't depend on FlatAffineConstraints - have AffineExprFlattener derive from SimpleAffineExprFlattener to use for all Analysis/Transforms purposes; override addLocalFloorDivId in the derived class - turn addAffineForOpDomain into a method on FlatAffineConstraints - turn AffineForOp::getAsValueMap into an AffineValueMap ctor PiperOrigin-RevId: 235283610
* EDSC: support call instructionsAlex Zinenko2019-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Introduce support for binding MLIR functions as constant expressions. Standard constant operation supports functions as possible constant values. Provide C APIs to look up existing named functions in an MLIR module and expose them to the Python bindings. Provide Python bindings to declare a function in an MLIR module without defining it and to add a definition given a function declaration. These declarations are useful when attempting to link MLIR modules with, e.g., the standard library. Introduce EDSC support for direct and indirect calls to other MLIR functions. Internally, an indirect call is always emitted to leverage existing support for delayed construction of MLIR Values using EDSC Exprs. If the expression is bound to a constant function (looked up or declared beforehand), MLIR constant folding will be able to replace an indirect call by a direct call. Currently, only zero- and one-result functions are supported since we don't have support for multi-valued expressions in EDSC. Expose function calling interface to Python bindings on expressions by defining a `__call__` function accepting a variable number of arguments. PiperOrigin-RevId: 234959444
* Adding -mlir-print-internal-attributes to print attributes with ':' prefixes.Ben Vanik2019-03-291-1/+7
| | | | | | This enables lit testing of passes that add internal attributes. PiperOrigin-RevId: 234809949
* Allow Builder to create function-type constantsAlex Zinenko2019-03-291-8/+24
| | | | | | | | | | | | | | | A recent change made ConstantOp::build accept a NumericAttr or assert that a generic Attribute is in fact a NumericAttr. The rationale behind the change was that NumericAttrs have a type that can be used as the result type of the constant operation. FunctionAttr also has a type, and it is valid to construct function-typed constants as exercised by the parser.mlir test. Relax ConstantOp::build back to take a generic Attribute. In the overload that only takes an attribute, assert that the Attribute is either a NumericAttr or a FunctionAttr, because it is necessary to extract the type. In the overload that takes both type type and the attribute, delegate the attribute type checking to ConstantOp::verify to prevent non-Builder-based Op construction mechanisms from creating invalid IR. PiperOrigin-RevId: 234798569
* Extend/improve getSliceBounds() / complete TODO + update unionBoundingBoxUday Bondhugula2019-03-292-42/+224
| | | | | | | | | - compute slices precisely where the destination iteration depends on multiple source iterations (instead of over-approximating to the whole source loop extent) - update unionBoundingBox to deal with input with non-matching symbols - reenable disabled backend test case PiperOrigin-RevId: 234714069
* Misc. updates/fixes to analysis utils used for DMA generation; update DMAUday Bondhugula2019-03-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | generation pass to make it drop certain assumptions, complete TODOs. - multiple fixes for getMemoryFootprintBytes - pass loopDepth correctly from getMemoryFootprintBytes() - use union while computing memory footprints - bug fixes for addAffineForOpDomain - take into account loop step - add domains of other loop IVs in turn that might have been used in the bounds - dma-generate: drop assumption of "non-unit stride loops being tile space loops and skipping those and recursing to inner depths"; DMA generation is now purely based on available fast mem capacity and memory footprint's calculated - handle memory region compute failures/bailouts correctly from dma-generate - loop tiling cleanup/NFC - update some debug and error messages to use emitNote/emitError in pipeline-data-transfer pass - NFC PiperOrigin-RevId: 234245969
* Update direction vector computation to use ↵MLIR Team2019-03-291-14/+19
| | | | | | | | FlatAffineConstraints::getLower/UpperBounds. Update FlatAffineConstraints::getLower/UpperBounds to project to the identifier for which bounds are being computed. This change enables computing bounds on an identifier which were previously dependent on the bounds of another identifier. PiperOrigin-RevId: 234017514
* Make IndexType a standard type instead of a builtin. This also cleans up ↵River Riddle2019-03-296-12/+12
| | | | | | some unnecessary factory methods on the Type class. PiperOrigin-RevId: 233640730
* Add dialect-specific decoding for opaque constants.Tatiana Shpeisman2019-03-296-9/+49
| | | | | | | | Associates opaque constants with a particular dialect. Adds general mechanism to register dialect-specific hooks defined in external components. Adds hooks to decode opaque tensor constant and extract an element of an opaque tensor constant. This CL does not change the existing mechanism for registering constant folding hook yet. One thing at a time. PiperOrigin-RevId: 233544757
* Remove the restriction that only registered terminator operations may ↵River Riddle2019-03-294-35/+20
| | | | | | terminate a block and have block operands. This allows for any operation to hold block operands. It also introduces the notion that unregistered operations may terminate a block. As such, the 'isTerminator' api on Instruction has been split into 'isKnownTerminator' and 'isKnownNonTerminator'. PiperOrigin-RevId: 233076831
* Automated rollback of changelist 232728977.Uday Bondhugula2019-03-291-1/+1
| | | | PiperOrigin-RevId: 232944889
* Disallow zero dimensions in vectors and memrefsAlex Zinenko2019-03-291-2/+19
| | | | | | | | | | | | | | | | | Aggregate types where at least one dimension is zero do not fully make sense as they cannot contain any values (their total size is zero). However, TensorFlow and XLA support tensors with zero sizes, so we must support those too. This is relatively safe since, unlike vectors and memrefs, we don't have first-class element accessors for MLIR tensors. To support sparse element attributes of vector types that have no non-zero elements, make sure that index and value element attributes have tensor type so that we never need to create a zero vector type internally. Note that this is already consistent with the inline documentation of the sparse elements attribute. Users of the sparse elements attribute should not rely on the storage schema anyway. PiperOrigin-RevId: 232896707
* Automated rollback of changelist 232717775.Uday Bondhugula2019-03-291-1/+1
| | | | PiperOrigin-RevId: 232807986
* Rename the 'if' operation in the AffineOps dialect to 'affine.if' and namespaceRiver Riddle2019-03-291-1/+1
| | | | | | the AffineOps dialect with 'affine'. PiperOrigin-RevId: 232728977
* Add constant build() method not requiring result typeLei Zhang2019-03-291-0/+6
| | | | | | | | Instead, we deduce the result type from the given attribute. This is in preparation for generating constant ops with TableGen. PiperOrigin-RevId: 232723467
* NFC: Rename the 'for' operation in the AffineOps dialect to 'affine.for'. ↵River Riddle2019-03-291-1/+1
| | | | | | The is the second step to adding a namespace to the AffineOps dialect. PiperOrigin-RevId: 232717775
* Adds the ability to compute the MemRefRegion of a sliced loop nest. Utilizes ↵MLIR Team2019-03-291-0/+60
| | | | | | | | | this feature during loop fusion cost computation, to compute what the write region of a fusion candidate loop nest slice would be (without having to materialize the slice or change the IR). *) Adds parameter to public API of MemRefRegion::compute for passing in the slice loop bounds to compute the memref region of the loop nest slice. *) Exposes public method MemRefRegion::getRegionSize for computing the size of the memref region in bytes. PiperOrigin-RevId: 232706165
* Remove findInstPositionInBlock from the Block api.River Riddle2019-03-291-13/+0
| | | | PiperOrigin-RevId: 232704766
* Move the AffineFor loop bound folding to a canonicalization pattern on the ↵River Riddle2019-03-291-7/+4
| | | | | | AffineForOp. PiperOrigin-RevId: 232610715
* Refactor the affine analysis by moving some functionality to IR and some to ↵River Riddle2019-03-293-0/+2521
| | | | | | | | | | | | | | AffineOps. This is important for allowing the affine dialect to define canonicalizations directly on the operations instead of relying on transformation passes, e.g. ComposeAffineMaps. A summary of the refactoring: * AffineStructures has moved to IR. * simplifyAffineExpr/simplifyAffineMap/getFlattenedAffineExpr have moved to IR. * makeComposedAffineApply/fullyComposeAffineMapAndOperands have moved to AffineOps. * ComposeAffineMaps is replaced by AffineApplyOp::canonicalize and deleted. PiperOrigin-RevId: 232586468
* Print parens around the return type of a function if it is also a function typeAlex Zinenko2019-03-291-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | Existing type syntax contains the following productions: function-type ::= type-list-parens `->` type-list type-list ::= type | type-list-parens type ::= <..> | function-type Due to these rules, when the parser sees `->` followed by `(`, it cannot disambiguate if `(` starts a parenthesized list of function result types, or a parenthesized list of operands of another function type, returned from the current function. We would need an unknown amount of lookahead to try to find the `->` at the right level of function nesting to differentiate between type lists and singular function types. Instead, require the result type of the function that is a function type itself to be always parenthesized, at the syntax level. Update the spec and the parser to correspond to the production rule names used in the spec (although it would have worked without modifications). Fix the function type parsing bug in the process, as it used to accept the non-parenthesized list of types for arguments, disallowed by the spec. PiperOrigin-RevId: 232528361
* Print non-default attribute types in optional attr dictionaryAlex Zinenko2019-03-291-5/+28
| | | | | | | | | | | | | | | In optional attribute dictionary used, among others, in the generic form of the ops, attribute types for integers and floats are omitted. This could lead to inconsistencies when round-tripping the IR, in particular the attributes are created with incorrect types after parsing (integers default to i64, floats default to f64). Provide API to emit a trailing type after the attribute for integers and floats. Use it while printing the optional attribute dictionary. Omitting types for i64 and f64 is a pragmatic decision that minimizes changes in tests. We may want to reconsider in the future and always print types of attributes in the generic form. PiperOrigin-RevId: 232480116
* Remove InstWalker and move all instruction walking to the api facilities on ↵River Riddle2019-03-294-73/+75
| | | | | | Function/Block/Instruction. PiperOrigin-RevId: 232388113
* NFC: Move AffineApplyOp to the AffineOps dialect. This also moves the ↵River Riddle2019-03-292-243/+1
| | | | | | isValidDim/isValidSymbol methods from Value to the AffineOps dialect. PiperOrigin-RevId: 232386632
OpenPOWER on IntegriCloud