tools/qsimd.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2static int maxBasicCpuidSupported() -
3{ -
4 -
5 qintptr tmp1; -
6 int result; -
7 asm ("xchg " "%%rbx"", %1\n" -
8 "cpuid\n" -
9 "xchg " "%%rbx"", %1\n" -
10 : "=&a" (result), "=&r" (tmp1) -
11 : "0" (0) -
12 : "ecx", "edx"); -
13 return result;
executed: return result;
Execution Count:4
4
14} -
15 -
16static void cpuidFeatures01(uint &ecx, uint &edx) -
17{ -
18 -
19 qintptr tmp1; -
20 asm ("xchg " "%%rbx"", %2\n" -
21 "cpuid\n" -
22 "xchg " "%%rbx"", %2\n" -
23 : "=&c" (ecx), "=&d" (edx), "=&r" (tmp1) -
24 : "a" (1)); -
25 -
26 -
27 -
28 -
29 -
30 -
31}
executed: }
Execution Count:4
4
32 -
33 -
34 -
35 -
36 -
37static void cpuidFeatures07_00(uint &ebx) -
38{ -
39 -
40 quintptr rbx; -
41 asm ("xchg " "%%rbx"", %0\n" -
42 "cpuid\n" -
43 "xchg " "%%rbx"", %0\n" -
44 : "=&r" (rbx) -
45 : "a" (7), "c" (0) -
46 : "%edx"); -
47 ebx = rbx; -
48 -
49 -
50 -
51 -
52 -
53}
executed: }
Execution Count:4
4
54 -
55 -
56 -
57 -
58 -
59static void xgetbv(uint in, uint &eax, uint &edx) -
60{ -
61 -
62 -
63 -
64 -
65 -
66 asm (".byte 0x0F, 0x01, 0xD0" -
67 : "=a" (eax), "=d" (edx) -
68 : "c" (in)); -
69 -
70}
never executed: }
0
71 -
72static inline uint detectProcessorFeatures() -
73{ -
74 uint features = 0; -
75 int cpuidLevel = maxBasicCpuidSupported(); -
76 if (cpuidLevel < 1)
partially evaluated: cpuidLevel < 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
77 return 0;
never executed: return 0;
0
78 -
79 uint cpuid01ECX = 0, cpuid01EDX = 0; -
80 cpuidFeatures01(cpuid01ECX, cpuid01EDX); -
81 -
82 -
83 -
84 -
85 -
86 -
87 features = SSE2; -
88 -
89 -
90 -
91 if (cpuid01ECX & (1u))
partially evaluated: cpuid01ECX & (1u)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
92 features |= SSE3;
executed: features |= SSE3;
Execution Count:4
4
93 if (cpuid01ECX & (1u << 9))
partially evaluated: cpuid01ECX & (1u << 9)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
94 features |= SSSE3;
executed: features |= SSSE3;
Execution Count:4
4
95 if (cpuid01ECX & (1u << 19))
partially evaluated: cpuid01ECX & (1u << 19)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
96 features |= SSE4_1;
executed: features |= SSE4_1;
Execution Count:4
4
97 if (cpuid01ECX & (1u << 20))
partially evaluated: cpuid01ECX & (1u << 20)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
98 features |= SSE4_2;
executed: features |= SSE4_2;
Execution Count:4
4
99 if (cpuid01ECX & (1u << 25))
partially evaluated: cpuid01ECX & (1u << 25)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
100 features |= 0;
executed: features |= 0;
Execution Count:4
4
101 -
102 uint xgetbvA = 0, xgetbvD = 0; -
103 if (cpuid01ECX & (1u << 27)) {
partially evaluated: cpuid01ECX & (1u << 27)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
104 -
105 xgetbv(0, xgetbvA, xgetbvD); -
106 }
never executed: }
0
107 -
108 uint cpuid0700EBX = 0; -
109 if (cpuidLevel >= 7)
partially evaluated: cpuidLevel >= 7
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
110 cpuidFeatures07_00(cpuid0700EBX);
executed: cpuidFeatures07_00(cpuid0700EBX);
Execution Count:4
4
111 -
112 if ((xgetbvA & 6) == 6) {
partially evaluated: (xgetbvA & 6) == 6
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
113 -
114 if (cpuid01ECX & (1u << 28))
never evaluated: cpuid01ECX & (1u << 28)
0
115 features |= AVX;
never executed: features |= AVX;
0
116 -
117 if (cpuid0700EBX & (1u << 5))
never evaluated: cpuid0700EBX & (1u << 5)
0
118 features |= AVX2;
never executed: features |= AVX2;
0
119 }
never executed: }
0
120 -
121 if (cpuid0700EBX & (1u << 4))
partially evaluated: cpuid0700EBX & (1u << 4)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
122 features |= HLE;
never executed: features |= HLE;
0
123 if (cpuid0700EBX & (1u << 11))
partially evaluated: cpuid0700EBX & (1u << 11)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
124 features |= RTM;
never executed: features |= RTM;
0
125 -
126 return features;
executed: return features;
Execution Count:4
4
127} -
128static const char features_string[] = -
129 " iwmmxt\0" -
130 " neon\0" -
131 " sse2\0" -
132 " sse3\0" -
133 " ssse3\0" -
134 " sse4.1\0" -
135 " sse4.2\0" -
136 " avx\0" -
137 " avx2\0" -
138 " hle\0" -
139 " rtm\0" -
140 "\0"; -
141 -
142static const int features_indices[] = { -
143 0, 8, 14, 20, 26, 33, 41, 49, -
144 54, 60, 65, -1 -
145}; -
146 -
147 -
148static const int features_count = (sizeof features_indices - 1) / (sizeof features_indices[0]); -
149 -
150 -
151 -
152static const uint minFeature = qCompilerCpuFeatures & ~HLE; -
153QBasicAtomicInt qt_cpu_features = { (0) }; -
154 -
155void qDetectCpuFeatures() -
156{ -
157 uint f = detectProcessorFeatures(); -
158 QByteArray disable = qgetenv("QT_NO_CPU_FEATURE"); -
159 if (!disable.isEmpty()) {
partially evaluated: !disable.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
160 disable.prepend(' '); -
161 for (int i = 0; i < features_count; ++i) {
never evaluated: i < features_count
0
162 if (disable.contains(features_string + features_indices[i]))
never evaluated: disable.contains(features_string + features_indices[i])
0
163 f &= ~(1 << i);
never executed: f &= ~(1 << i);
0
164 }
never executed: }
0
165 }
never executed: }
0
166 -
167 if (minFeature != 0 && (f & minFeature) != minFeature) {
partially evaluated: minFeature != 0
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: (f & minFeature) != minFeature
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
168 uint missing = minFeature & ~f; -
169 fprintf(stderr, "Incompatible processor. This Qt build requires the following features:\n "); -
170 for (int i = 0; i < features_count; ++i) {
never evaluated: i < features_count
0
171 if (missing & (1 << i))
never evaluated: missing & (1 << i)
0
172 fprintf(stderr, "%s", features_string + features_indices[i]);
never executed: fprintf(stderr, "%s", features_string + features_indices[i]);
0
173 }
never executed: }
0
174 fprintf(stderr, "\n"); -
175 fflush(stderr); -
176 QMessageLogger("tools/qsimd.cpp", 423, __PRETTY_FUNCTION__).fatal("Aborted. Incompatible processor: missing feature 0x%x -%s.", missing, -
177 features_string + features_indices[ffs(missing) - 1]); -
178 }
never executed: }
0
179 -
180 qt_cpu_features.store(f | QSimdInitialized); -
181}
executed: }
Execution Count:4
4
182 -
183void qDumpCPUFeatures() -
184{ -
185 uint features = qCpuFeatures(); -
186 printf("Processor features: "); -
187 for (int i = 0; i < features_count; ++i) {
never evaluated: i < features_count
0
188 if (features & (1 << i))
never evaluated: features & (1 << i)
0
189 printf("%s%s", features_string + features_indices[i], 0
190 minFeature & (1 << i) ? "[required]" : "");
never executed: printf("%s%s", features_string + features_indices[i], minFeature & (1 << i) ? "[required]" : "");
0
191 }
never executed: }
0
192 puts(""); -
193}
never executed: }
0
194 -
195 -
196 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial