~ubuntu-branches/ubuntu/trusty/libv8-3.14/trusty

« back to all changes in this revision

Viewing changes to src/ppc/constants-ppc.cc

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2014-02-12 10:26:54 UTC
  • Revision ID: package-import@ubuntu.com-20140212102654-mh2oalg31ifhjs0g
Tags: 3.14.5.8-5ubuntu1
* 0099_powerpc_support.patch: Pull in Andrew Low's powerpc port.
* debian/rules: Enable powerpc/ppc64/ppc64el for package builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2009 the V8 project authors. All rights reserved.
 
2
//
 
3
// Copyright IBM Corp. 2012, 2013. All rights reserved.
 
4
//
 
5
// Redistribution and use in source and binary forms, with or without
 
6
// modification, are permitted provided that the following conditions are
 
7
// met:
 
8
//
 
9
//     * Redistributions of source code must retain the above copyright
 
10
//       notice, this list of conditions and the following disclaimer.
 
11
//     * Redistributions in binary form must reproduce the above
 
12
//       copyright notice, this list of conditions and the following
 
13
//       disclaimer in the documentation and/or other materials provided
 
14
//       with the distribution.
 
15
//     * Neither the name of Google Inc. nor the names of its
 
16
//       contributors may be used to endorse or promote products derived
 
17
//       from this software without specific prior written permission.
 
18
//
 
19
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
20
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
21
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
22
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
23
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
24
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
25
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
26
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
27
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
28
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
29
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
30
 
 
31
#include "v8.h"
 
32
 
 
33
#if defined(V8_TARGET_ARCH_PPC)
 
34
 
 
35
#include "constants-ppc.h"
 
36
 
 
37
 
 
38
namespace v8 {
 
39
namespace internal {
 
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>".
 
43
const char* Registers::names_[kNumRegisters] = {
 
44
  "r0", "sp", "r2", "r3", "r4", "r5", "r6", "r7",
 
45
  "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
 
46
  "r16", "r17", "r18", "r19", "r20", "r21", "r22",
 
47
  "r23", "r24", "r25", "r26", "r27", "r28", "r29",
 
48
  "r30", "fp"
 
49
};
 
50
 
 
51
 
 
52
// List of alias names which can be used when referring to PPC registers.
 
53
const Registers::RegisterAlias Registers::aliases_[] = {
 
54
  {10, "sl"},
 
55
  {11, "r11"},
 
56
  {12, "r12"},
 
57
  {13, "r13"},
 
58
  {14, "r14"},
 
59
  {15, "r15"},
 
60
  {kNoRegister, NULL}
 
61
};
 
62
 
 
63
 
 
64
const char* Registers::Name(int reg) {
 
65
  const char* result;
 
66
  if ((0 <= reg) && (reg < kNumRegisters)) {
 
67
    result = names_[reg];
 
68
  } else {
 
69
    result = "noreg";
 
70
  }
 
71
  return result;
 
72
}
 
73
 
 
74
// Power
 
75
const char* FPRegisters::names_[kNumFPRegisters] = {
 
76
    "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
 
77
    "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15",
 
78
    "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23",
 
79
    "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31"
 
80
};
 
81
const char* FPRegisters::Name(int reg) {
 
82
  ASSERT((0 <= reg) && (reg < kNumFPRegisters));
 
83
  return names_[reg];
 
84
}
 
85
int FPRegisters::Number(const char* name) {
 
86
  for (int i = 0; i < kNumFPRegisters; i++) {
 
87
    if (strcmp(names_[i], name) == 0) {
 
88
        return i;
 
89
    }
 
90
  }
 
91
 
 
92
  // No register with the requested name found.
 
93
  return kNoRegister;
 
94
}
 
95
 
 
96
// end of Power
 
97
 
 
98
int Registers::Number(const char* name) {
 
99
  // Look through the canonical names.
 
100
  for (int i = 0; i < kNumRegisters; i++) {
 
101
    if (strcmp(names_[i], name) == 0) {
 
102
      return i;
 
103
    }
 
104
  }
 
105
 
 
106
  // Look through the alias names.
 
107
  int i = 0;
 
108
  while (aliases_[i].reg != kNoRegister) {
 
109
    if (strcmp(aliases_[i].name, name) == 0) {
 
110
      return aliases_[i].reg;
 
111
    }
 
112
    i++;
 
113
  }
 
114
 
 
115
  // No register with the requested name found.
 
116
  return kNoRegister;
 
117
}
 
118
 
 
119
 
 
120
} }  // namespace v8::internal
 
121
 
 
122
#endif  // V8_TARGET_ARCH_PPC