10 Commits

Author SHA1 Message Date
Mehdi Amini
97fa9a1f53
Revert "Reland "[mlir][llvm] Add intrinsic arg and result attribute support (…" (#151316)
Reverts llvm/llvm-project#151125

Broke the gcc-7 build:

include/mlir/Target/LLVMIR/ModuleTranslation.h:318:34: error: no type
named 'CallBase' in namespace 'llvm'
                           llvm::CallBase *call,
                           ~~~~~~^
2025-07-30 13:50:12 +02:00
Tobias Gysi
b7bfbc0c4c
Reland "[mlir][llvm] Add intrinsic arg and result attribute support (… (#151125)
…… (#151099)

This reverts commit 2780b8f22058b35a8e70045858b87a1966df8df3 to reland
59013d44058ef423a117f95092150e16e16fdb09.

In addition to the original commit this one includes:
- This includes a bazel fix
- Use `let methods` instead of `list<InterfaceMethod> methods`

The original commit message was:

This patch extends the LLVM dialect's intrinsic infra to support
argument and result attributes. Initial support is added for the memory
intrinsics llvm.intr.memcpy, llvm.intr.memmove, and llvm.intr.memset.

Additionally, an ArgAndResultAttrsOpInterface is factored out of
CallOpInterface and CallableOpInterface, enabling operations to have
argument and result attributes without requiring them to be a call or a
callable operation.
2025-07-30 13:35:20 +02:00
Tobias Gysi
2780b8f220
Revert "[mlir][llvm] Add intrinsic arg and result attribute support (… (#151099)
…#150783)"

This reverts commit 59013d44058ef423a117f95092150e16e16fdb09.

The change breaks a flang build bot:
https://lab.llvm.org/buildbot/#/builders/207/builds/4441
2025-07-29 10:15:08 +02:00
Tobias Gysi
59013d4405
[mlir][llvm] Add intrinsic arg and result attribute support (#150783)
This patch extends the LLVM dialect's intrinsic infra to support
argument and result attributes. Initial support is added for the memory
intrinsics `llvm.intr.memcpy`, `llvm.intr.memmove`, and
`llvm.intr.memset`.

Additionally, an ArgAndResultAttrsOpInterface is factored out of
CallOpInterface and CallableOpInterface, enabling operations to have
argument and result attributes without requiring them to be a call or a
callable operation.
2025-07-29 09:19:06 +02:00
Maksim Levental
2736fbd832
[mlir][NFC] update mlir/lib create APIs (26/n) (#149933)
See https://github.com/llvm/llvm-project/pull/147168 for more info.

---------

Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
2025-07-22 08:40:42 -04:00
Kazu Hirata
38b8ef16f7
[mlir] Remove unused includes (NFC) (#147158)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-07-05 10:38:27 -07:00
Bruno Cardoso Lopes
29e4fb64b3
[MLIR][LLVM] Importer: fix void returning intrinsic calls (#138325) 2025-05-05 13:54:40 -07:00
Bruno Cardoso Lopes
5265412c13
[MLIR][LLVMIR] Import: add flag to prefer using unregistered intrinsics (#130685)
Currently, there is no common mechanism for supported intrinsics to be
generically annotated with arg and ret attributes. Since there are many
supported intrinsics around different dialects, the amount of work to
teach all them about these attributes is not trivial (though it would be
nice in the long term).

This PR adds a new flag `-prefer-unregistered-intrinsics` that can be
used alongside `--import-llvm` to always use `llvm.intrinsic_call`
during import time (ignoring dialect hooks for custom intrinsic
support).

Using this flag allow us to roundtrip the LLVM IR while eliminating a
whole set of differences coming from lack of arg/ret attributes on
supported intrinsics.

Note `convertIntrinsic` has to be moved to an implementation file
because it queries into `moduleImport` state, which is a fwd declaration
in `LLVMImportInterface.h`
2025-03-14 18:04:32 -07:00
Bruno Cardoso Lopes
2bbe30bf35
[MLIR][LLVMIR] llvm.call_intrinsic: support operand/result attributes (#129640)
Basically catch up with llvm.call and add support for translate and
import to LLVM IR.

This PR is split into two commits in case it's easier to review the
refactoring part, which comes first (happy to split the PR if
necessary).

---------

Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
2025-03-05 11:27:01 -08:00
Bruno Cardoso Lopes
db0e7c72af
Reapply [MLIR][LLVMIR] Import unregistered intrinsics via llvm.intrin… (#129174)
…sic_call

Original introduced in https://github.com/llvm/llvm-project/pull/128626,
reverted in https://github.com/llvm/llvm-project/pull/128973

Reproduced the issue on a shared lib build locally on Linux, moved
content around to satisfy both static and shared lib builds.

### Original commit message

Currently, the llvm importer can only cover intrinsics that have a first
class representation in an MLIR dialect (arm-neon, etc). This PR
introduces a fallback mechanism that allow "unregistered" intrinsics to
be imported by using the generic `llvm.intrinsic_call` operation. This
is useful in several ways:

1. Allows round-trip the LLVM dialect output lowered from other dialects
(example: ClangIR)
2. Enables MLIR-linking tools to operate on imported LLVM IR without
requiring to add new operations to dozen of different targets.

If multiple dialects implement this interface hook, the last one to
register is the one converting all unregistered intrinsics.

---------

Co-authored-by: Bruno Cardoso Lopes <bcardosolopes@users.noreply.github.com>
2025-03-02 19:18:55 -08:00