blob: f57498d34f7851884dc101d750a87c4520fe8b14 [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
22#include "arch/mips64/registers_mips64.h"
23#include "base/logging.h"
24#include "base/macros.h"
25#include "globals.h"
26
27namespace art {
28namespace mips64 {
29
30// Constants used for the decoding or encoding of the individual fields of instructions.
31enum InstructionFields {
32 kOpcodeShift = 26,
33 kOpcodeBits = 6,
34 kRsShift = 21,
35 kRsBits = 5,
36 kRtShift = 16,
37 kRtBits = 5,
38 kRdShift = 11,
39 kRdBits = 5,
40 kShamtShift = 6,
41 kShamtBits = 5,
42 kFunctShift = 0,
43 kFunctBits = 6,
44
45 kFmtShift = 21,
46 kFmtBits = 5,
47 kFtShift = 16,
48 kFtBits = 5,
49 kFsShift = 11,
50 kFsBits = 5,
51 kFdShift = 6,
52 kFdBits = 5,
53
54 kBranchOffsetMask = 0x0000ffff,
55 kJumpOffsetMask = 0x03ffffff,
56};
57
58enum ScaleFactor {
59 TIMES_1 = 0,
60 TIMES_2 = 1,
61 TIMES_4 = 2,
62 TIMES_8 = 3
63};
64
65class Instr {
66 public:
67 static const uint32_t kBreakPointInstruction = 0x0000000D;
68
69 bool IsBreakPoint() {
Alexey Frunze4dda3372015-06-01 18:31:49 -070070 return ((*reinterpret_cast<const uint32_t*>(this)) & 0xFC00003F) == kBreakPointInstruction;
Andreas Gampe57b34292015-01-14 15:45:59 -080071 }
72
73 // Instructions are read out of a code stream. The only way to get a
74 // reference to an instruction is to convert a pointer. There is no way
75 // to allocate or create instances of class Instr.
76 // Use the At(pc) function to create references to Instr.
77 static Instr* At(uintptr_t pc) { return reinterpret_cast<Instr*>(pc); }
78
79 private:
80 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
81};
82
83} // namespace mips64
84} // namespace art
85
86#endif // ART_COMPILER_UTILS_MIPS64_CONSTANTS_MIPS64_H_