[libclc] r317932 - native_log2: Switch to generic native intrinsic inc file
Jan Vesely via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 10 14:16:15 PST 2017
Author: jvesely
Date: Fri Nov 10 14:16:15 2017
New Revision: 317932
URL: http://llvm.org/viewvc/llvm-project?rev=317932&view=rev
Log:
native_log2: Switch to generic native intrinsic inc file
v2: Add __CLC_XCONCAT instead of function name redirection
Use __CLC_XCONCAT for intrinsic functions as well
Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
Added:
libclc/trunk/generic/include/utils.h
libclc/trunk/generic/lib/math/native_unary_intrinsic.inc
- copied, changed from r317260, libclc/trunk/generic/lib/math/native_log2.inc
Removed:
libclc/trunk/generic/lib/math/native_log2.inc
Modified:
libclc/trunk/generic/lib/math/native_log2.cl
Added: libclc/trunk/generic/include/utils.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/utils.h?rev=317932&view=auto
==============================================================================
--- libclc/trunk/generic/include/utils.h (added)
+++ libclc/trunk/generic/include/utils.h Fri Nov 10 14:16:15 2017
@@ -0,0 +1,10 @@
+#ifndef __CLC_UTILS_H_
+#define __CLC_UTILS_H_
+
+#define __CLC_CONCAT(x, y) x ## y
+#define __CLC_XCONCAT(x, y) __CLC_CONCAT(x, y)
+
+#define __CLC_STR(x) #x
+#define __CLC_XSTR(x) __CLC_STR(x)
+
+#endif
Modified: libclc/trunk/generic/lib/math/native_log2.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/native_log2.cl?rev=317932&r1=317931&r2=317932&view=diff
==============================================================================
--- libclc/trunk/generic/lib/math/native_log2.cl (original)
+++ libclc/trunk/generic/lib/math/native_log2.cl Fri Nov 10 14:16:15 2017
@@ -22,11 +22,7 @@
#include <clc/clc.h>
-#define __CLC_FUNCTION __clc_native_log2
-#define __CLC_INTRINSIC "llvm.log2"
-#undef cl_khr_fp64
-#include <clc/math/unary_intrin.inc>
-
-#define __CLC_BODY <native_log2.inc>
+#define __CLC_NATIVE_INTRINSIC log2
+#define __CLC_BODY <native_unary_intrinsic.inc>
#define __FLOAT_ONLY
#include <clc/math/gentype.inc>
Removed: libclc/trunk/generic/lib/math/native_log2.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/native_log2.inc?rev=317931&view=auto
==============================================================================
--- libclc/trunk/generic/lib/math/native_log2.inc (original)
+++ libclc/trunk/generic/lib/math/native_log2.inc (removed)
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2014,2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log2(__CLC_GENTYPE val) {
- return __clc_native_log2(val);
-}
Copied: libclc/trunk/generic/lib/math/native_unary_intrinsic.inc (from r317260, libclc/trunk/generic/lib/math/native_log2.inc)
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/native_unary_intrinsic.inc?p2=libclc/trunk/generic/lib/math/native_unary_intrinsic.inc&p1=libclc/trunk/generic/lib/math/native_log2.inc&r1=317260&r2=317932&rev=317932&view=diff
==============================================================================
--- libclc/trunk/generic/lib/math/native_log2.inc (original)
+++ libclc/trunk/generic/lib/math/native_unary_intrinsic.inc Fri Nov 10 14:16:15 2017
@@ -20,6 +20,21 @@
* THE SOFTWARE.
*/
-_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE native_log2(__CLC_GENTYPE val) {
- return __clc_native_log2(val);
+#include <utils.h>
+
+#ifdef __CLC_SCALAR
+#define __CLC_FUNCTION __CLC_XCONCAT(__clc_native_, __CLC_NATIVE_INTRINSIC)
+#define __CLC_INTRINSIC "llvm." __CLC_XSTR(__CLC_NATIVE_INTRINSIC)
+
+#undef cl_khr_fp64
+#include <clc/math/unary_intrin.inc>
+
+#endif
+
+#define __CLC_FUNCTION __CLC_XCONCAT(native_, __CLC_NATIVE_INTRINSIC)
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE val) {
+ return __CLC_XCONCAT(__clc_native_, __CLC_NATIVE_INTRINSIC)(val);
}
+
+#undef __CLC_FUNCTION
More information about the cfe-commits
mailing list