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

Side by Side Diff: src/compiler/ia32/code-generator-ia32.cc

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/arm64/code-generator-arm64.cc ('k') | src/compiler/instruction.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #include "src/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/compiler/code-generator-impl.h" 7 #include "src/compiler/code-generator-impl.h"
8 #include "src/compiler/gap-resolver.h" 8 #include "src/compiler/gap-resolver.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 Operand HighOperand(InstructionOperand* op) { 52 Operand HighOperand(InstructionOperand* op) {
53 DCHECK(op->IsDoubleStackSlot()); 53 DCHECK(op->IsDoubleStackSlot());
54 return ToOperand(op, kPointerSize); 54 return ToOperand(op, kPointerSize);
55 } 55 }
56 56
57 Immediate ToImmediate(InstructionOperand* operand) { 57 Immediate ToImmediate(InstructionOperand* operand) {
58 Constant constant = ToConstant(operand); 58 Constant constant = ToConstant(operand);
59 switch (constant.type()) { 59 switch (constant.type()) {
60 case Constant::kInt32: 60 case Constant::kInt32:
61 return Immediate(constant.ToInt32()); 61 return Immediate(constant.ToInt32());
62 case Constant::kFloat32:
63 return Immediate(
64 isolate()->factory()->NewNumber(constant.ToFloat32(), TENURED));
62 case Constant::kFloat64: 65 case Constant::kFloat64:
63 return Immediate( 66 return Immediate(
64 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED)); 67 isolate()->factory()->NewNumber(constant.ToFloat64(), TENURED));
65 case Constant::kExternalReference: 68 case Constant::kExternalReference:
66 return Immediate(constant.ToExternalReference()); 69 return Immediate(constant.ToExternalReference());
67 case Constant::kHeapObject: 70 case Constant::kHeapObject:
68 return Immediate(constant.ToHeapObject()); 71 return Immediate(constant.ToHeapObject());
69 case Constant::kInt64: 72 case Constant::kInt64:
70 break; 73 break;
71 } 74 }
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } else { 835 } else {
833 __ mov(dst, src); 836 __ mov(dst, src);
834 } 837 }
835 } 838 }
836 } else if (destination->IsRegister()) { 839 } else if (destination->IsRegister()) {
837 Register dst = g.ToRegister(destination); 840 Register dst = g.ToRegister(destination);
838 __ mov(dst, g.ToImmediate(source)); 841 __ mov(dst, g.ToImmediate(source));
839 } else if (destination->IsStackSlot()) { 842 } else if (destination->IsStackSlot()) {
840 Operand dst = g.ToOperand(destination); 843 Operand dst = g.ToOperand(destination);
841 __ mov(dst, g.ToImmediate(source)); 844 __ mov(dst, g.ToImmediate(source));
845 } else if (src_constant.type() == Constant::kFloat32) {
846 // TODO(turbofan): Can we do better here?
847 Immediate src(bit_cast<int32_t>(src_constant.ToFloat32()));
848 if (destination->IsDoubleRegister()) {
849 XMMRegister dst = g.ToDoubleRegister(destination);
850 __ push(Immediate(src));
851 __ movss(dst, Operand(esp, 0));
852 __ add(esp, Immediate(kDoubleSize / 2));
853 } else {
854 DCHECK(destination->IsDoubleStackSlot());
855 Operand dst = g.ToOperand(destination);
856 __ mov(dst, src);
857 }
842 } else { 858 } else {
843 double v = g.ToDouble(source); 859 DCHECK_EQ(Constant::kFloat64, src_constant.type());
860 double v = src_constant.ToFloat64();
844 uint64_t int_val = bit_cast<uint64_t, double>(v); 861 uint64_t int_val = bit_cast<uint64_t, double>(v);
845 int32_t lower = static_cast<int32_t>(int_val); 862 int32_t lower = static_cast<int32_t>(int_val);
846 int32_t upper = static_cast<int32_t>(int_val >> kBitsPerInt); 863 int32_t upper = static_cast<int32_t>(int_val >> kBitsPerInt);
847 if (destination->IsDoubleRegister()) { 864 if (destination->IsDoubleRegister()) {
848 XMMRegister dst = g.ToDoubleRegister(destination); 865 XMMRegister dst = g.ToDoubleRegister(destination);
849 __ Move(dst, v); 866 __ Move(dst, v);
850 } else { 867 } else {
851 DCHECK(destination->IsDoubleStackSlot()); 868 DCHECK(destination->IsDoubleStackSlot());
852 Operand dst0 = g.ToOperand(destination); 869 Operand dst0 = g.ToOperand(destination);
853 Operand dst1 = g.HighOperand(destination); 870 Operand dst1 = g.HighOperand(destination);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 } 971 }
955 } 972 }
956 MarkLazyDeoptSite(); 973 MarkLazyDeoptSite();
957 } 974 }
958 975
959 #undef __ 976 #undef __
960 977
961 } // namespace compiler 978 } // namespace compiler
962 } // namespace internal 979 } // namespace internal
963 } // namespace v8 980 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/code-generator-arm64.cc ('k') | src/compiler/instruction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698