OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/locations.h" | 5 #include "vm/locations.h" |
6 | 6 |
7 #include "vm/intermediate_language.h" | 7 #include "vm/intermediate_language.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... | |
23 | 23 |
24 | 24 |
25 void LocationSummary::AllocateRegisters() { | 25 void LocationSummary::AllocateRegisters() { |
26 EmbeddedArray<bool, kNumberOfCpuRegisters> blocked_registers; | 26 EmbeddedArray<bool, kNumberOfCpuRegisters> blocked_registers; |
27 | 27 |
28 // Mark all available registers free. | 28 // Mark all available registers free. |
29 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) { | 29 for (intptr_t i = 0; i < kNumberOfCpuRegisters; i++) { |
30 blocked_registers[i] = false; | 30 blocked_registers[i] = false; |
31 } | 31 } |
32 | 32 |
33 // Mark all fixed registers as used. | 33 // Mark all fixed input, temp and output registers as used. |
34 for (intptr_t i = 0; i < count(); i++) { | 34 for (intptr_t i = 0; i < input_count(); i++) { |
35 Location loc = in(i); | 35 Location loc = in(i); |
36 if (loc.kind() == Location::kRegister) { | 36 if (loc.kind() == Location::kRegister) { |
37 ASSERT(!blocked_registers[loc.reg()]); | 37 ASSERT(!blocked_registers[loc.reg()]); |
38 blocked_registers[loc.reg()] = true; | 38 blocked_registers[loc.reg()] = true; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 for (intptr_t i = 0; i < temp_count(); i++) { | |
43 Location loc = temp(i); | |
44 if (loc.kind() == Location::kRegister) { | |
45 ASSERT(!blocked_registers[loc.reg()]); | |
46 blocked_registers[loc.reg()] = true; | |
47 } | |
48 } | |
49 | |
50 if (out().kind() == Location::kRegister) { | |
51 ASSERT(!blocked_registers[out().reg()]); | |
52 blocked_registers[out().reg()] = true; | |
srdjan
2012/05/24 18:57:16
We should be able to have the same input/temp and
| |
53 } | |
54 | |
42 // Do not allocate known registers. | 55 // Do not allocate known registers. |
43 blocked_registers[CTX] = true; | 56 blocked_registers[CTX] = true; |
44 if (TMP != kNoRegister) { | 57 if (TMP != kNoRegister) { |
45 blocked_registers[TMP] = true; | 58 blocked_registers[TMP] = true; |
46 } | 59 } |
47 | 60 |
48 // Allocate all unallocated input locations. | 61 // Allocate all unallocated input locations. |
49 for (intptr_t i = 0; i < count(); i++) { | 62 for (intptr_t i = 0; i < input_count(); i++) { |
50 Location loc = in(i); | 63 Location loc = in(i); |
51 if (loc.kind() == Location::kUnallocated) { | 64 if (loc.kind() == Location::kUnallocated) { |
52 ASSERT(loc.policy() == Location::kRequiresRegister); | 65 ASSERT(loc.policy() == Location::kRequiresRegister); |
53 set_in(i, Location::RegisterLocation( | 66 set_in(i, Location::RegisterLocation( |
54 AllocateFreeRegister(&blocked_registers))); | 67 AllocateFreeRegister(&blocked_registers))); |
55 } | 68 } |
56 } | 69 } |
57 | 70 |
71 // Allocate all unallocated temp locations. | |
72 for (intptr_t i = 0; i < temp_count(); i++) { | |
73 Location loc = temp(i); | |
74 if (loc.kind() == Location::kUnallocated) { | |
75 ASSERT(loc.policy() == Location::kRequiresRegister); | |
76 set_temp(i, Location::RegisterLocation( | |
77 AllocateFreeRegister(&blocked_registers))); | |
78 } | |
79 } | |
80 | |
58 Location result_location = out(); | 81 Location result_location = out(); |
59 if (result_location.kind() == Location::kUnallocated) { | 82 if (result_location.kind() == Location::kUnallocated) { |
60 switch (result_location.policy()) { | 83 switch (result_location.policy()) { |
61 case Location::kRequiresRegister: | 84 case Location::kRequiresRegister: |
62 result_location = Location::RegisterLocation( | 85 result_location = Location::RegisterLocation( |
63 AllocateFreeRegister(&blocked_registers)); | 86 AllocateFreeRegister(&blocked_registers)); |
64 break; | 87 break; |
65 case Location::kSameAsFirstInput: | 88 case Location::kSameAsFirstInput: |
66 result_location = in(0); | 89 result_location = in(0); |
67 break; | 90 break; |
68 } | 91 } |
69 set_out(result_location); | 92 set_out(result_location); |
70 } | 93 } |
71 } | 94 } |
72 | 95 |
73 | 96 |
74 } // namespace dart | 97 } // namespace dart |
75 | 98 |
OLD | NEW |