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
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
+// MSVC
+BUILTIN(__yield, "v", "")
+
#undef BUILTIN
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();
--- /dev/null
+// 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)
+