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

Unified Diff: src/base/cpu.cc

Issue 618193005: MIPS: Improve runtime detection and compatibility wrt arch. revisions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/toolchain.gypi ('k') | src/mips/constants-mips.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/cpu.cc
diff --git a/src/base/cpu.cc b/src/base/cpu.cc
index fbfbcf683b74e3014257cfe749e96eabdf2203cf..0a737a66d488e090e611f40440f64e001708123b 100644
--- a/src/base/cpu.cc
+++ b/src/base/cpu.cc
@@ -119,13 +119,18 @@ static uint32_t ReadELFHWCaps() {
int __detect_fp64_mode(void) {
double result = 0;
// Bit representation of (double)1 is 0x3FF0000000000000.
- asm(
- "lui $t0, 0x3FF0\n\t"
- "ldc1 $f0, %0\n\t"
- "mtc1 $t0, $f1\n\t"
- "sdc1 $f0, %0\n\t"
- : "+m" (result)
- : : "t0", "$f0", "$f1", "memory");
+ __asm__ volatile(
+ ".set push\n\t"
+ ".set noreorder\n\t"
+ ".set oddspreg\n\t"
+ "lui $t0, 0x3FF0\n\t"
+ "ldc1 $f0, %0\n\t"
+ "mtc1 $t0, $f1\n\t"
+ "sdc1 $f0, %0\n\t"
+ ".set pop\n\t"
+ : "+m"(result)
+ :
+ : "t0", "$f0", "$f1", "memory");
return !(result == 1);
}
@@ -133,9 +138,33 @@ int __detect_fp64_mode(void) {
int __detect_mips_arch_revision(void) {
// TODO(dusmil): Do the specific syscall as soon as it is implemented in mips
- // kernel. Currently fail-back to the least common denominator which is
- // mips32 revision 1.
- return 1;
+ // kernel.
+ // Detect r6 architectures through QNaN representation.
+ // The r6 variant uses IEEE2008 QNaN representation which is 7ff8xxxxxxxxxxxx,
+ // the same encoding for QNaN on x86, ARM.
+ // Non r6 variants uses 7ff7fxxxxxxxxxxx for QNaN which is SNaN on x86, ARM.
+ double result = 0;
+ uint64_t check, mask = 0x8000000000000LLU;
+ union {
+ double d;
+ uint64_t ull;
+ } conv;
+
+ __asm__ volatile(
+ ".set push\n\t"
+ ".set noreorder\n\t"
+ "ldc1 $f0, %0\n\t"
+ "div.d $f0, $f0, $f0\n\t"
+ "sdc1 $f0, %0\n\t"
+ ".set pop\n\t"
+ : "+m"(result)
+ :
+ : "$f0", "memory");
+ conv.d = result;
+ // Check bit 50 of NaN value.
+ // Fail-back to the least common denominator which is mips32 revision 1.
paul.l... 2014/10/02 16:26:47 nit: this should probably be "fall-back"
dusmil.imgtec 2014/10/02 17:02:09 Done.
+ check = conv.ull & mask;
+ return check ? 6 : 1;
}
#endif
« no previous file with comments | « build/toolchain.gypi ('k') | src/mips/constants-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698