diff options
author | Joey Gouly <joey.gouly@gmail.com> | 2017-02-10 15:51:11 +0000 |
---|---|---|
committer | Joey Gouly <joey.gouly@gmail.com> | 2017-02-10 15:51:11 +0000 |
commit | 588e03faa5a31ab50d1933a1448f6673c0585284 (patch) | |
tree | 2ff0cf8cab1146db428f2a9226a52f5f49b3987a | |
parent | a8716484f6d217777b39087292ce440de6fc538c (diff) |
[libclang] [OpenCL] Expose half type.
Expose the half type (fp16) through libclang and the python bindings.
It seems CXType_LastBuiltin was not updated in b2ea6d9 ("Enable
support for __float128 in Clang", 2016-04-13), so update it now.
Add an Index test for OpenCL types; in the future we will add other
OpenCL types such as images to this test.
Patch by Sven van Haastregt.
Differential Revision: https://reviews.llvm.org/D29718
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294754 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | bindings/python/clang/cindex.py | 1 | ||||
-rw-r--r-- | include/clang-c/Index.h | 3 | ||||
-rw-r--r-- | test/Index/opencl-types.cl | 24 | ||||
-rw-r--r-- | tools/libclang/CXType.cpp | 2 |
4 files changed, 29 insertions, 1 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index cf867bbf7d..48fc8b13a2 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1887,6 +1887,7 @@ TypeKind.OBJCID = TypeKind(27) TypeKind.OBJCCLASS = TypeKind(28) TypeKind.OBJCSEL = TypeKind(29) TypeKind.FLOAT128 = TypeKind(30) +TypeKind.HALF = TypeKind(31) TypeKind.COMPLEX = TypeKind(100) TypeKind.POINTER = TypeKind(101) TypeKind.BLOCKPOINTER = TypeKind(102) diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 15fde19eb9..d466fce851 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -3011,8 +3011,9 @@ enum CXTypeKind { CXType_ObjCClass = 28, CXType_ObjCSel = 29, CXType_Float128 = 30, + CXType_Half = 31, CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_ObjCSel, + CXType_LastBuiltin = CXType_Half, CXType_Complex = 100, CXType_Pointer = 101, diff --git a/test/Index/opencl-types.cl b/test/Index/opencl-types.cl new file mode 100644 index 0000000000..f15bc745a8 --- /dev/null +++ b/test/Index/opencl-types.cl @@ -0,0 +1,24 @@ +// RUN: c-index-test -test-print-type %s | FileCheck %s + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +typedef half half4 __attribute__((ext_vector_type(4))); +typedef float float4 __attribute__((ext_vector_type(4))); +typedef double double4 __attribute__((ext_vector_type(4))); + +void kernel testFloatTypes() { + half scalarHalf; + half4 vectorHalf; + float scalarFloat; + float4 vectorFloat; + double scalarDouble; + double4 vectorDouble; +} + +// CHECK: VarDecl=scalarHalf:11:8 (Definition) [type=half] [typekind=Half] [isPOD=1] +// CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] [canonicaltype=half __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1] +// CHECK: VarDecl=scalarFloat:13:9 (Definition) [type=float] [typekind=Float] [isPOD=1] +// CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] [typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1] +// CHECK: VarDecl=scalarDouble:15:10 (Definition) [type=double] [typekind=Double] [isPOD=1] +// CHECK: VarDecl=vectorDouble:16:11 (Definition) [type=double4] [typekind=Typedef] [canonicaltype=double __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1] diff --git a/tools/libclang/CXType.cpp b/tools/libclang/CXType.cpp index 2eeeba4366..54549ef1e3 100644 --- a/tools/libclang/CXType.cpp +++ b/tools/libclang/CXType.cpp @@ -48,6 +48,7 @@ static CXTypeKind GetBuiltinTypeKind(const BuiltinType *BT) { BTCASE(Long); BTCASE(LongLong); BTCASE(Int128); + BTCASE(Half); BTCASE(Float); BTCASE(Double); BTCASE(LongDouble); @@ -503,6 +504,7 @@ CXString clang_getTypeKindSpelling(enum CXTypeKind K) { TKIND(Long); TKIND(LongLong); TKIND(Int128); + TKIND(Half); TKIND(Float); TKIND(Double); TKIND(LongDouble); |