summaryrefslogtreecommitdiff
path: root/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
AgeCommit message (Collapse)Author
2025-11-17Add 'exact' flag to arith.shrui/shrsi/divsi/divui operations (#165923)Jeremy Furtek
This MR adds support for the `exact` flag to the `arith.shrui/shrsi/divsi/divui` operations. The semantics are identical to those of the LLVM dialect and the LLVM language reference. This MR also modifies the mechanism for converting `arith` dialect **attributes** to corresponding **properties** in the `LLVM` dialect. (As a specific example, the integer overflow flags `nsw/nuw` are **properties** in the `LLVM` dialect, as opposed to attributes.) Previously, attribute converter classes were required to have a specific method to support integer overflow flags: ```C++ template <typename SourceOp, typename TargetOp> class AttrConvertPassThrough { public: ... LLVM::IntegerOverflowFlags getOverflowFlags() const { return LLVM::IntegerOverflowFlags::none; } }; ``` This method was required, even for `arith` source operations that did not use integer overflow flags (e.g. `AttrConvertFastMathToLLVM`). This MR modifies the interface required by `arith` dialect attribute converters to instead provide a (possibly NULL) properties attribute: ```C++ template <typename SourceOp, typename TargetOp> class AttrConvertPassThrough { public: ... Attribute getPropAttr() const { return {}; } }; ``` For `arith` operations with attributes that map to `LLVM` dialect **properties**, the attribute converter can create a `DictionaryAttr` containing target properties and return that attribute from the attribute converter's `getPropAttr()` method. The `arith` attribute conversion framework will set the `propertiesAttr` of an `OperationState`, and the target operation's `setPropertiesFromAttr()` method will be invoked to set the properties when the target operation is created. The `AttrConvertOverflowToLLVM` class in this MR uses the new approach.
2025-08-14[mlir][LLVM][NFC] Simplify `copyUnrankedDescriptors` (#153597)Matthias Springer
Split the function into two: one that copies a single unranked descriptor and one that copies multiple unranked descriptors. This is in preparation of adding 1:N support to the Func->LLVM lowering patterns.
2025-08-14[mlir][LLVM][NFC] Simplify `computeSizes` function (#153588)Matthias Springer
Rename `computeSizes` to `computeSize` and make it compute just a single size. This is in preparation of adding 1:N support to the Func->LLVM lowering patterns.
2025-07-25[mlir][NFC] update `mlir` create APIs (34/n) (#150660)Maksim Levental
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-07-22[mlir][NFC] update `Conversion` create APIs (6/n) (#149888)Maksim Levental
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-06-27[MLIR] Replace getVoidPtrType with getPtrType in ConvertToLLVMPattern (#145657)Twice
`ConversionPattern::getVoidPtrType` looks a little confusion since the opaque pointer migration is already done. Also we cannot specify address space in this method. Maybe we can mark them as deprecated and add new method `getPtrType()`, as this PR did : )
2025-05-23[mlir][amx] Simplify intrinsic generation (#140559)Adam Siemieniuk
Replaces separate amx named intrinsic operations with direct calls to LLVM intrinsic functions. The existing amx tests are updated and expanded. The separate conversion step translating amx intrinsics into LLVM IR is eliminated. Instead, this step is now performed by the existing llvm dialect infrastructure. Related RFC: https://discourse.llvm.org/t/rfc-simplify-x86-intrinsic-generation/85581/7
2025-05-22Emit nuw and nsw for mul and add when lowering to llvm.getelementptr (#140966)Peiyong Lin
Now that the GEP no wrap flags are known when lowering to llvm.getelementptr, we can also emit nuw and nsw for the generated llvm.mul and llvm.add when no unsigned wrap and no signed wrap are used respectively. fixes: iree-org/iree#20483 Signed-off-by: Lin, Peiyong <linpyong@gmail.com>
2025-05-20Emit inbounds and nuw attributes in memref. (#138984)Peiyong Lin
Now that MLIR accepts nuw and nusw in getelementptr, this patch emits the inbounds and nuw attributes when lower memref to LLVM in load and store operators. This patch also strengthens the memref.load and memref.store spec about undefined behaviour during lowering. This patch also lifts the |rewriter| parameter in getStridedElementPtr ahead so that LLVM::GEPNoWrapFlags can be added at the end with a default value and grouped together with other operators' parameters. Signed-off-by: Lin, Peiyong <linpyong@gmail.com>
2025-05-19[mlir][llvm][x86vector] One-to-one intrinsic op interface (#140055)Adam Siemieniuk
Adds an LLVMIR op interface that can used by external operations to model LLVM intrinsics. Related 'op to llvm.call_intrinsic' rewriter helper is moved into common LLVM conversion patterns. The x86vector dialect is refactored to use the new common abstraction. The one-to-one intrinsic op is tied to LLVM intrinsic call semantics. Thus, the op interface, previously defined as a part of x86vector dialect, is moved into the LLVMIR interfaces to allow other low-level dialects to define operations abstracting specific intrinsic semantics while minimizing infrastructure duplication. Related RFC: https://discourse.llvm.org/t/rfc-simplify-x86-intrinsic-generation/85581/6
2025-04-20[mlir][LLVM] Add `OpBuilder &` to `lookupOrCreateFn` functions (#136421)Matthias Springer
These functions are called from lowering patterns. All IR modifications in a pattern must be performed through the provided rewriter, but these functions used to instantiate a new `OpBuilder`, bypassing the provided rewriter.
2025-04-18[mlir] AMDGPUToROCDL: lower `amdgpu.swizzle_bitmode` (#136223)Ivan Butygin
Repack `amdgpu.swizzle_bitmode` arguments and lower it to `rocdl.ds_swizzle`. Repacking logic is follows: * `sizeof(arg) < sizeof(i32)`: bitcast to integer and zext to i32 and then trunc and bitcast back. * `sizeof(arg) == sizeof(i32)`: just bitcast to i32 and back if not i32 * `sizeof(arg) > sizeof(i32)`: bitcast to `vector<Nxi32>`, extract individual elements and do a series of `rocdl.ds_swizzle` and then compose vector and bitcast back. Added repacking logic to LLVM utils so it can be used elsewhere. I'm planning to use it for `gpu.shuffle` later.
2025-04-07[mlir][memref] Check memory space before lowering alloc ops (#134427)Matthias Springer
Check the memory space before lowering allocation ops, instead of starting the lowering and then rolling back the pattern when the memory space was found to be incompatible with LLVM. Note: This is in preparation of the One-Shot Dialect Conversion refactoring. Note: `isConvertibleAndHasIdentityMaps` now also checks the memory space.
2025-02-06[mlir][LLVM] Switch `undef` for `poison` for uninitialized values (#125629)Krzysztof Drewniak
LLVM itself is generally moving away from using `undef` and towards using `poison`, to the point of having a lint that caches new uses of `undef` in tests. In order to not trip the lint on new patterns and to conform to the evolution of LLVM - Rename valious ::undef() methods on StructBuilder subclasses to ::poison() - Audit the uses of UndefOp in the MLIR libraries and replace almost all of them with PoisonOp The remaining uses of `undef` are initializing `uninitialized` memrefs, explicit conversions to undef from SPIR-V, and a few cases in AMDGPUToROCDL where usage like %v = insertelement <M x iN> undef, iN %v, i32 0 %arg = bitcast <M x iN> %v to i(M * N) is used to handle "i32" arguments that are are really packed vectors of smaller types that won't always be fully initialized.
2025-01-28[mlir] Fix conflict of user defined reserved functions with internal ↵Luohao Wang
prototypes (#123378) On lowering from `memref` to LLVM, `malloc` and other intrinsic functions from `libc` will be declared in the current module. User's redefinition of these reserved functions will poison the internal analysis with wrong prototype. This patch adds assertion on the found function's type and reports if it mismatch with the intended type. Related to #120950 --------- Co-authored-by: Luohao Wang <Luohaothu@users.noreply.github.com>
2025-01-21[mlir][IR][NFC] Move free-standing functions to `MemRefType` (#123465)Matthias Springer
Turn free-standing `MemRefType`-related helper functions in `BuiltinTypes.h` into member functions.
2024-10-04[mlir][memref] Fix `alloca` lowering with 0 dimensions (#111119)Matthias Springer
The `memref.alloca` lowering computed the allocation size incorrectly when there were 0 dimensions. Previously: ``` memref.alloca() : memref<10x0x2xf32> --> llvm.alloca 20xf32 ``` Now: ``` memref.alloca() : memref<10x0x2xf32> --> llvm.alloca 0xf32 ``` From the `llvm.alloca` documentation: ``` Allocating zero bytes is legal, but the returned pointer may not be unique. ```
2024-04-19[mlir][llvm] Port `overflowFlags` to a native operation property (RELAND) ↵Jeff Niu
(#89410) This PR changes the LLVM dialect's IntegerOverflowFlags to be stored on operations as native properties. Reland to fix flang
2024-04-18Revert "[mlir][llvm] Port `overflowFlags` to a native operation property" ↵Valentin Clement (バレンタイン クレメン)
(#89344) Reverts llvm/llvm-project#89312 as it breaks all flang buildbots
2024-04-18[mlir][llvm] Port `overflowFlags` to a native operation property (#89312)Jeff Niu
This PR changes the LLVM dialect's IntegerOverflowFlags to be stored on operations as native properties.
2023-11-03[MLIR][LLVM] Remove typed pointer conversion utils (#71169)Christian Ulmann
This commit removes the no longer required type pointer helpers from the LLVM dialect conversion utils. Typed pointers have been deprecated for a while now and it's planned to soon remove them from the LLVM dialect. Related PSA: https://discourse.llvm.org/t/psa-removal-of-typed-pointers-from-the-llvm-dialect/74502
2023-09-25[mlir][llvm] Replace NullOp by ZeroOp (#67183)Tobias Gysi
This revision replaces the LLVM dialect NullOp by the recently introduced ZeroOp. The ZeroOp is more generic in the sense that it represents zero values of any LLVM type rather than null pointers only. This is a follow to https://github.com/llvm/llvm-project/pull/65508
2023-08-14[mlir][Conversion] Store const type converter in ConversionPatternMatthias Springer
ConversionPatterns do not (and should not) modify the type converter that they are using. * Make `ConversionPattern::typeConverter` const. * Make member functions of the `LLVMTypeConverter` const. * Conversion patterns take a const type converter. * Various helper functions (that are called from patterns) now also take a const type converter. Differential Revision: https://reviews.llvm.org/D157601
2023-08-04Revert "Foo"Alex Zinenko
This reverts commit 3c9aa10c57cf0833ff108ecf9ffbb512bd96cc89. No proper description of the commit.
2023-08-04FooNicolas Vasilache
2023-08-02[mlir][LLVM] NFC - Remove createIndexConstant methodNicolas Vasilache
This revision removes the createIndexConstant method, which implicitly creates constants of the getIndexType type and updates all uses to the more explicit createIndexAttrConstant which requires an explicit Type parameter. This is an NFC step towards entangling index type conversion in LLVM lowering. The selection of which index type to use requires finer granularity than the existing implementations which all rely on pass level flags and end up in mismatches, especially on GPUs with multiple address spaces of different capacities. This revision also includes an NFC fix to MemRefToLLVM.cpp that prevents a crash in cases where an integer memory space cannot be derived for a MemRef. Differential Revision: https://reviews.llvm.org/D156854
2023-06-12[mlir][llvm] Ensure immediate usage in intrinsicsChristian Ulmann
This commit changes intrinsics that have immarg parameter attributes to model these parameters as attributes, instead of operands. Using operands only works if the operation is an `llvm.mlir.constant`, otherwise the exported LLVMIR is invalid. Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D151692
2023-05-22[mlir][memref] Fix num elements in lowering of memref.alloca op to LLVMFabian Mora
Fixes a mistake in the lowering of memref.alloca to llvm.alloca, as llvm.alloca uses the number of elements to allocate in the stack and not the size in bytes. Reference: LLVM IR: https://llvm.org/docs/LangRef.html#alloca-instruction LLVM MLIR: https://mlir.llvm.org/docs/Dialects/LLVM/#llvmalloca-mlirllvmallocaop Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D150705
2023-05-12[mlir] Move casting calls from methods to function callsTres Popp
The MLIR classes Type/Attribute/Operation/Op/Value support cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast functionality in addition to defining methods with the same name. This change begins the migration of uses of the method to the corresponding function call as has been decided as more consistent. Note that there still exist classes that only define methods directly, such as AffineExpr, and this does not include work currently to support a functional cast/isa call. Caveats include: - This clang-tidy script probably has more problems. - This only touches C++ code, so nothing that is being generated. Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 Implementation: This first patch was created with the following steps. The intention is to only do automated changes at first, so I waste less time if it's reverted, and so the first mass change is more clear as an example to other teams that will need to follow similar steps. Steps are described per line, as comments are removed by git: 0. Retrieve the change from the following to build clang-tidy with an additional check: https://github.com/llvm/llvm-project/compare/main...tpopp:llvm-project:tidy-cast-check 1. Build clang-tidy 2. Run clang-tidy over your entire codebase while disabling all checks and enabling the one relevant one. Run on all header files also. 3. Delete .inc files that were also modified, so the next build rebuilds them to a pure state. 4. Some changes have been deleted for the following reasons: - Some files had a variable also named cast - Some files had not included a header file that defines the cast functions - Some files are definitions of the classes that have the casting methods, so the code still refers to the method instead of the function without adding a prefix or removing the method declaration at the same time. ``` ninja -C $BUILD_DIR clang-tidy run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\ -header-filter=mlir/ mlir/* -fix rm -rf $BUILD_DIR/tools/mlir/**/*.inc git restore mlir/lib/IR mlir/lib/Dialect/DLTI/DLTI.cpp\ mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp\ mlir/lib/**/IR/\ mlir/lib/Dialect/SparseTensor/Transforms/SparseVectorization.cpp\ mlir/lib/Dialect/Vector/Transforms/LowerVectorMultiReduction.cpp\ mlir/test/lib/Dialect/Test/TestTypes.cpp\ mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp\ mlir/test/lib/Dialect/Test/TestAttributes.cpp\ mlir/unittests/TableGen/EnumsGenTest.cpp\ mlir/test/python/lib/PythonTestCAPI.cpp\ mlir/include/mlir/IR/ ``` Differential Revision: https://reviews.llvm.org/D150123
2023-04-26[MemRefToLLVM] Add a method in MemRefDescriptor to get the buffer addrQuentin Colombet
This patch pushes the computation of the start address of a memref in one place (a method in MemRefDescriptor.) This allows all the (indirect) users of this method to produce the start address in the same way. Thanks to this change, we expose more CSEs opportunities and thanks to that, the backend is able to properly find the `llvm.assume` expression related to the base address as demonstrated in the added test. Differential Revision: https://reviews.llvm.org/D148947
2023-04-13[mlir] LLVM lowering: don't use calling convention in op returnsAlex Zinenko
Conversions to the LLVM dialect have an option to use the "bare pointer" calling convention that converts memref types differently than the default convention. It has crept into the conversion of operations that are not related to calls but do require multiresult-to-struct packing. Use a similar mechanism for the latter without using the calling convention. Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D148086
2023-02-09[mlir] Handle different pointer sizes in unranked memref descriptorsKrzysztof Drewniak
The code for unranked memref descriptors assumed that sizeof(!llvm.ptr) == lizeof(!llvm.ptr<N>) for all address spaces N. This is not always true (ex. the AMDGPU compiler backend has sizeof(!llvm.ptr) = 64 bits but sizeof(!llvm.ptr<5>) = 32 bits, where address space 5 is used for stack allocations). While this is merely an overallocation in the case where a non-0 address space has pointers smaller than the default, the existing code could cause OOB memory accesses when sizeof(!llvm.ptr<N>) > sizeof(!llvm.ptr). So, add an address spaces parameter to computeSizes in order to partially resolve this class of bugs. Note that the LLVM data layout in the conversion passes is currently set to "" and not constructed from the MLIR data layout or some other source, but this could change in the future. Depends on D142159 Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D141293
2023-02-09Add generic type attribute mapping infrastructure, use it in GpuToXKrzysztof Drewniak
Remapping memory spaces is a function often needed in type conversions, most often when going to LLVM or to/from SPIR-V (a future commit), and it is possible that such remappings may become more common in the future as dialects take advantage of the more generic memory space infrastructure. Currently, memory space remappings are handled by running a special-purpose conversion pass before the main conversion that changes the address space attributes. In this commit, this approach is replaced by adding a notion of type attribute conversions TypeConverter, which is then used to convert memory space attributes. Then, we use this infrastructure throughout the *ToLLVM conversions. This has the advantage of loosing the requirements on the inputs to those passes from "all address spaces must be integers" to "all memory spaces must be convertible to integer spaces", a looser requirement that reduces the coupling between portions of MLIR. ON top of that, this change leads to the removal of most of the calls to getMemorySpaceAsInt(), bringing us closer to removing it. (A rework of the SPIR-V conversions to use this new system will be in a folowup commit.) As a note, one long-term motivation for this change is that I would eventually like to add an allocaMemorySpace key to MLIR data layouts and then call getMemRefAddressSpace(allocaMemorySpace) in the relevant *ToLLVM in order to ensure all alloca()s, whether incoming or produces during the LLVM lowering, have the correct address space for a given target. I expect that the type attribute conversion system may be useful in other contexts. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D142159
2023-02-09[mlir][FuncToLLVM] Add option for emitting opaque pointersMarkus Böck
Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179 FuncToLLVM contains some logic working with Memrefs and their lowerings and in the process creating pointer types, loads and allocas. This patch ports the code of these to be compatible with opaque pointers and adds a pass option to enable the use of opaque pointers within the pass. For the migration effort, the tests have been rewritten to use opaque pointers with dedicated test files for typed pointer support Differential Revision: https://reviews.llvm.org/D143608
2023-02-08[mlir][MemRef] Add option to `-finalize-memref-to-llvm` to emit opaque pointersMarkus Böck
This is the first patch in a series of patches part of this RFC: https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179 This patch adds the ability to lower the memref dialect to the LLVM Dialect with the use of opaque pointers instead of typed pointers. The latter are being phased out of LLVM and this patch is part of an effort to phase them out of MLIR as well. To do this, we'll need to support both typed and opaque pointers in lowering passes, to allow downstream projects to change without breakage. The gist of changes required to change a conversion pass are: * Change any `LLVM::LLVMPointerType::get` calls to NOT use an element type if opaque pointers are to be used. * Use the `build` method of `llvm.load` with the explicit result type. Since the pointer does not have an element type anymore it has to be specified explicitly. * Use the `build` method of `llvm.getelementptr` with the explicit `basePtrType`. Ditto to above, we have to now specify what the element type is so that GEP can do its indexing calculations * Use the `build` method of `llvm.alloca` with the explicit `elementType`. Ditto to the above, alloca needs to know how many bytes to allocate through the element type. * Get rid of any `llvm.bitcast`s * Adapt the tests to the above. Note that `llvm.store` changes syntax as well when using opaque pointers I'd like to note that the 3 `build` method changes work for both opaque and typed pointers, so unconditionally using the explicit element type form is always correct. For the testsuite a practical approach suggested by @ftynse was taken: I created a separate test file for testing the typed pointer lowering of Ops. This mostly comes down to checking that bitcasts have been created at the appropiate places, since these are required for typed pointer support. Differential Revision: https://reviews.llvm.org/D143268
2022-12-07[mlir][NFC] Add a new getStridesAndOffset functionQuentin Colombet
The new function is a wrapper around the regular `getStridesAndOffset` that offers a more compact way (as in writing less code) of getting the relevant information. This method is intended to be used only when it is known that the LogicalResult of the regular `getStridesAndOffset` must be "succeeded". This warpper will assert on that. Differential Revision: https://reviews.llvm.org/D139529
2022-11-21Merge kDynamicSize and kDynamicSentinel into one constant.Aliia Khasanova
resolve conflicts Differential Revision: https://reviews.llvm.org/D138282
2022-10-26[mlir][arith] Initial support for fastmath flag attributes in the Arithmetic ↵Jeremy Furtek
dialect (v2) This diff adds initial (partial) support for "fastmath" attributes for floating point operations in the arithmetic dialect. The "fastmath" attributes are implemented using a default-valued bit enum. The defined flags currently mirror the fastmath flags in the LLVM dialect (and in LLVM itself). Extending the set of flags (if necessary) is left as a future task. In this diff: - Definition of FastMathAttr as a custom attribute in the Arithmetic dialect that inherits from the EnumAttr class. - Definition of ArithFastMathInterface, which is an interface that is implemented by operations that have an arith::fastmath attribute. - Declaration of a default-valued fastmath attribute for unary and (some) binary floating point operations in the Arithmetic dialect. - Conversion code to lower arithmetic fastmath flags to LLVM fastmath flags NOT in this diff (but planned or currently in progress): - Documentation of flag meanings - Addition of FastMathAttr attributes to other dialects that might lower to the Arithmetic dialect (e.g. Math and Complex) - Folding/rewrite implementations that are enabled by fastmath flags - Specification of fastmath values from Python bindings (pending other in- progress diffs) Reviewed By: mehdi_amini, vzakhari Differential Revision: https://reviews.llvm.org/D126305
2022-08-25[mlir][LLVMIR] Fix oneToOneRewrite for zero-result opsJeff Niu
`oneToOneRewrite` segfaulted for zero result-ops because a null type was being passed to the op builders. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D132702
2022-08-11[mlir][LLVMIR] Clean up the definitions of ReturnOp/CallOpJeff Niu
2022-08-10[mlir][LLVMIR] "Modernize" Insert/ExtractValueOpJeff Niu
This patch "modernizes" the LLVM `insertvalue` and `extractvalue` operations to use DenseI64ArrayAttr, since they only require an array of indices and previously there was confusion about whether to use i32 or i64 arrays, and to use assembly format. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D131537
2022-08-09[mlir][LLVMIR] (NFC) Add convenience builders for ConstantOpJeff Niu
And clean up some of the user code
2022-08-01[mlir][flang] Make use of the new `GEPArg` builder of GEP Op to simplify codeMarkus Böck
This is the follow up on https://reviews.llvm.org/D130730 which goes through upstream code and removes creating constant values in favour of using the constant indices in GEP directly. This leads to less and more readable code and more compact IR as well. Differential Revision: https://reviews.llvm.org/D130731
2022-03-23[mlir] Make OpBuilder::createOperation to accept raw inputsChia-hung Duan
This provides a way to create an operation without manipulating OperationState directly. This is useful for creating unregistered ops. Reviewed By: rriddle, mehdi_amini Differential Revision: https://reviews.llvm.org/D120787
2022-01-12[mlir] Refactor ShapedType into an interfaceRiver Riddle
ShapedType was created in a time before interfaces, and is one of the earliest type base classes in the ecosystem. This commit refactors ShapedType into an interface, which is what it would have been if interfaces had existed at that time. The API of ShapedType and it's derived classes are essentially untouched by this refactor, with the exception being the API surrounding kDynamicIndex (which requires a sole home). For now, the API of ShapedType and its name have been kept as consistent to the current state of the world as possible (to help with potential migration churn, among other reasons). Moving forward though, we should look into potentially restructuring its API and possible its name as well (it should really have "Interface" at the end like other interfaces at the very least). One other potentially interesting note is that I've attached the ShapedType::Trait to TensorType/BaseMemRefType to act as mixins for the ShapedType API. This is kind of weird, but allows for sharing the same API (i.e. preventing API loss from the transition from base class -> Interface). This inheritance doesn't affect any of the derived classes, it is just for API mixin. Differential Revision: https://reviews.llvm.org/D116962
2022-01-07[mlir] Make it possible to directly supply constant values to LLVM GEPOpAlex Zinenko
In LLVM IR, the GEP indices that correspond to structures are required to be i32 constants. MLIR models constants as just values defined by special operations, and there is no verification that it is the case for structure indices in GEP. Furthermore, some common transformations such as control flow simplification may lead to the operands becoming non-constant. Make it possible to directly supply constant values to LLVM GEPOp to guarantee they remain constant until the translation to LLVM IR. This is not yet a requirement and the verifier is not modified, this will be introduced separately. Reviewed By: wsmoses Differential Revision: https://reviews.llvm.org/D116757
2022-01-02Apply clang-tidy fixes for performance-for-range-copy to MLIR (NFC)Mehdi Amini
2021-10-19[mlir][RFC] Refactor layout representation in MemRefTypeVladislav Vinogradov
The change is based on the proposal from the following discussion: https://llvm.discourse.group/t/rfc-memreftype-affine-maps-list-vs-single-item/3968 * Introduce `MemRefLayoutAttr` interface to get `AffineMap` from an `Attribute` (`AffineMapAttr` implements this interface). * Store layout as a single generic `MemRefLayoutAttr`. This change removes the affine map composition feature and related API. Actually, while the `MemRefType` itself supported it, almost none of the upstream can work with more than 1 affine map in `MemRefType`. The introduced `MemRefLayoutAttr` allows to re-implement this feature in a more stable way - via separate attribute class. Also the interface allows to use different layout representations rather than affine maps. For example, the described "stride + offset" form, which is currently supported in ASM parser only, can now be expressed as separate attribute. Reviewed By: ftynse, bondhugula Differential Revision: https://reviews.llvm.org/D111553
2021-07-12[MLIR][StandardToLLVM] Move `copyUnrankedDescriptors` to patternFrederik Gossen
Make the function `copyUnrankedDescriptors` accessible in `ConvertToLLVMPattern`. Differential Revision: https://reviews.llvm.org/D105810
2021-07-08[mlir] factor out ConvertToLLVMPatternAlex Zinenko
This class and classes that extend it are general utilities for any dialect that is being converted into the LLVM dialect. They are in no way specific to Standard-to-LLVM conversion and should not make their users depend on it. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D105542