Add CMake build option to generate intrinsic files.
This Cl adds an option to cmake to generate the intrinsic files as part of the buid. Change-Id: I785fbaa57b6d3b3ecd16e36b2f2baaa5da3cc9d9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108000 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@chromium.org> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
6ef419d29c
commit
c22b8b9dc8
|
@ -154,6 +154,8 @@ option_if_not_defined(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN
|
||||||
option_if_not_defined(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN})
|
option_if_not_defined(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN})
|
||||||
option_if_not_defined(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
option_if_not_defined(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
||||||
|
|
||||||
|
option_if_not_defined(TINT_BUILD_RUN_GENERATOR "Run the intrinsic generator" OFF)
|
||||||
|
|
||||||
option_if_not_defined(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
|
option_if_not_defined(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
|
||||||
option_if_not_defined(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF)
|
option_if_not_defined(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF)
|
||||||
option_if_not_defined(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF)
|
option_if_not_defined(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF)
|
||||||
|
@ -287,6 +289,7 @@ message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}")
|
||||||
message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
|
message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
|
||||||
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
|
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
|
||||||
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
|
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
|
||||||
|
message(STATUS "Tint build run generator: ${TINT_BUILD_RUN_GENERATOR}")
|
||||||
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
|
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
|
||||||
message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}")
|
message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}")
|
||||||
message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}")
|
message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}")
|
||||||
|
@ -478,6 +481,7 @@ endif()
|
||||||
function(tint_core_compile_options TARGET)
|
function(tint_core_compile_options TARGET)
|
||||||
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}")
|
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}")
|
||||||
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}/include")
|
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}/include")
|
||||||
|
target_include_directories(${TARGET} PUBLIC "${DAWN_BUILD_GEN_DIR}")
|
||||||
|
|
||||||
if (${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
if (${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
||||||
target_include_directories(${TARGET} PUBLIC
|
target_include_directories(${TARGET} PUBLIC
|
||||||
|
|
|
@ -48,8 +48,6 @@ endif()
|
||||||
|
|
||||||
set(TINT_LIB_SRCS
|
set(TINT_LIB_SRCS
|
||||||
../../include/tint/tint.h
|
../../include/tint/tint.h
|
||||||
ast/access.cc
|
|
||||||
ast/access.h
|
|
||||||
ast/alias.cc
|
ast/alias.cc
|
||||||
ast/alias.h
|
ast/alias.h
|
||||||
ast/array.cc
|
ast/array.cc
|
||||||
|
@ -79,8 +77,6 @@ set(TINT_LIB_SRCS
|
||||||
ast/break_statement.h
|
ast/break_statement.h
|
||||||
ast/builtin_attribute.cc
|
ast/builtin_attribute.cc
|
||||||
ast/builtin_attribute.h
|
ast/builtin_attribute.h
|
||||||
ast/builtin_value.cc
|
|
||||||
ast/builtin_value.h
|
|
||||||
ast/call_expression.cc
|
ast/call_expression.cc
|
||||||
ast/call_expression.h
|
ast/call_expression.h
|
||||||
ast/call_statement.cc
|
ast/call_statement.cc
|
||||||
|
@ -107,8 +103,6 @@ set(TINT_LIB_SRCS
|
||||||
ast/enable.h
|
ast/enable.h
|
||||||
ast/expression.cc
|
ast/expression.cc
|
||||||
ast/expression.h
|
ast/expression.h
|
||||||
ast/extension.cc
|
|
||||||
ast/extension.h
|
|
||||||
ast/external_texture.cc
|
ast/external_texture.cc
|
||||||
ast/external_texture.h
|
ast/external_texture.h
|
||||||
ast/f16.cc
|
ast/f16.cc
|
||||||
|
@ -186,8 +180,6 @@ set(TINT_LIB_SRCS
|
||||||
ast/statement.h
|
ast/statement.h
|
||||||
ast/static_assert.cc
|
ast/static_assert.cc
|
||||||
ast/static_assert.h
|
ast/static_assert.h
|
||||||
ast/address_space.cc
|
|
||||||
ast/address_space.h
|
|
||||||
ast/storage_texture.cc
|
ast/storage_texture.cc
|
||||||
ast/storage_texture.h
|
ast/storage_texture.h
|
||||||
ast/stride_attribute.cc
|
ast/stride_attribute.cc
|
||||||
|
@ -204,8 +196,6 @@ set(TINT_LIB_SRCS
|
||||||
ast/struct.h
|
ast/struct.h
|
||||||
ast/switch_statement.cc
|
ast/switch_statement.cc
|
||||||
ast/switch_statement.h
|
ast/switch_statement.h
|
||||||
ast/texel_format.cc
|
|
||||||
ast/texel_format.h
|
|
||||||
ast/texture.cc
|
ast/texture.cc
|
||||||
ast/texture.h
|
ast/texture.h
|
||||||
ast/traverse_expressions.h
|
ast/traverse_expressions.h
|
||||||
|
@ -283,11 +273,8 @@ set(TINT_LIB_SRCS
|
||||||
resolver/const_eval.h
|
resolver/const_eval.h
|
||||||
resolver/dependency_graph.cc
|
resolver/dependency_graph.cc
|
||||||
resolver/dependency_graph.h
|
resolver/dependency_graph.h
|
||||||
resolver/init_conv_intrinsic.cc
|
|
||||||
resolver/init_conv_intrinsic.h
|
|
||||||
resolver/intrinsic_table.cc
|
resolver/intrinsic_table.cc
|
||||||
resolver/intrinsic_table.h
|
resolver/intrinsic_table.h
|
||||||
resolver/intrinsic_table.inl
|
|
||||||
resolver/resolver.cc
|
resolver/resolver.cc
|
||||||
resolver/resolver.h
|
resolver/resolver.h
|
||||||
resolver/sem_helper.cc
|
resolver/sem_helper.cc
|
||||||
|
@ -316,8 +303,6 @@ set(TINT_LIB_SRCS
|
||||||
sem/bool.h
|
sem/bool.h
|
||||||
sem/break_if_statement.cc
|
sem/break_if_statement.cc
|
||||||
sem/break_if_statement.h
|
sem/break_if_statement.h
|
||||||
sem/builtin_type.cc
|
|
||||||
sem/builtin_type.h
|
|
||||||
sem/builtin.cc
|
sem/builtin.cc
|
||||||
sem/builtin.h
|
sem/builtin.h
|
||||||
sem/call_target.cc
|
sem/call_target.cc
|
||||||
|
@ -363,8 +348,6 @@ set(TINT_LIB_SRCS
|
||||||
sem/multisampled_texture.h
|
sem/multisampled_texture.h
|
||||||
sem/node.cc
|
sem/node.cc
|
||||||
sem/node.h
|
sem/node.h
|
||||||
sem/parameter_usage.cc
|
|
||||||
sem/parameter_usage.h
|
|
||||||
sem/pipeline_stage_set.h
|
sem/pipeline_stage_set.h
|
||||||
sem/pointer.cc
|
sem/pointer.cc
|
||||||
sem/pointer.h
|
sem/pointer.h
|
||||||
|
@ -541,6 +524,80 @@ set(TINT_LIB_SRCS
|
||||||
writer/writer.h
|
writer/writer.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
function(tint_generate TARGET)
|
||||||
|
set(IN
|
||||||
|
${PROJECT_SOURCE_DIR}/src/tint/intrinsics.def
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}.tmpl
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
COMMAND ./tools/run gen -o ${DAWN_BUILD_GEN_DIR} ${PROJECT_SOURCE_DIR}/src/tint/${TARGET}.tmpl
|
||||||
|
DEPENDS ${IN}
|
||||||
|
OUTPUT ${DAWN_BUILD_GEN_DIR}/src/tint/${TARGET}
|
||||||
|
COMMENT "Tint: Generating files for ${TARGET}"
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(tint_src_generate TARGET)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 TINT_GEN "BENCH;TEST" "" "")
|
||||||
|
tint_generate(${TARGET}.cc)
|
||||||
|
tint_generate(${TARGET}.h)
|
||||||
|
|
||||||
|
list(APPEND TINT_LIB_SRCS
|
||||||
|
${DAWN_BUILD_GEN_DIR}/src/tint/${TARGET}.cc
|
||||||
|
${DAWN_BUILD_GEN_DIR}/src/tint/${TARGET}.h
|
||||||
|
)
|
||||||
|
set(TINT_LIB_SRCS ${TINT_LIB_SRCS} PARENT_SCOPE)
|
||||||
|
|
||||||
|
if(${TINT_GEN_BENCH})
|
||||||
|
tint_generate(${TARGET}_bench.cc)
|
||||||
|
list(APPEND TINT_BENCHMARK_SRC ${DAWN_BUILD_GEN_DIR}/src/tint/${TARGET}_bench.cc)
|
||||||
|
set(TINT_BENCHMARK_SRCS ${TINT_BENCHMARK_SRCS} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
if(${TINT_GEN_TEST})
|
||||||
|
tint_generate(${TARGET}_test.cc)
|
||||||
|
list(APPEND TINT_TEST_SRCS ${DAWN_BUILD_GEN_DIR}/src/tint/${TARGET}_test.cc)
|
||||||
|
set(TINT_TEST_SRCS ${TINT_TEST_SRCS} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(${TINT_BUILD_RUN_GENERATOR})
|
||||||
|
tint_src_generate(ast/access)
|
||||||
|
tint_src_generate(ast/address_space BENCH TEST)
|
||||||
|
tint_src_generate(ast/builtin_value BENCH TEST)
|
||||||
|
tint_src_generate(ast/extension BENCH TEST)
|
||||||
|
tint_src_generate(ast/texel_format BENCH TEST)
|
||||||
|
tint_src_generate(resolver/init_conv_intrinsic)
|
||||||
|
tint_src_generate(sem/builtin_type)
|
||||||
|
tint_src_generate(sem/parameter_usage)
|
||||||
|
|
||||||
|
tint_generate(resolver/intrinsic_table.inl)
|
||||||
|
list(APPEND TINT_LIB_SRCS
|
||||||
|
${DAWN_BUILD_GEN_DIR}/src/tint/resolver/intrinsic_table.inl
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# Generated src files
|
||||||
|
list(APPEND TINT_LIB_SRCS
|
||||||
|
ast/access.cc
|
||||||
|
ast/access.h
|
||||||
|
ast/address_space.cc
|
||||||
|
ast/address_space.h
|
||||||
|
ast/builtin_value.cc
|
||||||
|
ast/builtin_value.h
|
||||||
|
ast/extension.cc
|
||||||
|
ast/extension.h
|
||||||
|
ast/texel_format.cc
|
||||||
|
ast/texel_format.h
|
||||||
|
resolver/init_conv_intrinsic.cc
|
||||||
|
resolver/init_conv_intrinsic.h
|
||||||
|
resolver/intrinsic_table.inl
|
||||||
|
sem/builtin_type.cc
|
||||||
|
sem/builtin_type.h
|
||||||
|
sem/parameter_usage.cc
|
||||||
|
sem/parameter_usage.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
list(APPEND TINT_LIB_SRCS diagnostic/printer_linux.cc)
|
list(APPEND TINT_LIB_SRCS diagnostic/printer_linux.cc)
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
|
@ -741,7 +798,6 @@ if(TINT_BUILD_TESTS)
|
||||||
ast/builtin_attribute_test.cc
|
ast/builtin_attribute_test.cc
|
||||||
ast/builtin_texture_helper_test.cc
|
ast/builtin_texture_helper_test.cc
|
||||||
ast/builtin_texture_helper_test.h
|
ast/builtin_texture_helper_test.h
|
||||||
ast/builtin_value_test.cc
|
|
||||||
ast/call_expression_test.cc
|
ast/call_expression_test.cc
|
||||||
ast/call_statement_test.cc
|
ast/call_statement_test.cc
|
||||||
ast/case_selector_test.cc
|
ast/case_selector_test.cc
|
||||||
|
@ -752,7 +808,6 @@ if(TINT_BUILD_TESTS)
|
||||||
ast/depth_texture_test.cc
|
ast/depth_texture_test.cc
|
||||||
ast/discard_statement_test.cc
|
ast/discard_statement_test.cc
|
||||||
ast/enable_test.cc
|
ast/enable_test.cc
|
||||||
ast/extension_test.cc
|
|
||||||
ast/external_texture_test.cc
|
ast/external_texture_test.cc
|
||||||
ast/f16_test.cc
|
ast/f16_test.cc
|
||||||
ast/f32_test.cc
|
ast/f32_test.cc
|
||||||
|
@ -784,7 +839,6 @@ if(TINT_BUILD_TESTS)
|
||||||
ast/sampler_test.cc
|
ast/sampler_test.cc
|
||||||
ast/stage_attribute_test.cc
|
ast/stage_attribute_test.cc
|
||||||
ast/static_assert_test.cc
|
ast/static_assert_test.cc
|
||||||
ast/address_space_test.cc
|
|
||||||
ast/storage_texture_test.cc
|
ast/storage_texture_test.cc
|
||||||
ast/stride_attribute_test.cc
|
ast/stride_attribute_test.cc
|
||||||
ast/struct_member_align_attribute_test.cc
|
ast/struct_member_align_attribute_test.cc
|
||||||
|
@ -794,7 +848,6 @@ if(TINT_BUILD_TESTS)
|
||||||
ast/struct_test.cc
|
ast/struct_test.cc
|
||||||
ast/switch_statement_test.cc
|
ast/switch_statement_test.cc
|
||||||
ast/test_helper.h
|
ast/test_helper.h
|
||||||
ast/texel_format_test.cc
|
|
||||||
ast/texture_test.cc
|
ast/texture_test.cc
|
||||||
ast/traverse_expressions_test.cc
|
ast/traverse_expressions_test.cc
|
||||||
ast/u32_test.cc
|
ast/u32_test.cc
|
||||||
|
@ -932,6 +985,16 @@ if(TINT_BUILD_TESTS)
|
||||||
writer/text_generator_test.cc
|
writer/text_generator_test.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NOT ${TINT_BUILD_RUN_GENERATOR})
|
||||||
|
# Generated test files
|
||||||
|
list(APPEND TINT_TEST_SRCS
|
||||||
|
ast/address_space_test.cc
|
||||||
|
ast/builtin_value_test.cc
|
||||||
|
ast/extension_test.cc
|
||||||
|
ast/texel_format_test.cc
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Uniformity analysis tests depend on WGSL reader
|
# Uniformity analysis tests depend on WGSL reader
|
||||||
if(${TINT_BUILD_WGSL_READER})
|
if(${TINT_BUILD_WGSL_READER})
|
||||||
list(APPEND TINT_TEST_SRCS
|
list(APPEND TINT_TEST_SRCS
|
||||||
|
@ -1349,14 +1412,21 @@ if(TINT_BUILD_BENCHMARKS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(TINT_BENCHMARK_SRC
|
set(TINT_BENCHMARK_SRC
|
||||||
"castable_bench.cc"
|
castable_bench.cc
|
||||||
"ast/extension_bench.cc"
|
bench/benchmark.cc
|
||||||
"ast/address_space_bench.cc"
|
reader/wgsl/parser_bench.cc
|
||||||
"ast/texel_format_bench.cc"
|
|
||||||
"bench/benchmark.cc"
|
|
||||||
"reader/wgsl/parser_bench.cc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(NOT ${TINT_BUILD_RUN_GENERATOR})
|
||||||
|
# Generated benchmark files
|
||||||
|
list(APPEND TINT_BENCHMARK_SRC
|
||||||
|
ast/address_space_bench.cc
|
||||||
|
ast/builtin_value_bench.cc
|
||||||
|
ast/extension_bench.cc
|
||||||
|
ast/texel_format_bench.cc
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${TINT_BUILD_GLSL_WRITER})
|
if (${TINT_BUILD_GLSL_WRITER})
|
||||||
list(APPEND TINT_BENCHMARK_SRC writer/glsl/generator_bench.cc)
|
list(APPEND TINT_BENCHMARK_SRC writer/glsl/generator_bench.cc)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -939,7 +939,9 @@ struct IntrinsicInfo {
|
||||||
OverloadInfo const* const overloads;
|
OverloadInfo const* const overloads;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "intrinsic_table.inl"
|
/// @cond IGNORE
|
||||||
|
#include "src/tint/resolver/intrinsic_table.inl"
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
/// IntrinsicPrototype describes a fully matched intrinsic.
|
/// IntrinsicPrototype describes a fully matched intrinsic.
|
||||||
struct IntrinsicPrototype {
|
struct IntrinsicPrototype {
|
||||||
|
|
Loading…
Reference in New Issue