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

Side by Side Diff: test/unittests/compiler/node-test-utils.cc

Issue 2122853002: Implement UnaligedLoad and UnaligedStore turbofan operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nits. Fixes some errors Created 4 years, 5 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
« no previous file with comments | « test/unittests/compiler/node-test-utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "test/unittests/compiler/node-test-utils.h" 5 #include "test/unittests/compiler/node-test-utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "src/assembler.h" 9 #include "src/assembler.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1187
1188 private: 1188 private:
1189 const Matcher<ElementAccess> access_matcher_; 1189 const Matcher<ElementAccess> access_matcher_;
1190 const Matcher<Node*> base_matcher_; 1190 const Matcher<Node*> base_matcher_;
1191 const Matcher<Node*> index_matcher_; 1191 const Matcher<Node*> index_matcher_;
1192 const Matcher<Node*> value_matcher_; 1192 const Matcher<Node*> value_matcher_;
1193 const Matcher<Node*> effect_matcher_; 1193 const Matcher<Node*> effect_matcher_;
1194 const Matcher<Node*> control_matcher_; 1194 const Matcher<Node*> control_matcher_;
1195 }; 1195 };
1196 1196
1197 #define LOAD_MATCHER(kLoad) \
1198 class Is##kLoad##Matcher final : public NodeMatcher { \
1199 public: \
1200 Is##kLoad##Matcher(const Matcher<kLoad##Representation>& rep_matcher, \
1201 const Matcher<Node*>& base_matcher, \
1202 const Matcher<Node*>& index_matcher, \
1203 const Matcher<Node*>& effect_matcher, \
1204 const Matcher<Node*>& control_matcher) \
1205 : NodeMatcher(IrOpcode::k##kLoad), \
1206 rep_matcher_(rep_matcher), \
1207 base_matcher_(base_matcher), \
1208 index_matcher_(index_matcher), \
1209 effect_matcher_(effect_matcher), \
1210 control_matcher_(control_matcher) {} \
1211 \
1212 void DescribeTo(std::ostream* os) const final { \
1213 NodeMatcher::DescribeTo(os); \
1214 *os << " whose rep ("; \
1215 rep_matcher_.DescribeTo(os); \
1216 *os << "), base ("; \
1217 base_matcher_.DescribeTo(os); \
1218 *os << "), index ("; \
1219 index_matcher_.DescribeTo(os); \
1220 *os << "), effect ("; \
1221 effect_matcher_.DescribeTo(os); \
1222 *os << ") and control ("; \
1223 control_matcher_.DescribeTo(os); \
1224 *os << ")"; \
1225 } \
1226 \
1227 bool MatchAndExplain(Node* node, \
1228 MatchResultListener* listener) const final { \
1229 Node* effect_node = nullptr; \
1230 Node* control_node = nullptr; \
1231 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) { \
1232 effect_node = NodeProperties::GetEffectInput(node); \
1233 } \
1234 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \
1235 control_node = NodeProperties::GetControlInput(node); \
1236 } \
1237 return (NodeMatcher::MatchAndExplain(node, listener) && \
1238 PrintMatchAndExplain(OpParameter<kLoad##Representation>(node), \
1239 "rep", rep_matcher_, listener) && \
1240 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \
1241 "base", base_matcher_, listener) && \
1242 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \
1243 "index", index_matcher_, listener) && \
1244 PrintMatchAndExplain(effect_node, "effect", effect_matcher_, \
1245 listener) && \
1246 PrintMatchAndExplain(control_node, "control", control_matcher_, \
1247 listener)); \
1248 } \
1249 \
1250 private: \
1251 const Matcher<kLoad##Representation> rep_matcher_; \
1252 const Matcher<Node*> base_matcher_; \
1253 const Matcher<Node*> index_matcher_; \
1254 const Matcher<Node*> effect_matcher_; \
1255 const Matcher<Node*> control_matcher_; \
1256 };
1197 1257
1198 class IsLoadMatcher final : public NodeMatcher { 1258 LOAD_MATCHER(Load)
1199 public: 1259 LOAD_MATCHER(UnalignedLoad)
1200 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher,
1201 const Matcher<Node*>& base_matcher,
1202 const Matcher<Node*>& index_matcher,
1203 const Matcher<Node*>& effect_matcher,
1204 const Matcher<Node*>& control_matcher)
1205 : NodeMatcher(IrOpcode::kLoad),
1206 rep_matcher_(rep_matcher),
1207 base_matcher_(base_matcher),
1208 index_matcher_(index_matcher),
1209 effect_matcher_(effect_matcher),
1210 control_matcher_(control_matcher) {}
1211 1260
1212 void DescribeTo(std::ostream* os) const final { 1261 #define STORE_MATCHER(kStore) \
1213 NodeMatcher::DescribeTo(os); 1262 class Is##kStore##Matcher final : public NodeMatcher { \
1214 *os << " whose rep ("; 1263 public: \
1215 rep_matcher_.DescribeTo(os); 1264 Is##kStore##Matcher(const Matcher<kStore##Representation>& rep_matcher, \
1216 *os << "), base ("; 1265 const Matcher<Node*>& base_matcher, \
1217 base_matcher_.DescribeTo(os); 1266 const Matcher<Node*>& index_matcher, \
1218 *os << "), index ("; 1267 const Matcher<Node*>& value_matcher, \
1219 index_matcher_.DescribeTo(os); 1268 const Matcher<Node*>& effect_matcher, \
1220 *os << "), effect ("; 1269 const Matcher<Node*>& control_matcher) \
1221 effect_matcher_.DescribeTo(os); 1270 : NodeMatcher(IrOpcode::k##kStore), \
1222 *os << ") and control ("; 1271 rep_matcher_(rep_matcher), \
1223 control_matcher_.DescribeTo(os); 1272 base_matcher_(base_matcher), \
1224 *os << ")"; 1273 index_matcher_(index_matcher), \
1225 } 1274 value_matcher_(value_matcher), \
1275 effect_matcher_(effect_matcher), \
1276 control_matcher_(control_matcher) {} \
1277 \
1278 void DescribeTo(std::ostream* os) const final { \
1279 NodeMatcher::DescribeTo(os); \
1280 *os << " whose rep ("; \
1281 rep_matcher_.DescribeTo(os); \
1282 *os << "), base ("; \
1283 base_matcher_.DescribeTo(os); \
1284 *os << "), index ("; \
1285 index_matcher_.DescribeTo(os); \
1286 *os << "), value ("; \
1287 value_matcher_.DescribeTo(os); \
1288 *os << "), effect ("; \
1289 effect_matcher_.DescribeTo(os); \
1290 *os << ") and control ("; \
1291 control_matcher_.DescribeTo(os); \
1292 *os << ")"; \
1293 } \
1294 \
1295 bool MatchAndExplain(Node* node, \
1296 MatchResultListener* listener) const final { \
1297 Node* effect_node = nullptr; \
1298 Node* control_node = nullptr; \
1299 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) { \
1300 effect_node = NodeProperties::GetEffectInput(node); \
1301 } \
1302 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \
1303 control_node = NodeProperties::GetControlInput(node); \
1304 } \
1305 return (NodeMatcher::MatchAndExplain(node, listener) && \
1306 PrintMatchAndExplain(OpParameter<kStore##Representation>(node), \
1307 "rep", rep_matcher_, listener) && \
1308 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \
1309 "base", base_matcher_, listener) && \
1310 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \
1311 "index", index_matcher_, listener) && \
1312 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), \
1313 "value", value_matcher_, listener) && \
1314 PrintMatchAndExplain(effect_node, "effect", effect_matcher_, \
1315 listener) && \
1316 PrintMatchAndExplain(control_node, "control", control_matcher_, \
1317 listener)); \
1318 } \
1319 \
1320 private: \
1321 const Matcher<kStore##Representation> rep_matcher_; \
1322 const Matcher<Node*> base_matcher_; \
1323 const Matcher<Node*> index_matcher_; \
1324 const Matcher<Node*> value_matcher_; \
1325 const Matcher<Node*> effect_matcher_; \
1326 const Matcher<Node*> control_matcher_; \
1327 };
1226 1328
1227 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { 1329 STORE_MATCHER(Store)
1228 Node* effect_node = nullptr; 1330 STORE_MATCHER(UnalignedStore)
1229 Node* control_node = nullptr;
1230 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
1231 effect_node = NodeProperties::GetEffectInput(node);
1232 }
1233 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
1234 control_node = NodeProperties::GetControlInput(node);
1235 }
1236 return (NodeMatcher::MatchAndExplain(node, listener) &&
1237 PrintMatchAndExplain(OpParameter<LoadRepresentation>(node), "rep",
1238 rep_matcher_, listener) &&
1239 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1240 base_matcher_, listener) &&
1241 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1242 "index", index_matcher_, listener) &&
1243 PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
1244 listener) &&
1245 PrintMatchAndExplain(control_node, "control", control_matcher_,
1246 listener));
1247 }
1248
1249 private:
1250 const Matcher<LoadRepresentation> rep_matcher_;
1251 const Matcher<Node*> base_matcher_;
1252 const Matcher<Node*> index_matcher_;
1253 const Matcher<Node*> effect_matcher_;
1254 const Matcher<Node*> control_matcher_;
1255 };
1256
1257
1258 class IsStoreMatcher final : public NodeMatcher {
1259 public:
1260 IsStoreMatcher(const Matcher<StoreRepresentation>& rep_matcher,
1261 const Matcher<Node*>& base_matcher,
1262 const Matcher<Node*>& index_matcher,
1263 const Matcher<Node*>& value_matcher,
1264 const Matcher<Node*>& effect_matcher,
1265 const Matcher<Node*>& control_matcher)
1266 : NodeMatcher(IrOpcode::kStore),
1267 rep_matcher_(rep_matcher),
1268 base_matcher_(base_matcher),
1269 index_matcher_(index_matcher),
1270 value_matcher_(value_matcher),
1271 effect_matcher_(effect_matcher),
1272 control_matcher_(control_matcher) {}
1273
1274 void DescribeTo(std::ostream* os) const final {
1275 NodeMatcher::DescribeTo(os);
1276 *os << " whose rep (";
1277 rep_matcher_.DescribeTo(os);
1278 *os << "), base (";
1279 base_matcher_.DescribeTo(os);
1280 *os << "), index (";
1281 index_matcher_.DescribeTo(os);
1282 *os << "), value (";
1283 value_matcher_.DescribeTo(os);
1284 *os << "), effect (";
1285 effect_matcher_.DescribeTo(os);
1286 *os << ") and control (";
1287 control_matcher_.DescribeTo(os);
1288 *os << ")";
1289 }
1290
1291 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1292 Node* effect_node = nullptr;
1293 Node* control_node = nullptr;
1294 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
1295 effect_node = NodeProperties::GetEffectInput(node);
1296 }
1297 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
1298 control_node = NodeProperties::GetControlInput(node);
1299 }
1300 return (NodeMatcher::MatchAndExplain(node, listener) &&
1301 PrintMatchAndExplain(OpParameter<StoreRepresentation>(node), "rep",
1302 rep_matcher_, listener) &&
1303 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1304 base_matcher_, listener) &&
1305 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1306 "index", index_matcher_, listener) &&
1307 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
1308 "value", value_matcher_, listener) &&
1309 PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
1310 listener) &&
1311 PrintMatchAndExplain(control_node, "control", control_matcher_,
1312 listener));
1313 }
1314
1315 private:
1316 const Matcher<StoreRepresentation> rep_matcher_;
1317 const Matcher<Node*> base_matcher_;
1318 const Matcher<Node*> index_matcher_;
1319 const Matcher<Node*> value_matcher_;
1320 const Matcher<Node*> effect_matcher_;
1321 const Matcher<Node*> control_matcher_;
1322 };
1323 1331
1324 class IsStackSlotMatcher final : public NodeMatcher { 1332 class IsStackSlotMatcher final : public NodeMatcher {
1325 public: 1333 public:
1326 explicit IsStackSlotMatcher(const Matcher<MachineRepresentation>& rep_matcher) 1334 explicit IsStackSlotMatcher(const Matcher<MachineRepresentation>& rep_matcher)
1327 : NodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {} 1335 : NodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {}
1328 1336
1329 void DescribeTo(std::ostream* os) const final { 1337 void DescribeTo(std::ostream* os) const final {
1330 NodeMatcher::DescribeTo(os); 1338 NodeMatcher::DescribeTo(os);
1331 *os << " whose rep ("; 1339 *os << " whose rep (";
1332 rep_matcher_.DescribeTo(os); 1340 rep_matcher_.DescribeTo(os);
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 const Matcher<Node*>& base_matcher, 2136 const Matcher<Node*>& base_matcher,
2129 const Matcher<Node*>& index_matcher, 2137 const Matcher<Node*>& index_matcher,
2130 const Matcher<Node*>& value_matcher, 2138 const Matcher<Node*>& value_matcher,
2131 const Matcher<Node*>& effect_matcher, 2139 const Matcher<Node*>& effect_matcher,
2132 const Matcher<Node*>& control_matcher) { 2140 const Matcher<Node*>& control_matcher) {
2133 return MakeMatcher(new IsStoreElementMatcher( 2141 return MakeMatcher(new IsStoreElementMatcher(
2134 access_matcher, base_matcher, index_matcher, value_matcher, 2142 access_matcher, base_matcher, index_matcher, value_matcher,
2135 effect_matcher, control_matcher)); 2143 effect_matcher, control_matcher));
2136 } 2144 }
2137 2145
2138
2139 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, 2146 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
2140 const Matcher<Node*>& base_matcher, 2147 const Matcher<Node*>& base_matcher,
2141 const Matcher<Node*>& index_matcher, 2148 const Matcher<Node*>& index_matcher,
2142 const Matcher<Node*>& effect_matcher, 2149 const Matcher<Node*>& effect_matcher,
2143 const Matcher<Node*>& control_matcher) { 2150 const Matcher<Node*>& control_matcher) {
2144 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, 2151 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
2145 effect_matcher, control_matcher)); 2152 effect_matcher, control_matcher));
2146 } 2153 }
2147 2154
2155 Matcher<Node*> IsUnalignedLoad(
2156 const Matcher<UnalignedLoadRepresentation>& rep_matcher,
2157 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher,
2158 const Matcher<Node*>& effect_matcher,
2159 const Matcher<Node*>& control_matcher) {
2160 return MakeMatcher(new IsUnalignedLoadMatcher(rep_matcher, base_matcher,
2161 index_matcher, effect_matcher,
2162 control_matcher));
2163 }
2148 2164
2149 Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher, 2165 Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
2150 const Matcher<Node*>& base_matcher, 2166 const Matcher<Node*>& base_matcher,
2151 const Matcher<Node*>& index_matcher, 2167 const Matcher<Node*>& index_matcher,
2152 const Matcher<Node*>& value_matcher, 2168 const Matcher<Node*>& value_matcher,
2153 const Matcher<Node*>& effect_matcher, 2169 const Matcher<Node*>& effect_matcher,
2154 const Matcher<Node*>& control_matcher) { 2170 const Matcher<Node*>& control_matcher) {
2155 return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher, 2171 return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher,
2156 index_matcher, value_matcher, 2172 index_matcher, value_matcher,
2157 effect_matcher, control_matcher)); 2173 effect_matcher, control_matcher));
2158 } 2174 }
2159 2175
2176 Matcher<Node*> IsUnalignedStore(
2177 const Matcher<UnalignedStoreRepresentation>& rep_matcher,
2178 const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher,
2179 const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher,
2180 const Matcher<Node*>& control_matcher) {
2181 return MakeMatcher(new IsUnalignedStoreMatcher(
2182 rep_matcher, base_matcher, index_matcher, value_matcher, effect_matcher,
2183 control_matcher));
2184 }
2185
2160 Matcher<Node*> IsStackSlot(const Matcher<MachineRepresentation>& rep_matcher) { 2186 Matcher<Node*> IsStackSlot(const Matcher<MachineRepresentation>& rep_matcher) {
2161 return MakeMatcher(new IsStackSlotMatcher(rep_matcher)); 2187 return MakeMatcher(new IsStackSlotMatcher(rep_matcher));
2162 } 2188 }
2163 2189
2164 Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher, 2190 Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher,
2165 const Matcher<Node*>& context_matcher, 2191 const Matcher<Node*>& context_matcher,
2166 const Matcher<Node*>& effect_matcher, 2192 const Matcher<Node*>& effect_matcher,
2167 const Matcher<Node*>& control_matcher) { 2193 const Matcher<Node*>& control_matcher) {
2168 return MakeMatcher(new IsToNumberMatcher(base_matcher, context_matcher, 2194 return MakeMatcher(new IsToNumberMatcher(base_matcher, context_matcher,
2169 effect_matcher, control_matcher)); 2195 effect_matcher, control_matcher));
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 IS_UNOP_MATCHER(ObjectIsSmi) 2350 IS_UNOP_MATCHER(ObjectIsSmi)
2325 IS_UNOP_MATCHER(StringFromCharCode) 2351 IS_UNOP_MATCHER(StringFromCharCode)
2326 IS_UNOP_MATCHER(Word32Clz) 2352 IS_UNOP_MATCHER(Word32Clz)
2327 IS_UNOP_MATCHER(Word32Ctz) 2353 IS_UNOP_MATCHER(Word32Ctz)
2328 IS_UNOP_MATCHER(Word32Popcnt) 2354 IS_UNOP_MATCHER(Word32Popcnt)
2329 #undef IS_UNOP_MATCHER 2355 #undef IS_UNOP_MATCHER
2330 2356
2331 } // namespace compiler 2357 } // namespace compiler
2332 } // namespace internal 2358 } // namespace internal
2333 } // namespace v8 2359 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698