forked from OSchip/llvm-project
[OpenCL] Hide sampler-less read_image builtins before CL1.2
Ensure sampler-less image read functions are not available with `-fdeclare-opencl-builtins` before OpenCL 1.2.
This commit is contained in:
parent
6617529a1d
commit
526c42e76c
|
@ -1092,24 +1092,26 @@ foreach coordTy = [Int, Float] in {
|
|||
}
|
||||
|
||||
// --- Table 23: Sampler-less Read Functions ---
|
||||
foreach aQual = ["RO", "RW"] in {
|
||||
foreach imgTy = [Image2d, Image1dArray] in {
|
||||
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
let MinVersion = CL12 in {
|
||||
foreach aQual = ["RO", "RW"] in {
|
||||
foreach imgTy = [Image2d, Image1dArray] in {
|
||||
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image3d, Image2dArray] in {
|
||||
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image1d, Image1dBuffer] in {
|
||||
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
}
|
||||
def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image3d, Image2dArray] in {
|
||||
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image1d, Image1dBuffer] in {
|
||||
def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
}
|
||||
def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
}
|
||||
|
||||
// --- Table 24: Image Write Functions ---
|
||||
|
@ -1187,16 +1189,18 @@ foreach aQual = ["RO"] in {
|
|||
}
|
||||
// OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions
|
||||
// --- Table 9 ---
|
||||
foreach aQual = ["RO", "RW"] in {
|
||||
foreach name = ["read_imageh"] in {
|
||||
foreach imgTy = [Image2d, Image1dArray] in {
|
||||
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image3d, Image2dArray] in {
|
||||
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image1d, Image1dBuffer] in {
|
||||
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
let MinVersion = CL12 in {
|
||||
foreach aQual = ["RO", "RW"] in {
|
||||
foreach name = ["read_imageh"] in {
|
||||
foreach imgTy = [Image2d, Image1dArray] in {
|
||||
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image3d, Image2dArray] in {
|
||||
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
|
||||
}
|
||||
foreach imgTy = [Image1d, Image1dBuffer] in {
|
||||
def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
|
||||
|
||||
// Test that Attr.Const from OpenCLBuiltins.td is lowered to a readnone attribute.
|
||||
// CHECK-LABEL: @test_const_attr
|
||||
|
|
|
@ -113,6 +113,12 @@ kernel void basic_image_readonly(read_only image2d_t image_read_only_image2d) {
|
|||
|
||||
resf = read_imagef(image_read_only_image2d, i2);
|
||||
res = read_imageh(image_read_only_image2d, i2);
|
||||
#if __OPENCL_C_VERSION__ < CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
|
||||
// expected-error@-3{{no matching function for call to 'read_imagef'}}
|
||||
// expected-note@-4 + {{candidate function not viable}}
|
||||
// expected-error@-4{{no matching function for call to 'read_imageh'}}
|
||||
// expected-note@-5 + {{candidate function not viable}}
|
||||
#endif
|
||||
res = read_imageh(image_read_only_image2d, sampler, i2);
|
||||
|
||||
int imgWidth = get_image_width(image_read_only_image2d);
|
||||
|
|
Loading…
Reference in New Issue