v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
constants-mips64.cc
Go to the documentation of this file.
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
3// found in the LICENSE file.
4
5#if V8_TARGET_ARCH_MIPS64
6
8
10
11namespace v8 {
12namespace internal {
13
15 Instr new_instr, WritableJitAllocation* jit_allocation) {
16 // Usually this is aligned, but when de/serializing that's not guaranteed.
17 if (jit_allocation) {
18 jit_allocation->WriteUnalignedValue(reinterpret_cast<Address>(this),
19 new_instr);
20 } else {
21 base::WriteUnalignedValue(reinterpret_cast<Address>(this), new_instr);
22 }
23}
24
25// -----------------------------------------------------------------------------
26// Registers.
27
28// These register names are defined in a way to match the native disassembler
29// formatting. See for example the command "objdump -d <binary file>".
31 "zero_reg", "at", "v0", "v1", "a0", "a1", "a2", "a3", "a4",
32 "a5", "a6", "a7", "t0", "t1", "t2", "t3", "s0", "s1",
33 "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0",
34 "k1", "gp", "sp", "fp", "ra", "LO", "HI", "pc"};
35
36// List of alias names which can be used when referring to MIPS registers.
37const Registers::RegisterAlias Registers::aliases_[] = {
38 {0, "zero"},
39 {23, "cp"},
40 {30, "s8"},
41 {30, "s8_fp"},
42 {kInvalidRegister, nullptr}};
43
44const char* Registers::Name(int reg) {
45 const char* result;
46 if ((0 <= reg) && (reg < kNumSimuRegisters)) {
47 result = names_[reg];
48 } else {
49 result = "noreg";
50 }
51 return result;
52}
53
54int Registers::Number(const char* name) {
55 // Look through the canonical names.
56 for (int i = 0; i < kNumSimuRegisters; i++) {
57 if (strcmp(names_[i], name) == 0) {
58 return i;
59 }
60 }
61
62 // Look through the alias names.
63 int i = 0;
64 while (aliases_[i].reg != kInvalidRegister) {
65 if (strcmp(aliases_[i].name, name) == 0) {
66 return aliases_[i].reg;
67 }
68 i++;
69 }
70
71 // No register with the reguested name found.
72 return kInvalidRegister;
73}
74
76 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10",
77 "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21",
78 "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"};
79
80// List of alias names which can be used when referring to MIPS registers.
81const FPURegisters::RegisterAlias FPURegisters::aliases_[] = {
82 {kInvalidRegister, nullptr}};
83
84const char* FPURegisters::Name(int creg) {
85 const char* result;
86 if ((0 <= creg) && (creg < kNumFPURegisters)) {
87 result = names_[creg];
88 } else {
89 result = "nocreg";
90 }
91 return result;
92}
93
94int FPURegisters::Number(const char* name) {
95 // Look through the canonical names.
96 for (int i = 0; i < kNumFPURegisters; i++) {
97 if (strcmp(names_[i], name) == 0) {
98 return i;
99 }
100 }
101
102 // Look through the alias names.
103 int i = 0;
104 while (aliases_[i].creg != kInvalidRegister) {
105 if (strcmp(aliases_[i].name, name) == 0) {
106 return aliases_[i].creg;
107 }
108 i++;
109 }
110
111 // No Cregister with the reguested name found.
112 return kInvalidFPURegister;
113}
114
116 "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10",
117 "w11", "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21",
118 "w22", "w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30", "w31"};
119
120const MSARegisters::RegisterAlias MSARegisters::aliases_[] = {
121 {kInvalidRegister, nullptr}};
122
123const char* MSARegisters::Name(int creg) {
124 const char* result;
125 if ((0 <= creg) && (creg < kNumMSARegisters)) {
126 result = names_[creg];
127 } else {
128 result = "nocreg";
129 }
130 return result;
131}
132
133int MSARegisters::Number(const char* name) {
134 // Look through the canonical names.
135 for (int i = 0; i < kNumMSARegisters; i++) {
136 if (strcmp(names_[i], name) == 0) {
137 return i;
138 }
139 }
140
141 // Look through the alias names.
142 int i = 0;
143 while (aliases_[i].creg != kInvalidRegister) {
144 if (strcmp(aliases_[i].name, name) == 0) {
145 return aliases_[i].creg;
146 }
147 i++;
148 }
149
150 // No Cregister with the reguested name found.
151 return kInvalidMSARegister;
152}
153
154} // namespace internal
155} // namespace v8
156
157#endif // V8_TARGET_ARCH_MIPS64
static const RegisterAlias aliases_[]
static const char * names_[kNumFPURegisters]
static const char * Name(int reg)
static int Number(const char *name)
V8_EXPORT_PRIVATE void SetInstructionBits(Instr new_instr, WritableJitAllocation *jit_allocation=nullptr)
static const RegisterAlias aliases_[]
static int Number(const char *name)
static const char * Name(int reg)
static const char * names_[kNumMSARegisters]
static const RegisterAlias aliases_[]
static const char * names_[kNumRegisters]
static int Number(const char *name)
static const char * Name(int reg)
ZoneVector< RpoNumber > & result
LiftoffRegister reg
static void WriteUnalignedValue(Address p, V value)
Definition memory.h:41
const int kNumMSARegisters
const int kNumFPURegisters
const int kInvalidFPURegister
const int kNumSimuRegisters
const int kInvalidRegister
const int kInvalidMSARegister