Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: src/base/cpu.cc

Issue 757503002: [x64] Introduce FMA3 instructions on scalar data elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/cpu.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/cpu.h" 5 #include "src/base/cpu.h"
6 6
7 #if V8_LIBC_MSVCRT 7 #if V8_LIBC_MSVCRT
8 #include <intrin.h> // __cpuid() 8 #include <intrin.h> // __cpuid()
9 #endif 9 #endif
10 #if V8_OS_LINUX 10 #if V8_OS_LINUX
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 __asm__ volatile ( 57 __asm__ volatile (
58 "cpuid \n\t" 58 "cpuid \n\t"
59 : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) 59 : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
60 : "a"(info_type) 60 : "a"(info_type)
61 ); 61 );
62 #endif // defined(__i386__) && defined(__pic__) 62 #endif // defined(__i386__) && defined(__pic__)
63 } 63 }
64 64
65 #endif // !V8_LIBC_MSVCRT 65 #endif // !V8_LIBC_MSVCRT
66 66
67 static V8_INLINE bool avx_os_support() {
Benedikt Meurer 2014/11/25 17:32:42 That does not belong here. The CPU class should on
68 #if !V8_LIBC_MSVCRT
69 unsigned int eax, edx;
70 unsigned int ecx = 0;
71 __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(ecx));
72 return (eax & 0x6) == 0x6;
73 #else
74 uint64_t xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
75 return (xcrFeatureMask & 0x6) == 0x6;
76 #endif
77 }
78
79
67 #elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 \ 80 #elif V8_HOST_ARCH_ARM || V8_HOST_ARCH_ARM64 \
68 || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64 81 || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64
69 82
70 #if V8_OS_LINUX 83 #if V8_OS_LINUX
71 84
72 #if V8_HOST_ARCH_ARM 85 #if V8_HOST_ARCH_ARM
73 86
74 // See <uapi/asm/hwcap.h> kernel header. 87 // See <uapi/asm/hwcap.h> kernel header.
75 /* 88 /*
76 * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP 89 * HWCAP flags - for elf_hwcap (in kernel) and AT_HWCAP
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 297 }
285 return false; 298 return false;
286 } 299 }
287 300
288 #endif // V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64 301 #endif // V8_HOST_ARCH_ARM || V8_HOST_ARCH_MIPS || V8_HOST_ARCH_MIPS64
289 302
290 #endif // V8_OS_LINUX 303 #endif // V8_OS_LINUX
291 304
292 #endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 305 #endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
293 306
294 CPU::CPU() : stepping_(0), 307 CPU::CPU()
295 model_(0), 308 : stepping_(0),
296 ext_model_(0), 309 model_(0),
297 family_(0), 310 ext_model_(0),
298 ext_family_(0), 311 family_(0),
299 type_(0), 312 ext_family_(0),
300 implementer_(0), 313 type_(0),
301 architecture_(0), 314 implementer_(0),
302 part_(0), 315 architecture_(0),
303 has_fpu_(false), 316 part_(0),
304 has_cmov_(false), 317 has_fpu_(false),
305 has_sahf_(false), 318 has_cmov_(false),
306 has_mmx_(false), 319 has_sahf_(false),
307 has_sse_(false), 320 has_mmx_(false),
308 has_sse2_(false), 321 has_sse_(false),
309 has_sse3_(false), 322 has_sse2_(false),
310 has_ssse3_(false), 323 has_sse3_(false),
311 has_sse41_(false), 324 has_ssse3_(false),
312 has_sse42_(false), 325 has_sse41_(false),
313 has_idiva_(false), 326 has_sse42_(false),
314 has_neon_(false), 327 has_avx_(false),
315 has_thumb2_(false), 328 has_fma3_(false),
316 has_vfp_(false), 329 has_idiva_(false),
317 has_vfp3_(false), 330 has_neon_(false),
318 has_vfp3_d32_(false), 331 has_thumb2_(false),
319 is_fp64_mode_(false) { 332 has_vfp_(false),
333 has_vfp3_(false),
334 has_vfp3_d32_(false),
335 is_fp64_mode_(false) {
320 memcpy(vendor_, "Unknown", 8); 336 memcpy(vendor_, "Unknown", 8);
321 #if V8_OS_NACL 337 #if V8_OS_NACL
322 // Portable host shouldn't do feature detection. 338 // Portable host shouldn't do feature detection.
323 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and 339 // TODO(jfb): Remove the hardcoded ARM simulator flags in the build, and
324 // hardcode them here instead. 340 // hardcode them here instead.
325 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 341 #elif V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
326 int cpu_info[4]; 342 int cpu_info[4];
327 343
328 // __cpuid with an InfoType argument of 0 returns the number of 344 // __cpuid with an InfoType argument of 0 returns the number of
329 // valid Ids in CPUInfo[0] and the CPU identification string in 345 // valid Ids in CPUInfo[0] and the CPU identification string in
(...skipping 19 matching lines...) Expand all
349 ext_family_ = (cpu_info[0] >> 20) & 0xff; 365 ext_family_ = (cpu_info[0] >> 20) & 0xff;
350 has_fpu_ = (cpu_info[3] & 0x00000001) != 0; 366 has_fpu_ = (cpu_info[3] & 0x00000001) != 0;
351 has_cmov_ = (cpu_info[3] & 0x00008000) != 0; 367 has_cmov_ = (cpu_info[3] & 0x00008000) != 0;
352 has_mmx_ = (cpu_info[3] & 0x00800000) != 0; 368 has_mmx_ = (cpu_info[3] & 0x00800000) != 0;
353 has_sse_ = (cpu_info[3] & 0x02000000) != 0; 369 has_sse_ = (cpu_info[3] & 0x02000000) != 0;
354 has_sse2_ = (cpu_info[3] & 0x04000000) != 0; 370 has_sse2_ = (cpu_info[3] & 0x04000000) != 0;
355 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; 371 has_sse3_ = (cpu_info[2] & 0x00000001) != 0;
356 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; 372 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0;
357 has_sse41_ = (cpu_info[2] & 0x00080000) != 0; 373 has_sse41_ = (cpu_info[2] & 0x00080000) != 0;
358 has_sse42_ = (cpu_info[2] & 0x00100000) != 0; 374 has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
375 has_avx_ = ((cpu_info[2] & 0x18000000) == 0x18000000) && avx_os_support();
Benedikt Meurer 2014/11/25 17:32:42 As mentioned above, remove the avx_os_support here
376 if (has_avx_) has_fma3_ = (cpu_info[2] & 0x00001000) != 0;
359 } 377 }
360 378
361 #if V8_HOST_ARCH_IA32 379 #if V8_HOST_ARCH_IA32
362 // SAHF is always available in compat/legacy mode, 380 // SAHF is always available in compat/legacy mode,
363 has_sahf_ = true; 381 has_sahf_ = true;
364 #else 382 #else
365 // Query extended IDs. 383 // Query extended IDs.
366 __cpuid(cpu_info, 0x80000000); 384 __cpuid(cpu_info, 0x80000000);
367 unsigned num_ext_ids = cpu_info[0]; 385 unsigned num_ext_ids = cpu_info[0];
368 386
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 if (end == part) { 569 if (end == part) {
552 part_ = 0; 570 part_ = 0;
553 } 571 }
554 delete[] part; 572 delete[] part;
555 } 573 }
556 574
557 #endif 575 #endif
558 } 576 }
559 577
560 } } // namespace v8::base 578 } } // namespace v8::base
OLDNEW
« no previous file with comments | « src/base/cpu.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698