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