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::kMaxFPRegisters]; | 18 double_register_names_[RegisterConfiguration::kMaxFPRegisters]; |
19 static char register_names_[10 * (RegisterConfiguration::kMaxGeneralRegisters + | 19 static char register_names_[10 * (RegisterConfiguration::kMaxGeneralRegisters + |
20 RegisterConfiguration::kMaxFPRegisters)]; | 20 RegisterConfiguration::kMaxFPRegisters)]; |
21 | 21 |
22 namespace { | |
23 static int allocatable_codes[InstructionSequenceTest::kDefaultNRegs] = { | |
24 0, 1, 2, 3, 4, 5, 6, 7}; | |
25 static int allocatable_double_codes[InstructionSequenceTest::kDefaultNRegs] = { | |
26 0, 1, 2, 3, 4, 5, 6, 7}; | |
27 } | |
28 | |
29 | |
30 static void InitializeRegisterNames() { | 22 static void InitializeRegisterNames() { |
31 char* loc = register_names_; | 23 char* loc = register_names_; |
32 for (int i = 0; i < RegisterConfiguration::kMaxGeneralRegisters; ++i) { | 24 for (int i = 0; i < RegisterConfiguration::kMaxGeneralRegisters; ++i) { |
33 general_register_names_[i] = loc; | 25 general_register_names_[i] = loc; |
34 loc += base::OS::SNPrintF(loc, 100, "gp_%d", i); | 26 loc += base::OS::SNPrintF(loc, 100, "gp_%d", i); |
35 *loc++ = 0; | 27 *loc++ = 0; |
36 } | 28 } |
37 for (int i = 0; i < RegisterConfiguration::kMaxFPRegisters; ++i) { | 29 for (int i = 0; i < RegisterConfiguration::kMaxFPRegisters; ++i) { |
38 double_register_names_[i] = loc; | 30 double_register_names_[i] = loc; |
39 loc += base::OS::SNPrintF(loc, 100, "fp_%d", i) + 1; | 31 loc += base::OS::SNPrintF(loc, 100, "fp_%d", i) + 1; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 return config()->GetAllocatableFloatCode(index); | 73 return config()->GetAllocatableFloatCode(index); |
82 case MachineRepresentation::kFloat64: | 74 case MachineRepresentation::kFloat64: |
83 return config()->GetAllocatableDoubleCode(index); | 75 return config()->GetAllocatableDoubleCode(index); |
84 case MachineRepresentation::kSimd128: | 76 case MachineRepresentation::kSimd128: |
85 return config()->GetAllocatableSimd128Code(index); | 77 return config()->GetAllocatableSimd128Code(index); |
86 default: | 78 default: |
87 return config()->GetAllocatableGeneralCode(index); | 79 return config()->GetAllocatableGeneralCode(index); |
88 } | 80 } |
89 } | 81 } |
90 | 82 |
91 RegisterConfiguration* InstructionSequenceTest::config() { | 83 extern const RegisterConfiguration* (*GetRegConfig)(); |
ivica.bogosavljevic
2016/10/19 14:30:40
Ugly but couldn't think of any better. If you have
titzer
2016/11/03 13:00:12
How about adding a separate method that has a XXXF
ivica.bogosavljevic
2016/11/03 15:22:54
Good idea!
| |
92 if (!config_) { | 84 |
93 config_.reset(new RegisterConfiguration( | 85 const RegisterConfiguration* InstructionSequenceTest::config() { |
94 num_general_registers_, num_double_registers_, num_general_registers_, | 86 return v8::internal::compiler::GetRegConfig(); |
95 num_double_registers_, num_double_registers_, allocatable_codes, | |
96 allocatable_double_codes, | |
97 kSimpleFPAliasing ? RegisterConfiguration::OVERLAP | |
98 : RegisterConfiguration::COMBINE, | |
99 general_register_names_, | |
100 double_register_names_, // float register names | |
101 double_register_names_, | |
102 double_register_names_)); // SIMD 128 register names | |
103 } | |
104 return config_.get(); | |
105 } | 87 } |
106 | 88 |
107 | 89 |
108 InstructionSequence* InstructionSequenceTest::sequence() { | 90 InstructionSequence* InstructionSequenceTest::sequence() { |
109 if (sequence_ == nullptr) { | 91 if (sequence_ == nullptr) { |
110 sequence_ = new (zone()) | 92 sequence_ = new (zone()) |
111 InstructionSequence(isolate(), zone(), &instruction_blocks_); | 93 InstructionSequence(isolate(), zone(), &instruction_blocks_); |
112 } | 94 } |
113 return sequence_; | 95 return sequence_; |
114 } | 96 } |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 | 541 |
560 | 542 |
561 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { | 543 Instruction* InstructionSequenceTest::AddInstruction(Instruction* instruction) { |
562 sequence()->AddInstruction(instruction); | 544 sequence()->AddInstruction(instruction); |
563 return instruction; | 545 return instruction; |
564 } | 546 } |
565 | 547 |
566 } // namespace compiler | 548 } // namespace compiler |
567 } // namespace internal | 549 } // namespace internal |
568 } // namespace v8 | 550 } // namespace v8 |
OLD | NEW |