| 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_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 | 9 |
| 10 #include "src/compiler/instruction-selector.h" | 10 #include "src/compiler/instruction-selector.h" |
| 11 #include "src/compiler/raw-machine-assembler.h" | 11 #include "src/compiler/raw-machine-assembler.h" |
| 12 #include "test/compiler-unittests/compiler-unittests.h" | 12 #include "test/compiler-unittests/compiler-unittests.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 namespace compiler { | 16 namespace compiler { |
| 17 | 17 |
| 18 class InstructionSelectorTest : public CompilerTest { | 18 class InstructionSelectorTest : public CompilerTest { |
| 19 public: | 19 public: |
| 20 InstructionSelectorTest() {} | 20 InstructionSelectorTest() {} |
| 21 virtual ~InstructionSelectorTest() {} | 21 virtual ~InstructionSelectorTest() {} |
| 22 | 22 |
| 23 protected: | 23 protected: |
| 24 class Stream; | 24 class Stream; |
| 25 | 25 |
| 26 enum StreamBuilderMode { kAllInstructions, kTargetInstructions }; | 26 enum StreamBuilderMode { kAllInstructions, kTargetInstructions }; |
| 27 | 27 |
| 28 class StreamBuilder V8_FINAL : public RawMachineAssembler { | 28 class StreamBuilder V8_FINAL : public RawMachineAssembler { |
| 29 public: | 29 public: |
| 30 StreamBuilder(InstructionSelectorTest* test, | 30 StreamBuilder(InstructionSelectorTest* test, MachineType return_type) |
| 31 MachineRepresentation return_type) | |
| 32 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), | 31 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), |
| 33 CallDescriptorBuilder(test->zone(), return_type)), | 32 CallDescriptorBuilder(test->zone(), return_type)), |
| 34 test_(test) {} | 33 test_(test) {} |
| 35 StreamBuilder(InstructionSelectorTest* test, | 34 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 36 MachineRepresentation return_type, | 35 MachineType parameter0_type) |
| 37 MachineRepresentation parameter0_type) | |
| 38 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), | 36 : RawMachineAssembler(new (test->zone()) Graph(test->zone()), |
| 39 CallDescriptorBuilder(test->zone(), return_type, | 37 CallDescriptorBuilder(test->zone(), return_type, |
| 40 parameter0_type)), | 38 parameter0_type)), |
| 41 test_(test) {} | 39 test_(test) {} |
| 42 StreamBuilder(InstructionSelectorTest* test, | 40 StreamBuilder(InstructionSelectorTest* test, MachineType return_type, |
| 43 MachineRepresentation return_type, | 41 MachineType parameter0_type, MachineType parameter1_type) |
| 44 MachineRepresentation parameter0_type, | |
| 45 MachineRepresentation parameter1_type) | |
| 46 : RawMachineAssembler( | 42 : RawMachineAssembler( |
| 47 new (test->zone()) Graph(test->zone()), | 43 new (test->zone()) Graph(test->zone()), |
| 48 CallDescriptorBuilder(test->zone(), return_type, parameter0_type, | 44 CallDescriptorBuilder(test->zone(), return_type, parameter0_type, |
| 49 parameter1_type)), | 45 parameter1_type)), |
| 50 test_(test) {} | 46 test_(test) {} |
| 51 | 47 |
| 52 Stream Build(CpuFeature feature) { | 48 Stream Build(CpuFeature feature) { |
| 53 return Build(InstructionSelector::Features(feature)); | 49 return Build(InstructionSelector::Features(feature)); |
| 54 } | 50 } |
| 55 Stream Build(CpuFeature feature1, CpuFeature feature2) { | 51 Stream Build(CpuFeature feature1, CpuFeature feature2) { |
| 56 return Build(InstructionSelector::Features(feature1, feature2)); | 52 return Build(InstructionSelector::Features(feature1, feature2)); |
| 57 } | 53 } |
| 58 Stream Build(StreamBuilderMode mode = kTargetInstructions) { | 54 Stream Build(StreamBuilderMode mode = kTargetInstructions) { |
| 59 return Build(InstructionSelector::Features(), mode); | 55 return Build(InstructionSelector::Features(), mode); |
| 60 } | 56 } |
| 61 Stream Build(InstructionSelector::Features features, | 57 Stream Build(InstructionSelector::Features features, |
| 62 StreamBuilderMode mode = kTargetInstructions); | 58 StreamBuilderMode mode = kTargetInstructions); |
| 63 | 59 |
| 64 private: | 60 private: |
| 65 MachineCallDescriptorBuilder* CallDescriptorBuilder( | 61 MachineCallDescriptorBuilder* CallDescriptorBuilder( |
| 66 Zone* zone, MachineRepresentation return_type) { | 62 Zone* zone, MachineType return_type) { |
| 67 return new (zone) MachineCallDescriptorBuilder(return_type, 0, NULL); | 63 return new (zone) MachineCallDescriptorBuilder(return_type, 0, NULL); |
| 68 } | 64 } |
| 69 | 65 |
| 70 MachineCallDescriptorBuilder* CallDescriptorBuilder( | 66 MachineCallDescriptorBuilder* CallDescriptorBuilder( |
| 71 Zone* zone, MachineRepresentation return_type, | 67 Zone* zone, MachineType return_type, MachineType parameter0_type) { |
| 72 MachineRepresentation parameter0_type) { | 68 MachineType* parameter_types = zone->NewArray<MachineType>(1); |
| 73 MachineRepresentation* parameter_types = | |
| 74 zone->NewArray<MachineRepresentation>(1); | |
| 75 parameter_types[0] = parameter0_type; | 69 parameter_types[0] = parameter0_type; |
| 76 return new (zone) | 70 return new (zone) |
| 77 MachineCallDescriptorBuilder(return_type, 1, parameter_types); | 71 MachineCallDescriptorBuilder(return_type, 1, parameter_types); |
| 78 } | 72 } |
| 79 | 73 |
| 80 MachineCallDescriptorBuilder* CallDescriptorBuilder( | 74 MachineCallDescriptorBuilder* CallDescriptorBuilder( |
| 81 Zone* zone, MachineRepresentation return_type, | 75 Zone* zone, MachineType return_type, MachineType parameter0_type, |
| 82 MachineRepresentation parameter0_type, | 76 MachineType parameter1_type) { |
| 83 MachineRepresentation parameter1_type) { | 77 MachineType* parameter_types = zone->NewArray<MachineType>(2); |
| 84 MachineRepresentation* parameter_types = | |
| 85 zone->NewArray<MachineRepresentation>(2); | |
| 86 parameter_types[0] = parameter0_type; | 78 parameter_types[0] = parameter0_type; |
| 87 parameter_types[1] = parameter1_type; | 79 parameter_types[1] = parameter1_type; |
| 88 return new (zone) | 80 return new (zone) |
| 89 MachineCallDescriptorBuilder(return_type, 2, parameter_types); | 81 MachineCallDescriptorBuilder(return_type, 2, parameter_types); |
| 90 } | 82 } |
| 91 | 83 |
| 92 private: | 84 private: |
| 93 InstructionSelectorTest* test_; | 85 InstructionSelectorTest* test_; |
| 94 }; | 86 }; |
| 95 | 87 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 ConstantMap immediates_; | 120 ConstantMap immediates_; |
| 129 std::deque<Instruction*> instructions_; | 121 std::deque<Instruction*> instructions_; |
| 130 }; | 122 }; |
| 131 }; | 123 }; |
| 132 | 124 |
| 133 } // namespace compiler | 125 } // namespace compiler |
| 134 } // namespace internal | 126 } // namespace internal |
| 135 } // namespace v8 | 127 } // namespace v8 |
| 136 | 128 |
| 137 #endif // V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ | 129 #endif // V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ |
| OLD | NEW |