opencl: define size of C types

Define the size of the c types according the OpenCL specification.

Note that OpenCL does not define the size of long double. Clang generates
fp128, even though there is no extension that allows such types. The
llvm-spirv translator simply crashes.
This commit is contained in:
Robin Voetter 2023-04-10 18:01:25 +02:00
parent aa9ea61216
commit 5e62ba1347
No known key found for this signature in database
GPG Key ID: E755662F227CB468

View File

@ -2220,6 +2220,17 @@ pub const Target = struct {
.longdouble => return 128,
},
.opencl => switch (c_type) {
.char => return 8,
.short, .ushort => return 16,
.int, .uint, .float => return 32,
.long, .ulong, .double => return 64,
.longlong, .ulonglong => return 128,
// Note: The OpenCL specification does not guarantee a particular size for long double,
// but clang uses 128 bits.
.longdouble => return 128,
},
.cloudabi,
.kfreebsd,
.lv2,
@ -2234,7 +2245,6 @@ pub const Target = struct {
.contiki,
.hermit,
.hurd,
.opencl,
.glsl450,
.vulkan,
.driverkit,