OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 #if V8_TARGET_ARCH_A64 | |
31 | |
32 #include "globals.h" | |
33 #include "utils.h" | |
34 #include "a64/decoder-a64.h" | |
35 | |
36 | |
37 namespace v8 { | |
38 namespace internal { | |
39 | |
40 | |
41 void DispatchingDecoderVisitor::AppendVisitor(DecoderVisitor* new_visitor) { | |
42 visitors_.remove(new_visitor); | |
43 visitors_.push_front(new_visitor); | |
44 } | |
45 | |
46 | |
47 void DispatchingDecoderVisitor::PrependVisitor(DecoderVisitor* new_visitor) { | |
48 visitors_.remove(new_visitor); | |
49 visitors_.push_back(new_visitor); | |
50 } | |
51 | |
52 | |
53 void DispatchingDecoderVisitor::InsertVisitorBefore( | |
54 DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) { | |
55 visitors_.remove(new_visitor); | |
56 std::list<DecoderVisitor*>::iterator it; | |
57 for (it = visitors_.begin(); it != visitors_.end(); it++) { | |
58 if (*it == registered_visitor) { | |
59 visitors_.insert(it, new_visitor); | |
60 return; | |
61 } | |
62 } | |
63 // We reached the end of the list. The last element must be | |
64 // registered_visitor. | |
65 ASSERT(*it == registered_visitor); | |
66 visitors_.insert(it, new_visitor); | |
67 } | |
68 | |
69 | |
70 void DispatchingDecoderVisitor::InsertVisitorAfter( | |
71 DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) { | |
72 visitors_.remove(new_visitor); | |
73 std::list<DecoderVisitor*>::iterator it; | |
74 for (it = visitors_.begin(); it != visitors_.end(); it++) { | |
75 if (*it == registered_visitor) { | |
76 it++; | |
77 visitors_.insert(it, new_visitor); | |
78 return; | |
79 } | |
80 } | |
81 // We reached the end of the list. The last element must be | |
82 // registered_visitor. | |
83 ASSERT(*it == registered_visitor); | |
84 visitors_.push_back(new_visitor); | |
85 } | |
86 | |
87 | |
88 void DispatchingDecoderVisitor::RemoveVisitor(DecoderVisitor* visitor) { | |
89 visitors_.remove(visitor); | |
90 } | |
91 | |
92 | |
93 #define DEFINE_VISITOR_CALLERS(A) \ | |
94 void DispatchingDecoderVisitor::Visit##A(Instruction* instr) { \ | |
95 if (!(instr->Mask(A##FMask) == A##Fixed)) { \ | |
96 ASSERT(instr->Mask(A##FMask) == A##Fixed); \ | |
97 } \ | |
98 std::list<DecoderVisitor*>::iterator it; \ | |
99 for (it = visitors_.begin(); it != visitors_.end(); it++) { \ | |
100 (*it)->Visit##A(instr); \ | |
101 } \ | |
102 } | |
103 VISITOR_LIST(DEFINE_VISITOR_CALLERS) | |
104 #undef DEFINE_VISITOR_CALLERS | |
105 | |
106 | |
107 } } // namespace v8::internal | |
108 | |
109 #endif // V8_TARGET_ARCH_A64 | |
OLD | NEW |