[PATCH] D30816: [OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL
Egor Churaev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 10 03:51:29 PST 2017
echuraev created this revision.
Herald added a subscriber: yaxunl.
I added a new rank to ImplicitConversionRank enum to resolve the function overload ambiguity with vector types. Rank of scalar types conversion is lower than vector splat. So, we can choose which function should we call. See test for more details.
https://reviews.llvm.org/D30816
Files:
include/clang/Sema/Overload.h
lib/Sema/SemaOverload.cpp
test/SemaOpenCL/overload-scalar-widening.cl
Index: test/SemaOpenCL/overload-scalar-widening.cl
===================================================================
--- /dev/null
+++ test/SemaOpenCL/overload-scalar-widening.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// expected-no-diagnostics
+
+typedef short short4 __attribute__((ext_vector_type(4)));
+
+short4 __attribute__ ((overloadable)) clamp(short4 x, short4 minval, short4 maxval);
+short4 __attribute__ ((overloadable)) clamp(short4 x, short minval, short maxval);
+
+void foo()
+{
+ short4 e0=0;
+ clamp(e0, 0, 255);
+}
Index: lib/Sema/SemaOverload.cpp
===================================================================
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -131,7 +131,7 @@
ICR_Conversion,
ICR_Conversion,
ICR_Conversion,
- ICR_Conversion,
+ ICR_OCL_Scalar_Widening,
ICR_Complex_Real_Conversion,
ICR_Conversion,
ICR_Conversion,
Index: include/clang/Sema/Overload.h
===================================================================
--- include/clang/Sema/Overload.h
+++ include/clang/Sema/Overload.h
@@ -98,6 +98,7 @@
ICR_Exact_Match = 0, ///< Exact Match
ICR_Promotion, ///< Promotion
ICR_Conversion, ///< Conversion
+ ICR_OCL_Scalar_Widening, ///< OpenCL Scalar Widening
ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion
ICR_Writeback_Conversion, ///< ObjC ARC writeback conversion
ICR_C_Conversion, ///< Conversion only allowed in the C standard.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30816.91308.patch
Type: text/x-patch
Size: 1582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170310/a4db86d8/attachment.bin>
More information about the cfe-commits
mailing list