Revision: 24486
Author: dusan.milosavlje...@imgtec.com
Date: Thu Oct 9 09:39:23 2014 UTC
Log: MIPS: Improve runtime detection and compatibility wrt arch.
revisions.
TEST=
BUG=
R=jkumme...@chromium.org, paul.l...@imgtec.com
Review URL: https://codereview.chromium.org/618193005
https://code.google.com/p/v8/source/detail?r=24486
Modified:
/branches/bleeding_edge/build/toolchain.gypi
/branches/bleeding_edge/src/base/cpu.cc
/branches/bleeding_edge/src/mips/constants-mips.h
=======================================
--- /branches/bleeding_edge/build/toolchain.gypi Wed Oct 8 09:09:57 2014
UTC
+++ /branches/bleeding_edge/build/toolchain.gypi Thu Oct 9 09:39:23 2014
UTC
@@ -302,7 +302,7 @@
'cflags': ['-mfp32'],
}],
['mips_arch_variant=="r6"', {
- 'cflags!': ['-mfp32'],
+ 'cflags!': ['-mfp32', '-mfpxx'],
'cflags': ['-mips32r6', '-Wa,-mips32r6'],
'ldflags': [
'-mips32r6',
@@ -312,14 +312,17 @@
}],
['mips_arch_variant=="r2"', {
'cflags': ['-mips32r2', '-Wa,-mips32r2'],
+ 'ldflags': ['-mips32r2'],
}],
['mips_arch_variant=="r1"', {
- 'cflags!': ['-mfp64'],
+ 'cflags!': ['-mfp64', '-mfpxx'],
'cflags': ['-mips32', '-Wa,-mips32'],
+ 'ldflags': ['-mips32'],
}],
['mips_arch_variant=="rx"', {
- 'cflags!': ['-mfp64'],
- 'cflags': ['-mips32', '-Wa,-mips32'],
+ 'cflags!': ['-mfp64', '-mfp32'],
+ 'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
+ 'ldflags': ['-mips32'],
}],
],
}],
@@ -400,7 +403,7 @@
'cflags': ['-mfp32'],
}],
['mips_arch_variant=="r6"', {
- 'cflags!': ['-mfp32'],
+ 'cflags!': ['-mfp32', '-mfpxx'],
'cflags': ['-mips32r6', '-Wa,-mips32r6'],
'ldflags': [
'-mips32r6',
@@ -410,17 +413,20 @@
}],
['mips_arch_variant=="r2"', {
'cflags': ['-mips32r2', '-Wa,-mips32r2'],
+ 'ldflags': ['-mips32r2'],
}],
['mips_arch_variant=="r1"', {
- 'cflags!': ['-mfp64'],
+ 'cflags!': ['-mfp64', '-mfpxx'],
'cflags': ['-mips32', '-Wa,-mips32'],
+ 'ldflags': ['-mips32'],
}],
['mips_arch_variant=="rx"', {
- 'cflags!': ['-mfp64'],
- 'cflags': ['-mips32', '-Wa,-mips32'],
+ 'cflags!': ['-mfp64', '-mfp32'],
+ 'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
+ 'ldflags': ['-mips32'],
}],
['mips_arch_variant=="loongson"', {
- 'cflags!': ['-mfp64'],
+ 'cflags!': ['-mfp64', '-mfp32', '-mfpxx'],
'cflags': ['-mips3', '-Wa,-mips3'],
}],
],
=======================================
--- /branches/bleeding_edge/src/base/cpu.cc Mon Oct 6 08:10:50 2014 UTC
+++ /branches/bleeding_edge/src/base/cpu.cc Thu Oct 9 09:39:23 2014 UTC
@@ -121,13 +121,18 @@
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);
}
@@ -135,9 +140,22 @@
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.
+ uint32_t result = 0;
+ __asm__ volatile(
+ "move $v0, $zero\n\t"
+ // Encoding for "addi $v0, $v0, 1" on non-r6,
+ // which is encoding for "bovc $v0, %v0, 1" on r6.
+ // Use machine code directly to avoid compilation errors with
different
+ // toolchains and maintain compatibility.
+ ".word 0x20420001\n\t"
+ "sw $v0, %0\n\t"
+ : "=m"(result)
+ :
+ : "v0", "memory");
+ // Result is 0 on r6 architectures, 1 on other architecture revisions.
+ // Fall-back to the least common denominator which is mips32 revision 1.
+ return result ? 1 : 6;
}
#endif
=======================================
--- /branches/bleeding_edge/src/mips/constants-mips.h Tue Aug 12 19:04:15
2014 UTC
+++ /branches/bleeding_edge/src/mips/constants-mips.h Thu Oct 9 09:39:23
2014 UTC
@@ -105,7 +105,7 @@
(kArchVariant == check)
#else
#define IsMipsArchVariant(check) \
- (CpuFeatures::IsSupported(check))
+ (CpuFeatures::IsSupported(static_cast<CpuFeature>(check)))
#endif
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.