summaryrefslogtreecommitdiffstats
path: root/libclc/generic/include/clc/math
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2012-05-29 00:42:29 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2012-05-29 00:42:29 +0000
commitd3c242ae642e3a88b5e6421b5637e48a051e8a5c (patch)
treeba204f1adcedb2cea9f66e434510bce1606aa616 /libclc/generic/include/clc/math
parent8b3721b01d0a8f364309a5c2af411434dae6c484 (diff)
downloadbcm5719-llvm-d3c242ae642e3a88b5e6421b5637e48a051e8a5c.tar.gz
bcm5719-llvm-d3c242ae642e3a88b5e6421b5637e48a051e8a5c.zip
Implement exp, exp2, log, log2, native_exp, native_exp2, native_log,
native_log2. Patch by Joshua Cranmer! llvm-svn: 157598
Diffstat (limited to 'libclc/generic/include/clc/math')
-rw-r--r--libclc/generic/include/clc/math/exp.h4
-rw-r--r--libclc/generic/include/clc/math/exp2.h6
-rw-r--r--libclc/generic/include/clc/math/log.h4
-rw-r--r--libclc/generic/include/clc/math/log2.h6
-rw-r--r--libclc/generic/include/clc/math/native_exp.h1
-rw-r--r--libclc/generic/include/clc/math/native_exp2.h1
-rw-r--r--libclc/generic/include/clc/math/native_log.h1
-rw-r--r--libclc/generic/include/clc/math/native_log2.h1
8 files changed, 24 insertions, 0 deletions
diff --git a/libclc/generic/include/clc/math/exp.h b/libclc/generic/include/clc/math/exp.h
new file mode 100644
index 00000000000..dbc4b841796
--- /dev/null
+++ b/libclc/generic/include/clc/math/exp.h
@@ -0,0 +1,4 @@
+#undef exp
+
+// exp(x) = exp2(x * log2(e)
+#define exp(val) (__clc_exp2((val) * 1.44269504f))
diff --git a/libclc/generic/include/clc/math/exp2.h b/libclc/generic/include/clc/math/exp2.h
new file mode 100644
index 00000000000..fe916338290
--- /dev/null
+++ b/libclc/generic/include/clc/math/exp2.h
@@ -0,0 +1,6 @@
+#undef exp2
+#define exp2 __clc_exp2
+
+#define FUNCTION __clc_exp2
+#define INTRINSIC "llvm.exp2"
+#include <clc/math/unary_intrin.inc>
diff --git a/libclc/generic/include/clc/math/log.h b/libclc/generic/include/clc/math/log.h
new file mode 100644
index 00000000000..644f8575c1b
--- /dev/null
+++ b/libclc/generic/include/clc/math/log.h
@@ -0,0 +1,4 @@
+#undef log
+
+// log(x) = log2(x) * (1/log2(e))
+#define log(val) (__clc_log2(val) * 0.693147181f)
diff --git a/libclc/generic/include/clc/math/log2.h b/libclc/generic/include/clc/math/log2.h
new file mode 100644
index 00000000000..d8a88422cff
--- /dev/null
+++ b/libclc/generic/include/clc/math/log2.h
@@ -0,0 +1,6 @@
+#undef log2
+#define log2 __clc_log2
+
+#define FUNCTION __clc_log2
+#define INTRINSIC "llvm.log2"
+#include <clc/math/unary_intrin.inc>
diff --git a/libclc/generic/include/clc/math/native_exp.h b/libclc/generic/include/clc/math/native_exp.h
new file mode 100644
index 00000000000..e206de66926
--- /dev/null
+++ b/libclc/generic/include/clc/math/native_exp.h
@@ -0,0 +1 @@
+#define native_exp exp
diff --git a/libclc/generic/include/clc/math/native_exp2.h b/libclc/generic/include/clc/math/native_exp2.h
new file mode 100644
index 00000000000..b6759390ee4
--- /dev/null
+++ b/libclc/generic/include/clc/math/native_exp2.h
@@ -0,0 +1 @@
+#define native_exp2 exp2
diff --git a/libclc/generic/include/clc/math/native_log.h b/libclc/generic/include/clc/math/native_log.h
new file mode 100644
index 00000000000..7805a39ed69
--- /dev/null
+++ b/libclc/generic/include/clc/math/native_log.h
@@ -0,0 +1 @@
+#define native_log log
diff --git a/libclc/generic/include/clc/math/native_log2.h b/libclc/generic/include/clc/math/native_log2.h
new file mode 100644
index 00000000000..0c692eec27f
--- /dev/null
+++ b/libclc/generic/include/clc/math/native_log2.h
@@ -0,0 +1 @@
+#define native_log2 log2
OpenPOWER on IntegriCloud