summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * Add start of textmate language grammar.Jacques Pienaar2019-08-121-0/+387
| | | | | | | | | | | | | | | | | | | | | | | | | | Basic* grammar to start of with, this doesn't handle custom ops and doesn't handle ops with regions. But useful enough to make reading the .mlir files easier. Followed the approach used for emacs & vim and placed in separate directory under utils. * I got a little bit carried away trying to handle attributes and tried to do some custom op printing handling, but finally abandoned it. Also first time writing a textmate grammar so I assume a lot can be improved :) PiperOrigin-RevId: 262985490
| * Use unreachable post switch rather than default case.Jacques Pienaar2019-08-121-4/+2
| | | | | | | | | | | | | | | | Prefer to enumerate all cases in the switch instead of using default to allow compiler to flag missing cases. This also avoids -Wcovered-switch-default warning. PiperOrigin-RevId: 262935972
| * Avoid passing in line/col for files not registered with SourceMgr.Jacques Pienaar2019-08-121-6/+4
| | | | | | | | | | | | | | | | | | This can result in index expression overflow in "Loc.getPointer() - ColumnNo" in SourgeMgr. loc could also be prefixed to the message additionally in this case. PiperOrigin-RevId: 262935408
| * Update typoJacques Pienaar2019-08-122-6/+6
| | | | | | | | | | | | cond_br was accidentally typed as br_cond in a few examples. PiperOrigin-RevId: 262929398
| * LLVM dialect: introduce llvm.addressof to access globalsAlex Zinenko2019-08-127-10/+178
| | | | | | | | | | | | | | | | | | | | | | This instruction is a local counterpart of llvm.global that takes a symbol reference to a global and produces an SSA value containing the pointer to it. Used in combination, these two operations allow one to use globals with other operations expecting SSA values. At a cost of IR indirection, we make sure the functions don't implicitly capture the surrounding SSA values and remain suitable for parallel processing. PiperOrigin-RevId: 262908622
| * Add lowering of vector dialect to LLVM dialect.Nicolas Vasilache2019-08-128-15/+303
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL is step 3/n towards building a simple, programmable and portable vector abstraction in MLIR that can go all the way down to generating assembly vector code via LLVM's opt and llc tools. This CL adds support for converting MLIR n-D vector types to (n-1)-D arrays of 1-D LLVM vectors and a conversion VectorToLLVM that lowers the `vector.extractelement` and `vector.outerproduct` instructions to the proper mix of `llvm.vectorshuffle`, `llvm.extractelement` and `llvm.mulf`. This has been independently verified to produce proper avx2 code. Input: ``` func @vec_1d(%arg0: vector<4xf32>, %arg1: vector<8xf32>) -> vector<8xf32> { %2 = vector.outerproduct %arg0, %arg1 : vector<4xf32>, vector<8xf32> %3 = vector.extractelement %2[0 : i32]: vector<4x8xf32> return %3 : vector<8xf32> } ``` Command: ``` mlir-opt vector-to-llvm.mlir -vector-lower-to-llvm-dialect --disable-pass-threading | mlir-opt -lower-to-cfg -lower-to-llvm | mlir-translate --mlir-to-llvmir | opt -O3 | llc -O3 -march=x86-64 -mcpu=haswell -mattr=fma,avx2 ``` Output: ``` vec_1d: # @vec_1d # %bb.0: vbroadcastss %xmm0, %ymm0 vmulps %ymm1, %ymm0, %ymm0 retq ``` PiperOrigin-RevId: 262895929
| * NFC: Update pattern rewrite API to pass OwningRewritePatternList by const ↵River Riddle2019-08-115-49/+54
| | | | | | | | | | | | | | | | reference. The pattern list is not modified by any of these APIs and should thus be passed with const. PiperOrigin-RevId: 262844002
| * ODS: Round out the definitions of the common integer attributes sizes, addingChris Lattner2019-08-111-0/+3
| | | | | | | | | | | | 1/8/16 bit attrs. NFC PiperOrigin-RevId: 262843016
| * Refactor DenseElementAttr::getValues methods to return full ranges for splats.River Riddle2019-08-114-33/+117
| | | | | | | | | | | | The current implementation only returns one element for the splat case, which often comes as a surprise; leading to subtle/confusing bugs. The new behavior will include an iterate over the full range of elements, as defined by the shaped type, by providing the splat value for each iterator index. PiperOrigin-RevId: 262756780
| * NFC: Standardize the terminology used for parent ops/regions/etc.River Riddle2019-08-0923-63/+59
| | | | | | | | | | | | There are currently several different terms used to refer to a parent IR unit in 'get' methods: getParent/getEnclosing/getContaining. This cl standardizes all of these methods to use 'getParent*'. PiperOrigin-RevId: 262680287
| * NFC: Refactoring PatternSymbolResolver into SymbolInfoMapLei Zhang2019-08-093-310/+429
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In declarative rewrite rules, a symbol can be bound to op arguments or results in the source pattern, and it can be bound to op results in the result pattern. This means given a symbol in the pattern, it can stands for different things: op operand, op attribute, single op result, op result pack. We need a better way to model this complexity so that we can handle according to the specific kind a symbol corresponds to. Created SymbolInfo class for maintaining the information regarding a symbol. Also created a companion SymbolInfoMap class for a map of such symbols, providing insertion and querying depending on use cases. PiperOrigin-RevId: 262675515
| * NFC: Update usages of OwningRewritePatternList to pass by & instead of &&.River Riddle2019-08-0923-55/+47
| | | | | | | | | | | | This will allow for reusing the same pattern list, which may be costly to continually reconstruct, on multiple invocations. PiperOrigin-RevId: 262664599
| * Translation to LLVM IR: use LogicalResult instead of boolAlex Zinenko2019-08-094-38/+35
| | | | | | | | | | | | | | | | The translation code predates the introduction of LogicalResult and was relying on the obsolete LLVM convention of returning false on success. Change it to use MLIR's LogicalResult abstraction instead. NFC. PiperOrigin-RevId: 262589432
| * LLVM dialect and translation: support global stringsAlex Zinenko2019-08-096-5/+81
| | | | | | | | | | | | | | | | | | | | | | Unlike regular constant values, strings must be placed in some memory and referred to through a pointer to that memory. Until now, they were not supported in function-local constant declarations with `llvm.constant`. Introduce support for global strings using `llvm.global`, which would translate them into global arrays in LLVM IR and thus make sure they have some memory allocated for storage. PiperOrigin-RevId: 262569316
| * Translation to LLVM: support llvm.globalAlex Zinenko2019-08-093-0/+21
| | | | | | | | | | | | | | Add support for translating recently introduced llvm.global operations to global variables in the LLVM IR proper. PiperOrigin-RevId: 262564700
| * External library name mangling support for linalg.Nicolas Vasilache2019-08-097-46/+108
| | | | | | | | | | | | | | | | | | | | This CL introduces the ability to generate the external library name for Linalg operations. The problem is that neither mlir or C support overloading and we want a simplified form of name mangling that is still reasonable to read. This CL creates the name of the external call that Linalg expects from the operation name and the type of its arguments. The interface library names are updated and use new cases are added for FillOp. PiperOrigin-RevId: 262556833
| * Allow linalg.view to change the underlying elemental type.Nicolas Vasilache2019-08-097-133/+129
| | | | | | | | | | | | | | | | | | This CL adds the ability for linalg.view to act as a bitcast operation. This will be used when promoting views into faster memory and casting to vector types. In the process, linalg.view is moved to ODS. PiperOrigin-RevId: 262556246
| * Add a higher-order vector.outerproduct operation in MLIRNicolas Vasilache2019-08-094-6/+104
| | | | | | | | | | | | | | | | This CL is step 2/n towards building a simple, programmable and portable vector abstraction in MLIR that can go all the way down to generating assembly vector code via LLVM's opt and llc tools. This CL adds the vector.outerproduct operation to the MLIR vector dialect as well as the appropriate roundtrip test. Lowering to LLVM will occur in the following CL. PiperOrigin-RevId: 262552027
| * Add a higher-order vector.extractelement operation in MLIRNicolas Vasilache2019-08-0915-14/+237
| | | | | | | | | | | | | | | | This CL is step 2/n towards building a simple, programmable and portable vector abstraction in MLIR that can go all the way down to generating assembly vector code via LLVM's opt and llc tools. This CL adds the vector.extractelement operation to the MLIR vector dialect as well as the appropriate roundtrip test. Lowering to LLVM will occur in the following CL. PiperOrigin-RevId: 262545089
| * Add support for vector ops in the LLVM dialectNicolas Vasilache2019-08-096-1/+243
| | | | | | | | | | | | | | | | | | | | | | | | This CL is step 1/n towards building a simple, programmable and portable vector abstraction in MLIR that can go all the way down to generating assembly vector code via LLVM's opt and llc tools. This CL adds the 3 instructions `llvm.extractelement`, `llvm.insertelement` and `llvm.shufflevector` as documented in the LLVM LangRef "Vector Instructions" section. The "Experimental Vector Reduction Intrinsics" are left out for now and can be added in the future on a per-need basis. Appropriate roundtrip and LLVM Target tests are added. PiperOrigin-RevId: 262542095
| * LLVM Dialect: introduce llvm.globalAlex Zinenko2019-08-096-0/+165
| | | | | | | | | | | | | | | | | | | | | | Introduce an operation that defines global constants and variables in the LLVM dialect, to reflect the corresponding LLVM IR capability. This operation is expected to live in the top-level module and behaves similarly to llvm.constant. It currently does not model many of the attributes supported by the LLVM IR for global values (memory space, alignment, thread-local, linkage) and will be extended as the relevant use cases appear. PiperOrigin-RevId: 262539445
| * Add support for floating-point comparison 'fcmp' to the LLVM dialect.Nagy Mostafa2019-08-089-32/+334
| | | | | | | | | | | | | | | | This adds support for fcmp to the LLVM dialect and adds any necessary lowerings, as well as support for EDSCs. Closes tensorflow/mlir#69 PiperOrigin-RevId: 262475255
| * Enable TTI for host TargetMachine in JitRunnerDiego Caballero2019-08-081-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit improves JitRunner so that it creates a target machine for the current CPU host which is used to properly initialize LLVM's TargetTransformInfo for such a target. This will enable optimizations such as vectorization in LLVM when using JitRunner. Please, note that, as part of this work, JITTargetMachineBuilder::detectHost() has been extended to include the host CPU name and sub-target features as part of the host CPU detection (https://reviews.llvm.org/D65760). Closes tensorflow/mlir#71 PiperOrigin-RevId: 262452525
| * Build SymbolTable upfront in ModuleOp verification.Mahesh Ravishankar2019-08-081-1/+2
| | | | | | | | | | | | | | | | Building the symbol table upfront from module op allows for O(1) lookup of the function while verifying duplicate EntryPointOp within the module. PiperOrigin-RevId: 262435697
| * Add SymbolTable trait to spirv::ModuleOp.Mahesh Ravishankar2019-08-082-10/+6
| | | | | | | | | | | | | | | | Adding the SymbolTable trait allows looking up the name of the functions using the symbol table while verifying EntryPointOps instead of manually tracking the function names. PiperOrigin-RevId: 262431220
| * Lexer: NFC: sort helper methods alphabeticallyAlex Zinenko2019-08-082-97/+97
| | | | | | | | | | | | | | | | Lexer methods were added progressively as implementation advanced. The rest of MLIR now tends to sort methods alphabetically for better discoverability in absence of tooling. Sort the lexer methods as well. PiperOrigin-RevId: 262406992
| * FunctionSupport: wrap around bool to have a more semantic callback typeAlex Zinenko2019-08-085-12/+26
| | | | | | | | | | | | | | | | | | | | | | | | This changes the type of the function type-building callback from (ArrayRef<Type>, ArrayRef<Type>, bool, string &) to (ArrayRef<Type>, ArrayRef<Type>, VariadicFlag, String &) to make the intended use clear from the callback signature alone. Also rearrange type definitions in Parser.cpp to make them more sorted alphabetically. PiperOrigin-RevId: 262405851
| * Introduce support for variadic function signatures for the LLVM dialectAlex Zinenko2019-08-0812-27/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | LLVM function type has first-class support for variadic functions. In the current lowering pipeline, it is emulated using an attribute on functions of standard function type. In LLVMFuncOp that has LLVM function type, this can be modeled directly. Introduce parsing support for variadic arguments to the function and use it to support variadic function declarations in LLVMFuncOp. Function definitions are currently not supported as that would require modeling va_start/va_end LLVM intrinsics in the dialect and we don't yet have a consistent story for LLVM intrinsics. PiperOrigin-RevId: 262372651
| * Command toyc should be toyc-ch2 in this chapterKan Chen2019-08-081-3/+3
| | | | | | | | | | | | Closes tensorflow/mlir#70 PiperOrigin-RevId: 262370485
| * Parser: treat implicit top-level module as an SSA name scopeAlex Zinenko2019-08-082-1/+15
| | | | | | | | | | | | | | | | | | | | Now that modules are also operations, nothing prevents one from defining SSA values in the module. Doing so in an implicit top-level module, i.e. outside of a `module` operation, was leading to a crash because the implicit module was not associated with an SSA name scope. Create a name scope before parsing the top-level module to fix this. PiperOrigin-RevId: 262366891
| * Add canonicalization pattern for linalg.dimNicolas Vasilache2019-08-083-0/+159
| | | | | | | | | | | | | | | | This CL introduces canonicalization patterns for linalg.dim. This allows the dimenions of chains of view, slice and subview operations to simplify. Down the line, when mixed with cse, this also allows better composition of linalg tiling and fusion by tracking operations that give the same result (not in this CL). PiperOrigin-RevId: 262365865
| * Add the LLVM IR unreachable instruction to the LLVMIR dialect.Eric Schweitz2019-08-082-0/+9
| | | | | | | | | | | | | | | | http://llvm.org/docs/LangRef.html#unreachable-instruction Closes tensorflow/mlir#64 PiperOrigin-RevId: 262301557
| * NFC: Update FuncOp::addEntryBlock to return the newly inserted block.River Riddle2019-08-078-20/+11
| | | | | | | | | | | | The entry block is often used recently after insertion. This removes the need to perform an additional lookup in such cases. PiperOrigin-RevId: 262265671
| * Initialize local variables for opcode to fix MSAN failuresLei Zhang2019-08-071-3/+3
| | | | | | | | PiperOrigin-RevId: 262225919
| * Add utility 'replaceAllUsesWith' methods to Operation.River Riddle2019-08-076-13/+33
| | | | | | | | | | | | These methods will allow replacing the uses of results with an existing operation, with the same number of results, or a range of values. This removes a number of hand-rolled result replacement loops and simplifies replacement for operations with multiple results. PiperOrigin-RevId: 262206600
| * Improve support for opaque types in MLIR, allowing dialects to opt intoChris Lattner2019-08-075-8/+45
| | | | | | | | | | | | supporting opaque types, and providing ODS support for matching them. PiperOrigin-RevId: 262183028
| * Fix verification of zero-dim memref in ↵Diego Caballero2019-08-078-9/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | affine.load/affine.store/std.load/std.store Verification complained when using zero-dimensional memrefs in affine.load, affine.store, std.load and std.store. This PR extends verification so that those memrefs can be used. Closes tensorflow/mlir#58 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/58 from dcaballe:dcaballe/zero-dim 49bcdcd45c52c48beca776431328e5ce551dfa9e PiperOrigin-RevId: 262164916
| * Have ValueUseIterator template use OperandType instead of IROperand.Andy Ly2019-08-061-1/+1
| | | | | | | | | | | | This was causing some issues using helper methods like llvm::make_early_inc_range on Value::getUses(), resulting in IROperand instead of OpOperand. PiperOrigin-RevId: 262056425
| * NFC: Simplify ModuleTerminatorOp by using the HasParent trait.River Riddle2019-08-063-15/+2
| | | | | | | | PiperOrigin-RevId: 261962104
| * Remove ops in regions/blocks from worklist when parent op is being removed ↵Andy Ly2019-08-064-0/+41
| | | | | | | | | | | | | | | | via GreedyPatternRewriteDriver::replaceOp. This fixes a bug where ops inside the parent op are visited even though the parent op has been removed. PiperOrigin-RevId: 261953580
| * NFC: Simplify ModuleOp by using the SingleBlockImplicitTerminator trait.River Riddle2019-08-063-22/+11
| | | | | | | | PiperOrigin-RevId: 261944712
| * Emit matchAndRewrite() for declarative rewrite rulesLei Zhang2019-08-061-115/+107
| | | | | | | | | | | | | | | | | | Previously we are emitting separate match() and rewrite() methods, which requires conveying a match state struct in a unique_ptr across these two methods. Changing to emit matchAndRewrite() simplifies the picture. PiperOrigin-RevId: 261906804
| * [spirv] Provide decorations in batch for op constructionLei Zhang2019-08-061-11/+10
| | | | | | | | | | | | | | | | | | | | Instead of setting the attributes for decorations one by one after constructing the op, this CL changes to attach all the attributes for decorations to the attribute vector for constructing the op. This should be simpler and more efficient. PiperOrigin-RevId: 261905578
| * Add a region to linalg.genericNicolas Vasilache2019-08-069-39/+292
| | | | | | | | | | | | | | | | | | | | This CL extends the Linalg GenericOp with an alternative way of specifying the body of the computation based on a single block region. The "fun" attribute becomes optional. Either a SymbolRef "fun" attribute or a single block region must be specified to describe the side-effect-free computation. Upon lowering to loops, the new region body is inlined in the innermost loop. The parser, verifier and pretty printer are extended. Appropriate roundtrip, negative and lowering to loop tests are added. PiperOrigin-RevId: 261895568
| * Refactor Linalg ops to loop lowering (NFC)Nicolas Vasilache2019-08-0614-269/+358
| | | | | | | | | | | | | | This CL modifies the LowerLinalgToLoopsPass to use RewritePattern. This will make it easier to inline Linalg generic functions and regions when emitting to loops in a subsequent CL. PiperOrigin-RevId: 261894120
| * Add TTI pass initialization to pass managers.Diego Caballero2019-08-054-16/+41
| | | | | | | | | | | | | | | | | | Many LLVM transformations benefits from knowing the targets. This enables optimizations, especially in a JIT context when the target is (generally) well-known. Closes tensorflow/mlir#49 PiperOrigin-RevId: 261840617
| * NFC: Implement OwningRewritePatternList as a class instead of a using directive.River Riddle2019-08-0534-133/+113
| | | | | | | | | | | | This allows for proper forward declaration, as opposed to leaking the internal implementation via a using directive. This also allows for all pattern building to go through 'insert' methods on the OwningRewritePatternList, replacing uses of 'push_back' and 'RewriteListBuilder'. PiperOrigin-RevId: 261816316
| * Fix header guard.Suharsh Sivakumar2019-08-051-0/+1
| | | | | | | | PiperOrigin-RevId: 261774919
| * Drop linalg.range_intersect opNicolas Vasilache2019-08-055-120/+1
| | | | | | | | | | | | This op is not useful. PiperOrigin-RevId: 261665736
| * Use SingleBlockImplicitTerminator trait for spv.moduleLei Zhang2019-08-053-11/+17
| | | | | | | | | | | | | | | | This trait provides the ensureTerminator() utility function and the checks to make sure a spv.module is indeed terminated with spv._module_end. PiperOrigin-RevId: 261664153
OpenPOWER on IntegriCloud