Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: src/compiler/node-matchers.h

Issue 1779713009: Implement optional turbofan UnalignedLoad and UnalignedStore operators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Unaligned access simulate using load/shift/or and store/shift/and Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_NODE_MATCHERS_H_ 5 #ifndef V8_COMPILER_NODE_MATCHERS_H_
6 #define V8_COMPILER_NODE_MATCHERS_H_ 6 #define V8_COMPILER_NODE_MATCHERS_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 // TODO(turbofan): Move ExternalReference out of assembler.h 10 // TODO(turbofan): Move ExternalReference out of assembler.h
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 : NodeMatcher(node), value_(), has_value_(false) { 98 : NodeMatcher(node), value_(), has_value_(false) {
99 if (opcode() == IrOpcode::kInt32Constant) { 99 if (opcode() == IrOpcode::kInt32Constant) {
100 value_ = static_cast<uint32_t>(OpParameter<int32_t>(node)); 100 value_ = static_cast<uint32_t>(OpParameter<int32_t>(node));
101 has_value_ = true; 101 has_value_ = true;
102 } else if (opcode() == IrOpcode::kInt64Constant) { 102 } else if (opcode() == IrOpcode::kInt64Constant) {
103 value_ = static_cast<uint64_t>(OpParameter<int64_t>(node)); 103 value_ = static_cast<uint64_t>(OpParameter<int64_t>(node));
104 has_value_ = true; 104 has_value_ = true;
105 } 105 }
106 } 106 }
107 107
108 template <>
109 inline ValueMatcher<
110 uint32_t, IrOpcode::kRelocatableInt32Constant>::ValueMatcher(Node* node)
111 : NodeMatcher(node),
112 value_(),
113 has_value_(opcode() == IrOpcode::kInt32Constant ||
114 opcode() == IrOpcode::kRelocatableInt32Constant) {
115 if (has_value_) {
116 value_ = static_cast<uint32_t>(OpParameter<int32_t>(node));
117 }
118 }
119
120 template <>
121 inline ValueMatcher<
122 uint64_t, IrOpcode::kRelocatableInt64Constant>::ValueMatcher(Node* node)
123 : NodeMatcher(node), value_(), has_value_(false) {
124 if (opcode() == IrOpcode::kInt32Constant ||
125 opcode() == IrOpcode::kRelocatableInt32Constant) {
126 value_ = static_cast<uint32_t>(OpParameter<int32_t>(node));
127 has_value_ = true;
128 } else if (opcode() == IrOpcode::kInt64Constant ||
129 opcode() == IrOpcode::kRelocatableInt64Constant) {
130 value_ = static_cast<uint64_t>(OpParameter<int64_t>(node));
131 has_value_ = true;
132 }
133 }
108 134
109 // A pattern matcher for integer constants. 135 // A pattern matcher for integer constants.
110 template <typename T, IrOpcode::Value kOpcode> 136 template <typename T, IrOpcode::Value kOpcode>
111 struct IntMatcher final : public ValueMatcher<T, kOpcode> { 137 struct IntMatcher final : public ValueMatcher<T, kOpcode> {
112 explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} 138 explicit IntMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
113 139
114 bool Is(const T& value) const { 140 bool Is(const T& value) const {
115 return this->HasValue() && this->Value() == value; 141 return this->HasValue() && this->Value() == value;
116 } 142 }
117 bool IsInRange(const T& low, const T& high) const { 143 bool IsInRange(const T& low, const T& high) const {
118 return this->HasValue() && low <= this->Value() && this->Value() <= high; 144 return this->HasValue() && low <= this->Value() && this->Value() <= high;
119 } 145 }
120 bool IsMultipleOf(T n) const { 146 bool IsMultipleOf(T n) const {
121 return this->HasValue() && (this->Value() % n) == 0; 147 return this->HasValue() && (this->Value() % n) == 0;
122 } 148 }
123 bool IsPowerOf2() const { 149 bool IsPowerOf2() const {
124 return this->HasValue() && this->Value() > 0 && 150 return this->HasValue() && this->Value() > 0 &&
125 (this->Value() & (this->Value() - 1)) == 0; 151 (this->Value() & (this->Value() - 1)) == 0;
126 } 152 }
127 bool IsNegativePowerOf2() const { 153 bool IsNegativePowerOf2() const {
128 return this->HasValue() && this->Value() < 0 && 154 return this->HasValue() && this->Value() < 0 &&
129 (-this->Value() & (-this->Value() - 1)) == 0; 155 (-this->Value() & (-this->Value() - 1)) == 0;
130 } 156 }
131 }; 157 };
132 158
133 typedef IntMatcher<int32_t, IrOpcode::kInt32Constant> Int32Matcher; 159 typedef IntMatcher<int32_t, IrOpcode::kInt32Constant> Int32Matcher;
134 typedef IntMatcher<uint32_t, IrOpcode::kInt32Constant> Uint32Matcher; 160 typedef IntMatcher<uint32_t, IrOpcode::kInt32Constant> Uint32Matcher;
161 typedef IntMatcher<uint32_t, IrOpcode::kRelocatableInt32Constant>
162 RelocatableInt32Matcher;
135 typedef IntMatcher<int64_t, IrOpcode::kInt64Constant> Int64Matcher; 163 typedef IntMatcher<int64_t, IrOpcode::kInt64Constant> Int64Matcher;
136 typedef IntMatcher<uint64_t, IrOpcode::kInt64Constant> Uint64Matcher; 164 typedef IntMatcher<uint64_t, IrOpcode::kInt64Constant> Uint64Matcher;
165 typedef IntMatcher<uint64_t, IrOpcode::kRelocatableInt64Constant>
166 RelocatableInt64Matcher;
137 #if V8_HOST_ARCH_32_BIT 167 #if V8_HOST_ARCH_32_BIT
138 typedef Int32Matcher IntPtrMatcher; 168 typedef Int32Matcher IntPtrMatcher;
139 typedef Uint32Matcher UintPtrMatcher; 169 typedef Uint32Matcher UintPtrMatcher;
170 typedef RelocatableInt32Matcher PtrMatcher;
140 #else 171 #else
141 typedef Int64Matcher IntPtrMatcher; 172 typedef Int64Matcher IntPtrMatcher;
142 typedef Uint64Matcher UintPtrMatcher; 173 typedef Uint64Matcher UintPtrMatcher;
174 typedef RelocatableInt64Matcher PtrMatcher;
143 #endif 175 #endif
144 176
145 177
146 // A pattern matcher for floating point constants. 178 // A pattern matcher for floating point constants.
147 template <typename T, IrOpcode::Value kOpcode> 179 template <typename T, IrOpcode::Value kOpcode>
148 struct FloatMatcher final : public ValueMatcher<T, kOpcode> { 180 struct FloatMatcher final : public ValueMatcher<T, kOpcode> {
149 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {} 181 explicit FloatMatcher(Node* node) : ValueMatcher<T, kOpcode>(node) {}
150 182
151 bool Is(const T& value) const { 183 bool Is(const T& value) const {
152 return this->HasValue() && this->Value() == value; 184 return this->HasValue() && this->Value() == value;
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 Node* branch_; 640 Node* branch_;
609 Node* if_true_; 641 Node* if_true_;
610 Node* if_false_; 642 Node* if_false_;
611 }; 643 };
612 644
613 } // namespace compiler 645 } // namespace compiler
614 } // namespace internal 646 } // namespace internal
615 } // namespace v8 647 } // namespace v8
616 648
617 #endif // V8_COMPILER_NODE_MATCHERS_H_ 649 #endif // V8_COMPILER_NODE_MATCHERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698