From b25d6195ccdb5bbf5cd95572e11f8c164f45bbe5 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 4 May 2014 02:52:25 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207930 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/BuiltinsARM.def | 3 +++ lib/CodeGen/CGBuiltin.cpp | 25 ++++++++++++++++++++----- test/CodeGen/builtins-arm.c | 24 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/include/clang/Basic/BuiltinsARM.def b/include/clang/Basic/BuiltinsARM.def index 8ca93e735f..9f650cc415 100644 --- a/include/clang/Basic/BuiltinsARM.def +++ b/include/clang/Basic/BuiltinsARM.def @@ -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 diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 3800685cfe..824de8ccbb 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -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(-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(-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) { diff --git a/test/CodeGen/builtins-arm.c b/test/CodeGen/builtins-arm.c index fe04026545..c5e487aafd 100644 --- a/test/CodeGen/builtins-arm.c +++ b/test/CodeGen/builtins-arm.c @@ -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(); } -- 2.40.0