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 #ifndef VM_LOCATIONS_H_ | 5 #ifndef VM_LOCATIONS_H_ |
6 #define VM_LOCATIONS_H_ | 6 #define VM_LOCATIONS_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/bitfield.h" | 10 #include "vm/bitfield.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 typedef BitField<Policy, 0, 1> PolicyField; | 90 typedef BitField<Policy, 0, 1> PolicyField; |
91 | 91 |
92 // TODO(vegorov): choose fixed size for this field. | 92 // TODO(vegorov): choose fixed size for this field. |
93 uword value_; | 93 uword value_; |
94 }; | 94 }; |
95 | 95 |
96 | 96 |
97 // Specification of locations for inputs and output. | 97 // Specification of locations for inputs and output. |
98 class LocationSummary : public ZoneAllocated { | 98 class LocationSummary : public ZoneAllocated { |
99 public: | 99 public: |
100 explicit LocationSummary(intptr_t count) | 100 LocationSummary(intptr_t input_count, intptr_t temp_count) |
101 : input_locations_(count), output_location_() { | 101 : input_locations_(input_count), |
102 for (intptr_t i = 0; i < count; i++) { | 102 temp_locations_(temp_count), |
| 103 output_location_() { |
| 104 for (intptr_t i = 0; i < input_count; i++) { |
103 input_locations_.Add(Location()); | 105 input_locations_.Add(Location()); |
104 } | 106 } |
| 107 for (intptr_t i = 0; i < temp_count; i++) { |
| 108 temp_locations_.Add(Location()); |
| 109 } |
105 } | 110 } |
106 | 111 |
107 intptr_t count() const { | 112 intptr_t input_count() const { |
108 return input_locations_.length(); | 113 return input_locations_.length(); |
109 } | 114 } |
110 | 115 |
111 Location in(intptr_t index) const { | 116 Location in(intptr_t index) const { |
112 return input_locations_[index]; | 117 return input_locations_[index]; |
113 } | 118 } |
114 | 119 |
115 void set_in(intptr_t index, Location loc) { | 120 void set_in(intptr_t index, Location loc) { |
116 input_locations_[index] = loc; | 121 input_locations_[index] = loc; |
117 } | 122 } |
118 | 123 |
| 124 intptr_t temp_count() const { |
| 125 return temp_locations_.length(); |
| 126 } |
| 127 |
| 128 Location temp(intptr_t index) const { |
| 129 return temp_locations_[index]; |
| 130 } |
| 131 |
| 132 void set_temp(intptr_t index, Location loc) { |
| 133 temp_locations_[index] = loc; |
| 134 } |
| 135 |
119 Location out() const { | 136 Location out() const { |
120 return output_location_; | 137 return output_location_; |
121 } | 138 } |
122 | 139 |
123 void set_out(Location loc) { | 140 void set_out(Location loc) { |
124 output_location_ = loc; | 141 output_location_ = loc; |
125 } | 142 } |
126 | 143 |
127 // Perform a greedy local register allocation. Consider all register free. | 144 // Perform a greedy local register allocation. Consider all register free. |
128 void AllocateRegisters(); | 145 void AllocateRegisters(); |
129 | 146 |
130 private: | 147 private: |
131 // TODO(vegorov): replace with ZoneArray. | 148 // TODO(vegorov): replace with ZoneArray. |
132 GrowableArray<Location> input_locations_; | 149 GrowableArray<Location> input_locations_; |
| 150 GrowableArray<Location> temp_locations_; |
133 Location output_location_; | 151 Location output_location_; |
134 }; | 152 }; |
135 | 153 |
136 | 154 |
137 } // namespace dart | 155 } // namespace dart |
138 | 156 |
139 #endif // VM_LOCATIONS_H_ | 157 #endif // VM_LOCATIONS_H_ |
OLD | NEW |