OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 M(UnboxFloat64x2) \ | 772 M(UnboxFloat64x2) \ |
773 M(BinaryFloat64x2Op) \ | 773 M(BinaryFloat64x2Op) \ |
774 M(Float64x2Zero) \ | 774 M(Float64x2Zero) \ |
775 M(Float64x2Constructor) \ | 775 M(Float64x2Constructor) \ |
776 M(Float64x2Splat) \ | 776 M(Float64x2Splat) \ |
777 M(Float32x4ToFloat64x2) \ | 777 M(Float32x4ToFloat64x2) \ |
778 M(Float64x2ToFloat32x4) \ | 778 M(Float64x2ToFloat32x4) \ |
779 M(Simd64x2Shuffle) \ | 779 M(Simd64x2Shuffle) \ |
780 M(Float64x2ZeroArg) \ | 780 M(Float64x2ZeroArg) \ |
781 M(Float64x2OneArg) \ | 781 M(Float64x2OneArg) \ |
| 782 M(MergedMath2) \ |
| 783 M(ExtractNthOutput) \ |
782 | 784 |
783 | 785 |
784 #define FORWARD_DECLARATION(type) class type##Instr; | 786 #define FORWARD_DECLARATION(type) class type##Instr; |
785 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 787 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
786 #undef FORWARD_DECLARATION | 788 #undef FORWARD_DECLARATION |
787 | 789 |
788 | 790 |
789 // Functions required in all concrete instruction classes. | 791 // Functions required in all concrete instruction classes. |
790 #define DECLARE_INSTRUCTION(type) \ | 792 #define DECLARE_INSTRUCTION(type) \ |
791 virtual Tag tag() const { return k##type; } \ | 793 virtual Tag tag() const { return k##type; } \ |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 friend class CheckSmiInstr; | 1094 friend class CheckSmiInstr; |
1093 friend class CheckArrayBoundInstr; | 1095 friend class CheckArrayBoundInstr; |
1094 friend class CheckEitherNonSmiInstr; | 1096 friend class CheckEitherNonSmiInstr; |
1095 friend class LICM; | 1097 friend class LICM; |
1096 friend class DoubleToSmiInstr; | 1098 friend class DoubleToSmiInstr; |
1097 friend class DoubleToDoubleInstr; | 1099 friend class DoubleToDoubleInstr; |
1098 friend class DoubleToFloatInstr; | 1100 friend class DoubleToFloatInstr; |
1099 friend class FloatToDoubleInstr; | 1101 friend class FloatToDoubleInstr; |
1100 friend class InvokeMathCFunctionInstr; | 1102 friend class InvokeMathCFunctionInstr; |
1101 friend class MergedMathInstr; | 1103 friend class MergedMathInstr; |
| 1104 friend class MergedMath2Instr; |
1102 friend class FlowGraphOptimizer; | 1105 friend class FlowGraphOptimizer; |
1103 friend class LoadIndexedInstr; | 1106 friend class LoadIndexedInstr; |
1104 friend class StoreIndexedInstr; | 1107 friend class StoreIndexedInstr; |
1105 friend class StoreInstanceFieldInstr; | 1108 friend class StoreInstanceFieldInstr; |
1106 friend class ComparisonInstr; | 1109 friend class ComparisonInstr; |
1107 friend class TargetEntryInstr; | 1110 friend class TargetEntryInstr; |
1108 friend class JoinEntryInstr; | 1111 friend class JoinEntryInstr; |
1109 friend class InstanceOfInstr; | 1112 friend class InstanceOfInstr; |
1110 friend class PolymorphicInstanceCallInstr; | 1113 friend class PolymorphicInstanceCallInstr; |
1111 friend class SmiToDoubleInstr; | 1114 friend class SmiToDoubleInstr; |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 | 1761 |
1759 intptr_t ssa_temp_index() const { return ssa_temp_index_; } | 1762 intptr_t ssa_temp_index() const { return ssa_temp_index_; } |
1760 void set_ssa_temp_index(intptr_t index) { | 1763 void set_ssa_temp_index(intptr_t index) { |
1761 ASSERT(index >= 0); | 1764 ASSERT(index >= 0); |
1762 ASSERT(is_used()); | 1765 ASSERT(is_used()); |
1763 ssa_temp_index_ = index; | 1766 ssa_temp_index_ = index; |
1764 } | 1767 } |
1765 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } | 1768 bool HasSSATemp() const { return ssa_temp_index_ >= 0; } |
1766 void ClearSSATempIndex() { ssa_temp_index_ = -1; } | 1769 void ClearSSATempIndex() { ssa_temp_index_ = -1; } |
1767 | 1770 |
| 1771 // Definitions which output register pairs need a second SSA index. |
| 1772 virtual bool RequiresPairSSAIndex() const { return false; } |
| 1773 virtual intptr_t pair_ssa_index() const { return -1; } |
| 1774 virtual void set_pair_ssa_index(intptr_t idx) { UNIMPLEMENTED(); } |
| 1775 |
1768 bool is_used() const { return (use_kind_ != kEffect); } | 1776 bool is_used() const { return (use_kind_ != kEffect); } |
1769 void set_use_kind(UseKind kind) { use_kind_ = kind; } | 1777 void set_use_kind(UseKind kind) { use_kind_ = kind; } |
1770 | 1778 |
1771 // Compile time type of the definition, which may be requested before type | 1779 // Compile time type of the definition, which may be requested before type |
1772 // propagation during graph building. | 1780 // propagation during graph building. |
1773 CompileType* Type() { | 1781 CompileType* Type() { |
1774 if (type_ == NULL) { | 1782 if (type_ == NULL) { |
1775 type_ = ComputeInitialType(); | 1783 type_ = ComputeInitialType(); |
1776 } | 1784 } |
1777 return type_; | 1785 return type_; |
(...skipping 5501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7279 } | 7287 } |
7280 | 7288 |
7281 ZoneGrowableArray<Value*>* inputs_; | 7289 ZoneGrowableArray<Value*>* inputs_; |
7282 | 7290 |
7283 const MethodRecognizer::Kind recognized_kind_; | 7291 const MethodRecognizer::Kind recognized_kind_; |
7284 | 7292 |
7285 DISALLOW_COPY_AND_ASSIGN(InvokeMathCFunctionInstr); | 7293 DISALLOW_COPY_AND_ASSIGN(InvokeMathCFunctionInstr); |
7286 }; | 7294 }; |
7287 | 7295 |
7288 | 7296 |
| 7297 class ExtractNthOutputInstr : public TemplateDefinition<1> { |
| 7298 public: |
| 7299 // Extract the Nth output register from value. |
| 7300 ExtractNthOutputInstr(Value* value, intptr_t n, Representation rep) |
| 7301 : index_(n), |
| 7302 rep_(rep) { |
| 7303 SetInputAt(0, value); |
| 7304 } |
| 7305 |
| 7306 Value* value() const { return inputs_[0]; } |
| 7307 |
| 7308 DECLARE_INSTRUCTION(ExtractNthOutput) |
| 7309 |
| 7310 virtual CompileType ComputeType() const; |
| 7311 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 7312 virtual bool CanDeoptimize() const { return false; } |
| 7313 |
| 7314 intptr_t index() const { return index_; } |
| 7315 |
| 7316 virtual Representation representation() const { |
| 7317 return rep_; |
| 7318 } |
| 7319 |
| 7320 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 7321 ASSERT(idx == 0); |
| 7322 if (representation() == kTagged) { |
| 7323 return kPairOfTagged; |
| 7324 } else if (representation() == kUnboxedDouble) { |
| 7325 return kPairOfUnboxedDouble; |
| 7326 } |
| 7327 UNREACHABLE(); |
| 7328 return rep_; |
| 7329 } |
| 7330 |
| 7331 virtual bool AllowsCSE() const { return true; } |
| 7332 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 7333 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 7334 virtual bool AttributesEqual(Instruction* other) const { |
| 7335 ExtractNthOutputInstr* other_extract = other->AsExtractNthOutput(); |
| 7336 return (other_extract->representation() == representation()) && |
| 7337 (other_extract->index() == index()); |
| 7338 } |
| 7339 |
| 7340 virtual bool MayThrow() const { return false; } |
| 7341 |
| 7342 private: |
| 7343 const intptr_t index_; |
| 7344 const Representation rep_; |
| 7345 |
| 7346 DISALLOW_COPY_AND_ASSIGN(ExtractNthOutputInstr); |
| 7347 }; |
| 7348 |
| 7349 |
| 7350 class MergedMath2Instr : public Definition { |
| 7351 public: |
| 7352 enum Kind { |
| 7353 kTruncDivMod, |
| 7354 kSinCos, |
| 7355 }; |
| 7356 |
| 7357 MergedMath2Instr(ZoneGrowableArray<Value*>* inputs, |
| 7358 intptr_t original_deopt_id, |
| 7359 MergedMath2Instr::Kind kind); |
| 7360 |
| 7361 static intptr_t InputCountFor(MergedMath2Instr::Kind kind) { |
| 7362 if (kind == kTruncDivMod) { |
| 7363 return 2; |
| 7364 } else if (kind == kSinCos) { |
| 7365 return 1; |
| 7366 } else { |
| 7367 UNIMPLEMENTED(); |
| 7368 return -1; |
| 7369 } |
| 7370 } |
| 7371 |
| 7372 virtual bool RequiresPairSSAIndex() const { return true; } |
| 7373 virtual intptr_t pair_ssa_index() const { return pair_ssa_index_; } |
| 7374 virtual void set_pair_ssa_index(intptr_t idx) { pair_ssa_index_ = idx; } |
| 7375 |
| 7376 MergedMath2Instr::Kind kind() const { return kind_; } |
| 7377 |
| 7378 virtual intptr_t InputCount() const { return inputs_->length(); } |
| 7379 |
| 7380 virtual Value* InputAt(intptr_t i) const { |
| 7381 return (*inputs_)[i]; |
| 7382 } |
| 7383 |
| 7384 static intptr_t OutputIndexOf(intptr_t kind); |
| 7385 static intptr_t OutputIndexOf(Token::Kind token); |
| 7386 |
| 7387 virtual CompileType ComputeType() const; |
| 7388 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 7389 |
| 7390 virtual bool CanDeoptimize() const { |
| 7391 if (kind_ == kTruncDivMod) { |
| 7392 return true; |
| 7393 } else if (kind_ == kSinCos) { |
| 7394 return false; |
| 7395 } else { |
| 7396 UNIMPLEMENTED(); |
| 7397 return false; |
| 7398 } |
| 7399 } |
| 7400 |
| 7401 virtual Representation representation() const { |
| 7402 if (kind_ == kTruncDivMod) { |
| 7403 return kPairOfTagged; |
| 7404 } else if (kind_ == kSinCos) { |
| 7405 return kPairOfUnboxedDouble; |
| 7406 } else { |
| 7407 UNIMPLEMENTED(); |
| 7408 return kTagged; |
| 7409 } |
| 7410 } |
| 7411 |
| 7412 virtual Representation RequiredInputRepresentation(intptr_t idx) const { |
| 7413 ASSERT((0 <= idx) && (idx < InputCount())); |
| 7414 if (kind_ == kTruncDivMod) { |
| 7415 return kTagged; |
| 7416 } else if (kind_ == kSinCos) { |
| 7417 return kUnboxedDouble; |
| 7418 } else { |
| 7419 UNIMPLEMENTED(); |
| 7420 return kTagged; |
| 7421 } |
| 7422 } |
| 7423 |
| 7424 virtual intptr_t DeoptimizationTarget() const { return deopt_id_; } |
| 7425 |
| 7426 DECLARE_INSTRUCTION(MergedMath2) |
| 7427 |
| 7428 virtual bool AllowsCSE() const { return true; } |
| 7429 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 7430 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 7431 virtual bool AttributesEqual(Instruction* other) const { |
| 7432 MergedMath2Instr* other_invoke = other->AsMergedMath2(); |
| 7433 return other_invoke->kind() == kind(); |
| 7434 } |
| 7435 |
| 7436 virtual bool MayThrow() const { return false; } |
| 7437 |
| 7438 static const char* KindToCString(MergedMath2Instr::Kind kind) { |
| 7439 if (kind == kTruncDivMod) return "TruncDivMod"; |
| 7440 if (kind == kSinCos) return "SinCos"; |
| 7441 UNIMPLEMENTED(); |
| 7442 return ""; |
| 7443 } |
| 7444 |
| 7445 private: |
| 7446 virtual void RawSetInputAt(intptr_t i, Value* value) { |
| 7447 (*inputs_)[i] = value; |
| 7448 } |
| 7449 intptr_t pair_ssa_index_; |
| 7450 ZoneGrowableArray<Value*>* inputs_; |
| 7451 MergedMath2Instr::Kind kind_; |
| 7452 DISALLOW_COPY_AND_ASSIGN(MergedMath2Instr); |
| 7453 }; |
| 7454 |
| 7455 |
7289 class MergedMathInstr : public Definition { | 7456 class MergedMathInstr : public Definition { |
7290 public: | 7457 public: |
7291 enum Kind { | 7458 enum Kind { |
7292 kTruncDivMod, | 7459 kTruncDivMod, |
7293 kTruncDivRem, | 7460 kTruncDivRem, |
7294 kSinCos, | 7461 kSinCos, |
7295 }; | 7462 }; |
7296 | 7463 |
7297 MergedMathInstr(ZoneGrowableArray<Value*>* inputs, | 7464 MergedMathInstr(ZoneGrowableArray<Value*>* inputs, |
7298 intptr_t original_deopt_id, | 7465 intptr_t original_deopt_id, |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7723 ForwardInstructionIterator* current_iterator_; | 7890 ForwardInstructionIterator* current_iterator_; |
7724 | 7891 |
7725 private: | 7892 private: |
7726 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 7893 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
7727 }; | 7894 }; |
7728 | 7895 |
7729 | 7896 |
7730 } // namespace dart | 7897 } // namespace dart |
7731 | 7898 |
7732 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 7899 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
OLD | NEW |