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

Side by Side Diff: src/hydrogen-instructions.h

Issue 6328009: Move swapping of operands for commutative binary operations to the lithium IR... Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 public: 1864 public:
1865 HBinaryOperation(HValue* left, HValue* right) { 1865 HBinaryOperation(HValue* left, HValue* right) {
1866 ASSERT(left != NULL && right != NULL); 1866 ASSERT(left != NULL && right != NULL);
1867 SetOperandAt(0, left); 1867 SetOperandAt(0, left);
1868 SetOperandAt(1, right); 1868 SetOperandAt(1, right);
1869 } 1869 }
1870 1870
1871 HValue* left() const { return OperandAt(0); } 1871 HValue* left() const { return OperandAt(0); }
1872 HValue* right() const { return OperandAt(1); } 1872 HValue* right() const { return OperandAt(1); }
1873 1873
1874 // TODO(kasperl): Move these helpers to the IA-32 Lithium
1875 // instruction sequence builder.
1876 HValue* LeastConstantOperand() const {
1877 if (IsCommutative() && left()->IsConstant()) return right();
1878 return left();
1879 }
1880 HValue* MostConstantOperand() const {
1881 if (IsCommutative() && left()->IsConstant()) return left();
1882 return right();
1883 }
1884
1885 virtual bool IsCommutative() const { return false; }
1886
1887 virtual void PrintDataTo(StringStream* stream) const; 1874 virtual void PrintDataTo(StringStream* stream) const;
1888 virtual int OperandCount() const { return operands_.length(); } 1875 virtual int OperandCount() const { return operands_.length(); }
1889 virtual HValue* OperandAt(int index) const { return operands_[index]; } 1876 virtual HValue* OperandAt(int index) const { return operands_[index]; }
1890 1877
1891 DECLARE_INSTRUCTION(BinaryOperation) 1878 DECLARE_INSTRUCTION(BinaryOperation)
1892 1879
1893 protected: 1880 protected:
1894 virtual void InternalSetOperandAt(int index, HValue* value) { 1881 virtual void InternalSetOperandAt(int index, HValue* value) {
1895 operands_[index] = value; 1882 operands_[index] = value;
1896 } 1883 }
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 DECLARE_CONCRETE_INSTRUCTION(Power, "power") 2315 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
2329 }; 2316 };
2330 2317
2331 2318
2332 class HAdd: public HArithmeticBinaryOperation { 2319 class HAdd: public HArithmeticBinaryOperation {
2333 public: 2320 public:
2334 HAdd(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2321 HAdd(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
2335 SetFlag(kCanOverflow); 2322 SetFlag(kCanOverflow);
2336 } 2323 }
2337 2324
2338 // Add is only commutative if two integer values are added and not if two
2339 // tagged values are added (because it might be a String concatenation).
2340 virtual bool IsCommutative() const {
2341 return !representation().IsTagged();
2342 }
2343
2344 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2325 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2345 2326
2346 virtual HType CalculateInferredType() const; 2327 virtual HType CalculateInferredType() const;
2347 2328
2348 DECLARE_CONCRETE_INSTRUCTION(Add, "add") 2329 DECLARE_CONCRETE_INSTRUCTION(Add, "add")
2349 2330
2350 protected: 2331 protected:
2351 virtual Range* InferRange(); 2332 virtual Range* InferRange();
2352 }; 2333 };
2353 2334
(...skipping 14 matching lines...) Expand all
2368 2349
2369 2350
2370 class HMul: public HArithmeticBinaryOperation { 2351 class HMul: public HArithmeticBinaryOperation {
2371 public: 2352 public:
2372 HMul(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2353 HMul(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
2373 SetFlag(kCanOverflow); 2354 SetFlag(kCanOverflow);
2374 } 2355 }
2375 2356
2376 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2357 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2377 2358
2378 // Only commutative if it is certain that not two objects are multiplicated.
2379 virtual bool IsCommutative() const {
2380 return !representation().IsTagged();
2381 }
2382
2383 DECLARE_CONCRETE_INSTRUCTION(Mul, "mul") 2359 DECLARE_CONCRETE_INSTRUCTION(Mul, "mul")
2384 2360
2385 protected: 2361 protected:
2386 virtual Range* InferRange(); 2362 virtual Range* InferRange();
2387 }; 2363 };
2388 2364
2389 2365
2390 class HMod: public HArithmeticBinaryOperation { 2366 class HMod: public HArithmeticBinaryOperation {
2391 public: 2367 public:
2392 HMod(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2368 HMod(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
(...skipping 23 matching lines...) Expand all
2416 protected: 2392 protected:
2417 virtual Range* InferRange(); 2393 virtual Range* InferRange();
2418 }; 2394 };
2419 2395
2420 2396
2421 class HBitAnd: public HBitwiseBinaryOperation { 2397 class HBitAnd: public HBitwiseBinaryOperation {
2422 public: 2398 public:
2423 HBitAnd(HValue* left, HValue* right) 2399 HBitAnd(HValue* left, HValue* right)
2424 : HBitwiseBinaryOperation(left, right) { } 2400 : HBitwiseBinaryOperation(left, right) { }
2425 2401
2426 virtual bool IsCommutative() const { return true; }
2427 virtual HType CalculateInferredType() const; 2402 virtual HType CalculateInferredType() const;
2428 2403
2429 DECLARE_CONCRETE_INSTRUCTION(BitAnd, "bit_and") 2404 DECLARE_CONCRETE_INSTRUCTION(BitAnd, "bit_and")
2430 2405
2431 protected: 2406 protected:
2432 virtual Range* InferRange(); 2407 virtual Range* InferRange();
2433 }; 2408 };
2434 2409
2435 2410
2436 class HBitXor: public HBitwiseBinaryOperation { 2411 class HBitXor: public HBitwiseBinaryOperation {
2437 public: 2412 public:
2438 HBitXor(HValue* left, HValue* right) 2413 HBitXor(HValue* left, HValue* right)
2439 : HBitwiseBinaryOperation(left, right) { } 2414 : HBitwiseBinaryOperation(left, right) { }
2440 2415
2441 virtual bool IsCommutative() const { return true; }
2442 virtual HType CalculateInferredType() const; 2416 virtual HType CalculateInferredType() const;
2443 2417
2444 DECLARE_CONCRETE_INSTRUCTION(BitXor, "bit_xor") 2418 DECLARE_CONCRETE_INSTRUCTION(BitXor, "bit_xor")
2445 }; 2419 };
2446 2420
2447 2421
2448 class HBitOr: public HBitwiseBinaryOperation { 2422 class HBitOr: public HBitwiseBinaryOperation {
2449 public: 2423 public:
2450 HBitOr(HValue* left, HValue* right) 2424 HBitOr(HValue* left, HValue* right)
2451 : HBitwiseBinaryOperation(left, right) { } 2425 : HBitwiseBinaryOperation(left, right) { }
2452 2426
2453 virtual bool IsCommutative() const { return true; }
2454 virtual HType CalculateInferredType() const; 2427 virtual HType CalculateInferredType() const;
2455 2428
2456 DECLARE_CONCRETE_INSTRUCTION(BitOr, "bit_or") 2429 DECLARE_CONCRETE_INSTRUCTION(BitOr, "bit_or")
2457 2430
2458 protected: 2431 protected:
2459 virtual Range* InferRange(); 2432 virtual Range* InferRange();
2460 }; 2433 };
2461 2434
2462 2435
2463 class HShl: public HBitwiseBinaryOperation { 2436 class HShl: public HBitwiseBinaryOperation {
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 HValue* object() const { return left(); } 3113 HValue* object() const { return left(); }
3141 HValue* key() const { return right(); } 3114 HValue* key() const { return right(); }
3142 }; 3115 };
3143 3116
3144 #undef DECLARE_INSTRUCTION 3117 #undef DECLARE_INSTRUCTION
3145 #undef DECLARE_CONCRETE_INSTRUCTION 3118 #undef DECLARE_CONCRETE_INSTRUCTION
3146 3119
3147 } } // namespace v8::internal 3120 } } // namespace v8::internal
3148 3121
3149 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 3122 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698