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