r207275 - CodeGen: add __yield intrinsic for ARM

Saleem Abdulrasool compnerd at compnerd.org
Fri Apr 25 14:13:30 PDT 2014


Author: compnerd
Date: Fri Apr 25 16:13:29 2014
New Revision: 207275

URL: http://llvm.org/viewvc/llvm-project?rev=207275&view=rev
Log:
CodeGen: add __yield intrinsic for ARM

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.

Added:
    cfe/trunk/test/CodeGen/builtins-arm-microsoft.c
Modified:
    cfe/trunk/include/clang/Basic/BuiltinsARM.def
    cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=207275&r1=207274&r2=207275&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Fri Apr 25 16:13:29 2014
@@ -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

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=207275&r1=207274&r2=207275&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Apr 25 16:13:29 2014
@@ -4326,6 +4326,11 @@ Value *CodeGenFunction::EmitAArch64Built
 
 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();

Added: cfe/trunk/test/CodeGen/builtins-arm-microsoft.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm-microsoft.c?rev=207275&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-arm-microsoft.c (added)
+++ cfe/trunk/test/CodeGen/builtins-arm-microsoft.c Fri Apr 25 16:13:29 2014
@@ -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)
+





More information about the cfe-commits mailing list