diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 8ae347128edb7..cc2aa952b7770 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2336,6 +2336,10 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, } } } + if (Opts.SYCL) { + Opts.NativeHalfType = 1; + Opts.NativeHalfArgsAndReturns = 1; + } Opts.HIP = IK.getLanguage() == Language::HIP; Opts.CUDA = IK.getLanguage() == Language::CUDA || Opts.HIP; diff --git a/clang/lib/Sema/SPIRVBuiltins.td b/clang/lib/Sema/SPIRVBuiltins.td index d9c81db7a9f79..8da140df48792 100644 --- a/clang/lib/Sema/SPIRVBuiltins.td +++ b/clang/lib/Sema/SPIRVBuiltins.td @@ -298,7 +298,7 @@ def Long : IntType<"long", QualType<"getIntTypeForBitwidth(64, true)", def ULong : UIntType<"ulong", QualType<"getIntTypeForBitwidth(64, false)">, 64>; def Float : FPType<"float", QualType<"FloatTy">, 32>; def Double : FPType<"double", QualType<"DoubleTy">, 64>; -def Half : FPType<"half", QualType<"Float16Ty">, 16>; +def Half : FPType<"half", QualType<"HalfTy">, 16>; def Void : Type<"void", QualType<"VoidTy">>; // FIXME: ensure this is portable... def Size : Type<"size_t", QualType<"getSizeType()">>; diff --git a/sycl/include/CL/sycl/detail/generic_type_traits.hpp b/sycl/include/CL/sycl/detail/generic_type_traits.hpp index eb8bfd53aa574..0c7bfd88dbd48 100644 --- a/sycl/include/CL/sycl/detail/generic_type_traits.hpp +++ b/sycl/include/CL/sycl/detail/generic_type_traits.hpp @@ -408,8 +408,8 @@ template struct select_cl_vector_or_scalar< T, typename std::enable_if::value>::type> { using type = - // select_cl_scalar_t returns _Float16, so, we try to instantiate vec - // class with _Float16 DataType, which is not expected there + // select_cl_scalar_t returns __fp16, so, we try to instantiate vec + // class with __fp16 DataType, which is not expected there // So, leave vector as-is vec::value, typename T::element_type, diff --git a/sycl/include/CL/sycl/half_type.hpp b/sycl/include/CL/sycl/half_type.hpp index d836af37c9698..16d635c564b0f 100644 --- a/sycl/include/CL/sycl/half_type.hpp +++ b/sycl/include/CL/sycl/half_type.hpp @@ -21,7 +21,7 @@ #ifdef __SYCL_DEVICE_ONLY__ // `constexpr` could work because the implicit conversion from `float` to -// `_Float16` can be `constexpr`. +// `__fp16` can be `constexpr`. #define __SYCL_CONSTEXPR_ON_DEVICE constexpr #else #define __SYCL_CONSTEXPR_ON_DEVICE @@ -103,8 +103,8 @@ class half; // - VecNStorageT - representation of N-element vector of halfs. Follows the // same logic as StorageT #ifdef __SYCL_DEVICE_ONLY__ - using StorageT = _Float16; - using BIsRepresentationT = _Float16; + using StorageT = __fp16; + using BIsRepresentationT = __fp16; using Vec2StorageT = StorageT __attribute__((ext_vector_type(2))); using Vec3StorageT = StorageT __attribute__((ext_vector_type(3)));