[PATCH] D59843: [PowerPC] Add support for __dcbf builtin

Ahsan Saghir via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 13:26:37 PDT 2019


saghir updated this revision to Diff 193957.
saghir added a comment.

Removed check for basic block in dcbf.ll


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59843/new/

https://reviews.llvm.org/D59843

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-cache.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/test/CodeGen/PowerPC/dcbf.ll


Index: llvm/test/CodeGen/PowerPC/dcbf.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/dcbf.ll
@@ -0,0 +1,15 @@
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s \
+; RUN:     -verify-machineinstrs -ppc-asm-full-reg-names \
+; RUN:     -ppc-vsr-nums-as-vr | FileCheck %s
+
+; Function Attrs: nounwind
+define void @dcbf_test(i8* %a) {
+entry:
+  tail call void @llvm.ppc.dcbf(i8* %a)
+; CHECK-LABEL: @dcbf_test
+; CHECK: dcbf 0, r3
+; CHECK-NEXT: blr
+ret void
+}
+
+declare void @llvm.ppc.dcbf(i8*)
Index: llvm/include/llvm/IR/IntrinsicsPowerPC.td
===================================================================
--- llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -18,7 +18,8 @@
 let TargetPrefix = "ppc" in {  // All intrinsics start with "llvm.ppc.".
   // dcba/dcbf/dcbi/dcbst/dcbt/dcbz/dcbzl(PPC970) instructions.
   def int_ppc_dcba  : Intrinsic<[], [llvm_ptr_ty], []>;
-  def int_ppc_dcbf  : Intrinsic<[], [llvm_ptr_ty], []>;
+  def int_ppc_dcbf  : GCCBuiltin<"__builtin_dcbf">,  
+                      Intrinsic<[], [llvm_ptr_ty], []>;
   def int_ppc_dcbi  : Intrinsic<[], [llvm_ptr_ty], []>;
   def int_ppc_dcbst : Intrinsic<[], [llvm_ptr_ty], []>;
   def int_ppc_dcbt  : Intrinsic<[], [llvm_ptr_ty],
Index: clang/test/CodeGen/builtins-ppc-cache.c
===================================================================
--- /dev/null
+++ clang/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*
+}
Index: clang/include/clang/Basic/BuiltinsPPC.def
===================================================================
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -478,6 +478,9 @@
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Cache built-ins
+BUILTIN(__builtin_dcbf, "vvC*", "")
+
 // FIXME: Obviously incomplete.
 
 #undef BUILTIN


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59843.193957.patch
Type: text/x-patch
Size: 2903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190405/939b6918/attachment.bin>


More information about the llvm-commits mailing list