forked from OSchip/llvm-project
[PowerPC] Support __builtin_ppc_get_timebase
GCC 4.8+ has a PowerPC-specific intrinsic, __builtin_ppc_get_timebase, to do what Clang's __builtin_readcyclecounter does. For compatibility with code that uses GCC's spelling (including glibc), support it as well. Partially fixes PR23681. llvm-svn: 246510
This commit is contained in:
parent
f4967754a5
commit
65e1e4dbe0
|
@ -17,6 +17,8 @@
|
|||
|
||||
// The format of this database matches clang/Basic/Builtins.def.
|
||||
|
||||
BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n")
|
||||
|
||||
// This is just a placeholder, the types and attributes are wrong.
|
||||
BUILTIN(__builtin_altivec_vaddcuw, "V4UiV4UiV4Ui", "")
|
||||
|
||||
|
|
|
@ -6414,6 +6414,11 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
|
|||
switch (BuiltinID) {
|
||||
default: return nullptr;
|
||||
|
||||
// __builtin_ppc_get_timebase is GCC 4.8+'s PowerPC-specific name for what we
|
||||
// call __builtin_readcyclecounter.
|
||||
case PPC::BI__builtin_ppc_get_timebase:
|
||||
return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::readcyclecounter));
|
||||
|
||||
// vec_ld, vec_lvsl, vec_lvsr
|
||||
case PPC::BI__builtin_altivec_lvx:
|
||||
case PPC::BI__builtin_altivec_lvxl:
|
||||
|
|
|
@ -7,3 +7,10 @@ void test_eh_return_data_regno()
|
|||
res = __builtin_eh_return_data_regno(0); // CHECK: store volatile i32 3
|
||||
res = __builtin_eh_return_data_regno(1); // CHECK: store volatile i32 4
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define i64 @test_builtin_ppc_get_timebase
|
||||
long long test_builtin_ppc_get_timebase() {
|
||||
// CHECK: call i64 @llvm.readcyclecounter()
|
||||
return __builtin_ppc_get_timebase();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue