mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-08 01:36:47 +08:00
inline cpuid for better branch prediction
BUG=none TEST=disassembly shows 6 instructions (due to auto init) Review URL: http://webrtc-codereview.appspot.com/285001 git-svn-id: http://libyuv.googlecode.com/svn/trunk@90 16f28f9a-4ce2-e073-06de-1de4eb20be90
This commit is contained in:
parent
12d048335d
commit
3c00cf04f3
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 89
|
||||
Version: 90
|
||||
License: BSD
|
||||
License File: LICENSE
|
||||
|
||||
|
||||
@ -24,7 +24,13 @@ static const int kCpuHasNEON = 4;
|
||||
static const int kCpuInitialized = 8;
|
||||
|
||||
// Detect CPU has SSE2 etc.
|
||||
bool TestCpuFlag(int flag);
|
||||
// test_flag parameter should be one of kCpuHas constants above
|
||||
// returns non-zero if instruction set is detected
|
||||
static inline int TestCpuFlag(int test_flag) {
|
||||
extern int cpu_info_;
|
||||
extern int InitCpuFlags();
|
||||
return (cpu_info_ ? cpu_info_ : InitCpuFlags()) & test_flag;
|
||||
}
|
||||
|
||||
// For testing, allow CPU flags to be disabled.
|
||||
// ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3.
|
||||
|
||||
@ -43,10 +43,9 @@ static inline void __cpuid(int cpu_info[4], int info_type) {
|
||||
namespace libyuv {
|
||||
|
||||
// CPU detect function for SIMD instruction sets.
|
||||
static int cpu_info_ = 0;
|
||||
int cpu_info_ = 0;
|
||||
|
||||
// TODO(fbarchard): (cpu_info[2] & 0x10000000 ? kCpuHasAVX : 0)
|
||||
static void InitCpuFlags() {
|
||||
int InitCpuFlags() {
|
||||
#ifdef CPU_X86
|
||||
int cpu_info[4];
|
||||
__cpuid(cpu_info, 1);
|
||||
@ -65,6 +64,7 @@ static void InitCpuFlags() {
|
||||
#else
|
||||
cpu_info_ = kCpuInitialized;
|
||||
#endif
|
||||
return cpu_info_;
|
||||
}
|
||||
|
||||
void MaskCpuFlags(int enable_flags) {
|
||||
@ -72,11 +72,4 @@ void MaskCpuFlags(int enable_flags) {
|
||||
cpu_info_ = (cpu_info_ & enable_flags) | kCpuInitialized;
|
||||
}
|
||||
|
||||
bool TestCpuFlag(int flag) {
|
||||
if (0 == cpu_info_) {
|
||||
InitCpuFlags();
|
||||
}
|
||||
return (cpu_info_ & flag) ? true : false;
|
||||
}
|
||||
|
||||
} // namespace libyuv
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user