OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #if V8_TARGET_ARCH_MIPS64 | 10 #if V8_TARGET_ARCH_MIPS64 |
(...skipping 3959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3970 0x10101LU >> | 3970 0x10101LU >> |
3971 16); | 3971 16); |
3972 | 3972 |
3973 output = output | (static_cast<uint32_t>(o_byte << 24)); | 3973 output = output | (static_cast<uint32_t>(o_byte << 24)); |
3974 input = input >> 8; | 3974 input = input >> 8; |
3975 } | 3975 } |
3976 | 3976 |
3977 alu_out = static_cast<int64_t>(static_cast<int32_t>(output)); | 3977 alu_out = static_cast<int64_t>(static_cast<int32_t>(output)); |
3978 break; | 3978 break; |
3979 } | 3979 } |
3980 case SEB: | 3980 case SEB: { |
3981 case SEH: | 3981 uint8_t input = static_cast<uint8_t>(rt()); |
3982 case WSBH: | 3982 uint32_t output = input; |
3983 alu_out = 0x12345678; | 3983 uint32_t mask = 0x00000080; |
3984 UNREACHABLE(); | 3984 |
| 3985 // Extending sign |
| 3986 if (mask & input) { |
| 3987 output |= 0xFFFFFF00; |
| 3988 } |
| 3989 |
| 3990 alu_out = static_cast<int32_t>(output); |
3985 break; | 3991 break; |
| 3992 } |
| 3993 case SEH: { |
| 3994 uint16_t input = static_cast<uint16_t>(rt()); |
| 3995 uint32_t output = input; |
| 3996 uint32_t mask = 0x00008000; |
| 3997 |
| 3998 // Extending sign |
| 3999 if (mask & input) { |
| 4000 output |= 0xFFFF0000; |
| 4001 } |
| 4002 |
| 4003 alu_out = static_cast<int32_t>(output); |
| 4004 break; |
| 4005 } |
| 4006 case WSBH: { |
| 4007 uint32_t input = static_cast<uint32_t>(rt()); |
| 4008 uint64_t output = 0; |
| 4009 |
| 4010 uint32_t mask = 0xFF000000; |
| 4011 for (int i = 0; i < 4; i++) { |
| 4012 uint32_t tmp = mask & input; |
| 4013 if (i % 2 == 0) { |
| 4014 tmp = tmp >> 8; |
| 4015 } else { |
| 4016 tmp = tmp << 8; |
| 4017 } |
| 4018 output = output | tmp; |
| 4019 mask = mask >> 8; |
| 4020 } |
| 4021 mask = 0x80000000; |
| 4022 |
| 4023 // Extending sign |
| 4024 if (mask & output) { |
| 4025 output |= 0xFFFFFFFF00000000; |
| 4026 } |
| 4027 |
| 4028 alu_out = static_cast<int64_t>(output); |
| 4029 break; |
| 4030 } |
3986 default: { | 4031 default: { |
3987 const uint8_t bp2 = get_instr()->Bp2Value(); | 4032 const uint8_t bp2 = get_instr()->Bp2Value(); |
3988 sa >>= kBp2Bits; | 4033 sa >>= kBp2Bits; |
3989 switch (sa) { | 4034 switch (sa) { |
3990 case ALIGN: { | 4035 case ALIGN: { |
3991 if (bp2 == 0) { | 4036 if (bp2 == 0) { |
3992 alu_out = static_cast<int32_t>(rt()); | 4037 alu_out = static_cast<int32_t>(rt()); |
3993 } else { | 4038 } else { |
3994 uint64_t rt_hi = rt() << (8 * bp2); | 4039 uint64_t rt_hi = rt() << (8 * bp2); |
3995 uint64_t rs_lo = rs() >> (8 * (4 - bp2)); | 4040 uint64_t rs_lo = rs() >> (8 * (4 - bp2)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4034 output = output | ((static_cast<uint64_t>(o_byte) << 56)); | 4079 output = output | ((static_cast<uint64_t>(o_byte) << 56)); |
4035 input = input >> 8; | 4080 input = input >> 8; |
4036 } | 4081 } |
4037 | 4082 |
4038 alu_out = static_cast<int64_t>(output); | 4083 alu_out = static_cast<int64_t>(output); |
4039 break; | 4084 break; |
4040 } | 4085 } |
4041 } | 4086 } |
4042 break; | 4087 break; |
4043 } | 4088 } |
4044 case DSBH: | 4089 case DSBH: { |
4045 case DSHD: | 4090 uint64_t input = static_cast<uint64_t>(rt()); |
4046 alu_out = 0x12345678; | 4091 uint64_t output = 0; |
4047 UNREACHABLE(); | 4092 |
| 4093 uint64_t mask = 0xFF00000000000000; |
| 4094 for (int i = 0; i < 8; i++) { |
| 4095 uint64_t tmp = mask & input; |
| 4096 if (i % 2 == 0) |
| 4097 tmp = tmp >> 8; |
| 4098 else |
| 4099 tmp = tmp << 8; |
| 4100 |
| 4101 output = output | tmp; |
| 4102 mask = mask >> 8; |
| 4103 } |
| 4104 |
| 4105 alu_out = static_cast<int64_t>(output); |
4048 break; | 4106 break; |
| 4107 } |
| 4108 case DSHD: { |
| 4109 uint64_t input = static_cast<uint64_t>(rt()); |
| 4110 uint64_t output = 0; |
| 4111 |
| 4112 uint64_t mask = 0xFFFF000000000000; |
| 4113 for (int i = 0; i < 4; i++) { |
| 4114 uint64_t tmp = mask & input; |
| 4115 if (i == 0) |
| 4116 tmp = tmp >> 48; |
| 4117 else if (i == 1) |
| 4118 tmp = tmp >> 16; |
| 4119 else if (i == 2) |
| 4120 tmp = tmp << 16; |
| 4121 else |
| 4122 tmp = tmp << 48; |
| 4123 output = output | tmp; |
| 4124 mask = mask >> 16; |
| 4125 } |
| 4126 |
| 4127 alu_out = static_cast<int64_t>(output); |
| 4128 break; |
| 4129 } |
4049 default: { | 4130 default: { |
4050 const uint8_t bp3 = get_instr()->Bp3Value(); | 4131 const uint8_t bp3 = get_instr()->Bp3Value(); |
4051 sa >>= kBp3Bits; | 4132 sa >>= kBp3Bits; |
4052 switch (sa) { | 4133 switch (sa) { |
4053 case DALIGN: { | 4134 case DALIGN: { |
4054 if (bp3 == 0) { | 4135 if (bp3 == 0) { |
4055 alu_out = static_cast<int64_t>(rt()); | 4136 alu_out = static_cast<int64_t>(rt()); |
4056 } else { | 4137 } else { |
4057 uint64_t rt_hi = rt() << (8 * bp3); | 4138 uint64_t rt_hi = rt() << (8 * bp3); |
4058 uint64_t rs_lo = rs() >> (8 * (8 - bp3)); | 4139 uint64_t rs_lo = rs() >> (8 * (8 - bp3)); |
(...skipping 29 matching lines...) Expand all Loading... |
4088 case COP1X: | 4169 case COP1X: |
4089 DecodeTypeRegisterCOP1X(); | 4170 DecodeTypeRegisterCOP1X(); |
4090 break; | 4171 break; |
4091 case SPECIAL: | 4172 case SPECIAL: |
4092 DecodeTypeRegisterSPECIAL(); | 4173 DecodeTypeRegisterSPECIAL(); |
4093 break; | 4174 break; |
4094 case SPECIAL2: | 4175 case SPECIAL2: |
4095 DecodeTypeRegisterSPECIAL2(); | 4176 DecodeTypeRegisterSPECIAL2(); |
4096 break; | 4177 break; |
4097 case SPECIAL3: | 4178 case SPECIAL3: |
4098 switch (instr->FunctionFieldRaw()) { | 4179 DecodeTypeRegisterSPECIAL3(); |
4099 case BSHFL: { | |
4100 int32_t saVal = sa(); | |
4101 saVal >>= kBp2Bits; | |
4102 switch (saVal) { | |
4103 case ALIGN: { | |
4104 DecodeTypeRegisterSPECIAL3(); | |
4105 break; | |
4106 } | |
4107 } | |
4108 } | |
4109 case DBSHFL: { | |
4110 int32_t saVal = sa(); | |
4111 saVal >>= kBp2Bits; | |
4112 switch (saVal) { | |
4113 case DALIGN: { | |
4114 DecodeTypeRegisterSPECIAL3(); | |
4115 break; | |
4116 } | |
4117 } | |
4118 } | |
4119 default: | |
4120 DecodeTypeRegisterSPECIAL3(); | |
4121 break; | |
4122 } | |
4123 break; | 4180 break; |
4124 // Unimplemented opcodes raised an error in the configuration step before, | 4181 // Unimplemented opcodes raised an error in the configuration step before, |
4125 // so we can use the default here to set the destination register in common | 4182 // so we can use the default here to set the destination register in common |
4126 // cases. | 4183 // cases. |
4127 default: | 4184 default: |
4128 UNREACHABLE(); | 4185 UNREACHABLE(); |
4129 } | 4186 } |
4130 } | 4187 } |
4131 | 4188 |
4132 | 4189 |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4937 } | 4994 } |
4938 | 4995 |
4939 | 4996 |
4940 #undef UNSUPPORTED | 4997 #undef UNSUPPORTED |
4941 } // namespace internal | 4998 } // namespace internal |
4942 } // namespace v8 | 4999 } // namespace v8 |
4943 | 5000 |
4944 #endif // USE_SIMULATOR | 5001 #endif // USE_SIMULATOR |
4945 | 5002 |
4946 #endif // V8_TARGET_ARCH_MIPS64 | 5003 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |