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