[llvm-branch-commits] [clang] f706b87 - Alias, test cases

Albion Fung via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jun 21 19:06:57 PDT 2021


Author: Albion Fung
Date: 2021-06-09T15:13:16-05:00
New Revision: f706b87ada57d1e0c618f8f2e370a8956712c9aa

URL: https://github.com/llvm/llvm-project/commit/f706b87ada57d1e0c618f8f2e370a8956712c9aa
DIFF: https://github.com/llvm/llvm-project/commit/f706b87ada57d1e0c618f8f2e370a8956712c9aa.diff

LOG: Alias, test cases

Added: 
    clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore-64-only.c
    clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore.c

Modified: 
    clang/lib/Basic/Targets/PPC.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 2ceb0b0cbf1c9..09d89f2688827 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -367,6 +367,10 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
     Builder.defineMacro("__dcbtst", "__builtin_ppc_dcbtst");
     Builder.defineMacro("__dcbz", "__builtin_ppc_dcbz");
     Builder.defineMacro("__icbt", "__builtin_ppc_icbt");
+    Builder.defineMacro("__ldarx", "__builtin_ppc_ldarx");
+    Builder.defineMacro("__lwarx", "__builtin_ppc_lwarx");
+    Builder.defineMacro("__lharx", "__builtin_ppc_lharx");
+    Builder.defineMacro("__lbarx", "__builtin_ppc_lbarx");
   }
 };
 

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore-64-only.c b/clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore-64-only.c
new file mode 100644
index 0000000000000..1d8915c21bc3e
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore-64-only.c
@@ -0,0 +1,8 @@
+// RUN: %clang -c -O2 -S -mcpu=pwr8 %s -o - | \
+// RUN: FileCheck %s
+long test_ldarx(volatile long* a) {
+  // CHECK-LABEL: test_ldarx
+  // CHECK:       ldarx 3, 0, 3
+  // CHECK-NEXT:  blr
+  return __ldarx(a);
+}

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore.c b/clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore.c
new file mode 100644
index 0000000000000..e32e5fcab91c7
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-atomicLoadStore.c
@@ -0,0 +1,40 @@
+// RUN: %clang -mcpu=pwr8 -c -m32 -O2 -S %s -o - | \
+// RUN: FileCheck %s --check-prefix=CHECK-32
+// RUN: %clang -mcpu=pwr8 -c -m64 -O2 -S %s -o - | \
+// RUN: FileCheck %s --check-prefix=CHECK-64
+
+int test_lwarx(volatile int* a) {
+  // CHECK-64-LABEL: test_lwarx
+  // CHECK-64:       lwarx 3, 0, 3
+  // CHECK-64-NEXT:  extsw 3, 3
+  // CHECK-64-NEXT:  blr
+
+  // CHECK-32-LABEL: test_lwarx
+  // CHECK-32:       lwarx 3, 0, 3
+  // CHECK-32-NEXT:  blr
+  return __lwarx(a);
+}
+
+short test_lharx(volatile short* a) {
+  // CHECK-64-LABEL: test_lharx
+  // CHECK-64:       lharx 3, 0, 3
+  // CHECK-64-NEXT:  extsh 3, 3
+  // CHECK-64-NEXT:  blr
+
+  // CHECK-32-LABEL: test_lharx
+  // CHECK-32:       lharx 3, 0, 3
+  // CHECK-32-NEXT:  blr
+  return __lharx(a);
+}
+
+char test_lbarx(volatile char* a) {
+  // CHECK-64-LABEL: test_lbarx
+  // CHECK-64:       lbarx 3, 0, 3
+  // CHECK-64-NEXT:  clrldi 3, 3, 56
+  // CHECK-64-NEXT:  blr
+
+  // CHECK-32-LABEL: test_lbarx
+  // CHECK-32:       clrlwi 3, 3, 24
+  // CHECK-32-NEXT:  blr
+  return __lbarx(a);
+}


        


More information about the llvm-branch-commits mailing list