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