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" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 | 14 |
15 class UnallocatedLocation; | |
16 | |
17 // Location objects are used to connect register allocator and code generator. | 15 // Location objects are used to connect register allocator and code generator. |
18 // Instruction templates used by code generator have a corresponding | 16 // Instruction templates used by code generator have a corresponding |
19 // LocationSummary object which specifies expected location for every input | 17 // LocationSummary object which specifies expected location for every input |
20 // and output. | 18 // and output. |
21 // Each location is encoded as a single word: low 2 bits denote location kind, | 19 // Each location is encoded as a single word: low 2 bits denote location kind, |
22 // rest is kind specific location payload e.g. for REGISTER kind payload is | 20 // rest is kind specific location payload e.g. for REGISTER kind payload is |
23 // register code (value of the Register enumeration). | 21 // register code (value of the Register enumeration). |
24 class Location : public ValueObject { | 22 class Location : public ValueObject { |
25 public: | 23 public: |
26 enum Kind { | 24 enum Kind { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 typedef BitField<Policy, 0, 1> PolicyField; | 93 typedef BitField<Policy, 0, 1> PolicyField; |
96 | 94 |
97 // TODO(vegorov): choose fixed size for this field. | 95 // TODO(vegorov): choose fixed size for this field. |
98 uword value_; | 96 uword value_; |
99 }; | 97 }; |
100 | 98 |
101 | 99 |
102 // Specification of locations for inputs and output. | 100 // Specification of locations for inputs and output. |
103 class LocationSummary : public ZoneAllocated { | 101 class LocationSummary : public ZoneAllocated { |
104 public: | 102 public: |
105 LocationSummary(intptr_t input_count, intptr_t temp_count) | 103 enum ContainsCall { |
104 kNoCall, | |
105 kCall, | |
106 }; | |
107 | |
108 enum ContainsBranch { | |
109 kNoBranch, | |
110 kBranch | |
111 }; | |
112 | |
113 LocationSummary(intptr_t input_count, | |
114 intptr_t temp_count, | |
115 ContainsCall call = kNoCall, | |
srdjan
2012/06/18 16:33:20
I am not sure having default value for 'call' is g
Vyacheslav Egorov (Google)
2012/06/18 17:51:16
Having default value is definitely less safe than
| |
116 ContainsBranch branch = kNoBranch) | |
106 : input_locations_(input_count), | 117 : input_locations_(input_count), |
107 temp_locations_(temp_count), | 118 temp_locations_(temp_count), |
108 output_location_() { | 119 output_location_(), |
120 is_call_(call == kCall), | |
121 is_branch_(branch == kBranch) { | |
109 for (intptr_t i = 0; i < input_count; i++) { | 122 for (intptr_t i = 0; i < input_count; i++) { |
110 input_locations_.Add(Location()); | 123 input_locations_.Add(Location()); |
111 } | 124 } |
112 for (intptr_t i = 0; i < temp_count; i++) { | 125 for (intptr_t i = 0; i < temp_count; i++) { |
113 temp_locations_.Add(Location()); | 126 temp_locations_.Add(Location()); |
114 } | 127 } |
115 } | 128 } |
116 | 129 |
117 intptr_t input_count() const { | 130 intptr_t input_count() const { |
118 return input_locations_.length(); | 131 return input_locations_.length(); |
(...skipping 20 matching lines...) Expand all Loading... | |
139 } | 152 } |
140 | 153 |
141 Location out() const { | 154 Location out() const { |
142 return output_location_; | 155 return output_location_; |
143 } | 156 } |
144 | 157 |
145 void set_out(Location loc) { | 158 void set_out(Location loc) { |
146 output_location_ = loc; | 159 output_location_ = loc; |
147 } | 160 } |
148 | 161 |
149 // Perform a greedy local register allocation. Consider all register free. | 162 bool is_call() const { |
150 void AllocateRegisters(); | 163 return is_call_; |
164 } | |
151 | 165 |
152 static LocationSummary* Make(intptr_t input_count, Location out); | 166 // TODO(vegorov): this is a temporary solution. Once we will start removing |
167 // comparison operations from the flow graph when they are fused with a branch | |
168 // we should eliminate this. | |
169 bool is_branch() const { | |
170 return is_branch_; | |
171 } | |
172 | |
173 static LocationSummary* Make(intptr_t input_count, | |
174 Location out, | |
175 ContainsCall contains_call = kNoCall, | |
176 ContainsBranch contains_branch = kNoBranch); | |
153 | 177 |
154 private: | 178 private: |
155 // TODO(vegorov): replace with ZoneArray. | 179 // TODO(vegorov): replace with ZoneArray. |
156 GrowableArray<Location> input_locations_; | 180 GrowableArray<Location> input_locations_; |
157 GrowableArray<Location> temp_locations_; | 181 GrowableArray<Location> temp_locations_; |
158 Location output_location_; | 182 Location output_location_; |
183 | |
184 const bool is_call_; | |
185 const bool is_branch_; | |
159 }; | 186 }; |
160 | 187 |
161 | 188 |
162 } // namespace dart | 189 } // namespace dart |
163 | 190 |
164 #endif // VM_LOCATIONS_H_ | 191 #endif // VM_LOCATIONS_H_ |
OLD | NEW |