]> granicus.if.org Git - clang/commitdiff
CodeGen: add __yield intrinsic for ARM
authorSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 25 Apr 2014 21:13:29 +0000 (21:13 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 25 Apr 2014 21:13:29 +0000 (21:13 +0000)
The __yield intrinsic generates a hint instruction to indicate that the thread
is not performing any useful operations at the moment.  This is for
compatibility with MSVC, although, the intrinsic is also part of the ACLE, and
is enabled globally as a result.

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

include/clang/Basic/BuiltinsARM.def
lib/CodeGen/CGBuiltin.cpp
test/CodeGen/builtins-arm-microsoft.c [new file with mode: 0644]

index aab9255a6d32f2475f8c7c42ca5445532a5940ab..99dbb9affa8c9e1104ab6ac954e4f8bb971c577f 100644 (file)
@@ -65,4 +65,7 @@ BUILTIN(__builtin_arm_sevl, "v", "")
 BUILTIN(__builtin_arm_dmb, "vUi", "nc")
 BUILTIN(__builtin_arm_dsb, "vUi", "nc")
 
+// MSVC
+BUILTIN(__yield, "v", "")
+
 #undef BUILTIN
index d267ecee73ed7c784243b94a6f3857ecde5455f2..56fa69aec53fa4bb8544072eada4b69ec85e1614 100644 (file)
@@ -4326,6 +4326,11 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 
 Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
                                            const CallExpr *E) {
+  if (BuiltinID == ARM::BI__yield) {
+    Function *F = CGM.getIntrinsic(Intrinsic::arm_hint);
+    return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, 1));
+  }
+
   if (BuiltinID == ARM::BI__clear_cache) {
     assert(E->getNumArgs() == 2 && "__clear_cache takes 2 arguments");
     const FunctionDecl *FD = E->getDirectCallee();
diff --git a/test/CodeGen/builtins-arm-microsoft.c b/test/CodeGen/builtins-arm-microsoft.c
new file mode 100644 (file)
index 0000000..682ec91
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple thumbv7-windows -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-eabi -emit-llvm -o - %s | FileCheck %s
+// REQUIRES: arm-registered-target
+
+void test_yield_intrinsic() {
+  __yield();
+}
+
+// CHECK: call void @llvm.arm.hint(i32 1)
+