Files
clang-p2996/mlir/tools/mlir-irdl-to-cpp/CMakeLists.txt
Ivan Ho c76e2800e3 [MLIR][IRDL] Added IRDL to C++ Translation (#141248)
This PR introduces a new tool, mlir-irdl-to-cpp, that converts IRDL to
C++ definitions.

The C++ definitions allow use of the IRDL-defined dialect in MLIR C++
infrastructure, enabling the use of conversion patterns with IRDL
dialects for example. This PR also adds CMake utilities to easily
integrate the IRDL dialects into MLIR projects.

Note that most IRDL features are not supported. In general, we are only
able to define simple types and operations.

- The only type constraint supported is irdl.any.
- Variadic operands and results are not supported.
- Verifiers for the IRDL constraints are not generated.
- Attributes are not supported.

---------

Co-authored-by: Théo Degioanni <theo.degioanni.llvm.deluge062@simplelogin.fr>
Co-authored-by: Fehr Mathieu <mathieu.fehr@gmail.com>
2025-05-25 16:42:30 +02:00

29 lines
922 B
CMake

add_llvm_executable(mlir-irdl-to-cpp
mlir-irdl-to-cpp.cpp
)
mlir_target_link_libraries(mlir-irdl-to-cpp
PRIVATE
MLIRTargetIRDLToCpp
)
# Set up a native build when cross-compiling.
if(LLVM_USE_HOST_TOOLS)
build_native_tool(
mlir-irdl-to-cpp
MLIR_IRDL_TO_CPP_EXE
# Native tool must depend on target tool so that the native tool gets
# properly rebuilt when the target tool changes.
DEPENDS mlir-irdl-to-cpp
)
add_custom_target(mlir-irdl-to-cpp-host DEPENDS ${MLIR_IRDL_TO_CPP_EXE})
set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp-host)
else()
set(MLIR_IRDL_TO_CPP_EXE $<TARGET_FILE:mlir-irdl-to-cpp>)
set(MLIR_IRDL_TO_CPP_TARGET mlir-irdl-to-cpp)
endif()
# Save the executable path and target name to the cache to expose it globally.
set(MLIR_IRDL_TO_CPP_EXE "${MLIR_IRDL_TO_CPP_EXE}" CACHE INTERNAL "")
set(MLIR_IRDL_TO_CPP_TARGET "${MLIR_IRDL_TO_CPP_TARGET}" CACHE INTERNAL "")