@@ -87,11 +87,11 @@ class Type<string _Name, QualType _QTName> {
87
87
// OpenCL vector types (e.g. int2, int3, int16, float8, ...).
88
88
class VectorType<Type _Ty, int _VecWidth> : Type<_Ty.Name, _Ty.QTName> {
89
89
let VecWidth = _VecWidth;
90
+ let AccessQualifier = "";
90
91
// Inherited fields
91
92
let IsPointer = _Ty.IsPointer;
92
93
let IsConst = _Ty.IsConst;
93
94
let IsVolatile = _Ty.IsVolatile;
94
- let AccessQualifier = _Ty.AccessQualifier;
95
95
let AddrSpace = _Ty.AddrSpace;
96
96
}
97
97
@@ -129,10 +129,16 @@ class VolatileType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> {
129
129
let AddrSpace = _Ty.AddrSpace;
130
130
}
131
131
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;
135
136
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;
136
142
}
137
143
138
144
// List of Types.
@@ -221,37 +227,21 @@ def Void : Type<"void_t", QualType<"VoidTy">>;
221
227
// OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types.
222
228
// Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter.
223
229
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>>;
255
245
256
246
def Sampler : Type<"Sampler", QualType<"OCLSamplerTy">>;
257
247
def Event : Type<"Event", QualType<"OCLEventTy">>;
@@ -398,14 +388,132 @@ foreach name = ["max", "min"] in {
398
388
def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1]>;
399
389
}
400
390
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
+ }
409
517
410
518
411
519
// OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions
0 commit comments