| 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_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 enum StreamBuilderMode { | 29 enum StreamBuilderMode { |
| 30 kAllInstructions, | 30 kAllInstructions, |
| 31 kTargetInstructions, | 31 kTargetInstructions, |
| 32 kAllExceptNopInstructions | 32 kAllExceptNopInstructions |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 class StreamBuilder V8_FINAL : public RawMachineAssembler { | 35 class StreamBuilder V8_FINAL : public RawMachineAssembler { |
| 36 public: | 36 public: |
| 37 StreamBuilder(InstructionSelectorTest* test, MachineType return_type) | 37 StreamBuilder(InstructionSelectorTest* test, MachineType return_type) |
| 38 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), | 38 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), |
| 39 CallDescriptorBuilder(test->zone(), return_type)), | 39 MakeMachineSignature(test->zone(), return_type)), |
| 40 test_(test) {} | 40 test_(test) {} |
| 41 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, | 41 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 42 MachineType parameter0_type) | 42 MachineType parameter0_type) |
| 43 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), | 43 : RawMachineAssembler( |
| 44 CallDescriptorBuilder(test->zone(), return_type, | 44 new (test->zone()) Graph(test->zone()), |
| 45 parameter0_type)), | 45 MakeMachineSignature(test->zone(), return_type, parameter0_type)), |
| 46 test_(test) {} | 46 test_(test) {} |
| 47 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, | 47 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 48 MachineType parameter0_type, MachineType parameter1_type) | 48 MachineType parameter0_type, MachineType parameter1_type) |
| 49 : RawMachineAssembler( | 49 : RawMachineAssembler( |
| 50 new (test->zone()) Graph(test->zone()), | 50 new (test->zone()) Graph(test->zone()), |
| 51 CallDescriptorBuilder(test->zone(), return_type, parameter0_type, | 51 MakeMachineSignature(test->zone(), return_type, parameter0_type, |
| 52 parameter1_type)), | 52 parameter1_type)), |
| 53 test_(test) {} | 53 test_(test) {} |
| 54 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, | 54 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 55 MachineType parameter0_type, MachineType parameter1_type, | 55 MachineType parameter0_type, MachineType parameter1_type, |
| 56 MachineType parameter2_type) | 56 MachineType parameter2_type) |
| 57 : RawMachineAssembler( | 57 : RawMachineAssembler( |
| 58 new (test->zone()) Graph(test->zone()), | 58 new (test->zone()) Graph(test->zone()), |
| 59 CallDescriptorBuilder(test->zone(), return_type, parameter0_type, | 59 MakeMachineSignature(test->zone(), return_type, parameter0_type, |
| 60 parameter1_type, parameter2_type)), | 60 parameter1_type, parameter2_type)), |
| 61 test_(test) {} | 61 test_(test) {} |
| 62 | 62 |
| 63 Stream Build(CpuFeature feature) { | 63 Stream Build(CpuFeature feature) { |
| 64 return Build(InstructionSelector::Features(feature)); | 64 return Build(InstructionSelector::Features(feature)); |
| 65 } | 65 } |
| 66 Stream Build(CpuFeature feature1, CpuFeature feature2) { | 66 Stream Build(CpuFeature feature1, CpuFeature feature2) { |
| 67 return Build(InstructionSelector::Features(feature1, feature2)); | 67 return Build(InstructionSelector::Features(feature1, feature2)); |
| 68 } | 68 } |
| 69 Stream Build(StreamBuilderMode mode = kTargetInstructions) { | 69 Stream Build(StreamBuilderMode mode = kTargetInstructions) { |
| 70 return Build(InstructionSelector::Features(), mode); | 70 return Build(InstructionSelector::Features(), mode); |
| 71 } | 71 } |
| 72 Stream Build(InstructionSelector::Features features, | 72 Stream Build(InstructionSelector::Features features, |
| 73 StreamBuilderMode mode = kTargetInstructions); | 73 StreamBuilderMode mode = kTargetInstructions); |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 MachineCallDescriptorBuilder* CallDescriptorBuilder( | 76 MachineSignature* MakeMachineSignature(Zone* zone, |
| 77 Zone* zone, MachineType return_type) { | 77 MachineType return_type) { |
| 78 return new (zone) MachineCallDescriptorBuilder(return_type, 0, NULL); | 78 MachineSignature::Builder builder(zone, 1, 0); |
| 79 builder.AddReturn(return_type); |
| 80 return builder.Build(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 MachineCallDescriptorBuilder* CallDescriptorBuilder( | 83 MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, |
| 82 Zone* zone, MachineType return_type, MachineType parameter0_type) { | 84 MachineType parameter0_type) { |
| 83 MachineType* parameter_types = zone->NewArray<MachineType>(1); | 85 MachineSignature::Builder builder(zone, 1, 1); |
| 84 parameter_types[0] = parameter0_type; | 86 builder.AddReturn(return_type); |
| 85 return new (zone) | 87 builder.AddParam(parameter0_type); |
| 86 MachineCallDescriptorBuilder(return_type, 1, parameter_types); | 88 return builder.Build(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 MachineCallDescriptorBuilder* CallDescriptorBuilder( | 91 MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, |
| 90 Zone* zone, MachineType return_type, MachineType parameter0_type, | 92 MachineType parameter0_type, |
| 91 MachineType parameter1_type) { | 93 MachineType parameter1_type) { |
| 92 MachineType* parameter_types = zone->NewArray<MachineType>(2); | 94 MachineSignature::Builder builder(zone, 1, 2); |
| 93 parameter_types[0] = parameter0_type; | 95 builder.AddReturn(return_type); |
| 94 parameter_types[1] = parameter1_type; | 96 builder.AddParam(parameter0_type); |
| 95 return new (zone) | 97 builder.AddParam(parameter1_type); |
| 96 MachineCallDescriptorBuilder(return_type, 2, parameter_types); | 98 return builder.Build(); |
| 97 } | 99 } |
| 98 | 100 |
| 99 MachineCallDescriptorBuilder* CallDescriptorBuilder( | 101 MachineSignature* MakeMachineSignature(Zone* zone, MachineType return_type, |
| 100 Zone* zone, MachineType return_type, MachineType parameter0_type, | 102 MachineType parameter0_type, |
| 101 MachineType parameter1_type, MachineType parameter2_type) { | 103 MachineType parameter1_type, |
| 102 MachineType* parameter_types = zone->NewArray<MachineType>(3); | 104 MachineType parameter2_type) { |
| 103 parameter_types[0] = parameter0_type; | 105 MachineSignature::Builder builder(zone, 1, 3); |
| 104 parameter_types[1] = parameter1_type; | 106 builder.AddReturn(return_type); |
| 105 parameter_types[2] = parameter2_type; | 107 builder.AddParam(parameter0_type); |
| 106 return new (zone) | 108 builder.AddParam(parameter1_type); |
| 107 MachineCallDescriptorBuilder(return_type, 3, parameter_types); | 109 builder.AddParam(parameter2_type); |
| 110 return builder.Build(); |
| 108 } | 111 } |
| 109 | 112 |
| 110 private: | 113 private: |
| 111 InstructionSelectorTest* test_; | 114 InstructionSelectorTest* test_; |
| 112 }; | 115 }; |
| 113 | 116 |
| 114 class Stream V8_FINAL { | 117 class Stream V8_FINAL { |
| 115 public: | 118 public: |
| 116 size_t size() const { return instructions_.size(); } | 119 size_t size() const { return instructions_.size(); } |
| 117 const Instruction* operator[](size_t index) const { | 120 const Instruction* operator[](size_t index) const { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 template <typename T> | 196 template <typename T> |
| 194 class InstructionSelectorTestWithParam | 197 class InstructionSelectorTestWithParam |
| 195 : public InstructionSelectorTest, | 198 : public InstructionSelectorTest, |
| 196 public ::testing::WithParamInterface<T> {}; | 199 public ::testing::WithParamInterface<T> {}; |
| 197 | 200 |
| 198 } // namespace compiler | 201 } // namespace compiler |
| 199 } // namespace internal | 202 } // namespace internal |
| 200 } // namespace v8 | 203 } // namespace v8 |
| 201 | 204 |
| 202 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 205 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| OLD | NEW |