@@ -23,29 +23,78 @@ using namespace jit_compiler::translation;
23
23
using namespace llvm ;
24
24
25
25
SPIRV::TranslatorOpts &SPIRVLLVMTranslator::translatorOpts () {
26
- static auto Opts = []() -> SPIRV::TranslatorOpts {
26
+ // Keep this in sync with clang/lib/Driver/ToolChains/Clang.cpp
27
+ // TODO: consider introducing a config file that both clang and jit-compiler
28
+ // could use during options setting.
29
+ std::vector<SPIRV::ExtensionID> AllowedExtensions{
30
+ SPIRV::ExtensionID::SPV_EXT_shader_atomic_float_add,
31
+ SPIRV::ExtensionID::SPV_EXT_shader_atomic_float_min_max,
32
+ SPIRV::ExtensionID::SPV_KHR_no_integer_wrap_decoration,
33
+ SPIRV::ExtensionID::SPV_KHR_float_controls,
34
+ SPIRV::ExtensionID::SPV_KHR_expect_assume,
35
+ SPIRV::ExtensionID::SPV_KHR_linkonce_odr,
36
+ SPIRV::ExtensionID::SPV_INTEL_subgroups,
37
+ SPIRV::ExtensionID::SPV_INTEL_media_block_io,
38
+ SPIRV::ExtensionID::SPV_INTEL_device_side_avc_motion_estimation,
39
+ SPIRV::ExtensionID::SPV_INTEL_fpga_loop_controls,
40
+ SPIRV::ExtensionID::SPV_INTEL_unstructured_loop_controls,
41
+ SPIRV::ExtensionID::SPV_INTEL_fpga_reg,
42
+ SPIRV::ExtensionID::SPV_INTEL_blocking_pipes,
43
+ SPIRV::ExtensionID::SPV_INTEL_function_pointers,
44
+ SPIRV::ExtensionID::SPV_INTEL_kernel_attributes,
45
+ SPIRV::ExtensionID::SPV_INTEL_io_pipes,
46
+ SPIRV::ExtensionID::SPV_INTEL_inline_assembly,
47
+ SPIRV::ExtensionID::SPV_INTEL_arbitrary_precision_integers,
48
+ SPIRV::ExtensionID::SPV_INTEL_float_controls2,
49
+ SPIRV::ExtensionID::SPV_INTEL_vector_compute,
50
+ SPIRV::ExtensionID::SPV_INTEL_fast_composite,
51
+ SPIRV::ExtensionID::SPV_INTEL_arbitrary_precision_fixed_point,
52
+ SPIRV::ExtensionID::SPV_INTEL_arbitrary_precision_floating_point,
53
+ SPIRV::ExtensionID::SPV_INTEL_variable_length_array,
54
+ SPIRV::ExtensionID::SPV_INTEL_fp_fast_math_mode,
55
+ SPIRV::ExtensionID::SPV_INTEL_long_composites,
56
+ SPIRV::ExtensionID::SPV_INTEL_arithmetic_fence,
57
+ SPIRV::ExtensionID::SPV_INTEL_global_variable_decorations,
58
+ SPIRV::ExtensionID::SPV_INTEL_cache_controls,
59
+ SPIRV::ExtensionID::SPV_INTEL_fpga_buffer_location,
60
+ SPIRV::ExtensionID::SPV_INTEL_fpga_argument_interfaces,
61
+ SPIRV::ExtensionID::SPV_INTEL_fpga_invocation_pipelining_attributes,
62
+ SPIRV::ExtensionID::SPV_INTEL_fpga_latency_control,
63
+ SPIRV::ExtensionID::SPV_KHR_shader_clock,
64
+ SPIRV::ExtensionID::SPV_INTEL_bindless_images,
65
+ SPIRV::ExtensionID::SPV_INTEL_task_sequence,
66
+ SPIRV::ExtensionID::SPV_INTEL_bfloat16_conversion,
67
+ SPIRV::ExtensionID::SPV_INTEL_joint_matrix,
68
+ SPIRV::ExtensionID::SPV_INTEL_hw_thread_queries,
69
+ SPIRV::ExtensionID::SPV_KHR_uniform_group_instructions,
70
+ SPIRV::ExtensionID::SPV_INTEL_masked_gather_scatter,
71
+ SPIRV::ExtensionID::SPV_INTEL_tensor_float32_conversion,
72
+ SPIRV::ExtensionID::SPV_INTEL_optnone,
73
+ SPIRV::ExtensionID::SPV_KHR_non_semantic_info,
74
+ SPIRV::ExtensionID::SPV_KHR_cooperative_matrix,
75
+ SPIRV::ExtensionID::SPV_EXT_shader_atomic_float16_add,
76
+ SPIRV::ExtensionID::SPV_INTEL_fp_max_error};
77
+
78
+ static auto Opts = [&]() -> SPIRV::TranslatorOpts {
27
79
// Options for translation between SPIR-V and LLVM IR.
28
- // Set SPIRV-V 1.4 as the maximum version number for now.
80
+ // Set SPIRV-V 1.5 as the maximum version number for now.
29
81
// Note that some parts of the code depend on the available builtins, e.g.,
30
82
// passes/kernel-fusion/Builtins.cpp, so updating the SPIR-V version should
31
83
// involve revisiting that code.
32
- SPIRV::TranslatorOpts TransOpt{SPIRV::VersionNumber::SPIRV_1_4 };
84
+ SPIRV::TranslatorOpts TransOpt{SPIRV::VersionNumber::SPIRV_1_5 };
33
85
// Enable attachment of kernel arg names as metadata.
34
86
TransOpt.enableGenArgNameMD ();
35
87
// Enable mem2reg.
36
88
TransOpt.setMemToRegEnabled (true );
37
- // Enable all extensions.
38
- // TODO: Specifically enable only the
39
- // extensions listed in the KernelInfo.
40
- // FIXME: Because there's no size provided,
41
- // there's currently no obvious way to iterate the
42
- // array of extensions in KernelInfo.
43
- TransOpt.enableAllExtensions ();
44
- // TODO: Remove this workaround.
45
- TransOpt.setAllowedToUseExtension (
46
- SPIRV::ExtensionID::SPV_KHR_untyped_pointers, false );
89
+ for (auto &Ext : AllowedExtensions)
90
+ TransOpt.setAllowedToUseExtension (Ext, true );
47
91
TransOpt.setDesiredBIsRepresentation (
48
92
SPIRV::BIsRepresentation::SPIRVFriendlyIR);
93
+ TransOpt.setDebugInfoEIS (
94
+ SPIRV::DebugInfoEIS::NonSemantic_Shader_DebugInfo_200);
95
+ const llvm::SmallVector<llvm::StringRef, 4 > AllowedIntrinsics = {
96
+ " llvm.genx." };
97
+ TransOpt.setSPIRVAllowUnknownIntrinsics (AllowedIntrinsics);
49
98
// TODO: We need to take care of specialization constants, either by
50
99
// instantiating them by the user-supplied value from the SYCL runtime or by
51
100
// making sure they are correctly represented in the output of the fusion
0 commit comments