OLD | NEW |
(Empty) | |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #include "v8.h" |
| 29 |
| 30 #include "constants-arm.h" |
| 31 |
| 32 |
| 33 namespace assembler { |
| 34 namespace arm { |
| 35 |
| 36 namespace v8i = v8::internal; |
| 37 |
| 38 |
| 39 // These register names are defined in a way to match the native disassembler |
| 40 // formatting. See for example the command "objdump -d <binary file>". |
| 41 const char* Registers::names_[kNumRegisters] = { |
| 42 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
| 43 "r8", "r9", "r10", "fp", "ip", "sp", "lr", "pc", |
| 44 }; |
| 45 |
| 46 |
| 47 // List of alias names which can be used when referring to ARM registers. |
| 48 const Registers::RegisterAlias Registers::aliases_[] = { |
| 49 {10, "sl"}, |
| 50 {11, "r11"}, |
| 51 {12, "r12"}, |
| 52 {13, "r13"}, |
| 53 {14, "r14"}, |
| 54 {15, "r15"}, |
| 55 {kNoRegister, NULL} |
| 56 }; |
| 57 |
| 58 |
| 59 const char* Registers::Name(int reg) { |
| 60 const char* result; |
| 61 if ((0 <= reg) && (reg < kNumRegisters)) { |
| 62 result = names_[reg]; |
| 63 } else { |
| 64 result = "noreg"; |
| 65 } |
| 66 return result; |
| 67 } |
| 68 |
| 69 |
| 70 int Registers::Number(const char* name) { |
| 71 // Look through the canonical names. |
| 72 for (int i = 0; i < kNumRegisters; i++) { |
| 73 if (strcmp(names_[i], name) == 0) { |
| 74 return i; |
| 75 } |
| 76 } |
| 77 |
| 78 // Look through the alias names. |
| 79 int i = 0; |
| 80 while (aliases_[i].reg != kNoRegister) { |
| 81 if (strcmp(aliases_[i].name, name) == 0) { |
| 82 return aliases_[i].reg; |
| 83 } |
| 84 i++; |
| 85 } |
| 86 |
| 87 // No register with the reguested name found. |
| 88 return kNoRegister; |
| 89 } |
| 90 |
| 91 |
| 92 } } // namespace assembler::arm |
OLD | NEW |