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 3339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3350 SetOperandAt(1, left); | 3350 SetOperandAt(1, left); |
3351 SetOperandAt(2, right); | 3351 SetOperandAt(2, right); |
3352 observed_input_representation_[0] = Representation::None(); | 3352 observed_input_representation_[0] = Representation::None(); |
3353 observed_input_representation_[1] = Representation::None(); | 3353 observed_input_representation_[1] = Representation::None(); |
3354 } | 3354 } |
3355 | 3355 |
3356 HValue* context() { return OperandAt(0); } | 3356 HValue* context() { return OperandAt(0); } |
3357 HValue* left() { return OperandAt(1); } | 3357 HValue* left() { return OperandAt(1); } |
3358 HValue* right() { return OperandAt(2); } | 3358 HValue* right() { return OperandAt(2); } |
3359 | 3359 |
3360 // TODO(kasperl): Move these helpers to the IA-32 Lithium | 3360 // True if switching left and right operands likely generates better code. |
3361 // instruction sequence builder. | 3361 bool AreOperandsBetterSwitched() { |
3362 HValue* LeastConstantOperand() { | 3362 if (IsCommutative()) { |
Sven Panne
2013/05/07 11:38:40
Starting with "if (!IsCommutative()) return false;
danno
2013/05/08 08:37:18
Done.
| |
3363 if (IsCommutative() && left()->IsConstant()) return right(); | 3363 // Constant operands are better off on the right, they can be inlined in |
3364 return left(); | 3364 // many situations on most platforms. |
3365 if (left()->IsConstant()) return true; | |
3366 if (right()->IsConstant()) return false; | |
3367 // Otherwise, if there is only one use of the right operand, it would be | |
3368 // better off on the left for platforms that only have 2-arg arithmetic | |
3369 // ops (e.g ia32, x64) that clobber the left operand. | |
3370 if (right()->UseCount() == 1) return true; | |
3371 } | |
3372 return false; | |
3365 } | 3373 } |
3366 | 3374 |
3367 HValue* MostConstantOperand() { | 3375 HValue* BetterLeftOperand() { |
3368 if (IsCommutative() && left()->IsConstant()) return left(); | 3376 return AreOperandsBetterSwitched() ? right() : left(); |
3369 return right(); | 3377 } |
3378 | |
3379 HValue* BetterRightOperand() { | |
3380 return AreOperandsBetterSwitched() ? left() : right(); | |
3370 } | 3381 } |
3371 | 3382 |
3372 void set_observed_input_representation(int index, Representation rep) { | 3383 void set_observed_input_representation(int index, Representation rep) { |
3373 ASSERT(index >= 1 && index <= 2); | 3384 ASSERT(index >= 1 && index <= 2); |
3374 observed_input_representation_[index - 1] = rep; | 3385 observed_input_representation_[index - 1] = rep; |
3375 } | 3386 } |
3376 | 3387 |
3377 virtual void initialize_output_representation(Representation observed) { | 3388 virtual void initialize_output_representation(Representation observed) { |
3378 observed_output_representation_ = observed; | 3389 observed_output_representation_ = observed; |
3379 } | 3390 } |
(...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6522 virtual bool IsDeletable() const { return true; } | 6533 virtual bool IsDeletable() const { return true; } |
6523 }; | 6534 }; |
6524 | 6535 |
6525 | 6536 |
6526 #undef DECLARE_INSTRUCTION | 6537 #undef DECLARE_INSTRUCTION |
6527 #undef DECLARE_CONCRETE_INSTRUCTION | 6538 #undef DECLARE_CONCRETE_INSTRUCTION |
6528 | 6539 |
6529 } } // namespace v8::internal | 6540 } } // namespace v8::internal |
6530 | 6541 |
6531 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6542 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |