r359517 - Add __builtin_dcbf support for PPC

Ahsan Saghir via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 29 16:25:33 PDT 2019


Author: saghir
Date: Mon Apr 29 16:25:33 2019
New Revision: 359517

URL: http://llvm.org/viewvc/llvm-project?rev=359517&view=rev
Log:
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

Added:
    cfe/trunk/test/CodeGen/builtins-ppc-cache.c
Modified:
    cfe/trunk/docs/LanguageExtensions.rst
    cfe/trunk/include/clang/Basic/BuiltinsPPC.def

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=359517&r1=359516&r2=359517&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Mon Apr 29 16:25:33 2019
@@ -2448,6 +2448,31 @@ Note that the mode argument will modulo
 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
 ==============================
 

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=359517&r1=359516&r2=359517&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Mon Apr 29 16:25:33 2019
@@ -478,6 +478,9 @@ BUILTIN(__builtin_pack_vector_int128, "V
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Cache built-ins
+BUILTIN(__builtin_dcbf, "vvC*", "")
+
 // FIXME: Obviously incomplete.
 
 #undef BUILTIN

Added: cfe/trunk/test/CodeGen/builtins-ppc-cache.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-cache.c?rev=359517&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-ppc-cache.c (added)
+++ cfe/trunk/test/CodeGen/builtins-ppc-cache.c Mon Apr 29 16:25:33 2019
@@ -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*
+}




More information about the cfe-commits mailing list