blob: 56b3e0255ece035f92f9cf294f9846f44138a33e [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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
Ben Murdochb8a8cc12014-11-26 15:28:44 +00005#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
12namespace v8 {
13namespace internal {
14
15
16void DispatchingDecoderVisitor::AppendVisitor(DecoderVisitor* new_visitor) {
17 visitors_.remove(new_visitor);
18 visitors_.push_back(new_visitor);
19}
20
21
22void DispatchingDecoderVisitor::PrependVisitor(DecoderVisitor* new_visitor) {
23 visitors_.remove(new_visitor);
24 visitors_.push_front(new_visitor);
25}
26
27
28void 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
45void 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
63void 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 }
78VISITOR_LIST(DEFINE_VISITOR_CALLERS)
79#undef DEFINE_VISITOR_CALLERS
80
81
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000082} // namespace internal
83} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +000084
85#endif // V8_TARGET_ARCH_ARM64