| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3356 SetOperandAt(1, left); | 3356 SetOperandAt(1, left); |
| 3357 SetOperandAt(2, right); | 3357 SetOperandAt(2, right); |
| 3358 observed_input_representation_[0] = Representation::None(); | 3358 observed_input_representation_[0] = Representation::None(); |
| 3359 observed_input_representation_[1] = Representation::None(); | 3359 observed_input_representation_[1] = Representation::None(); |
| 3360 } | 3360 } |
| 3361 | 3361 |
| 3362 HValue* context() { return OperandAt(0); } | 3362 HValue* context() { return OperandAt(0); } |
| 3363 HValue* left() { return OperandAt(1); } | 3363 HValue* left() { return OperandAt(1); } |
| 3364 HValue* right() { return OperandAt(2); } | 3364 HValue* right() { return OperandAt(2); } |
| 3365 | 3365 |
| 3366 // True if switching left and right operands likely generates better code. | 3366 // TODO(kasperl): Move these helpers to the IA-32 Lithium |
| 3367 bool AreOperandsBetterSwitched() { | 3367 // instruction sequence builder. |
| 3368 if (!IsCommutative()) return false; | 3368 HValue* LeastConstantOperand() { |
| 3369 | 3369 if (IsCommutative() && left()->IsConstant()) return right(); |
| 3370 // Constant operands are better off on the right, they can be inlined in | 3370 return left(); |
| 3371 // many situations on most platforms. | |
| 3372 if (left()->IsConstant()) return true; | |
| 3373 if (right()->IsConstant()) return false; | |
| 3374 | |
| 3375 // Otherwise, if there is only one use of the right operand, it would be | |
| 3376 // better off on the left for platforms that only have 2-arg arithmetic | |
| 3377 // ops (e.g ia32, x64) that clobber the left operand. | |
| 3378 return (right()->UseCount() == 1); | |
| 3379 } | 3371 } |
| 3380 | 3372 |
| 3381 HValue* BetterLeftOperand() { | 3373 HValue* MostConstantOperand() { |
| 3382 return AreOperandsBetterSwitched() ? right() : left(); | 3374 if (IsCommutative() && left()->IsConstant()) return left(); |
| 3383 } | 3375 return right(); |
| 3384 | |
| 3385 HValue* BetterRightOperand() { | |
| 3386 return AreOperandsBetterSwitched() ? left() : right(); | |
| 3387 } | 3376 } |
| 3388 | 3377 |
| 3389 void set_observed_input_representation(int index, Representation rep) { | 3378 void set_observed_input_representation(int index, Representation rep) { |
| 3390 ASSERT(index >= 1 && index <= 2); | 3379 ASSERT(index >= 1 && index <= 2); |
| 3391 observed_input_representation_[index - 1] = rep; | 3380 observed_input_representation_[index - 1] = rep; |
| 3392 } | 3381 } |
| 3393 | 3382 |
| 3394 virtual void initialize_output_representation(Representation observed) { | 3383 virtual void initialize_output_representation(Representation observed) { |
| 3395 observed_output_representation_ = observed; | 3384 observed_output_representation_ = observed; |
| 3396 } | 3385 } |
| (...skipping 3162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6559 virtual bool IsDeletable() const { return true; } | 6548 virtual bool IsDeletable() const { return true; } |
| 6560 }; | 6549 }; |
| 6561 | 6550 |
| 6562 | 6551 |
| 6563 #undef DECLARE_INSTRUCTION | 6552 #undef DECLARE_INSTRUCTION |
| 6564 #undef DECLARE_CONCRETE_INSTRUCTION | 6553 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6565 | 6554 |
| 6566 } } // namespace v8::internal | 6555 } } // namespace v8::internal |
| 6567 | 6556 |
| 6568 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6557 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |