• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_PPC || V8_TARGET_ARCH_PPC64
6 
7 #include "src/codegen/ppc/constants-ppc.h"
8 
9 namespace v8 {
10 namespace internal {
11 
12 // These register names are defined in a way to match the native disassembler
13 // formatting. See for example the command "objdump -d <binary file>".
14 const char* Registers::names_[kNumRegisters] = {
15     "r0",  "sp",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",  "r8",  "r9",  "r10",
16     "r11", "ip",  "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21",
17     "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", "fp"};
18 
19 const char* DoubleRegisters::names_[kNumDoubleRegisters] = {
20     "d0",  "d1",  "d2",  "d3",  "d4",  "d5",  "d6",  "d7",  "d8",  "d9",  "d10",
21     "d11", "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21",
22     "d22", "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31"};
23 
Number(const char * name)24 int DoubleRegisters::Number(const char* name) {
25   for (int i = 0; i < kNumDoubleRegisters; i++) {
26     if (strcmp(names_[i], name) == 0) {
27       return i;
28     }
29   }
30 
31   // No register with the requested name found.
32   return kNoRegister;
33 }
34 
Number(const char * name)35 int Registers::Number(const char* name) {
36   // Look through the canonical names.
37   for (int i = 0; i < kNumRegisters; i++) {
38     if (strcmp(names_[i], name) == 0) {
39       return i;
40     }
41   }
42 
43   // No register with the requested name found.
44   return kNoRegister;
45 }
46 }  // namespace internal
47 }  // namespace v8
48 
49 #endif  // V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64
50