[all-commits] [llvm/llvm-project] dbb864: [mlir][LLVM] Support `immargs` in LLVM_IntrOpBase ...

Benjamin Maxwell via All-commits all-commits at lists.llvm.org
Thu Nov 23 02:12:25 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dbb86433333154226233da46271e8c520e8a5119
      https://github.com/llvm/llvm-project/commit/dbb86433333154226233da46271e8c520e8a5119
  Author: Benjamin Maxwell <benjamin.maxwell at arm.com>
  Date:   2023-11-23 (Thu, 23 Nov 2023)

  Changed paths:
    M mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
    M mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
    M mlir/include/mlir/Target/LLVMIR/ModuleImport.h
    M mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
    M mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
    M mlir/lib/Target/LLVMIR/ModuleImport.cpp
    M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    M mlir/test/Target/LLVMIR/Import/intrinsic.ll

  Log Message:
  -----------
  [mlir][LLVM] Support `immargs` in LLVM_IntrOpBase intrinsics (#73013)

This extends `LLVM_IntrOpBase` so that it can be passed a list of
`immArgPositions` and a list (of the same length) of `immArgAttrNames`.
`immArgPositions` contains the positions of `immargs` on the LLVM IR
intrinsic, and `immArgAttrNames` maps those to a corresponding MLIR
attribute.

This allows modeling LLVM `immargs` as MLIR attributes, which is the
closest match semantically (and had already been done manually for the
LLVM dialect intrinsics).

This has two upsides:
* It's slightly easier to implement intrinsics with immargs now
(especially if they make use of other features, such as overloads)
* It clearly defines that `immargs` should map to attributes, before
there was no mention of `immargs` in LLVMOpBase.td, so implementing them
was unclear

This works with other features of the `LLVM_IntrOpBase`, so `immargs`
can be marked as overloaded too (which is used in some intrinsics).

As part of this patch (and to test correctness) existing intrinsics have
been updated to use these new parameters.

This also uncovered a few issues with the
`llvm.intr.vector.insert/extract` intrinsics. First, the argument order
for insert did not match the LLVM intrinsic, and secondly, both were
missing a mlirBuilder (so failed to import from LLVM IR). This is
corrected with this patch (and a test case added).




More information about the All-commits mailing list