Skip to content

Commit 988f1e3

Browse files
committedSep 5, 2019
[OpenCL] Add image type handling for builtins
Image types were previously available, but not working. This patch adds image type handling. Rename the image type definitions in the .td file to make them consistent with other type names. Use abstract types to represent the unqualified types. Instantiate access-qualified image types at the point of use using, e.g. `ImageType<Image2d, "RO">`. Add/update TableGen definitions for the read_image/write_image builtin functions. Patch by Pierre Gondois and Sven van Haastregt. Differential Revision: https://reviews.llvm.org/D63480 llvm-svn: 371046
1 parent aff45e4 commit 988f1e3

File tree

3 files changed

+248
-46
lines changed

3 files changed

+248
-46
lines changed
 

‎clang/lib/Sema/OpenCLBuiltins.td

Lines changed: 151 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ class Type<string _Name, QualType _QTName> {
8787
// OpenCL vector types (e.g. int2, int3, int16, float8, ...).
8888
class VectorType<Type _Ty, int _VecWidth> : Type<_Ty.Name, _Ty.QTName> {
8989
let VecWidth = _VecWidth;
90+
let AccessQualifier = "";
9091
// Inherited fields
9192
let IsPointer = _Ty.IsPointer;
9293
let IsConst = _Ty.IsConst;
9394
let IsVolatile = _Ty.IsVolatile;
94-
let AccessQualifier = _Ty.AccessQualifier;
9595
let AddrSpace = _Ty.AddrSpace;
9696
}
9797

@@ -129,10 +129,16 @@ class VolatileType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> {
129129
let AddrSpace = _Ty.AddrSpace;
130130
}
131131

132-
// OpenCL image types (e.g. image2d_t, ...)
133-
class ImageType<Type _Ty, QualType _QTName, string _AccessQualifier> :
134-
Type<_Ty.Name, _QTName> {
132+
// OpenCL image types (e.g. image2d).
133+
class ImageType<Type _Ty, string _AccessQualifier> :
134+
Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> {
135+
let VecWidth = 0;
135136
let AccessQualifier = _AccessQualifier;
137+
// Inherited fields
138+
let IsPointer = _Ty.IsPointer;
139+
let IsConst = _Ty.IsConst;
140+
let IsVolatile = _Ty.IsVolatile;
141+
let AddrSpace = _Ty.AddrSpace;
136142
}
137143

138144
// List of Types.
@@ -221,37 +227,21 @@ def Void : Type<"void_t", QualType<"VoidTy">>;
221227
// OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types.
222228
// Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter.
223229

224-
// OpenCL v1.2 s6.1.3: Other Built-in Data Types
225-
// These definitions with a "null" name are "abstract". They should not
226-
// be used in definitions of Builtin functions.
227-
def image2d_t : Type<"image2d_t", QualType<"null", 1>>;
228-
def image3d_t : Type<"image3d_t", QualType<"null", 1>>;
229-
def image2d_array_t : Type<"image2d_array_t", QualType<"null", 1>>;
230-
def image1d_t : Type<"image1d_t", QualType<"null", 1>>;
231-
def image1d_buffer_t : Type<"image1d_buffer_t", QualType<"null", 1>>;
232-
def image1d_array_t : Type<"image1d_array_t", QualType<"null", 1>>;
233-
// Unlike the few functions above, the following definitions can be used
234-
// in definitions of Builtin functions (they have a QualType with a name).
235-
foreach v = ["RO", "WO", "RW"] in {
236-
def image2d_#v#_t : ImageType<image2d_t,
237-
QualType<"OCLImage2d"#v#"Ty">,
238-
v>;
239-
def image3d_#v#_t : ImageType<image3d_t,
240-
QualType<"OCLImage3d"#v#"Ty">,
241-
v>;
242-
def image2d_array#v#_t : ImageType<image2d_array_t,
243-
QualType<"OCLImage2dArray"#v#"Ty">,
244-
v>;
245-
def image1d_#v#_t : ImageType<image1d_t,
246-
QualType<"OCLImage1d"#v#"Ty">,
247-
v>;
248-
def image1d_buffer#v#_t : ImageType<image1d_buffer_t,
249-
QualType<"OCLImage1dBuffer"#v#"Ty">,
250-
v>;
251-
def image1d_array#v#_t : ImageType<image1d_array_t,
252-
QualType<"OCLImage1dArray"#v#"Ty">,
253-
v>;
254-
}
230+
// OpenCL v1.0/1.2/2.0 s6.1.3: Other Built-in Data Types.
231+
// The image definitions are "abstract". They should not be used without
232+
// specifying an access qualifier (RO/WO/RW).
233+
def Image1d : Type<"Image1d", QualType<"OCLImage1d", 1>>;
234+
def Image2d : Type<"Image2d", QualType<"OCLImage2d", 1>>;
235+
def Image3d : Type<"Image3d", QualType<"OCLImage3d", 1>>;
236+
def Image1dArray : Type<"Image1dArray", QualType<"OCLImage1dArray", 1>>;
237+
def Image1dBuffer : Type<"Image1dBuffer", QualType<"OCLImage1dBuffer", 1>>;
238+
def Image2dArray : Type<"Image2dArray", QualType<"OCLImage2dArray", 1>>;
239+
def Image2dDepth : Type<"Image2dDepth", QualType<"OCLImage2dDepth", 1>>;
240+
def Image2dArrayDepth : Type<"Image2dArrayDepth", QualType<"OCLImage2dArrayDepth", 1>>;
241+
def Image2dMsaa : Type<"Image2dMsaa", QualType<"OCLImage2dMSAA", 1>>;
242+
def Image2dArrayMsaa : Type<"Image2dArrayMsaa", QualType<"OCLImage2dArrayMSAA", 1>>;
243+
def Image2dMsaaDepth : Type<"Image2dMsaaDepth", QualType<"OCLImage2dMSAADepth", 1>>;
244+
def Image2dArrayMsaaDepth : Type<"Image2dArrayMsaaDepth", QualType<"OCLImage2dArrayMSAADepth", 1>>;
255245

256246
def Sampler : Type<"Sampler", QualType<"OCLSamplerTy">>;
257247
def Event : Type<"Event", QualType<"OCLEventTy">>;
@@ -398,14 +388,132 @@ foreach name = ["max", "min"] in {
398388
def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1]>;
399389
}
400390

401-
// OpenCL v1.2 s6.12.14: Built-in Image Read Functions
402-
def read_imagef : Builtin<"read_imagef",
403-
[VectorType<Float, 4>, image2d_RO_t, VectorType<Int, 2>]>;
404-
def write_imagef : Builtin<"write_imagef",
405-
[Void,
406-
image2d_WO_t,
407-
VectorType<Int, 2>,
408-
VectorType<Float, 4>]>;
391+
//--------------------------------------------------------------------
392+
// OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14: Image Read and Write Functions
393+
// OpenCL Extension v2.0 s5.1.8 and s6.1.8: Image Read and Write Functions
394+
// --- Table 22: Image Read Functions with Samplers ---
395+
foreach imgTy = [Image1d] in {
396+
foreach coordTy = [Int, Float] in {
397+
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, coordTy]>;
398+
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, coordTy]>;
399+
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, coordTy]>;
400+
}
401+
}
402+
foreach imgTy = [Image2d, Image1dArray] in {
403+
foreach coordTy = [Int, Float] in {
404+
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>]>;
405+
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>]>;
406+
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>]>;
407+
}
408+
}
409+
foreach imgTy = [Image3d, Image2dArray] in {
410+
foreach coordTy = [Int, Float] in {
411+
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>]>;
412+
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>]>;
413+
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>]>;
414+
}
415+
}
416+
foreach coordTy = [Int, Float] in {
417+
def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, "RO">, Sampler, VectorType<coordTy, 2>]>;
418+
def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, "RO">, Sampler, VectorType<coordTy, 4>]>;
419+
}
420+
421+
// --- Table 23: Sampler-less Read Functions ---
422+
foreach aQual = ["RO", "RW"] in {
423+
foreach imgTy = [Image2d, Image1dArray] in {
424+
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>]>;
425+
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>]>;
426+
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>]>;
427+
}
428+
foreach imgTy = [Image3d, Image2dArray] in {
429+
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>]>;
430+
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>]>;
431+
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>]>;
432+
}
433+
foreach imgTy = [Image1d, Image1dBuffer] in {
434+
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, Int]>;
435+
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, Int]>;
436+
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Int]>;
437+
}
438+
def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>]>;
439+
def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>]>;
440+
}
441+
442+
// --- Table 24: Image Write Functions ---
443+
foreach aQual = ["WO", "RW"] in {
444+
foreach imgTy = [Image2d] in {
445+
def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
446+
def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
447+
def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
448+
}
449+
foreach imgTy = [Image2dArray] in {
450+
def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
451+
def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
452+
def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
453+
}
454+
foreach imgTy = [Image1d, Image1dBuffer] in {
455+
def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, Int, VectorType<Float, 4>]>;
456+
def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, Int, VectorType<Int, 4>]>;
457+
def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, Int, VectorType<UInt, 4>]>;
458+
}
459+
foreach imgTy = [Image1dArray] in {
460+
def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
461+
def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
462+
def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
463+
}
464+
foreach imgTy = [Image3d] in {
465+
def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
466+
def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
467+
def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
468+
}
469+
def : Builtin<"write_imagef", [Void, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>, Float]>;
470+
def : Builtin<"write_imagef", [Void, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>, Float]>;
471+
}
472+
473+
// OpenCL extension v2.0 s5.1.9: Built-in Image Read Functions
474+
// --- Table 8 ---
475+
foreach aQual = ["RO"] in {
476+
foreach name = ["read_imageh"] in {
477+
foreach coordTy = [Int, Float] in {
478+
foreach imgTy = [Image2d, Image1dArray] in {
479+
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 2>]>;
480+
}
481+
foreach imgTy = [Image3d, Image2dArray] in {
482+
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 4>]>;
483+
}
484+
foreach imgTy = [Image1d] in {
485+
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, coordTy]>;
486+
}
487+
}
488+
}
489+
}
490+
// OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions
491+
// --- Table 9 ---
492+
foreach aQual = ["RO", "RW"] in {
493+
foreach name = ["read_imageh"] in {
494+
foreach imgTy = [Image2d, Image1dArray] in {
495+
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>]>;
496+
}
497+
foreach imgTy = [Image3d, Image2dArray] in {
498+
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>]>;
499+
}
500+
foreach imgTy = [Image1d, Image1dBuffer] in {
501+
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Int]>;
502+
}
503+
}
504+
}
505+
// OpenCL extension v2.0 s5.1.11: Built-in Image Write Functions
506+
// --- Table 10 ---
507+
foreach aQual = ["WO", "RW"] in {
508+
foreach name = ["write_imageh"] in {
509+
def : Builtin<name, [Void, ImageType<Image2d, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
510+
def : Builtin<name, [Void, ImageType<Image2dArray, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
511+
def : Builtin<name, [Void, ImageType<Image1d, aQual>, Int, VectorType<Half, 4>]>;
512+
def : Builtin<name, [Void, ImageType<Image1dBuffer, aQual>, Int, VectorType<Half, 4>]>;
513+
def : Builtin<name, [Void, ImageType<Image1dArray, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
514+
def : Builtin<name, [Void, ImageType<Image3d, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
515+
}
516+
}
409517

410518

411519
// OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions

‎clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
// Test the -fdeclare-opencl-builtins option.
66

7+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
8+
79
// Provide typedefs when invoking clang without -finclude-default-header.
810
#ifdef NO_HEADER
911
typedef char char2 __attribute__((ext_vector_type(2)));
1012
typedef char char4 __attribute__((ext_vector_type(4)));
1113
typedef float float4 __attribute__((ext_vector_type(4)));
14+
typedef half half4 __attribute__((ext_vector_type(4)));
1215
typedef int int2 __attribute__((ext_vector_type(2)));
1316
typedef int int4 __attribute__((ext_vector_type(4)));
1417
typedef long long2 __attribute__((ext_vector_type(2)));
@@ -46,6 +49,33 @@ char4 test_int(char c, char4 c4) {
4649
return max(c4, c);
4750
}
4851

52+
kernel void basic_image_readonly(read_only image2d_t image_read_only_image2d) {
53+
int2 i2;
54+
sampler_t sampler;
55+
half4 res;
56+
float4 resf;
57+
58+
resf = read_imagef(image_read_only_image2d, i2);
59+
res = read_imageh(image_read_only_image2d, i2);
60+
res = read_imageh(image_read_only_image2d, sampler, i2);
61+
}
62+
63+
kernel void basic_image_readwrite(read_write image3d_t image_read_write_image3d) {
64+
half4 h4;
65+
int4 i4;
66+
67+
write_imageh(image_read_write_image3d, i4, h4);
68+
}
69+
70+
kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_image1d_buffer) {
71+
half4 h4;
72+
float4 f4;
73+
int i;
74+
75+
write_imagef(image_write_only_image1d_buffer, i, f4);
76+
write_imageh(image_write_only_image1d_buffer, i, h4);
77+
}
78+
4979
kernel void basic_subgroup(global uint *out) {
5080
out[0] = get_sub_group_size();
5181
}

‎clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include "llvm/ADT/StringExtras.h"
5757
#include "llvm/ADT/StringRef.h"
5858
#include "llvm/ADT/StringSet.h"
59+
#include "llvm/ADT/StringSwitch.h"
5960
#include "llvm/Support/ErrorHandling.h"
6061
#include "llvm/Support/raw_ostream.h"
6162
#include "llvm/TableGen/Error.h"
@@ -233,6 +234,13 @@ void BuiltinNameEmitter::EmitDeclarations() {
233234

234235
// Structure definitions.
235236
OS << R"(
237+
// Image access qualifier.
238+
enum OpenCLAccessQual : unsigned char {
239+
OCLAQ_None,
240+
OCLAQ_ReadOnly,
241+
OCLAQ_WriteOnly,
242+
OCLAQ_ReadWrite
243+
};
236244
237245
// Represents a return type or argument type.
238246
struct OpenCLTypeStruct {
@@ -246,6 +254,8 @@ struct OpenCLTypeStruct {
246254
const bool IsConst;
247255
// 0 if the type is not volatile.
248256
const bool IsVolatile;
257+
// Access qualifier.
258+
const OpenCLAccessQual AccessQualifier;
249259
// Address space of the pointer (if applicable).
250260
const LangAS AS;
251261
};
@@ -347,12 +357,20 @@ void BuiltinNameEmitter::GetOverloads() {
347357
void BuiltinNameEmitter::EmitTypeTable() {
348358
OS << "static const OpenCLTypeStruct TypeTable[] = {\n";
349359
for (const auto &T : TypeMap) {
350-
OS << " // " << T.second << "\n";
351-
OS << " {OCLT_" << T.first->getValueAsString("Name") << ", "
360+
const char *AccessQual =
361+
StringSwitch<const char *>(T.first->getValueAsString("AccessQualifier"))
362+
.Case("RO", "OCLAQ_ReadOnly")
363+
.Case("WO", "OCLAQ_WriteOnly")
364+
.Case("RW", "OCLAQ_ReadWrite")
365+
.Default("OCLAQ_None");
366+
367+
OS << " // " << T.second << "\n"
368+
<< " {OCLT_" << T.first->getValueAsString("Name") << ", "
352369
<< T.first->getValueAsInt("VecWidth") << ", "
353370
<< T.first->getValueAsBit("IsPointer") << ", "
354371
<< T.first->getValueAsBit("IsConst") << ", "
355372
<< T.first->getValueAsBit("IsVolatile") << ", "
373+
<< AccessQual << ", "
356374
<< T.first->getValueAsString("AddrSpace") << "},\n";
357375
}
358376
OS << "};\n\n";
@@ -455,6 +473,47 @@ static void OCL2Qual(ASTContext &Context, const OpenCLTypeStruct &Ty,
455473
// Start of switch statement over all types.
456474
OS << "\n switch (Ty.ID) {\n";
457475

476+
// Switch cases for image types (Image2d, Image3d, ...)
477+
std::vector<Record *> ImageTypes =
478+
Records.getAllDerivedDefinitions("ImageType");
479+
480+
// Map an image type name to its 3 access-qualified types (RO, WO, RW).
481+
std::map<StringRef, SmallVector<Record *, 3>> ImageTypesMap;
482+
for (auto *IT : ImageTypes) {
483+
auto Entry = ImageTypesMap.find(IT->getValueAsString("Name"));
484+
if (Entry == ImageTypesMap.end()) {
485+
SmallVector<Record *, 3> ImageList;
486+
ImageList.push_back(IT);
487+
ImageTypesMap.insert(
488+
std::make_pair(IT->getValueAsString("Name"), ImageList));
489+
} else {
490+
Entry->second.push_back(IT);
491+
}
492+
}
493+
494+
// Emit the cases for the image types. For an image type name, there are 3
495+
// corresponding QualTypes ("RO", "WO", "RW"). The "AccessQualifier" field
496+
// tells which one is needed. Emit a switch statement that puts the
497+
// corresponding QualType into "QT".
498+
for (const auto &ITE : ImageTypesMap) {
499+
OS << " case OCLT_" << ITE.first.str() << ":\n"
500+
<< " switch (Ty.AccessQualifier) {\n"
501+
<< " case OCLAQ_None:\n"
502+
<< " llvm_unreachable(\"Image without access qualifier\");\n";
503+
for (const auto &Image : ITE.second) {
504+
OS << StringSwitch<const char *>(
505+
Image->getValueAsString("AccessQualifier"))
506+
.Case("RO", " case OCLAQ_ReadOnly:\n")
507+
.Case("WO", " case OCLAQ_WriteOnly:\n")
508+
.Case("RW", " case OCLAQ_ReadWrite:\n")
509+
<< " QT.push_back(Context."
510+
<< Image->getValueAsDef("QTName")->getValueAsString("Name") << ");\n"
511+
<< " break;\n";
512+
}
513+
OS << " }\n"
514+
<< " break;\n";
515+
}
516+
458517
// Switch cases for generic types.
459518
for (const auto *GenType : Records.getAllDerivedDefinitions("GenericType")) {
460519
OS << " case OCLT_" << GenType->getValueAsString("Name") << ":\n";
@@ -495,6 +554,9 @@ static void OCL2Qual(ASTContext &Context, const OpenCLTypeStruct &Ty,
495554
StringMap<bool> TypesSeen;
496555

497556
for (const auto *T : Types) {
557+
// Check this is not an image type
558+
if (ImageTypesMap.find(T->getValueAsString("Name")) != ImageTypesMap.end())
559+
continue;
498560
// Check we have not seen this Type
499561
if (TypesSeen.find(T->getValueAsString("Name")) != TypesSeen.end())
500562
continue;
@@ -512,7 +574,9 @@ static void OCL2Qual(ASTContext &Context, const OpenCLTypeStruct &Ty,
512574
}
513575

514576
// End of switch statement.
515-
OS << " } // end of switch (Ty.ID)\n\n";
577+
OS << " default:\n"
578+
<< " llvm_unreachable(\"OpenCL builtin type not handled yet\");\n"
579+
<< " } // end of switch (Ty.ID)\n\n";
516580

517581
// Step 2.
518582
// Add ExtVector types if this was a generic type, as the switch statement

0 commit comments

Comments
 (0)
Please sign in to comment.