]> granicus.if.org Git - clang/commitdiff
CodeGen: complete ARM ACLE hint 8.4 support
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 4 May 2014 02:52:25 +0000 (02:52 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sun, 4 May 2014 02:52:25 +0000 (02:52 +0000)
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.

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

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

index 8ca93e735f64b2964a78f37773fd65a221eab0d3..9f650cc4154586c383e527e6127551a6b910d2e5 100644 (file)
@@ -60,6 +60,9 @@ BUILTIN(__builtin_arm_crc32cd, "UiUiLLUi", "nc")
 
 // HINT
 BUILTIN(__yield, "v", "")
+BUILTIN(__wfe, "v", "")
+BUILTIN(__wfi, "v", "")
+BUILTIN(__sev, "v", "")
 BUILTIN(__sevl, "v", "")
 
 // Data barrier
index 3800685cfefc1634d06735f53c00f3cfab1d0885..824de8ccbb95d3c43acd95fa7c029c5fa40ad81c 100644 (file)
@@ -4327,14 +4327,29 @@ 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));
+  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) {
index fe04026545f73912de47d8155cdbf8bb31d7eabe..c5e487aafd6c3347a2fc2b26d948b3362a9c81d1 100644 (file)
@@ -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();
 }