blob: 41eb77c9aedb6b35b8683a76280a52245cb95360 [file] [log] [blame]
Andreas Gampe57b34292015-01-14 15:45:59 -08001/*
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 Gampe57943812017-12-06 21:39:13 -080022#include <android-base/logging.h>
23
Andreas Gampe57b34292015-01-14 15:45:59 -080024#include "arch/mips64/registers_mips64.h"
David Sehr1979c642018-04-26 14:41:18 -070025#include "base/globals.h"
Andreas Gampe57b34292015-01-14 15:45:59 -080026#include "base/macros.h"
Andreas Gampe57b34292015-01-14 15:45:59 -080027
28namespace art {
29namespace mips64 {
30
31// Constants used for the decoding or encoding of the individual fields of instructions.
32enum 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 Jakovljevic5a9e51d2017-03-16 16:11:43 +000055 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 Jakovljevic3f444032017-03-31 14:38:20 +020070 kI10Shift = 11,
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +000071 kS10MinorShift = 2,
72
Andreas Gampe57b34292015-01-14 15:45:59 -080073 kBranchOffsetMask = 0x0000ffff,
74 kJumpOffsetMask = 0x03ffffff,
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +000075 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 Gampe57b34292015-01-14 15:45:59 -080085};
86
87enum ScaleFactor {
88 TIMES_1 = 0,
89 TIMES_2 = 1,
90 TIMES_4 = 2,
91 TIMES_8 = 3
92};
93
94class Instr {
95 public:
96 static const uint32_t kBreakPointInstruction = 0x0000000D;
97
98 bool IsBreakPoint() {
Alexey Frunze4dda3372015-06-01 18:31:49 -070099 return ((*reinterpret_cast<const uint32_t*>(this)) & 0xFC00003F) == kBreakPointInstruction;
Andreas Gampe57b34292015-01-14 15:45:59 -0800100 }
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_