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

Side by Side Diff: src/compiler/instruction.h

Issue 600383002: [turbofan] Add backend support for Float32Constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add InstructionSelector unit test. Created 6 years, 2 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/compiler/ia32/code-generator-ia32.cc ('k') | src/compiler/instruction.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 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 #ifndef V8_COMPILER_INSTRUCTION_H_ 5 #ifndef V8_COMPILER_INSTRUCTION_H_
6 #define V8_COMPILER_INSTRUCTION_H_ 6 #define V8_COMPILER_INSTRUCTION_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 DCHECK(!source_position_.IsInvalid()); 647 DCHECK(!source_position_.IsInvalid());
648 DCHECK(!source_position_.IsUnknown()); 648 DCHECK(!source_position_.IsUnknown());
649 } 649 }
650 650
651 SourcePosition source_position_; 651 SourcePosition source_position_;
652 }; 652 };
653 653
654 654
655 class Constant FINAL { 655 class Constant FINAL {
656 public: 656 public:
657 enum Type { kInt32, kInt64, kFloat64, kExternalReference, kHeapObject }; 657 enum Type {
658 kInt32,
659 kInt64,
660 kFloat32,
661 kFloat64,
662 kExternalReference,
663 kHeapObject
664 };
658 665
659 explicit Constant(int32_t v) : type_(kInt32), value_(v) {} 666 explicit Constant(int32_t v) : type_(kInt32), value_(v) {}
660 explicit Constant(int64_t v) : type_(kInt64), value_(v) {} 667 explicit Constant(int64_t v) : type_(kInt64), value_(v) {}
668 explicit Constant(float v) : type_(kFloat32), value_(bit_cast<int32_t>(v)) {}
661 explicit Constant(double v) : type_(kFloat64), value_(bit_cast<int64_t>(v)) {} 669 explicit Constant(double v) : type_(kFloat64), value_(bit_cast<int64_t>(v)) {}
662 explicit Constant(ExternalReference ref) 670 explicit Constant(ExternalReference ref)
663 : type_(kExternalReference), value_(bit_cast<intptr_t>(ref)) {} 671 : type_(kExternalReference), value_(bit_cast<intptr_t>(ref)) {}
664 explicit Constant(Handle<HeapObject> obj) 672 explicit Constant(Handle<HeapObject> obj)
665 : type_(kHeapObject), value_(bit_cast<intptr_t>(obj)) {} 673 : type_(kHeapObject), value_(bit_cast<intptr_t>(obj)) {}
666 674
667 Type type() const { return type_; } 675 Type type() const { return type_; }
668 676
669 int32_t ToInt32() const { 677 int32_t ToInt32() const {
670 DCHECK_EQ(kInt32, type()); 678 DCHECK_EQ(kInt32, type());
671 return static_cast<int32_t>(value_); 679 return static_cast<int32_t>(value_);
672 } 680 }
673 681
674 int64_t ToInt64() const { 682 int64_t ToInt64() const {
675 if (type() == kInt32) return ToInt32(); 683 if (type() == kInt32) return ToInt32();
676 DCHECK_EQ(kInt64, type()); 684 DCHECK_EQ(kInt64, type());
677 return value_; 685 return value_;
678 } 686 }
679 687
688 float ToFloat32() const {
689 DCHECK_EQ(kFloat32, type());
690 return bit_cast<float>(static_cast<int32_t>(value_));
691 }
692
680 double ToFloat64() const { 693 double ToFloat64() const {
681 if (type() == kInt32) return ToInt32(); 694 if (type() == kInt32) return ToInt32();
682 DCHECK_EQ(kFloat64, type()); 695 DCHECK_EQ(kFloat64, type());
683 return bit_cast<double>(value_); 696 return bit_cast<double>(value_);
684 } 697 }
685 698
686 ExternalReference ToExternalReference() const { 699 ExternalReference ToExternalReference() const {
687 DCHECK_EQ(kExternalReference, type()); 700 DCHECK_EQ(kExternalReference, type());
688 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_)); 701 return bit_cast<ExternalReference>(static_cast<intptr_t>(value_));
689 } 702 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 DeoptimizationVector deoptimization_entries_; 944 DeoptimizationVector deoptimization_entries_;
932 }; 945 };
933 946
934 OStream& operator<<(OStream& os, const InstructionSequence& code); 947 OStream& operator<<(OStream& os, const InstructionSequence& code);
935 948
936 } // namespace compiler 949 } // namespace compiler
937 } // namespace internal 950 } // namespace internal
938 } // namespace v8 951 } // namespace v8
939 952
940 #endif // V8_COMPILER_INSTRUCTION_H_ 953 #endif // V8_COMPILER_INSTRUCTION_H_
OLDNEW
« no previous file with comments | « src/compiler/ia32/code-generator-ia32.cc ('k') | src/compiler/instruction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698