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 #include "src/base/utils/random-number-generator.h" | 5 #include "src/base/utils/random-number-generator.h" |
6 #include "src/compiler/pipeline.h" | 6 #include "src/compiler/pipeline.h" |
7 #include "test/unittests/compiler/instruction-sequence-unittest.h" | 7 #include "test/unittests/compiler/instruction-sequence-unittest.h" |
8 #include "test/unittests/test-utils.h" | 8 #include "test/unittests/test-utils.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 static const char* | 15 static const char* |
16 general_register_names_[RegisterConfiguration::kMaxGeneralRegisters]; | 16 general_register_names_[RegisterConfiguration::kMaxGeneralRegisters]; |
17 static const char* | 17 static const char* |
18 double_register_names_[RegisterConfiguration::kMaxDoubleRegisters]; | 18 double_register_names_[RegisterConfiguration::kMaxDoubleRegisters]; |
19 static char register_names_[10 * (RegisterConfiguration::kMaxGeneralRegisters + | 19 static char register_names_[10 * (RegisterConfiguration::kMaxGeneralRegisters + |
20 RegisterConfiguration::kMaxDoubleRegisters)]; | 20 RegisterConfiguration::kMaxDoubleRegisters)]; |
21 | 21 |
22 | 22 |
| 23 namespace { |
| 24 static int allocatable_codes[InstructionSequenceTest::kDefaultNRegs] = { |
| 25 0, 1, 2, 3, 4, 5, 6, 7}; |
| 26 static int allocatable_double_codes[InstructionSequenceTest::kDefaultNRegs] = { |
| 27 0, 1, 2, 3, 4, 5, 6, 7}; |
| 28 } |
| 29 |
| 30 |
23 static void InitializeRegisterNames() { | 31 static void InitializeRegisterNames() { |
24 char* loc = register_names_; | 32 char* loc = register_names_; |
25 for (int i = 0; i < RegisterConfiguration::kMaxGeneralRegisters; ++i) { | 33 for (int i = 0; i < RegisterConfiguration::kMaxGeneralRegisters; ++i) { |
26 general_register_names_[i] = loc; | 34 general_register_names_[i] = loc; |
27 loc += base::OS::SNPrintF(loc, 100, "gp_%d", i); | 35 loc += base::OS::SNPrintF(loc, 100, "gp_%d", i); |
28 *loc++ = 0; | 36 *loc++ = 0; |
29 } | 37 } |
30 for (int i = 0; i < RegisterConfiguration::kMaxDoubleRegisters; ++i) { | 38 for (int i = 0; i < RegisterConfiguration::kMaxDoubleRegisters; ++i) { |
31 double_register_names_[i] = loc; | 39 double_register_names_[i] = loc; |
32 loc += base::OS::SNPrintF(loc, 100, "fp_%d", i) + 1; | 40 loc += base::OS::SNPrintF(loc, 100, "fp_%d", i) + 1; |
(...skipping 19 matching lines...) Expand all Loading... |
52 CHECK(instructions_.empty()); | 60 CHECK(instructions_.empty()); |
53 CHECK(instruction_blocks_.empty()); | 61 CHECK(instruction_blocks_.empty()); |
54 num_general_registers_ = num_general_registers; | 62 num_general_registers_ = num_general_registers; |
55 num_double_registers_ = num_double_registers; | 63 num_double_registers_ = num_double_registers; |
56 } | 64 } |
57 | 65 |
58 | 66 |
59 RegisterConfiguration* InstructionSequenceTest::config() { | 67 RegisterConfiguration* InstructionSequenceTest::config() { |
60 if (config_.is_empty()) { | 68 if (config_.is_empty()) { |
61 config_.Reset(new RegisterConfiguration( | 69 config_.Reset(new RegisterConfiguration( |
62 num_general_registers_, num_double_registers_, num_double_registers_, | 70 num_general_registers_, num_double_registers_, num_general_registers_, |
63 general_register_names_, double_register_names_)); | 71 num_double_registers_, num_double_registers_, allocatable_codes, |
| 72 allocatable_double_codes, general_register_names_, |
| 73 double_register_names_)); |
64 } | 74 } |
65 return config_.get(); | 75 return config_.get(); |
66 } | 76 } |
67 | 77 |
68 | 78 |
69 InstructionSequence* InstructionSequenceTest::sequence() { | 79 InstructionSequence* InstructionSequenceTest::sequence() { |
70 if (sequence_ == nullptr) { | 80 if (sequence_ == nullptr) { |
71 sequence_ = new (zone()) | 81 sequence_ = new (zone()) |
72 InstructionSequence(isolate(), zone(), &instruction_blocks_); | 82 InstructionSequence(isolate(), zone(), &instruction_blocks_); |
73 } | 83 } |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 502 |
493 | 503 |
494 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { | 504 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { |
495 sequence()->AddInstruction(instruction); | 505 sequence()->AddInstruction(instruction); |
496 return instruction; | 506 return instruction; |
497 } | 507 } |
498 | 508 |
499 } // namespace compiler | 509 } // namespace compiler |
500 } // namespace internal | 510 } // namespace internal |
501 } // namespace v8 | 511 } // namespace v8 |
OLD | NEW |