1 // Copyright 2013 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_ARM64 6 7 #include "src/arm64/decoder-arm64.h" 8 #include "src/globals.h" 9 #include "src/utils.h" 10 11 12 namespace v8 { 13 namespace internal { 14 15 16 void DispatchingDecoderVisitor::AppendVisitor(DecoderVisitor* new_visitor) { 17 visitors_.remove(new_visitor); 18 visitors_.push_back(new_visitor); 19 } 20 21 22 void DispatchingDecoderVisitor::PrependVisitor(DecoderVisitor* new_visitor) { 23 visitors_.remove(new_visitor); 24 visitors_.push_front(new_visitor); 25 } 26 27 28 void DispatchingDecoderVisitor::InsertVisitorBefore( 29 DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) { 30 visitors_.remove(new_visitor); 31 std::list<DecoderVisitor*>::iterator it; 32 for (it = visitors_.begin(); it != visitors_.end(); it++) { 33 if (*it == registered_visitor) { 34 visitors_.insert(it, new_visitor); 35 return; 36 } 37 } 38 // We reached the end of the list. The last element must be 39 // registered_visitor. 40 DCHECK(*it == registered_visitor); 41 visitors_.insert(it, new_visitor); 42 } 43 44 45 void DispatchingDecoderVisitor::InsertVisitorAfter( 46 DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) { 47 visitors_.remove(new_visitor); 48 std::list<DecoderVisitor*>::iterator it; 49 for (it = visitors_.begin(); it != visitors_.end(); it++) { 50 if (*it == registered_visitor) { 51 it++; 52 visitors_.insert(it, new_visitor); 53 return; 54 } 55 } 56 // We reached the end of the list. The last element must be 57 // registered_visitor. 58 DCHECK(*it == registered_visitor); 59 visitors_.push_back(new_visitor); 60 } 61 62 63 void DispatchingDecoderVisitor::RemoveVisitor(DecoderVisitor* visitor) { 64 visitors_.remove(visitor); 65 } 66 67 68 #define DEFINE_VISITOR_CALLERS(A) \ 69 void DispatchingDecoderVisitor::Visit##A(Instruction* instr) { \ 70 if (!(instr->Mask(A##FMask) == A##Fixed)) { \ 71 DCHECK(instr->Mask(A##FMask) == A##Fixed); \ 72 } \ 73 std::list<DecoderVisitor*>::iterator it; \ 74 for (it = visitors_.begin(); it != visitors_.end(); it++) { \ 75 (*it)->Visit##A(instr); \ 76 } \ 77 } 78 VISITOR_LIST(DEFINE_VISITOR_CALLERS) 79 #undef DEFINE_VISITOR_CALLERS 80 81 82 } // namespace internal 83 } // namespace v8 84 85 #endif // V8_TARGET_ARCH_ARM64 86