@@ -36,7 +36,7 @@ string(TOUPPER "${LLVM_ENABLE_LTO}" uppercase_LLVM_ENABLE_LTO)
3636# The following only works with the Ninja generator in CMake >= 3.0.
3737set (LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
3838 "Define the maximum number of concurrent compilation jobs (Ninja only)." )
39- if (LLVM_RAM_PER_COMPILE_JOB OR LLVM_RAM_PER_LINK_JOB)
39+ if (LLVM_RAM_PER_COMPILE_JOB OR LLVM_RAM_PER_LINK_JOB OR LLVM_RAM_PER_TABLEGEN_JOB )
4040 cmake_host_system_information (RESULT available_physical_memory QUERY AVAILABLE_PHYSICAL_MEMORY)
4141 cmake_host_system_information (RESULT number_of_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
4242endif ()
@@ -86,6 +86,28 @@ elseif(LLVM_PARALLEL_LINK_JOBS)
8686 message (WARNING "Job pooling is only available with Ninja generators." )
8787endif ()
8888
89+ set (LLVM_PARALLEL_TABLEGEN_JOBS "" CACHE STRING
90+ "Define the maximum number of concurrent tablegen jobs (Ninja only)." )
91+ if (LLVM_RAM_PER_TABLEGEN_JOB)
92+ math (EXPR jobs_with_sufficient_memory "${available_physical_memory} / ${LLVM_RAM_PER_TABLEGEN_JOB} " OUTPUT_FORMAT DECIMAL)
93+ if (jobs_with_sufficient_memory LESS 1)
94+ set (jobs_with_sufficient_memory 1)
95+ endif ()
96+ if (jobs_with_sufficient_memory LESS number_of_logical_cores)
97+ set (LLVM_PARALLEL_TABLEGEN_JOBS "${jobs_with_sufficient_memory} " )
98+ else ()
99+ set (LLVM_PARALLEL_TABLEGEN_JOBS "${number_of_logical_cores} " )
100+ endif ()
101+ endif ()
102+ if (LLVM_PARALLEL_TABLEGEN_JOBS)
103+ if (NOT CMAKE_GENERATOR MATCHES "Ninja" )
104+ message (WARNING "Job pooling is only available with Ninja generators." )
105+ else ()
106+ set_property (GLOBAL APPEND PROPERTY JOB_POOLS tablegen_job_pool=${LLVM_PARALLEL_TABLEGEN_JOBS} )
107+ # Job pool for tablegen is set on the add_custom_command
108+ endif ()
109+ endif ()
110+
89111if ( LLVM_ENABLE_ASSERTIONS )
90112 # MSVC doesn't like _DEBUG on release builds. See PR 4379.
91113 if ( NOT MSVC )
0 commit comments