| OLD | NEW |
| 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_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 5 #ifndef V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| 6 #define V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 6 #define V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 int64_t ToInt64(const InstructionOperand* operand) const { | 160 int64_t ToInt64(const InstructionOperand* operand) const { |
| 161 return ToConstant(operand).ToInt64(); | 161 return ToConstant(operand).ToInt64(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 Handle<HeapObject> ToHeapObject(const InstructionOperand* operand) const { | 164 Handle<HeapObject> ToHeapObject(const InstructionOperand* operand) const { |
| 165 return ToConstant(operand).ToHeapObject(); | 165 return ToConstant(operand).ToHeapObject(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 int ToVreg(const InstructionOperand* operand) const { | 168 int ToVreg(const InstructionOperand* operand) const { |
| 169 if (operand->IsConstant()) return operand->index(); | 169 if (operand->IsConstant()) { |
| 170 return ConstantOperand::cast(operand)->virtual_register(); |
| 171 } |
| 170 EXPECT_EQ(InstructionOperand::UNALLOCATED, operand->kind()); | 172 EXPECT_EQ(InstructionOperand::UNALLOCATED, operand->kind()); |
| 171 return UnallocatedOperand::cast(operand)->virtual_register(); | 173 return UnallocatedOperand::cast(operand)->virtual_register(); |
| 172 } | 174 } |
| 173 | 175 |
| 174 int ToVreg(const Node* node) const; | 176 int ToVreg(const Node* node) const; |
| 175 | 177 |
| 176 bool IsFixed(const InstructionOperand* operand, Register reg) const; | 178 bool IsFixed(const InstructionOperand* operand, Register reg) const; |
| 177 bool IsSameAsFirst(const InstructionOperand* operand) const; | 179 bool IsSameAsFirst(const InstructionOperand* operand) const; |
| 178 bool IsUsedAtStart(const InstructionOperand* operand) const; | 180 bool IsUsedAtStart(const InstructionOperand* operand) const; |
| 179 | 181 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 195 return !IsDouble(virtual_register) && !IsReference(virtual_register); | 197 return !IsDouble(virtual_register) && !IsReference(virtual_register); |
| 196 } | 198 } |
| 197 | 199 |
| 198 bool IsReference(int virtual_register) const { | 200 bool IsReference(int virtual_register) const { |
| 199 return references_.find(virtual_register) != references_.end(); | 201 return references_.find(virtual_register) != references_.end(); |
| 200 } | 202 } |
| 201 | 203 |
| 202 Constant ToConstant(const InstructionOperand* operand) const { | 204 Constant ToConstant(const InstructionOperand* operand) const { |
| 203 ConstantMap::const_iterator i; | 205 ConstantMap::const_iterator i; |
| 204 if (operand->IsConstant()) { | 206 if (operand->IsConstant()) { |
| 205 i = constants_.find(operand->index()); | 207 i = constants_.find(ConstantOperand::cast(operand)->virtual_register()); |
| 208 EXPECT_EQ(ConstantOperand::cast(operand)->virtual_register(), i->first); |
| 206 EXPECT_FALSE(constants_.end() == i); | 209 EXPECT_FALSE(constants_.end() == i); |
| 207 } else { | 210 } else { |
| 208 EXPECT_EQ(InstructionOperand::IMMEDIATE, operand->kind()); | 211 EXPECT_EQ(InstructionOperand::IMMEDIATE, operand->kind()); |
| 209 i = immediates_.find(operand->index()); | 212 i = immediates_.find(ImmediateOperand::cast(operand)->index()); |
| 213 EXPECT_EQ(ImmediateOperand::cast(operand)->index(), i->first); |
| 210 EXPECT_FALSE(immediates_.end() == i); | 214 EXPECT_FALSE(immediates_.end() == i); |
| 211 } | 215 } |
| 212 EXPECT_EQ(operand->index(), i->first); | |
| 213 return i->second; | 216 return i->second; |
| 214 } | 217 } |
| 215 | 218 |
| 216 friend class StreamBuilder; | 219 friend class StreamBuilder; |
| 217 | 220 |
| 218 typedef std::map<int, Constant> ConstantMap; | 221 typedef std::map<int, Constant> ConstantMap; |
| 219 typedef std::map<NodeId, int> VirtualRegisters; | 222 typedef std::map<NodeId, int> VirtualRegisters; |
| 220 | 223 |
| 221 ConstantMap constants_; | 224 ConstantMap constants_; |
| 222 ConstantMap immediates_; | 225 ConstantMap immediates_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 234 template <typename T> | 237 template <typename T> |
| 235 class InstructionSelectorTestWithParam | 238 class InstructionSelectorTestWithParam |
| 236 : public InstructionSelectorTest, | 239 : public InstructionSelectorTest, |
| 237 public ::testing::WithParamInterface<T> {}; | 240 public ::testing::WithParamInterface<T> {}; |
| 238 | 241 |
| 239 } // namespace compiler | 242 } // namespace compiler |
| 240 } // namespace internal | 243 } // namespace internal |
| 241 } // namespace v8 | 244 } // namespace v8 |
| 242 | 245 |
| 243 #endif // V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 246 #endif // V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| OLD | NEW |