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

Side by Side Diff: test/compiler-unittests/instruction-selector-unittest.cc

Issue 484103002: [turbofan] Add TruncateFloat64ToInt32 machine operator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Disable test-run-machops/RunTruncateFloat64ToInt32P on arm64. Created 6 years, 4 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
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 #include "test/compiler-unittests/instruction-selector-unittest.h" 5 #include "test/compiler-unittests/instruction-selector-unittest.h"
6 6
7 #include "src/flags.h" 7 #include "src/flags.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 s.immediates_.insert(std::make_pair( 64 s.immediates_.insert(std::make_pair(
65 input->index(), sequence.GetImmediate(input->index()))); 65 input->index(), sequence.GetImmediate(input->index())));
66 } 66 }
67 } 67 }
68 s.instructions_.push_back(instr); 68 s.instructions_.push_back(instr);
69 } 69 }
70 return s; 70 return s;
71 } 71 }
72 72
73 73
74 // -----------------------------------------------------------------------------
75 // Return.
76
77
74 TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) { 78 TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) {
75 StreamBuilder m(this, kMachInt32, kMachInt32); 79 StreamBuilder m(this, kMachInt32, kMachInt32);
76 m.Return(m.Parameter(0)); 80 m.Return(m.Parameter(0));
77 Stream s = m.Build(kAllInstructions); 81 Stream s = m.Build(kAllInstructions);
78 ASSERT_EQ(2U, s.size()); 82 ASSERT_EQ(2U, s.size());
79 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); 83 EXPECT_EQ(kArchNop, s[0]->arch_opcode());
80 ASSERT_EQ(1U, s[0]->OutputCount()); 84 ASSERT_EQ(1U, s[0]->OutputCount());
81 EXPECT_EQ(kArchRet, s[1]->arch_opcode()); 85 EXPECT_EQ(kArchRet, s[1]->arch_opcode());
82 EXPECT_EQ(1U, s[1]->InputCount()); 86 EXPECT_EQ(1U, s[1]->InputCount());
83 } 87 }
84 88
85 89
86 TARGET_TEST_F(InstructionSelectorTest, ReturnZero) { 90 TARGET_TEST_F(InstructionSelectorTest, ReturnZero) {
87 StreamBuilder m(this, kMachInt32); 91 StreamBuilder m(this, kMachInt32);
88 m.Return(m.Int32Constant(0)); 92 m.Return(m.Int32Constant(0));
89 Stream s = m.Build(kAllInstructions); 93 Stream s = m.Build(kAllInstructions);
90 ASSERT_EQ(2U, s.size()); 94 ASSERT_EQ(2U, s.size());
91 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); 95 EXPECT_EQ(kArchNop, s[0]->arch_opcode());
92 ASSERT_EQ(1U, s[0]->OutputCount()); 96 ASSERT_EQ(1U, s[0]->OutputCount());
93 EXPECT_EQ(InstructionOperand::CONSTANT, s[0]->OutputAt(0)->kind()); 97 EXPECT_EQ(InstructionOperand::CONSTANT, s[0]->OutputAt(0)->kind());
94 EXPECT_EQ(0, s.ToInt32(s[0]->OutputAt(0))); 98 EXPECT_EQ(0, s.ToInt32(s[0]->OutputAt(0)));
95 EXPECT_EQ(kArchRet, s[1]->arch_opcode()); 99 EXPECT_EQ(kArchRet, s[1]->arch_opcode());
96 EXPECT_EQ(1U, s[1]->InputCount()); 100 EXPECT_EQ(1U, s[1]->InputCount());
97 } 101 }
98 102
103
104 // -----------------------------------------------------------------------------
105 // Conversions.
106
107
108 TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToInt32WithParameter) {
109 StreamBuilder m(this, kMachInt32, kMachFloat64);
110 m.Return(m.TruncateFloat64ToInt32(m.Parameter(0)));
111 Stream s = m.Build(kAllInstructions);
112 ASSERT_EQ(3U, s.size());
113 EXPECT_EQ(kArchNop, s[0]->arch_opcode());
114 EXPECT_EQ(kArchTruncateDoubleToI, s[1]->arch_opcode());
115 EXPECT_EQ(1U, s[1]->InputCount());
116 EXPECT_EQ(1U, s[1]->OutputCount());
117 EXPECT_EQ(kArchRet, s[2]->arch_opcode());
118 }
119
99 } // namespace compiler 120 } // namespace compiler
100 } // namespace internal 121 } // namespace internal
101 } // namespace v8 122 } // namespace v8
OLDNEW
« no previous file with comments | « test/compiler-unittests/graph-unittest.cc ('k') | test/compiler-unittests/machine-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698