r207930 - CodeGen: complete ARM ACLE hint 8.4 support

Saleem Abdulrasool compnerd at compnerd.org
Sat May 3 19:52:25 PDT 2014


Author: compnerd
Date: Sat May  3 21:52:25 2014
New Revision: 207930

URL: http://llvm.org/viewvc/llvm-project?rev=207930&view=rev
Log:
CodeGen: complete ARM ACLE hint 8.4 support

Add support for the remaining hints from the ACLE.  Although __dbg is listed as
a hint, it is handled different, so it is not covered by this change.

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=207930&r1=207929&r2=207930&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Sat May  3 21:52:25 2014
@@ -60,6 +60,9 @@ BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi
 
 // HINT
 BUILTIN(__yield, "v", "")
+BUILTIN(__wfe, "v", "")
+BUILTIN(__wfi, "v", "")
+BUILTIN(__sev, "v", "")
 BUILTIN(__sevl, "v", "")
 
 // Data barrier

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=207930&r1=207929&r2=207930&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat May  3 21:52:25 2014
@@ -4327,14 +4327,29 @@ 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));
+  unsigned HintID = static_cast<unsigned>(-1);
+  switch (BuiltinID) {
+  default: break;
+  case ARM::BI__yield:
+    HintID = 1;
+    break;
+  case ARM::BI__wfe:
+    HintID = 2;
+    break;
+  case ARM::BI__wfi:
+    HintID = 3;
+    break;
+  case ARM::BI__sev:
+    HintID = 4;
+    break;
+  case ARM::BI__sevl:
+    HintID = 5;
+    break;
   }
 
-  if (BuiltinID == ARM::BI__sevl) {
+  if (HintID != static_cast<unsigned>(-1)) {
     Function *F = CGM.getIntrinsic(Intrinsic::arm_hint);
-    return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, 5));
+    return Builder.CreateCall(F, llvm::ConstantInt::get(Int32Ty, HintID));
   }
 
   if (BuiltinID == ARM::BI__clear_cache) {

Modified: cfe/trunk/test/CodeGen/builtins-arm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm.c?rev=207930&r1=207929&r2=207930&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-arm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-arm.c Sat May  3 21:52:25 2014
@@ -19,6 +19,30 @@ void test_eh_return_data_regno()
   res = __builtin_eh_return_data_regno(1);  // CHECK: store volatile i32 1
 }
 
+void yield() {
+  __yield();
+}
+
+// CHECK: call {{.*}} @llvm.arm.hint(i32 1)
+
+void wfe() {
+  __wfe();
+}
+
+// CHECK: call {{.*}} @llvm.arm.hint(i32 2)
+
+void wfi() {
+  __wfi();
+}
+
+// CHECK: call {{.*}} @llvm.arm.hint(i32 3)
+
+void sev() {
+  __sev();
+}
+
+// CHECK: call {{.*}} @llvm.arm.hint(i32 4)
+
 void sevl() {
   __sevl();
 }





More information about the cfe-commits mailing list