| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_S390_CONSTANTS_S390_H_ | 5 #ifndef V8_S390_CONSTANTS_S390_H_ |
| 6 #define V8_S390_CONSTANTS_S390_H_ | 6 #define V8_S390_CONSTANTS_S390_H_ |
| 7 | 7 |
| 8 // Get the standard printf format macros for C99 stdint types. | 8 // Get the standard printf format macros for C99 stdint types. |
| 9 #ifndef __STDC_FORMAT_MACROS | 9 #ifndef __STDC_FORMAT_MACROS |
| 10 #define __STDC_FORMAT_MACROS | 10 #define __STDC_FORMAT_MACROS |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 // S390 Opcode Format Types | 1073 // S390 Opcode Format Types |
| 1074 // Based on the first byte of the opcode, we can determine how to extract | 1074 // Based on the first byte of the opcode, we can determine how to extract |
| 1075 // the entire opcode of the instruction. The various favours include: | 1075 // the entire opcode of the instruction. The various favours include: |
| 1076 enum OpcodeFormatType { | 1076 enum OpcodeFormatType { |
| 1077 ONE_BYTE_OPCODE, // One Byte - Bits 0 to 7 | 1077 ONE_BYTE_OPCODE, // One Byte - Bits 0 to 7 |
| 1078 TWO_BYTE_OPCODE, // Two Bytes - Bits 0 to 15 | 1078 TWO_BYTE_OPCODE, // Two Bytes - Bits 0 to 15 |
| 1079 TWO_BYTE_DISJOINT_OPCODE, // Two Bytes - Bits 0 to 7, 40 to 47 | 1079 TWO_BYTE_DISJOINT_OPCODE, // Two Bytes - Bits 0 to 7, 40 to 47 |
| 1080 THREE_NIBBLE_OPCODE // Three Nibbles - Bits 0 to 7, 12 to 15 | 1080 THREE_NIBBLE_OPCODE // Three Nibbles - Bits 0 to 7, 12 to 15 |
| 1081 }; | 1081 }; |
| 1082 | 1082 |
| 1083 static OpcodeFormatType OpcodeFormatTable[256]; |
| 1083 // Helper macro to define static accessors. | 1084 // Helper macro to define static accessors. |
| 1084 // We use the cast to char* trick to bypass the strict anti-aliasing rules. | 1085 // We use the cast to char* trick to bypass the strict anti-aliasing rules. |
| 1085 #define DECLARE_STATIC_TYPED_ACCESSOR(return_type, Name) \ | 1086 #define DECLARE_STATIC_TYPED_ACCESSOR(return_type, Name) \ |
| 1086 static inline return_type Name(Instr instr) { \ | 1087 static inline return_type Name(Instr instr) { \ |
| 1087 char* temp = reinterpret_cast<char*>(&instr); \ | 1088 char* temp = reinterpret_cast<char*>(&instr); \ |
| 1088 return reinterpret_cast<Instruction*>(temp)->Name(); \ | 1089 return reinterpret_cast<Instruction*>(temp)->Name(); \ |
| 1089 } | 1090 } |
| 1090 | 1091 |
| 1091 #define DECLARE_STATIC_ACCESSOR(Name) DECLARE_STATIC_TYPED_ACCESSOR(int, Name) | 1092 #define DECLARE_STATIC_ACCESSOR(Name) DECLARE_STATIC_TYPED_ACCESSOR(int, Name) |
| 1092 | 1093 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 *reinterpret_cast<uint32_t*>(instr) = static_cast<uint32_t>(value >> 16); | 1248 *reinterpret_cast<uint32_t*>(instr) = static_cast<uint32_t>(value >> 16); |
| 1248 *reinterpret_cast<uint16_t*>(instr + 4) = | 1249 *reinterpret_cast<uint16_t*>(instr + 4) = |
| 1249 static_cast<uint16_t>(value & 0xFFFF); | 1250 static_cast<uint16_t>(value & 0xFFFF); |
| 1250 #endif | 1251 #endif |
| 1251 } | 1252 } |
| 1252 } | 1253 } |
| 1253 | 1254 |
| 1254 // Get Instruction Format Type | 1255 // Get Instruction Format Type |
| 1255 static OpcodeFormatType getOpcodeFormatType(const byte* instr) { | 1256 static OpcodeFormatType getOpcodeFormatType(const byte* instr) { |
| 1256 const byte firstByte = *instr; | 1257 const byte firstByte = *instr; |
| 1257 // Based on Figure B-3 in z/Architecture Principles of | 1258 return OpcodeFormatTable[firstByte]; |
| 1258 // Operation. | |
| 1259 | |
| 1260 // 1-byte opcodes | |
| 1261 // I, RR, RS, RSI, RX, SS Formats | |
| 1262 if ((0x04 <= firstByte && 0x9B >= firstByte) || | |
| 1263 (0xA8 <= firstByte && 0xB1 >= firstByte) || | |
| 1264 (0xBA <= firstByte && 0xBF >= firstByte) || (0xC5 == firstByte) || | |
| 1265 (0xC7 == firstByte) || (0xD0 <= firstByte && 0xE2 >= firstByte) || | |
| 1266 (0xE8 <= firstByte && 0xEA >= firstByte) || | |
| 1267 (0xEE <= firstByte && 0xFD >= firstByte)) { | |
| 1268 return ONE_BYTE_OPCODE; | |
| 1269 } | |
| 1270 | |
| 1271 // 2-byte opcodes | |
| 1272 // E, IE, RRD, RRE, RRF, SIL, S, SSE Formats | |
| 1273 if ((0x00 == firstByte) || // Software breakpoint 0x0001 | |
| 1274 (0x01 == firstByte) || (0xB2 == firstByte) || (0xB3 == firstByte) || | |
| 1275 (0xB9 == firstByte) || (0xE5 == firstByte)) { | |
| 1276 return TWO_BYTE_OPCODE; | |
| 1277 } | |
| 1278 | |
| 1279 // 3-nibble opcodes | |
| 1280 // RI, RIL, SSF Formats | |
| 1281 if ((0xA5 == firstByte) || (0xA7 == firstByte) || | |
| 1282 (0xC0 <= firstByte && 0xCC >= firstByte)) { // C5,C7 handled above | |
| 1283 return THREE_NIBBLE_OPCODE; | |
| 1284 } | |
| 1285 // Remaining ones are all TWO_BYTE_DISJOINT OPCODES. | |
| 1286 DCHECK(InstructionLength(instr) == 6); | |
| 1287 return TWO_BYTE_DISJOINT_OPCODE; | |
| 1288 } | 1259 } |
| 1289 | 1260 |
| 1290 // Extract the full opcode from the instruction. | 1261 // Extract the full opcode from the instruction. |
| 1291 static inline Opcode S390OpcodeValue(const byte* instr) { | 1262 static inline Opcode S390OpcodeValue(const byte* instr) { |
| 1292 OpcodeFormatType opcodeType = getOpcodeFormatType(instr); | 1263 OpcodeFormatType opcodeType = getOpcodeFormatType(instr); |
| 1293 | 1264 |
| 1294 // The native instructions are encoded in big-endian format | 1265 // The native instructions are encoded in big-endian format |
| 1295 // even if running on little-endian host. Hence, we need | 1266 // even if running on little-endian host. Hence, we need |
| 1296 // to ensure we use byte* based bit-wise logic. | 1267 // to ensure we use byte* based bit-wise logic. |
| 1297 switch (opcodeType) { | 1268 switch (opcodeType) { |
| 1298 case ONE_BYTE_OPCODE: | 1269 case ONE_BYTE_OPCODE: |
| 1299 // One Byte - Bits 0 to 7 | 1270 // One Byte - Bits 0 to 7 |
| 1300 return static_cast<Opcode>(*instr); | 1271 return static_cast<Opcode>(*instr); |
| 1301 case TWO_BYTE_OPCODE: | 1272 case TWO_BYTE_OPCODE: |
| 1302 // Two Bytes - Bits 0 to 15 | 1273 // Two Bytes - Bits 0 to 15 |
| 1303 return static_cast<Opcode>((*instr << 8) | (*(instr + 1))); | 1274 return static_cast<Opcode>((*instr << 8) | (*(instr + 1))); |
| 1304 case TWO_BYTE_DISJOINT_OPCODE: | 1275 case TWO_BYTE_DISJOINT_OPCODE: |
| 1305 // Two Bytes - Bits 0 to 7, 40 to 47 | 1276 // Two Bytes - Bits 0 to 7, 40 to 47 |
| 1306 return static_cast<Opcode>((*instr << 8) | (*(instr + 5) & 0xFF)); | 1277 return static_cast<Opcode>((*instr << 8) | (*(instr + 5) & 0xFF)); |
| 1307 case THREE_NIBBLE_OPCODE: | 1278 default: |
| 1279 // case THREE_NIBBLE_OPCODE: |
| 1308 // Three Nibbles - Bits 0 to 7, 12 to 15 | 1280 // Three Nibbles - Bits 0 to 7, 12 to 15 |
| 1309 return static_cast<Opcode>((*instr << 4) | (*(instr + 1) & 0xF)); | 1281 return static_cast<Opcode>((*instr << 4) | (*(instr + 1) & 0xF)); |
| 1310 default: | |
| 1311 break; | |
| 1312 } | 1282 } |
| 1313 | 1283 |
| 1314 UNREACHABLE(); | 1284 UNREACHABLE(); |
| 1315 return static_cast<Opcode>(-1); | 1285 return static_cast<Opcode>(-1); |
| 1316 } | 1286 } |
| 1317 | 1287 |
| 1318 // Fields used in Software interrupt instructions | 1288 // Fields used in Software interrupt instructions |
| 1319 inline SoftwareInterruptCodes SvcValue() const { | 1289 inline SoftwareInterruptCodes SvcValue() const { |
| 1320 return static_cast<SoftwareInterruptCodes>(Bits<FourByteInstr, int>(15, 0)); | 1290 return static_cast<SoftwareInterruptCodes>(Bits<FourByteInstr, int>(15, 0)); |
| 1321 } | 1291 } |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 static int Number(const char* name); | 1522 static int Number(const char* name); |
| 1553 | 1523 |
| 1554 private: | 1524 private: |
| 1555 static const char* names_[kNumDoubleRegisters]; | 1525 static const char* names_[kNumDoubleRegisters]; |
| 1556 }; | 1526 }; |
| 1557 | 1527 |
| 1558 } // namespace internal | 1528 } // namespace internal |
| 1559 } // namespace v8 | 1529 } // namespace v8 |
| 1560 | 1530 |
| 1561 #endif // V8_S390_CONSTANTS_S390_H_ | 1531 #endif // V8_S390_CONSTANTS_S390_H_ |
| OLD | NEW |