| Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_UTILS_MIPS64_CONSTANTS_MIPS64_H_ |
| 18 | #define ART_COMPILER_UTILS_MIPS64_CONSTANTS_MIPS64_H_ |
| 19 | |
| 20 | #include <iosfwd> |
| 21 | |
| Andreas Gampe | 5794381 | 2017-12-06 21:39:13 -0800 | [diff] [blame] | 22 | #include <android-base/logging.h> |
| 23 | |
| Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 24 | #include "arch/mips64/registers_mips64.h" |
| David Sehr | 1979c64 | 2018-04-26 14:41:18 -0700 | [diff] [blame] | 25 | #include "base/globals.h" |
| Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 26 | #include "base/macros.h" |
| Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 27 | |
| 28 | namespace art { |
| 29 | namespace mips64 { |
| 30 | |
| 31 | // Constants used for the decoding or encoding of the individual fields of instructions. |
| 32 | enum InstructionFields { |
| 33 | kOpcodeShift = 26, |
| 34 | kOpcodeBits = 6, |
| 35 | kRsShift = 21, |
| 36 | kRsBits = 5, |
| 37 | kRtShift = 16, |
| 38 | kRtBits = 5, |
| 39 | kRdShift = 11, |
| 40 | kRdBits = 5, |
| 41 | kShamtShift = 6, |
| 42 | kShamtBits = 5, |
| 43 | kFunctShift = 0, |
| 44 | kFunctBits = 6, |
| 45 | |
| 46 | kFmtShift = 21, |
| 47 | kFmtBits = 5, |
| 48 | kFtShift = 16, |
| 49 | kFtBits = 5, |
| 50 | kFsShift = 11, |
| 51 | kFsBits = 5, |
| 52 | kFdShift = 6, |
| 53 | kFdBits = 5, |
| 54 | |
| Goran Jakovljevic | 5a9e51d | 2017-03-16 16:11:43 +0000 | [diff] [blame] | 55 | kMsaOperationShift = 23, |
| 56 | kMsaELMOperationShift = 22, |
| 57 | kMsa2ROperationShift = 18, |
| 58 | kMsa2RFOperationShift = 17, |
| 59 | kDfShift = 21, |
| 60 | kDfMShift = 16, |
| 61 | kDf2RShift = 16, |
| 62 | kDfNShift = 16, |
| 63 | kWtShift = 16, |
| 64 | kWtBits = 5, |
| 65 | kWsShift = 11, |
| 66 | kWsBits = 5, |
| 67 | kWdShift = 6, |
| 68 | kWdBits = 5, |
| 69 | kS10Shift = 16, |
| Goran Jakovljevic | 3f44403 | 2017-03-31 14:38:20 +0200 | [diff] [blame] | 70 | kI10Shift = 11, |
| Goran Jakovljevic | 5a9e51d | 2017-03-16 16:11:43 +0000 | [diff] [blame] | 71 | kS10MinorShift = 2, |
| 72 | |
| Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 73 | kBranchOffsetMask = 0x0000ffff, |
| 74 | kJumpOffsetMask = 0x03ffffff, |
| Goran Jakovljevic | 5a9e51d | 2017-03-16 16:11:43 +0000 | [diff] [blame] | 75 | kMsaMajorOpcode = 0x1e, |
| 76 | kMsaDfMByteMask = 0x70, |
| 77 | kMsaDfMHalfwordMask = 0x60, |
| 78 | kMsaDfMWordMask = 0x40, |
| 79 | kMsaDfMDoublewordMask = 0x00, |
| 80 | kMsaDfNByteMask = 0x00, |
| 81 | kMsaDfNHalfwordMask = 0x20, |
| 82 | kMsaDfNWordMask = 0x30, |
| 83 | kMsaDfNDoublewordMask = 0x38, |
| 84 | kMsaS10Mask = 0x3ff, |
| Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | enum ScaleFactor { |
| 88 | TIMES_1 = 0, |
| 89 | TIMES_2 = 1, |
| 90 | TIMES_4 = 2, |
| 91 | TIMES_8 = 3 |
| 92 | }; |
| 93 | |
| 94 | class Instr { |
| 95 | public: |
| 96 | static const uint32_t kBreakPointInstruction = 0x0000000D; |
| 97 | |
| 98 | bool IsBreakPoint() { |
| Alexey Frunze | 4dda337 | 2015-06-01 18:31:49 -0700 | [diff] [blame] | 99 | return ((*reinterpret_cast<const uint32_t*>(this)) & 0xFC00003F) == kBreakPointInstruction; |
| Andreas Gampe | 57b3429 | 2015-01-14 15:45:59 -0800 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | // Instructions are read out of a code stream. The only way to get a |
| 103 | // reference to an instruction is to convert a pointer. There is no way |
| 104 | // to allocate or create instances of class Instr. |
| 105 | // Use the At(pc) function to create references to Instr. |
| 106 | static Instr* At(uintptr_t pc) { return reinterpret_cast<Instr*>(pc); } |
| 107 | |
| 108 | private: |
| 109 | DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); |
| 110 | }; |
| 111 | |
| 112 | } // namespace mips64 |
| 113 | } // namespace art |
| 114 | |
| 115 | #endif // ART_COMPILER_UTILS_MIPS64_CONSTANTS_MIPS64_H_ |