Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10446,12 +10446,48 @@ static void getSPIRVBackendOpts(const llvm::opt::ArgList &TCArgs,
TCArgs.MakeArgString("--avoid-spirv-capabilities=Shader"));
BackendArgs.push_back(
TCArgs.MakeArgString("--translator-compatibility-mode"));
// TODO: A list of SPIR-V extensions that are supported by the SPIR-V backend
// is growing. Let's postpone the decision on which extensions to enable until
// - the list is stable, and
// - we decide on a mapping of user requested extensions into backend's ones.
// Meanwhile we enable all the SPIR-V backend extensions.
BackendArgs.push_back(TCArgs.MakeArgString("--spirv-ext=all"));

// SPIR-V backend recently started to support extensions not supported by
// drivers (e.g. SPV_KHR_float_controls2). At the same time, SPIR-V backend
// doesn't support the syntax for disabling specific extensions (i.e.
// --spirv-ext=-<extension>). We need to come up with a list of SPIR-V
// extensions that are supported by the backend, but also by the driver. Below
// is the first approach for such a list.
// FIXME: A priori, we wouldn't expect
// SPV_EXT_relaxed_printf_string_address_space to be required, but without
// it, some SYCL E2E tests fail. Let's keep it until we figure out what's
// the problem.
std::string ExtArg("-spirv-ext=");
std::string DefaultExtArg = "+SPV_EXT_relaxed_printf_string_address_space"
",+SPV_EXT_shader_atomic_float16_add"
",+SPV_EXT_shader_atomic_float_add"
",+SPV_EXT_shader_atomic_float_min_max";
std::string IntelExtArg = ",+SPV_INTEL_2d_block_io"
",+SPV_INTEL_arbitrary_precision_integers"
",+SPV_INTEL_bfloat16_conversion"
",+SPV_INTEL_bindless_images"
",+SPV_INTEL_cache_controls"
",+SPV_INTEL_float_controls2"
",+SPV_INTEL_fp_max_error"
",+SPV_INTEL_function_pointers"
",+SPV_INTEL_inline_assembly"
",+SPV_INTEL_joint_matrix"
",+SPV_INTEL_long_composites"
",+SPV_INTEL_subgroups"
",+SPV_INTEL_tensor_float32_conversion"
",+SPV_INTEL_variable_length_array";
std::string KHRExtArg = ",+SPV_KHR_16bit_storage"
",+SPV_KHR_cooperative_matrix"
",+SPV_KHR_expect_assume"
",+SPV_KHR_float_controls"
",+SPV_KHR_linkonce_odr"
",+SPV_KHR_no_integer_wrap_decoration"
",+SPV_KHR_non_semantic_info"
",+SPV_KHR_shader_clock"
",+SPV_KHR_uniform_group_instructions";
ExtArg = ExtArg + DefaultExtArg + IntelExtArg + KHRExtArg;
BackendArgs.push_back(TCArgs.MakeArgString(ExtArg));

// TODO:
// - handle -Xspirv-translator option to avoid "argument unused during
// compilation" error
Expand Down
29 changes: 28 additions & 1 deletion clang/test/Driver/sycl-spirv-backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,31 @@
///
// RUN: %clangxx -fsycl -fsycl-use-spirv-backend-for-spirv-gen -### %s 2>&1 | FileCheck %s

// CHECK: llc{{.*}} "-filetype=obj" "-mtriple=spirv64{{[^-]*}}-unknown-unknown" "--avoid-spirv-capabilities=Shader" "--translator-compatibility-mode" "--spirv-ext=
// CHECK: llc{{.*}} "-filetype=obj" "-mtriple=spirv64{{[^-]*}}-unknown-unknown" "--avoid-spirv-capabilities=Shader" "--translator-compatibility-mode" "-spirv-ext=
// CHECK-SAME: +SPV_EXT_relaxed_printf_string_address_space
// CHECK-SAME:,+SPV_EXT_shader_atomic_float16_add
// CHECK-SAME:,+SPV_EXT_shader_atomic_float_add
// CHECK-SAME:,+SPV_EXT_shader_atomic_float_min_max
// CHECK-SAME:,+SPV_INTEL_2d_block_io
// CHECK-SAME:,+SPV_INTEL_arbitrary_precision_integers
// CHECK-SAME:,+SPV_INTEL_bfloat16_conversion
// CHECK-SAME:,+SPV_INTEL_bindless_images
// CHECK-SAME:,+SPV_INTEL_cache_controls
// CHECK-SAME:,+SPV_INTEL_float_controls2
// CHECK-SAME:,+SPV_INTEL_fp_max_error
// CHECK-SAME:,+SPV_INTEL_function_pointers
// CHECK-SAME:,+SPV_INTEL_inline_assembly
// CHECK-SAME:,+SPV_INTEL_joint_matrix
// CHECK-SAME:,+SPV_INTEL_long_composites
// CHECK-SAME:,+SPV_INTEL_subgroups
// CHECK-SAME:,+SPV_INTEL_tensor_float32_conversion
// CHECK-SAME:,+SPV_INTEL_variable_length_array
// CHECK-SAME:,+SPV_KHR_16bit_storage
// CHECK-SAME:,+SPV_KHR_cooperative_matrix
// CHECK-SAME:,+SPV_KHR_expect_assume
// CHECK-SAME:,+SPV_KHR_float_controls
// CHECK-SAME:,+SPV_KHR_linkonce_odr
// CHECK-SAME:,+SPV_KHR_no_integer_wrap_decoration
// CHECK-SAME:,+SPV_KHR_non_semantic_info
// CHECK-SAME:,+SPV_KHR_shader_clock
// CHECK-SAME:,+SPV_KHR_uniform_group_instructions"
Loading