| 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_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| 6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| 7 | 7 |
| 8 #include "src/compiler/instruction-selector.h" | 8 #include "src/compiler/instruction-selector.h" |
| 9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
| 10 #include "src/compiler/raw-machine-assembler.h" | 10 #include "src/compiler/raw-machine-assembler.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 MaybeHandle<Code> code_; | 72 MaybeHandle<Code> code_; |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 | 75 |
| 76 template <typename ReturnType> | 76 template <typename ReturnType> |
| 77 class BufferedRawMachineAssemblerTester | 77 class BufferedRawMachineAssemblerTester |
| 78 : public RawMachineAssemblerTester<int32_t> { | 78 : public RawMachineAssemblerTester<int32_t> { |
| 79 public: | 79 public: |
| 80 BufferedRawMachineAssemblerTester() | 80 BufferedRawMachineAssemblerTester(MachineType p0 = kMachNone, |
| 81 : BufferedRawMachineAssemblerTester(0, kMachNone, kMachNone, kMachNone, | 81 MachineType p1 = kMachNone, |
| 82 kMachNone) {} | 82 MachineType p2 = kMachNone, |
| 83 | 83 MachineType p3 = kMachNone) |
| 84 | 84 : BufferedRawMachineAssemblerTester(ComputeParameterCount(p0, p1, p2, p3), |
| 85 explicit BufferedRawMachineAssemblerTester(MachineType p0) | 85 p0, p1, p2, p3) {} |
| 86 : BufferedRawMachineAssemblerTester(1, p0, kMachNone, kMachNone, | |
| 87 kMachNone) {} | |
| 88 | |
| 89 | |
| 90 BufferedRawMachineAssemblerTester(MachineType p0, MachineType p1) | |
| 91 : BufferedRawMachineAssemblerTester(2, p0, p1, kMachNone, kMachNone) {} | |
| 92 | |
| 93 | |
| 94 BufferedRawMachineAssemblerTester(MachineType p0, MachineType p1, | |
| 95 MachineType p2) | |
| 96 : BufferedRawMachineAssemblerTester(3, p0, p1, p2, kMachNone) {} | |
| 97 | |
| 98 | |
| 99 BufferedRawMachineAssemblerTester(MachineType p0, MachineType p1, | |
| 100 MachineType p2, MachineType p3) | |
| 101 : BufferedRawMachineAssemblerTester(4, p0, p1, p2, p3) {} | |
| 102 | 86 |
| 103 | 87 |
| 104 // The BufferedRawMachineAssemblerTester does not pass parameters directly | 88 // The BufferedRawMachineAssemblerTester does not pass parameters directly |
| 105 // to the constructed IR graph. Instead it passes a pointer to the parameter | 89 // to the constructed IR graph. Instead it passes a pointer to the parameter |
| 106 // to the IR graph, and adds Load nodes to the IR graph to load the | 90 // to the IR graph, and adds Load nodes to the IR graph to load the |
| 107 // parameters from memory. Thereby it is possible to pass 64 bit parameters | 91 // parameters from memory. Thereby it is possible to pass 64 bit parameters |
| 108 // to the IR graph. | 92 // to the IR graph. |
| 109 Node* Parameter(size_t index) { | 93 Node* Parameter(size_t index) { |
| 110 CHECK(index >= 0 && index < 4); | 94 CHECK(index >= 0 && index < 4); |
| 111 return parameter_nodes_[index]; | 95 return parameter_nodes_[index]; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0)); | 170 p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0)); |
| 187 parameter_nodes_[1] = | 171 parameter_nodes_[1] = |
| 188 p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1)); | 172 p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1)); |
| 189 parameter_nodes_[2] = | 173 parameter_nodes_[2] = |
| 190 p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2)); | 174 p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2)); |
| 191 parameter_nodes_[3] = | 175 parameter_nodes_[3] = |
| 192 p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3)); | 176 p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3)); |
| 193 } | 177 } |
| 194 | 178 |
| 195 | 179 |
| 180 static uint32_t ComputeParameterCount(MachineType p0, MachineType p1, |
| 181 MachineType p2, MachineType p3) { |
| 182 if (p0 == kMachNone) { |
| 183 return 0; |
| 184 } |
| 185 if (p1 == kMachNone) { |
| 186 return 1; |
| 187 } |
| 188 if (p2 == kMachNone) { |
| 189 return 2; |
| 190 } |
| 191 if (p3 == kMachNone) { |
| 192 return 3; |
| 193 } |
| 194 return 4; |
| 195 } |
| 196 |
| 197 |
| 196 CSignature* test_graph_signature_; | 198 CSignature* test_graph_signature_; |
| 197 Node* parameter_nodes_[4]; | 199 Node* parameter_nodes_[4]; |
| 198 uint32_t return_parameter_index_; | 200 uint32_t return_parameter_index_; |
| 199 }; | 201 }; |
| 200 | 202 |
| 201 | 203 |
| 202 template <> | 204 template <> |
| 203 class BufferedRawMachineAssemblerTester<void> | 205 class BufferedRawMachineAssemblerTester<void> |
| 204 : public RawMachineAssemblerTester<void> { | 206 : public RawMachineAssemblerTester<void> { |
| 205 public: | 207 public: |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } else { | 522 } else { |
| 521 CHECK_EQ(x, y); | 523 CHECK_EQ(x, y); |
| 522 } | 524 } |
| 523 } | 525 } |
| 524 | 526 |
| 525 } // namespace compiler | 527 } // namespace compiler |
| 526 } // namespace internal | 528 } // namespace internal |
| 527 } // namespace v8 | 529 } // namespace v8 |
| 528 | 530 |
| 529 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 531 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| OLD | NEW |