Skip to content

Commit 18bf272

Browse files
bcardosolopeslanza
authored andcommittedJan 25, 2025
[CIR] Move CIR dialect from mlir to clang
This was discussed as part of the RFC and since we are going to require some AST presence in CIR soon, implement the dialect move sooner than later.
1 parent 36181b6 commit 18bf272

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+193
-138
lines changed
 

‎clang/include/clang/CIR/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
33
include_directories(${MLIR_INCLUDE_DIR})
44
include_directories(${MLIR_TABLEGEN_OUTPUT_DIR})
55

6-
# add_subdirectory(Dialect)
6+
add_subdirectory(Dialect)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root
2+
set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir
3+
set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include)
4+
set(MLIR_TABLEGEN_EXE $<TARGET_FILE:mlir-tblgen>)
5+
include_directories(SYSTEM ${MLIR_INCLUDE_DIR})
6+
include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR})
7+
8+
add_custom_target(clang-cir-doc)
9+
10+
# This replicates part of the add_mlir_doc cmake function from MLIR that cannot
11+
# be used here. This happens because it expects to be run inside MLIR directory
12+
# which is not the case for CIR (and also FIR, both have similar workarounds).
13+
function(add_clang_mlir_doc doc_filename output_file output_directory command)
14+
set(LLVM_TARGET_DEFINITIONS ${doc_filename}.td)
15+
tablegen(MLIR ${output_file}.md ${command} ${ARGN} "-I${MLIR_MAIN_SRC_DIR}" "-I${MLIR_INCLUDE_DIR}")
16+
set(GEN_DOC_FILE ${MLIR_BINARY_DIR}/docs/${output_directory}${output_file}.md)
17+
add_custom_command(
18+
OUTPUT ${GEN_DOC_FILE}
19+
COMMAND ${CMAKE_COMMAND} -E copy
20+
${CMAKE_CURRENT_BINARY_DIR}/${output_file}.md
21+
${GEN_DOC_FILE}
22+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output_file}.md)
23+
add_custom_target(${output_file}DocGen DEPENDS ${GEN_DOC_FILE})
24+
add_dependencies(clang-cir-doc ${output_file}DocGen)
25+
endfunction()
26+
27+
add_subdirectory(IR)
28+
29+
set(LLVM_TARGET_DEFINITIONS Passes.td)
30+
mlir_tablegen(Passes.h.inc -gen-pass-decls -name CIR)
31+
mlir_tablegen(Passes.capi.h.inc -gen-pass-capi-header --prefix CIR)
32+
mlir_tablegen(Passes.capi.cpp.inc -gen-pass-capi-impl --prefix CIR)
33+
add_public_tablegen_target(MLIRCIRPassIncGen)
34+
35+
add_clang_mlir_doc(Passes CIRPasses ./ -gen-pass-doc)

0 commit comments

Comments
 (0)
Please sign in to comment.