r213250 - Port memory barriers intrinsics to AArch64
Yi Kong
Yi.Kong at arm.com
Thu Jul 17 03:52:07 PDT 2014
Author: kongyi
Date: Thu Jul 17 05:52:06 2014
New Revision: 213250
URL: http://llvm.org/viewvc/llvm-project?rev=213250&view=rev
Log:
Port memory barriers intrinsics to AArch64
Memory barrier __builtin_arm_[dmb, dsb, isb] intrinsics are required to
implement their corresponding ACLE and MSVC intrinsics.
This patch ports ARM dmb, dsb, isb intrinsic to AArch64.
Requires LLVM r213247.
Differential Revision: http://reviews.llvm.org/D4521
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtins-arm64.c
cfe/trunk/test/Sema/builtins-arm64.c
Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=213250&r1=213249&r2=213250&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Thu Jul 17 05:52:06 2014
@@ -45,4 +45,9 @@ BUILTIN(__builtin_arm_crc32cw, "UiUiUi",
BUILTIN(__builtin_arm_crc32d, "UiUiLUi", "nc")
BUILTIN(__builtin_arm_crc32cd, "UiUiLUi", "nc")
+// Memory barrier
+BUILTIN(__builtin_arm_dmb, "vUi", "nc")
+BUILTIN(__builtin_arm_dsb, "vUi", "nc")
+BUILTIN(__builtin_arm_isb, "vUi", "nc")
+
#undef BUILTIN
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=213250&r1=213249&r2=213250&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jul 17 05:52:06 2014
@@ -645,7 +645,18 @@ bool Sema::CheckAArch64BuiltinFunctionCa
if (CheckNeonBuiltinFunctionCall(BuiltinID, TheCall))
return true;
- return false;
+ // For intrinsics which take an immediate value as part of the instruction,
+ // range check them here.
+ unsigned i = 0, l = 0, u = 0;
+ switch (BuiltinID) {
+ default: return false;
+ case AArch64::BI__builtin_arm_dmb:
+ case AArch64::BI__builtin_arm_dsb:
+ case AArch64::BI__builtin_arm_isb: l = 0; u = 15; break;
+ }
+
+ // FIXME: VFP Intrinsics should error if VFP not present.
+ return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
}
bool Sema::CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
Modified: cfe/trunk/test/CodeGen/builtins-arm64.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm64.c?rev=213250&r1=213249&r2=213250&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-arm64.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm64.c Thu Jul 17 05:52:06 2014
@@ -23,3 +23,9 @@ void hints() {
__builtin_arm_sev(); //CHECK: call {{.*}} @llvm.aarch64.hint(i32 4)
__builtin_arm_sevl(); //CHECK: call {{.*}} @llvm.aarch64.hint(i32 5)
}
+
+void barriers() {
+ __builtin_arm_dmb(1); //CHECK: call {{.*}} @llvm.aarch64.dmb(i32 1)
+ __builtin_arm_dsb(2); //CHECK: call {{.*}} @llvm.aarch64.dsb(i32 2)
+ __builtin_arm_isb(3); //CHECK: call {{.*}} @llvm.aarch64.isb(i32 3)
+}
Modified: cfe/trunk/test/Sema/builtins-arm64.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins-arm64.c?rev=213250&r1=213249&r2=213250&view=diff
==============================================================================
--- cfe/trunk/test/Sema/builtins-arm64.c (original)
+++ cfe/trunk/test/Sema/builtins-arm64.c Thu Jul 17 05:52:06 2014
@@ -16,3 +16,9 @@ void test_clear_cache_voids(void *start,
void test_clear_cache_no_args() {
__clear_cache(); // expected-error {{too few arguments to function call}}
}
+
+void test_memory_barriers() {
+ __builtin_arm_dmb(16); // expected-error {{argument should be a value from 0 to 15}}
+ __builtin_arm_dsb(17); // expected-error {{argument should be a value from 0 to 15}}
+ __builtin_arm_isb(18); // expected-error {{argument should be a value from 0 to 15}}
+}
More information about the cfe-commits
mailing list