v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
constants-arm.cc
Go to the documentation of this file.
1// Copyright 2009 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_ARM
6
8
10
11namespace v8 {
12namespace internal {
13
15 WritableJitAllocation* jit_allocation) {
16 if (jit_allocation) {
17 jit_allocation->WriteValue(reinterpret_cast<Address>(this), value);
18 } else {
19 *reinterpret_cast<Instr*>(this) = value;
20 }
21}
22
24 // Reconstruct a double from the immediate encoded in the vmov instruction.
25 //
26 // instruction: [xxxxxxxx,xxxxabcd,xxxxxxxx,xxxxefgh]
27 // double: [aBbbbbbb,bbcdefgh,00000000,00000000,
28 // 00000000,00000000,00000000,00000000]
29 //
30 // where B = ~b. Only the high 16 bits are affected.
31 uint64_t high16;
32 high16 = (Bits(17, 16) << 4) | Bits(3, 0); // xxxxxxxx,xxcdefgh.
33 high16 |= (0xFF * Bit(18)) << 6; // xxbbbbbb,bbxxxxxx.
34 high16 |= (Bit(18) ^ 1) << 14; // xBxxxxxx,xxxxxxxx.
35 high16 |= Bit(19) << 15; // axxxxxxx,xxxxxxxx.
36
37 uint64_t imm = high16 << 48;
38 return Float64::FromBits(imm);
39}
40
41// These register names are defined in a way to match the native disassembler
42// formatting. See for example the command "objdump -d <binary file>".
43const char* Registers::names_[kNumRegisters] = {
44 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
45 "r8", "r9", "r10", "fp", "ip", "sp", "lr", "pc",
46};
47
48// List of alias names which can be used when referring to ARM registers.
49const Registers::RegisterAlias Registers::aliases_[] = {
50 {10, "sl"}, {11, "r11"}, {12, "r12"}, {13, "r13"},
51 {14, "r14"}, {15, "r15"}, {kNoRegister, nullptr}};
52
53// Support for VFP registers s0 to s31 (d0 to d15) and d16-d31.
54// Note that "sN:sM" is the same as "dN/2" up to d15.
55// These register names are defined in a way to match the native disassembler
56// formatting. See for example the command "objdump -d <binary file>".
58 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10",
59 "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21",
60 "s22", "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", "d0",
61 "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11",
62 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", "d22",
63 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31"};
64
65const char* VFPRegisters::Name(int reg, bool is_double) {
66 DCHECK((0 <= reg) && (reg < kNumVFPRegisters));
67 return names_[reg + (is_double ? kNumVFPSingleRegisters : 0)];
68}
69
70int VFPRegisters::Number(const char* name, bool* is_double) {
71 for (int i = 0; i < kNumVFPRegisters; i++) {
72 if (strcmp(names_[i], name) == 0) {
74 *is_double = false;
75 return i;
76 } else {
77 *is_double = true;
79 }
80 }
81 }
82
83 // No register with the requested name found.
84 return kNoRegister;
85}
86
87int Registers::Number(const char* name) {
88 // Look through the canonical names.
89 for (int i = 0; i < kNumRegisters; i++) {
90 if (strcmp(names_[i], name) == 0) {
91 return i;
92 }
93 }
94
95 // Look through the alias names.
96 int i = 0;
97 while (aliases_[i].reg != kNoRegister) {
98 if (strcmp(aliases_[i].name, name) == 0) {
99 return aliases_[i].reg;
100 }
101 i++;
102 }
103
104 // No register with the requested name found.
105 return kNoRegister;
106}
107
108} // namespace internal
109} // namespace v8
110
111#endif // V8_TARGET_ARCH_ARM
int Bits(int hi, int lo) const
V8_EXPORT_PRIVATE void SetInstructionBits(Instr value, WritableJitAllocation *jit_allocation=nullptr)
Float64 DoubleImmedVmov() const
static const RegisterAlias aliases_[]
static const char * names_[kNumRegisters]
static int Number(const char *name)
static const char * names_[kNumVFPRegisters]
static const char * Name(int reg, bool is_double)
static int Number(const char *name, bool *is_double)
LiftoffRegister reg
FloatWithBits< 64 > Float64
Definition index.h:234
constexpr int kNumVFPSingleRegisters
constexpr int kNoRegister
constexpr int kNumVFPRegisters
constexpr int kNumRegisters
#define DCHECK(condition)
Definition logging.h:482