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

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

Issue 500343002: [turbofan] Add backend support for load/store float32 values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE 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 #ifndef V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ 5 #ifndef V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_
6 #define V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ 6 #define V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 10
11 #include "src/base/utils/random-number-generator.h" 11 #include "src/base/utils/random-number-generator.h"
12 #include "src/compiler/instruction-selector.h" 12 #include "src/compiler/instruction-selector.h"
13 #include "src/compiler/raw-machine-assembler.h" 13 #include "src/compiler/raw-machine-assembler.h"
14 #include "test/compiler-unittests/compiler-unittests.h" 14 #include "test/compiler-unittests/compiler-unittests.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 namespace compiler { 18 namespace compiler {
19 19
20 class InstructionSelectorTest : public CompilerTest { 20 class InstructionSelectorTest : public CompilerTest {
21 public: 21 public:
22 InstructionSelectorTest(); 22 InstructionSelectorTest();
23 virtual ~InstructionSelectorTest() {} 23 virtual ~InstructionSelectorTest() {}
24 24
25 base::RandomNumberGenerator* rng() { return &rng_; } 25 base::RandomNumberGenerator* rng() { return &rng_; }
26 26
27 protected:
28 class Stream; 27 class Stream;
29 28
30 enum StreamBuilderMode { kAllInstructions, kTargetInstructions }; 29 enum StreamBuilderMode { kAllInstructions, kTargetInstructions };
31 30
32 class StreamBuilder V8_FINAL : public RawMachineAssembler { 31 class StreamBuilder V8_FINAL : public RawMachineAssembler {
33 public: 32 public:
34 StreamBuilder(InstructionSelectorTest* test, MachineType return_type) 33 StreamBuilder(InstructionSelectorTest* test, MachineType return_type)
35 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), 34 : RawMachineAssembler(new (test->zone()) Graph(test->zone()),
36 CallDescriptorBuilder(test->zone(), return_type)), 35 CallDescriptorBuilder(test->zone(), return_type)),
37 test_(test) {} 36 test_(test) {}
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 }; 108 };
110 109
111 class Stream V8_FINAL { 110 class Stream V8_FINAL {
112 public: 111 public:
113 size_t size() const { return instructions_.size(); } 112 size_t size() const { return instructions_.size(); }
114 const Instruction* operator[](size_t index) const { 113 const Instruction* operator[](size_t index) const {
115 EXPECT_LT(index, size()); 114 EXPECT_LT(index, size());
116 return instructions_[index]; 115 return instructions_[index];
117 } 116 }
118 117
118 bool IsDouble(const InstructionOperand* operand) const {
119 return IsDouble(ToVreg(operand));
120 }
119 bool IsDouble(int virtual_register) const { 121 bool IsDouble(int virtual_register) const {
120 return doubles_.find(virtual_register) != doubles_.end(); 122 return doubles_.find(virtual_register) != doubles_.end();
121 } 123 }
122 124
125 bool IsInteger(const InstructionOperand* operand) const {
126 return IsInteger(ToVreg(operand));
127 }
128 bool IsInteger(int virtual_register) const {
129 return !IsDouble(virtual_register) && !IsReference(virtual_register);
130 }
131
132 bool IsReference(const InstructionOperand* operand) const {
133 return IsReference(ToVreg(operand));
134 }
123 bool IsReference(int virtual_register) const { 135 bool IsReference(int virtual_register) const {
124 return references_.find(virtual_register) != references_.end(); 136 return references_.find(virtual_register) != references_.end();
125 } 137 }
126 138
127 int32_t ToInt32(const InstructionOperand* operand) const { 139 int32_t ToInt32(const InstructionOperand* operand) const {
128 return ToConstant(operand).ToInt32(); 140 return ToConstant(operand).ToInt32();
129 } 141 }
130 142
131 int ToVreg(const InstructionOperand* operand) const { 143 int ToVreg(const InstructionOperand* operand) const {
144 if (operand->IsConstant()) return operand->index();
132 EXPECT_EQ(InstructionOperand::UNALLOCATED, operand->kind()); 145 EXPECT_EQ(InstructionOperand::UNALLOCATED, operand->kind());
133 return UnallocatedOperand::cast(operand)->virtual_register(); 146 return UnallocatedOperand::cast(operand)->virtual_register();
134 } 147 }
135 148
136 private: 149 private:
137 Constant ToConstant(const InstructionOperand* operand) const { 150 Constant ToConstant(const InstructionOperand* operand) const {
138 ConstantMap::const_iterator i; 151 ConstantMap::const_iterator i;
139 if (operand->IsConstant()) { 152 if (operand->IsConstant()) {
140 i = constants_.find(operand->index()); 153 i = constants_.find(operand->index());
141 EXPECT_FALSE(constants_.end() == i); 154 EXPECT_FALSE(constants_.end() == i);
(...skipping 24 matching lines...) Expand all
166 template <typename T> 179 template <typename T>
167 class InstructionSelectorTestWithParam 180 class InstructionSelectorTestWithParam
168 : public InstructionSelectorTest, 181 : public InstructionSelectorTest,
169 public ::testing::WithParamInterface<T> {}; 182 public ::testing::WithParamInterface<T> {};
170 183
171 } // namespace compiler 184 } // namespace compiler
172 } // namespace internal 185 } // namespace internal
173 } // namespace v8 186 } // namespace v8
174 187
175 #endif // V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ 188 #endif // V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698