v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
constants-loong64.cc
Go to the documentation of this file.
1// Copyright 2021 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_LOONG64
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", "ra", "tp", "sp", "a0", "a1", "a2", "a3", "a4", "a5", "a6",
32 "a7", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8", "x_reg",
33 "fp", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "pc"};
34
35// List of alias names which can be used when referring to registers.
36const Registers::RegisterAlias Registers::aliases_[] = {
37 {0, "zero"}, {30, "cp"}, {kInvalidRegister, nullptr}};
38
39const char* Registers::Name(int reg) {
40 const char* result;
41 if ((0 <= reg) && (reg < kNumSimuRegisters)) {
42 result = names_[reg];
43 } else {
44 result = "noreg";
45 }
46 return result;
47}
48
49int Registers::Number(const char* name) {
50 // Look through the canonical names.
51 for (int i = 0; i < kNumSimuRegisters; i++) {
52 if (strcmp(names_[i], name) == 0) {
53 return i;
54 }
55 }
56
57 // Look through the alias names.
58 int i = 0;
59 while (aliases_[i].reg != kInvalidRegister) {
60 if (strcmp(aliases_[i].name, name) == 0) {
61 return aliases_[i].reg;
62 }
63 i++;
64 }
65
66 // No register with the reguested name found.
67 return kInvalidRegister;
68}
69
71 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10",
72 "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21",
73 "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"};
74
75// List of alias names which can be used when referring to LoongArch registers.
76const FPURegisters::RegisterAlias FPURegisters::aliases_[] = {
77 {kInvalidRegister, nullptr}};
78
79const char* FPURegisters::Name(int creg) {
80 const char* result;
81 if ((0 <= creg) && (creg < kNumFPURegisters)) {
82 result = names_[creg];
83 } else {
84 result = "nocreg";
85 }
86 return result;
87}
88
89int FPURegisters::Number(const char* name) {
90 // Look through the canonical names.
91 for (int i = 0; i < kNumFPURegisters; i++) {
92 if (strcmp(names_[i], name) == 0) {
93 return i;
94 }
95 }
96
97 // Look through the alias names.
98 int i = 0;
99 while (aliases_[i].creg != kInvalidRegister) {
100 if (strcmp(aliases_[i].name, name) == 0) {
101 return aliases_[i].creg;
102 }
103 i++;
104 }
105
106 // No Cregister with the reguested name found.
107 return kInvalidFPURegister;
108}
109
110} // namespace internal
111} // namespace v8
112
113#endif // V8_TARGET_ARCH_LOONG64
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 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 kNumFPURegisters
const int kInvalidFPURegister
const int kNumSimuRegisters
const int kInvalidRegister