OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "mips/assembler-mips-inl.h" | 40 #include "mips/assembler-mips-inl.h" |
41 #include "serialize.h" | 41 #include "serialize.h" |
42 | 42 |
43 namespace v8 { | 43 namespace v8 { |
44 namespace internal { | 44 namespace internal { |
45 | 45 |
46 #ifdef DEBUG | 46 #ifdef DEBUG |
47 bool CpuFeatures::initialized_ = false; | 47 bool CpuFeatures::initialized_ = false; |
48 #endif | 48 #endif |
49 unsigned CpuFeatures::supported_ = 0; | 49 unsigned CpuFeatures::supported_ = 0; |
50 unsigned CpuFeatures::found_by_runtime_probing_ = 0; | 50 unsigned CpuFeatures::found_by_runtime_probing_only_ = 0; |
51 | 51 |
52 | 52 |
53 ExternalReference ExternalReference::cpu_features() { | 53 ExternalReference ExternalReference::cpu_features() { |
54 ASSERT(CpuFeatures::initialized_); | 54 ASSERT(CpuFeatures::initialized_); |
55 return ExternalReference(&CpuFeatures::supported_); | 55 return ExternalReference(&CpuFeatures::supported_); |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 // Get the CPU features enabled by the build. For cross compilation the | 59 // Get the CPU features enabled by the build. For cross compilation the |
60 // preprocessor symbols CAN_USE_FPU_INSTRUCTIONS | 60 // preprocessor symbols CAN_USE_FPU_INSTRUCTIONS |
61 // can be defined to enable FPU instructions when building the | 61 // can be defined to enable FPU instructions when building the |
62 // snapshot. | 62 // snapshot. |
63 static uint64_t CpuFeaturesImpliedByCompiler() { | 63 static uint64_t CpuFeaturesImpliedByCompiler() { |
64 uint64_t answer = 0; | 64 uint64_t answer = 0; |
65 #ifdef CAN_USE_FPU_INSTRUCTIONS | 65 #ifdef CAN_USE_FPU_INSTRUCTIONS |
66 answer |= 1u << FPU; | 66 answer |= static_cast<uint64_t>(1) << FPU; |
67 #endif // def CAN_USE_FPU_INSTRUCTIONS | 67 #endif // def CAN_USE_FPU_INSTRUCTIONS |
68 | 68 |
69 #ifdef __mips__ | 69 #ifdef __mips__ |
70 // If the compiler is allowed to use FPU then we can use FPU too in our code | 70 // If the compiler is allowed to use FPU then we can use FPU too in our code |
71 // generation even when generating snapshots. This won't work for cross | 71 // generation even when generating snapshots. This won't work for cross |
72 // compilation. | 72 // compilation. |
73 #if(defined(__mips_hard_float) && __mips_hard_float != 0) | 73 #if(defined(__mips_hard_float) && __mips_hard_float != 0) |
74 answer |= 1u << FPU; | 74 answer |= static_cast<uint64_t>(1) << FPU; |
75 #endif // defined(__mips_hard_float) && __mips_hard_float != 0 | 75 #endif // defined(__mips_hard_float) && __mips_hard_float != 0 |
76 #endif // def __mips__ | 76 #endif // def __mips__ |
77 | 77 |
78 return answer; | 78 return answer; |
79 } | 79 } |
80 | 80 |
81 | 81 |
82 const char* DoubleRegister::AllocationIndexToString(int index) { | 82 const char* DoubleRegister::AllocationIndexToString(int index) { |
83 if (CpuFeatures::IsSupported(FPU)) { | 83 if (CpuFeatures::IsSupported(FPU)) { |
84 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 84 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (Serializer::enabled()) { | 122 if (Serializer::enabled()) { |
123 // No probing for features if we might serialize (generate snapshot). | 123 // No probing for features if we might serialize (generate snapshot). |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 // If the compiler is allowed to use fpu then we can use fpu too in our | 127 // If the compiler is allowed to use fpu then we can use fpu too in our |
128 // code generation. | 128 // code generation. |
129 #if !defined(__mips__) | 129 #if !defined(__mips__) |
130 // For the simulator=mips build, use FPU when FLAG_enable_fpu is enabled. | 130 // For the simulator=mips build, use FPU when FLAG_enable_fpu is enabled. |
131 if (FLAG_enable_fpu) { | 131 if (FLAG_enable_fpu) { |
132 supported_ |= 1u << FPU; | 132 supported_ |= static_cast<uint64_t>(1) << FPU; |
133 } | 133 } |
134 #else | 134 #else |
135 // Probe for additional features not already known to be available. | 135 // Probe for additional features not already known to be available. |
136 if (OS::MipsCpuHasFeature(FPU)) { | 136 if (OS::MipsCpuHasFeature(FPU)) { |
137 // This implementation also sets the FPU flags if | 137 // This implementation also sets the FPU flags if |
138 // runtime detection of FPU returns true. | 138 // runtime detection of FPU returns true. |
139 supported_ |= 1u << FPU; | 139 supported_ |= static_cast<uint64_t>(1) << FPU; |
140 found_by_runtime_probing_ |= 1u << FPU; | 140 found_by_runtime_probing_only_ |= static_cast<uint64_t>(1) << FPU; |
141 } | 141 } |
142 #endif | 142 #endif |
143 } | 143 } |
144 | 144 |
145 | 145 |
146 int ToNumber(Register reg) { | 146 int ToNumber(Register reg) { |
147 ASSERT(reg.is_valid()); | 147 ASSERT(reg.is_valid()); |
148 const int kNumbers[] = { | 148 const int kNumbers[] = { |
149 0, // zero_reg | 149 0, // zero_reg |
150 1, // at | 150 1, // at |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 } | 867 } |
868 | 868 |
869 | 869 |
870 void Assembler::GenInstrRegister(Opcode opcode, | 870 void Assembler::GenInstrRegister(Opcode opcode, |
871 SecondaryField fmt, | 871 SecondaryField fmt, |
872 FPURegister ft, | 872 FPURegister ft, |
873 FPURegister fs, | 873 FPURegister fs, |
874 FPURegister fd, | 874 FPURegister fd, |
875 SecondaryField func) { | 875 SecondaryField func) { |
876 ASSERT(fd.is_valid() && fs.is_valid() && ft.is_valid()); | 876 ASSERT(fd.is_valid() && fs.is_valid() && ft.is_valid()); |
877 ASSERT(CpuFeatures::IsEnabled(FPU)); | 877 ASSERT(IsEnabled(FPU)); |
878 Instr instr = opcode | fmt | (ft.code() << kFtShift) | (fs.code() << kFsShift) | 878 Instr instr = opcode | fmt | (ft.code() << kFtShift) | (fs.code() << kFsShift) |
879 | (fd.code() << kFdShift) | func; | 879 | (fd.code() << kFdShift) | func; |
880 emit(instr); | 880 emit(instr); |
881 } | 881 } |
882 | 882 |
883 | 883 |
884 void Assembler::GenInstrRegister(Opcode opcode, | 884 void Assembler::GenInstrRegister(Opcode opcode, |
885 FPURegister fr, | 885 FPURegister fr, |
886 FPURegister ft, | 886 FPURegister ft, |
887 FPURegister fs, | 887 FPURegister fs, |
888 FPURegister fd, | 888 FPURegister fd, |
889 SecondaryField func) { | 889 SecondaryField func) { |
890 ASSERT(fd.is_valid() && fr.is_valid() && fs.is_valid() && ft.is_valid()); | 890 ASSERT(fd.is_valid() && fr.is_valid() && fs.is_valid() && ft.is_valid()); |
891 ASSERT(CpuFeatures::IsEnabled(FPU)); | 891 ASSERT(IsEnabled(FPU)); |
892 Instr instr = opcode | (fr.code() << kFrShift) | (ft.code() << kFtShift) | 892 Instr instr = opcode | (fr.code() << kFrShift) | (ft.code() << kFtShift) |
893 | (fs.code() << kFsShift) | (fd.code() << kFdShift) | func; | 893 | (fs.code() << kFsShift) | (fd.code() << kFdShift) | func; |
894 emit(instr); | 894 emit(instr); |
895 } | 895 } |
896 | 896 |
897 | 897 |
898 void Assembler::GenInstrRegister(Opcode opcode, | 898 void Assembler::GenInstrRegister(Opcode opcode, |
899 SecondaryField fmt, | 899 SecondaryField fmt, |
900 Register rt, | 900 Register rt, |
901 FPURegister fs, | 901 FPURegister fs, |
902 FPURegister fd, | 902 FPURegister fd, |
903 SecondaryField func) { | 903 SecondaryField func) { |
904 ASSERT(fd.is_valid() && fs.is_valid() && rt.is_valid()); | 904 ASSERT(fd.is_valid() && fs.is_valid() && rt.is_valid()); |
905 ASSERT(CpuFeatures::IsEnabled(FPU)); | 905 ASSERT(IsEnabled(FPU)); |
906 Instr instr = opcode | fmt | (rt.code() << kRtShift) | 906 Instr instr = opcode | fmt | (rt.code() << kRtShift) |
907 | (fs.code() << kFsShift) | (fd.code() << kFdShift) | func; | 907 | (fs.code() << kFsShift) | (fd.code() << kFdShift) | func; |
908 emit(instr); | 908 emit(instr); |
909 } | 909 } |
910 | 910 |
911 | 911 |
912 void Assembler::GenInstrRegister(Opcode opcode, | 912 void Assembler::GenInstrRegister(Opcode opcode, |
913 SecondaryField fmt, | 913 SecondaryField fmt, |
914 Register rt, | 914 Register rt, |
915 FPUControlRegister fs, | 915 FPUControlRegister fs, |
916 SecondaryField func) { | 916 SecondaryField func) { |
917 ASSERT(fs.is_valid() && rt.is_valid()); | 917 ASSERT(fs.is_valid() && rt.is_valid()); |
918 ASSERT(CpuFeatures::IsEnabled(FPU)); | 918 ASSERT(IsEnabled(FPU)); |
919 Instr instr = | 919 Instr instr = |
920 opcode | fmt | (rt.code() << kRtShift) | (fs.code() << kFsShift) | func; | 920 opcode | fmt | (rt.code() << kRtShift) | (fs.code() << kFsShift) | func; |
921 emit(instr); | 921 emit(instr); |
922 } | 922 } |
923 | 923 |
924 | 924 |
925 // Instructions with immediate value. | 925 // Instructions with immediate value. |
926 // Registers are in the order of the instruction encoding, from left to right. | 926 // Registers are in the order of the instruction encoding, from left to right. |
927 void Assembler::GenInstrImmediate(Opcode opcode, | 927 void Assembler::GenInstrImmediate(Opcode opcode, |
928 Register rs, | 928 Register rs, |
(...skipping 14 matching lines...) Expand all Loading... |
943 Instr instr = opcode | (rs.code() << kRsShift) | SF | (j & kImm16Mask); | 943 Instr instr = opcode | (rs.code() << kRsShift) | SF | (j & kImm16Mask); |
944 emit(instr); | 944 emit(instr); |
945 } | 945 } |
946 | 946 |
947 | 947 |
948 void Assembler::GenInstrImmediate(Opcode opcode, | 948 void Assembler::GenInstrImmediate(Opcode opcode, |
949 Register rs, | 949 Register rs, |
950 FPURegister ft, | 950 FPURegister ft, |
951 int32_t j) { | 951 int32_t j) { |
952 ASSERT(rs.is_valid() && ft.is_valid() && (is_int16(j) || is_uint16(j))); | 952 ASSERT(rs.is_valid() && ft.is_valid() && (is_int16(j) || is_uint16(j))); |
953 ASSERT(CpuFeatures::IsEnabled(FPU)); | 953 ASSERT(IsEnabled(FPU)); |
954 Instr instr = opcode | (rs.code() << kRsShift) | (ft.code() << kFtShift) | 954 Instr instr = opcode | (rs.code() << kRsShift) | (ft.code() << kFtShift) |
955 | (j & kImm16Mask); | 955 | (j & kImm16Mask); |
956 emit(instr); | 956 emit(instr); |
957 } | 957 } |
958 | 958 |
959 | 959 |
960 void Assembler::GenInstrJump(Opcode opcode, | 960 void Assembler::GenInstrJump(Opcode opcode, |
961 uint32_t address) { | 961 uint32_t address) { |
962 BlockTrampolinePoolScope block_trampoline_pool(this); | 962 BlockTrampolinePoolScope block_trampoline_pool(this); |
963 ASSERT(is_uint26(address)); | 963 ASSERT(is_uint26(address)); |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 | 1865 |
1866 | 1866 |
1867 void Assembler::cvt_d_s(FPURegister fd, FPURegister fs) { | 1867 void Assembler::cvt_d_s(FPURegister fd, FPURegister fs) { |
1868 GenInstrRegister(COP1, S, f0, fs, fd, CVT_D_S); | 1868 GenInstrRegister(COP1, S, f0, fs, fd, CVT_D_S); |
1869 } | 1869 } |
1870 | 1870 |
1871 | 1871 |
1872 // Conditions. | 1872 // Conditions. |
1873 void Assembler::c(FPUCondition cond, SecondaryField fmt, | 1873 void Assembler::c(FPUCondition cond, SecondaryField fmt, |
1874 FPURegister fs, FPURegister ft, uint16_t cc) { | 1874 FPURegister fs, FPURegister ft, uint16_t cc) { |
1875 ASSERT(CpuFeatures::IsEnabled(FPU)); | 1875 ASSERT(IsEnabled(FPU)); |
1876 ASSERT(is_uint3(cc)); | 1876 ASSERT(is_uint3(cc)); |
1877 ASSERT((fmt & ~(31 << kRsShift)) == 0); | 1877 ASSERT((fmt & ~(31 << kRsShift)) == 0); |
1878 Instr instr = COP1 | fmt | ft.code() << 16 | fs.code() << kFsShift | 1878 Instr instr = COP1 | fmt | ft.code() << 16 | fs.code() << kFsShift |
1879 | cc << 8 | 3 << 4 | cond; | 1879 | cc << 8 | 3 << 4 | cond; |
1880 emit(instr); | 1880 emit(instr); |
1881 } | 1881 } |
1882 | 1882 |
1883 | 1883 |
1884 void Assembler::fcmp(FPURegister src1, const double src2, | 1884 void Assembler::fcmp(FPURegister src1, const double src2, |
1885 FPUCondition cond) { | 1885 FPUCondition cond) { |
1886 ASSERT(CpuFeatures::IsEnabled(FPU)); | 1886 ASSERT(IsEnabled(FPU)); |
1887 ASSERT(src2 == 0.0); | 1887 ASSERT(src2 == 0.0); |
1888 mtc1(zero_reg, f14); | 1888 mtc1(zero_reg, f14); |
1889 cvt_d_w(f14, f14); | 1889 cvt_d_w(f14, f14); |
1890 c(cond, D, src1, f14, 0); | 1890 c(cond, D, src1, f14, 0); |
1891 } | 1891 } |
1892 | 1892 |
1893 | 1893 |
1894 void Assembler::bc1f(int16_t offset, uint16_t cc) { | 1894 void Assembler::bc1f(int16_t offset, uint16_t cc) { |
1895 ASSERT(CpuFeatures::IsEnabled(FPU)); | 1895 ASSERT(IsEnabled(FPU)); |
1896 ASSERT(is_uint3(cc)); | 1896 ASSERT(is_uint3(cc)); |
1897 Instr instr = COP1 | BC1 | cc << 18 | 0 << 16 | (offset & kImm16Mask); | 1897 Instr instr = COP1 | BC1 | cc << 18 | 0 << 16 | (offset & kImm16Mask); |
1898 emit(instr); | 1898 emit(instr); |
1899 } | 1899 } |
1900 | 1900 |
1901 | 1901 |
1902 void Assembler::bc1t(int16_t offset, uint16_t cc) { | 1902 void Assembler::bc1t(int16_t offset, uint16_t cc) { |
1903 ASSERT(CpuFeatures::IsEnabled(FPU)); | 1903 ASSERT(IsEnabled(FPU)); |
1904 ASSERT(is_uint3(cc)); | 1904 ASSERT(is_uint3(cc)); |
1905 Instr instr = COP1 | BC1 | cc << 18 | 1 << 16 | (offset & kImm16Mask); | 1905 Instr instr = COP1 | BC1 | cc << 18 | 1 << 16 | (offset & kImm16Mask); |
1906 emit(instr); | 1906 emit(instr); |
1907 } | 1907 } |
1908 | 1908 |
1909 | 1909 |
1910 // Debugging. | 1910 // Debugging. |
1911 void Assembler::RecordJSReturn() { | 1911 void Assembler::RecordJSReturn() { |
1912 positions_recorder()->WriteRecordedPositions(); | 1912 positions_recorder()->WriteRecordedPositions(); |
1913 CheckBuffer(); | 1913 CheckBuffer(); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 } | 2296 } |
2297 | 2297 |
2298 if (patched) { | 2298 if (patched) { |
2299 CPU::FlushICache(pc+2, sizeof(Address)); | 2299 CPU::FlushICache(pc+2, sizeof(Address)); |
2300 } | 2300 } |
2301 } | 2301 } |
2302 | 2302 |
2303 } } // namespace v8::internal | 2303 } } // namespace v8::internal |
2304 | 2304 |
2305 #endif // V8_TARGET_ARCH_MIPS | 2305 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |