]> granicus.if.org Git - clang/commitdiff
[COFF, ARM64] Add MS builtins __dmb, __dsb, __isb
authorMartin Storsjo <martin@martin.st>
Thu, 12 Oct 2017 07:05:37 +0000 (07:05 +0000)
committerMartin Storsjo <martin@martin.st>
Thu, 12 Oct 2017 07:05:37 +0000 (07:05 +0000)
Differential Revision: https://reviews.llvm.org/D38821

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315567 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/BuiltinsAArch64.def
lib/Basic/Targets/AArch64.cpp
test/CodeGen/arm64-microsoft-intrinsics.c [new file with mode: 0644]

index 1db4c1471029bc99e425b00e907f1b561686fc93..55a4f70176d0086d59ec8fda4e4feb33ef442ce5 100644 (file)
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+#if defined(BUILTIN) && !defined(LANGBUILTIN)
+#   define LANGBUILTIN(ID, TYPE, ATTRS, BUILTIN_LANG) BUILTIN(ID, TYPE, ATTRS)
+#endif
+
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
@@ -61,4 +65,9 @@ BUILTIN(__builtin_arm_wsr, "vcC*Ui", "nc")
 BUILTIN(__builtin_arm_wsr64, "vcC*LUi", "nc")
 BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
 
+LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
+LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
+
 #undef BUILTIN
+#undef LANGBUILTIN
index e915d362b905e5702b79543fbeed7417e0670bde..f58bf9f277ded4fe786fb5b3eb89be5add40ec74 100644 (file)
@@ -27,6 +27,8 @@ const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = {
 
 #define BUILTIN(ID, TYPE, ATTRS)                                               \
    {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define LANGBUILTIN(ID, TYPE, ATTRS, LANG)                                     \
+  {#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
 #include "clang/Basic/BuiltinsAArch64.def"
 };
 
diff --git a/test/CodeGen/arm64-microsoft-intrinsics.c b/test/CodeGen/arm64-microsoft-intrinsics.c
new file mode 100644 (file)
index 0000000..ff802e7
--- /dev/null
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm64-windows -fms-compatibility -emit-llvm -o - %s \
+// RUN:    | FileCheck %s -check-prefix CHECK-MSVC
+
+// RUN: not %clang_cc1 -triple arm64-linux -Werror -S -o /dev/null %s 2>&1 \
+// RUN:    | FileCheck %s -check-prefix CHECK-LINUX
+
+void check__dmb(void) {
+  __dmb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dmb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dmb'
+
+void check__dsb(void) {
+  __dsb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.dsb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__dsb'
+
+void check__isb(void) {
+  __isb(0);
+}
+
+// CHECK-MSVC: @llvm.aarch64.isb(i32 0)
+// CHECK-LINUX: error: implicit declaration of function '__isb'