clc: Allow bitfields

bitfields are not officially supported by Open CL but there is a clang
extension that adds support.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33576>
This commit is contained in:
Konstantin Seurer 2025-02-17 10:02:43 +01:00 committed by Marge Bot
parent ed07aab147
commit a80fab3e87
4 changed files with 10 additions and 0 deletions

View file

@ -92,6 +92,11 @@ struct clc_compile_args {
*/
const char * const *allowed_spirv_extensions;
/* Indicate that the input file tries to be compatible with C code. This
* means that for example the bit-field clang extension is enabled.
*/
bool c_compatible;
unsigned address_bits;
};

View file

@ -945,6 +945,9 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+cl_khr_global_int32_extended_atomics");
c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+cl_khr_local_int32_base_atomics");
c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+cl_khr_local_int32_extended_atomics");
if (args->c_compatible) {
c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+__cl_clang_bitfields");
}
c->getPreprocessorOpts().addMacroDef("cl_khr_expect_assume=1");
bool needs_opencl_c_h = false;

View file

@ -133,6 +133,7 @@ main(int argc, char **argv)
.source.value = map,
.args = util_dynarray_begin(&clang_args),
.num_args = util_dynarray_num_elements(&clang_args, char *),
.c_compatible = true,
};
/* Enable all features, we don't know the target here and it is the

View file

@ -151,6 +151,7 @@ impl SPIRVBin {
features: features,
use_llvm_spirv_target: false,
allowed_spirv_extensions: spirv_extensions.as_ptr(),
c_compatible: false,
address_bits: address_bits,
};
let mut msgs: Vec<String> = Vec::new();