Qt 4.8
Functions | Variables
qsimd.cpp File Reference
#include "qsimd_p.h"
#include <QByteArray>
#include <stdio.h>
#include <windows.h>

Go to the source code of this file.

Functions

static uint detectProcessorFeatures ()
 
uint qDetectCPUFeatures ()
 
void qDumpCPUFeatures ()
 

Variables

const int features_count = (sizeof features_indices - 1) / (sizeof features_indices[0])
 
static const int features_indices []
 
static const char features_string []
 

Function Documentation

◆ detectProcessorFeatures()

static uint detectProcessorFeatures ( )
inlinestatic

Definition at line 81 of file qsimd.cpp.

Referenced by qDetectCPUFeatures().

82 {
83  uint features = 0;
84 
85 #if defined (ARM)
86  if (IsProcessorFeaturePresent(PF_ARM_INTEL_WMMX)) {
87  features = IWMMXT;
88  return features;
89  }
90 #elif defined(_X86_)
91  features = 0;
92 #if defined QT_HAVE_MMX
93  if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE))
94  features |= MMX;
95 #endif
96 #if defined QT_HAVE_3DNOW
97  if (IsProcessorFeaturePresent(PF_3DNOW_INSTRUCTIONS_AVAILABLE))
98  features |= MMX3DNOW;
99 #endif
100  return features;
101 #endif
102  features = 0;
103  return features;
104 }
Definition: qsimd_p.h:212
unsigned int uint
Definition: qglobal.h:996

◆ qDetectCPUFeatures()

uint qDetectCPUFeatures ( )

Definition at line 382 of file qsimd.cpp.

Referenced by qDumpCPUFeatures(), qInitDrawhelperAsm(), qInitImageConversions(), and QJpegHandler::QJpegHandler().

383 {
384  static QBasicAtomicInt features = Q_BASIC_ATOMIC_INITIALIZER(-1);
385  if (features != -1)
386  return features;
387 
389  QByteArray disable = qgetenv("QT_NO_CPU_FEATURE");
390  if (!disable.isEmpty()) {
391  disable.prepend(' ');
392  for (int i = 0; i < features_count; ++i) {
393  if (disable.contains(features_string + features_indices[i]))
394  f &= ~(1 << i);
395  }
396  }
397 
398  features = f;
399  return features;
400 }
static const int features_indices[]
Definition: qsimd.cpp:374
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
const int features_count
Definition: qsimd.cpp:380
QByteArray & prepend(char c)
Prepends the character ch to this byte array.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
Definition: qbasicatomic.h:218
unsigned int uint
Definition: qglobal.h:996
static const char features_string[]
Definition: qsimd.cpp:357
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static uint detectProcessorFeatures()
Definition: qsimd.cpp:81
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
Definition: qbytearray.h:525

◆ qDumpCPUFeatures()

void qDumpCPUFeatures ( )

Definition at line 402 of file qsimd.cpp.

Referenced by QLibraryInfo::location().

403 {
404  uint features = qDetectCPUFeatures();
405  printf("Processor features: ");
406  for (int i = 0; i < features_count; ++i) {
407  if (features & (1 << i))
408  printf("%s", features_string + features_indices[i]);
409  }
410  puts("");
411 }
static const int features_indices[]
Definition: qsimd.cpp:374
const int features_count
Definition: qsimd.cpp:380
unsigned int uint
Definition: qglobal.h:996
uint qDetectCPUFeatures()
Definition: qsimd.cpp:382
static const char features_string[]
Definition: qsimd.cpp:357

Variable Documentation

◆ features_count

const int features_count = (sizeof features_indices - 1) / (sizeof features_indices[0])

Definition at line 380 of file qsimd.cpp.

Referenced by qDetectCPUFeatures(), and qDumpCPUFeatures().

◆ features_indices

const int features_indices[]
static
Initial value:
= {
0, 5, 13, 23, 36, 41, 47, 53,
61, 67, 73, 80, 88, 96, -1
}

Definition at line 374 of file qsimd.cpp.

Referenced by qDetectCPUFeatures(), and qDumpCPUFeatures().

◆ features_string

const char features_string[]
static
Initial value:
=
" mmx\0"
" mmxext\0"
" mmx3dnow\0"
" mmx3dnowext\0"
" sse\0"
" sse2\0"
" cmov\0"
" iwmmxt\0"
" neon\0"
" sse3\0"
" ssse3\0"
" sse4.1\0"
" sse4.2\0"
" avx\0"
"\0"

Definition at line 357 of file qsimd.cpp.

Referenced by qDetectCPUFeatures(), and qDumpCPUFeatures().