summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhsan Saghir <saghir.ibm@gmail.com>2019-04-29 23:25:33 +0000
committerAhsan Saghir <saghir.ibm@gmail.com>2019-04-29 23:25:33 +0000
commitcde6bbc766130822b7b296d84d9e03cbdd010b95 (patch)
treecc908bab3c4842edea46d576df4d4edbd7b50858
parent6eedd8523a8d0f6c4deb0a240408270ce850b59b (diff)
Add __builtin_dcbf support for PPC
Summary: This patch adds support for __builtin_dcbf for PPC. __builtin_dcbf copies the contents of a modified block from the data cache to main memory and flushes the copy from the data cache. Differential revision: https://reviews.llvm.org/D59843 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359517 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--docs/LanguageExtensions.rst25
-rw-r--r--include/clang/Basic/BuiltinsPPC.def3
-rw-r--r--test/CodeGen/builtins-ppc-cache.c47
3 files changed, 75 insertions, 0 deletions
diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst
index 0299dde887..7772bf53e8 100644
--- a/docs/LanguageExtensions.rst
+++ b/docs/LanguageExtensions.rst
@@ -2448,6 +2448,31 @@ Note that the mode argument will modulo 4, so if the integer argument is greater
than 3, it will only use the least significant two bits of the mode.
Namely, ``__builtin_setrnd(102))`` is equal to ``__builtin_setrnd(2)``.
+PowerPC cache builtins
+^^^^^^^^^^^^^^^^^^^^^^
+
+The PowerPC architecture specifies instructions implementing cache operations.
+Clang provides builtins that give direct programmer access to these cache
+instructions.
+
+Currently the following builtins are implemented in clang:
+
+``__builtin_dcbf`` copies the contents of a modified block from the data cache
+to main memory and flushes the copy from the data cache.
+
+**Syntax**:
+
+.. code-block:: c
+
+ void __dcbf(const void* addr); /* Data Cache Block Flush */
+
+**Example of Use**:
+
+.. code-block:: c
+
+ int a = 1;
+ __builtin_dcbf (&a);
+
Extensions for Static Analysis
==============================
diff --git a/include/clang/Basic/BuiltinsPPC.def b/include/clang/Basic/BuiltinsPPC.def
index 9292458462..3b6348ad7d 100644
--- a/include/clang/Basic/BuiltinsPPC.def
+++ b/include/clang/Basic/BuiltinsPPC.def
@@ -478,6 +478,9 @@ BUILTIN(__builtin_pack_vector_int128, "V1LLLiULLiULLi", "")
// Set the floating point rounding mode
BUILTIN(__builtin_setrnd, "di", "")
+// Cache built-ins
+BUILTIN(__builtin_dcbf, "vvC*", "")
+
// FIXME: Obviously incomplete.
#undef BUILTIN
diff --git a/test/CodeGen/builtins-ppc-cache.c b/test/CodeGen/builtins-ppc-cache.c
new file mode 100644
index 0000000000..81c69e97bd
--- /dev/null
+++ b/test/CodeGen/builtins-ppc-cache.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu -emit-llvm \
+// RUN: -o - %s | FileCheck %s
+
+int A;
+int B[5];
+float C;
+float D[5];
+double E;
+double F[5];
+
+void func(int a, int b[], float c, float d[], double e, double f[]) {
+ __builtin_dcbf (&a);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&A);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&b[2]);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&B[2]);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&c);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&C);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&d[2]);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&D[2]);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&e);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&E);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&f[0]);
+ // CHECK: @llvm.ppc.dcbf(i8*
+
+ __builtin_dcbf (&F[0]);
+ // CHECK: @llvm.ppc.dcbf(i8*
+}