Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_OPTIMIZING_LOCATIONS_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_LOCATIONS_H_ |
| 19 | |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 20 | #include "base/arena_containers.h" |
Mathieu Chartier | b666f48 | 2015-02-18 14:33:14 -0800 | [diff] [blame] | 21 | #include "base/arena_object.h" |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 22 | #include "base/bit_field.h" |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 23 | #include "base/bit_vector.h" |
Ian Rogers | 0279ebb | 2014-10-08 17:27:48 -0700 | [diff] [blame] | 24 | #include "base/value_object.h" |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 25 | |
| 26 | namespace art { |
| 27 | |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 28 | class HConstant; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 29 | class HInstruction; |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 30 | class Location; |
| 31 | |
| 32 | std::ostream& operator<<(std::ostream& os, const Location& location); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * A Location is an abstraction over the potential location |
| 36 | * of an instruction. It could be in register or stack. |
| 37 | */ |
Vladimir Marko | 76c92ac | 2015-09-17 15:39:16 +0100 | [diff] [blame] | 38 | class Location : public ValueObject { |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 39 | public: |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 40 | enum OutputOverlap { |
Roland Levillain | 3d31242 | 2016-06-23 13:53:42 +0100 | [diff] [blame] | 41 | // The liveness of the output overlaps the liveness of one or |
| 42 | // several input(s); the register allocator cannot reuse an |
| 43 | // input's location for the output's location. |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 44 | kOutputOverlap, |
Roland Levillain | 3d31242 | 2016-06-23 13:53:42 +0100 | [diff] [blame] | 45 | // The liveness of the output does not overlap the liveness of any |
| 46 | // input; the register allocator is allowed to reuse an input's |
| 47 | // location for the output's location. |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 48 | kNoOutputOverlap |
| 49 | }; |
Nicolas Geoffray | 9ae0daa | 2014-09-30 22:40:23 +0100 | [diff] [blame] | 50 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 51 | enum Kind { |
| 52 | kInvalid = 0, |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 53 | kConstant = 1, |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 54 | kStackSlot = 2, // 32bit stack slot. |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 55 | kDoubleStackSlot = 3, // 64bit stack slot. |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 56 | |
| 57 | kRegister = 4, // Core register. |
| 58 | |
| 59 | // We do not use the value 5 because it conflicts with kLocationConstantMask. |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 60 | kDoNotUse5 = 5, |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 61 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 62 | kFpuRegister = 6, // Float register. |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 63 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 64 | kRegisterPair = 7, // Long register. |
| 65 | |
| 66 | kFpuRegisterPair = 8, // Double register. |
| 67 | |
| 68 | // We do not use the value 9 because it conflicts with kLocationConstantMask. |
| 69 | kDoNotUse9 = 9, |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 70 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 71 | // Unallocated location represents a location that is not fixed and can be |
| 72 | // allocated by a register allocator. Each unallocated location has |
| 73 | // a policy that specifies what kind of location is suitable. Payload |
| 74 | // contains register allocation policy. |
Mark Mendell | 3e6a3bf | 2015-01-19 14:09:22 -0500 | [diff] [blame] | 75 | kUnallocated = 10, |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
Vladimir Marko | 76c92ac | 2015-09-17 15:39:16 +0100 | [diff] [blame] | 78 | Location() : ValueObject(), value_(kInvalid) { |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 79 | // Verify that non-constant location kinds do not interfere with kConstant. |
Andreas Gampe | 785d2f2 | 2014-11-03 22:57:30 -0800 | [diff] [blame] | 80 | static_assert((kInvalid & kLocationConstantMask) != kConstant, "TagError"); |
| 81 | static_assert((kUnallocated & kLocationConstantMask) != kConstant, "TagError"); |
| 82 | static_assert((kStackSlot & kLocationConstantMask) != kConstant, "TagError"); |
| 83 | static_assert((kDoubleStackSlot & kLocationConstantMask) != kConstant, "TagError"); |
| 84 | static_assert((kRegister & kLocationConstantMask) != kConstant, "TagError"); |
Andreas Gampe | 785d2f2 | 2014-11-03 22:57:30 -0800 | [diff] [blame] | 85 | static_assert((kFpuRegister & kLocationConstantMask) != kConstant, "TagError"); |
| 86 | static_assert((kRegisterPair & kLocationConstantMask) != kConstant, "TagError"); |
| 87 | static_assert((kFpuRegisterPair & kLocationConstantMask) != kConstant, "TagError"); |
| 88 | static_assert((kConstant & kLocationConstantMask) == kConstant, "TagError"); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 89 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 90 | DCHECK(!IsValid()); |
| 91 | } |
| 92 | |
Vladimir Marko | fa6b93c | 2015-09-15 10:15:55 +0100 | [diff] [blame] | 93 | Location(const Location& other) : value_(other.value_) {} |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 94 | |
| 95 | Location& operator=(const Location& other) { |
| 96 | value_ = other.value_; |
| 97 | return *this; |
| 98 | } |
| 99 | |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 100 | bool IsConstant() const { |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 101 | return (value_ & kLocationConstantMask) == kConstant; |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | static Location ConstantLocation(HConstant* constant) { |
| 105 | DCHECK(constant != nullptr); |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 106 | return Location(kConstant | reinterpret_cast<uintptr_t>(constant)); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | HConstant* GetConstant() const { |
| 110 | DCHECK(IsConstant()); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 111 | return reinterpret_cast<HConstant*>(value_ & ~kLocationConstantMask); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 112 | } |
| 113 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 114 | bool IsValid() const { |
| 115 | return value_ != kInvalid; |
| 116 | } |
| 117 | |
| 118 | bool IsInvalid() const { |
| 119 | return !IsValid(); |
| 120 | } |
| 121 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 122 | // Empty location. Used if there the location should be ignored. |
| 123 | static Location NoLocation() { |
| 124 | return Location(); |
| 125 | } |
| 126 | |
| 127 | // Register locations. |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 128 | static Location RegisterLocation(int reg) { |
| 129 | return Location(kRegister, reg); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 130 | } |
| 131 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 132 | static Location FpuRegisterLocation(int reg) { |
| 133 | return Location(kFpuRegister, reg); |
| 134 | } |
| 135 | |
| 136 | static Location RegisterPairLocation(int low, int high) { |
| 137 | return Location(kRegisterPair, low << 16 | high); |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 140 | static Location FpuRegisterPairLocation(int low, int high) { |
| 141 | return Location(kFpuRegisterPair, low << 16 | high); |
| 142 | } |
| 143 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 144 | bool IsRegister() const { |
| 145 | return GetKind() == kRegister; |
| 146 | } |
| 147 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 148 | bool IsFpuRegister() const { |
| 149 | return GetKind() == kFpuRegister; |
| 150 | } |
| 151 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 152 | bool IsRegisterPair() const { |
| 153 | return GetKind() == kRegisterPair; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 156 | bool IsFpuRegisterPair() const { |
| 157 | return GetKind() == kFpuRegisterPair; |
| 158 | } |
| 159 | |
Nicolas Geoffray | da02afe | 2015-02-11 02:29:42 +0000 | [diff] [blame] | 160 | bool IsRegisterKind() const { |
| 161 | return IsRegister() || IsFpuRegister() || IsRegisterPair() || IsFpuRegisterPair(); |
| 162 | } |
| 163 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 164 | int reg() const { |
| 165 | DCHECK(IsRegister() || IsFpuRegister()); |
| 166 | return GetPayload(); |
| 167 | } |
| 168 | |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 169 | int low() const { |
| 170 | DCHECK(IsPair()); |
| 171 | return GetPayload() >> 16; |
| 172 | } |
| 173 | |
| 174 | int high() const { |
| 175 | DCHECK(IsPair()); |
| 176 | return GetPayload() & 0xFFFF; |
| 177 | } |
| 178 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 179 | template <typename T> |
Roland Levillain | 271ab9c | 2014-11-27 15:23:57 +0000 | [diff] [blame] | 180 | T AsRegister() const { |
| 181 | DCHECK(IsRegister()); |
| 182 | return static_cast<T>(reg()); |
| 183 | } |
| 184 | |
| 185 | template <typename T> |
| 186 | T AsFpuRegister() const { |
| 187 | DCHECK(IsFpuRegister()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 188 | return static_cast<T>(reg()); |
| 189 | } |
| 190 | |
| 191 | template <typename T> |
| 192 | T AsRegisterPairLow() const { |
| 193 | DCHECK(IsRegisterPair()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 194 | return static_cast<T>(low()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | template <typename T> |
| 198 | T AsRegisterPairHigh() const { |
| 199 | DCHECK(IsRegisterPair()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 200 | return static_cast<T>(high()); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 201 | } |
| 202 | |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 203 | template <typename T> |
| 204 | T AsFpuRegisterPairLow() const { |
| 205 | DCHECK(IsFpuRegisterPair()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 206 | return static_cast<T>(low()); |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | template <typename T> |
| 210 | T AsFpuRegisterPairHigh() const { |
| 211 | DCHECK(IsFpuRegisterPair()); |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 212 | return static_cast<T>(high()); |
| 213 | } |
| 214 | |
| 215 | bool IsPair() const { |
| 216 | return IsRegisterPair() || IsFpuRegisterPair(); |
| 217 | } |
| 218 | |
| 219 | Location ToLow() const { |
Nicolas Geoffray | 234d69d | 2015-03-09 10:28:50 +0000 | [diff] [blame] | 220 | if (IsRegisterPair()) { |
| 221 | return Location::RegisterLocation(low()); |
| 222 | } else if (IsFpuRegisterPair()) { |
| 223 | return Location::FpuRegisterLocation(low()); |
| 224 | } else { |
| 225 | DCHECK(IsDoubleStackSlot()); |
| 226 | return Location::StackSlot(GetStackIndex()); |
| 227 | } |
Nicolas Geoffray | 840e546 | 2015-01-07 16:01:24 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | Location ToHigh() const { |
Nicolas Geoffray | 234d69d | 2015-03-09 10:28:50 +0000 | [diff] [blame] | 231 | if (IsRegisterPair()) { |
| 232 | return Location::RegisterLocation(high()); |
| 233 | } else if (IsFpuRegisterPair()) { |
| 234 | return Location::FpuRegisterLocation(high()); |
| 235 | } else { |
| 236 | DCHECK(IsDoubleStackSlot()); |
| 237 | return Location::StackSlot(GetHighStackIndex(4)); |
| 238 | } |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 241 | static uintptr_t EncodeStackIndex(intptr_t stack_index) { |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 242 | DCHECK(-kStackIndexBias <= stack_index); |
| 243 | DCHECK(stack_index < kStackIndexBias); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 244 | return static_cast<uintptr_t>(kStackIndexBias + stack_index); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static Location StackSlot(intptr_t stack_index) { |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 248 | uintptr_t payload = EncodeStackIndex(stack_index); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 249 | Location loc(kStackSlot, payload); |
| 250 | // Ensure that sign is preserved. |
| 251 | DCHECK_EQ(loc.GetStackIndex(), stack_index); |
| 252 | return loc; |
| 253 | } |
| 254 | |
| 255 | bool IsStackSlot() const { |
| 256 | return GetKind() == kStackSlot; |
| 257 | } |
| 258 | |
| 259 | static Location DoubleStackSlot(intptr_t stack_index) { |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 260 | uintptr_t payload = EncodeStackIndex(stack_index); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 261 | Location loc(kDoubleStackSlot, payload); |
| 262 | // Ensure that sign is preserved. |
| 263 | DCHECK_EQ(loc.GetStackIndex(), stack_index); |
| 264 | return loc; |
| 265 | } |
| 266 | |
| 267 | bool IsDoubleStackSlot() const { |
| 268 | return GetKind() == kDoubleStackSlot; |
| 269 | } |
| 270 | |
| 271 | intptr_t GetStackIndex() const { |
| 272 | DCHECK(IsStackSlot() || IsDoubleStackSlot()); |
| 273 | // Decode stack index manually to preserve sign. |
| 274 | return GetPayload() - kStackIndexBias; |
| 275 | } |
| 276 | |
| 277 | intptr_t GetHighStackIndex(uintptr_t word_size) const { |
| 278 | DCHECK(IsDoubleStackSlot()); |
| 279 | // Decode stack index manually to preserve sign. |
| 280 | return GetPayload() - kStackIndexBias + word_size; |
| 281 | } |
| 282 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 283 | Kind GetKind() const { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 284 | return IsConstant() ? kConstant : KindField::Decode(value_); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | bool Equals(Location other) const { |
| 288 | return value_ == other.value_; |
| 289 | } |
| 290 | |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 291 | bool Contains(Location other) const { |
| 292 | if (Equals(other)) { |
| 293 | return true; |
Zheng Xu | ad4450e | 2015-04-17 18:48:56 +0800 | [diff] [blame] | 294 | } else if (IsPair() || IsDoubleStackSlot()) { |
| 295 | return ToLow().Equals(other) || ToHigh().Equals(other); |
Nicolas Geoffray | f7a0c4e | 2015-02-10 17:08:47 +0000 | [diff] [blame] | 296 | } |
| 297 | return false; |
| 298 | } |
| 299 | |
Zheng Xu | ad4450e | 2015-04-17 18:48:56 +0800 | [diff] [blame] | 300 | bool OverlapsWith(Location other) const { |
| 301 | // Only check the overlapping case that can happen with our register allocation algorithm. |
| 302 | bool overlap = Contains(other) || other.Contains(*this); |
| 303 | if (kIsDebugBuild && !overlap) { |
| 304 | // Note: These are also overlapping cases. But we are not able to handle them in |
| 305 | // ParallelMoveResolverWithSwap. Make sure that we do not meet such case with our compiler. |
| 306 | if ((IsPair() && other.IsPair()) || (IsDoubleStackSlot() && other.IsDoubleStackSlot())) { |
| 307 | DCHECK(!Contains(other.ToLow())); |
| 308 | DCHECK(!Contains(other.ToHigh())); |
| 309 | } |
| 310 | } |
| 311 | return overlap; |
| 312 | } |
| 313 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 314 | const char* DebugString() const { |
| 315 | switch (GetKind()) { |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 316 | case kInvalid: return "I"; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 317 | case kRegister: return "R"; |
| 318 | case kStackSlot: return "S"; |
| 319 | case kDoubleStackSlot: return "DS"; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 320 | case kUnallocated: return "U"; |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 321 | case kConstant: return "C"; |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 322 | case kFpuRegister: return "F"; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 323 | case kRegisterPair: return "RP"; |
Nicolas Geoffray | 1ba0f59 | 2014-10-27 15:14:55 +0000 | [diff] [blame] | 324 | case kFpuRegisterPair: return "FP"; |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 325 | case kDoNotUse5: // fall-through |
| 326 | case kDoNotUse9: |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 327 | LOG(FATAL) << "Should not use this location kind"; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 328 | } |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 329 | UNREACHABLE(); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 330 | return "?"; |
| 331 | } |
| 332 | |
| 333 | // Unallocated locations. |
| 334 | enum Policy { |
| 335 | kAny, |
| 336 | kRequiresRegister, |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 337 | kRequiresFpuRegister, |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 338 | kSameAsFirstInput, |
| 339 | }; |
| 340 | |
| 341 | bool IsUnallocated() const { |
| 342 | return GetKind() == kUnallocated; |
| 343 | } |
| 344 | |
| 345 | static Location UnallocatedLocation(Policy policy) { |
| 346 | return Location(kUnallocated, PolicyField::Encode(policy)); |
| 347 | } |
| 348 | |
| 349 | // Any free register is suitable to replace this unallocated location. |
| 350 | static Location Any() { |
| 351 | return UnallocatedLocation(kAny); |
| 352 | } |
| 353 | |
| 354 | static Location RequiresRegister() { |
| 355 | return UnallocatedLocation(kRequiresRegister); |
| 356 | } |
| 357 | |
Nicolas Geoffray | 7fb49da | 2014-10-06 09:12:41 +0100 | [diff] [blame] | 358 | static Location RequiresFpuRegister() { |
| 359 | return UnallocatedLocation(kRequiresFpuRegister); |
| 360 | } |
| 361 | |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 362 | static Location RegisterOrConstant(HInstruction* instruction); |
Mark Mendell | ea5af68 | 2015-10-22 17:35:49 -0400 | [diff] [blame] | 363 | static Location RegisterOrInt32Constant(HInstruction* instruction); |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 364 | static Location ByteRegisterOrConstant(int reg, HInstruction* instruction); |
Mark Mendell | ea5af68 | 2015-10-22 17:35:49 -0400 | [diff] [blame] | 365 | static Location FpuRegisterOrConstant(HInstruction* instruction); |
| 366 | static Location FpuRegisterOrInt32Constant(HInstruction* instruction); |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 367 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 368 | // The location of the first input to the instruction will be |
| 369 | // used to replace this unallocated location. |
| 370 | static Location SameAsFirstInput() { |
| 371 | return UnallocatedLocation(kSameAsFirstInput); |
| 372 | } |
| 373 | |
| 374 | Policy GetPolicy() const { |
| 375 | DCHECK(IsUnallocated()); |
| 376 | return PolicyField::Decode(GetPayload()); |
| 377 | } |
| 378 | |
Matthew Gharrity | d9ffd0d | 2016-06-22 10:27:55 -0700 | [diff] [blame^] | 379 | bool RequiresRegisterKind() const { |
| 380 | return GetPolicy() == kRequiresRegister || GetPolicy() == kRequiresFpuRegister; |
| 381 | } |
| 382 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 383 | uintptr_t GetEncoding() const { |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 384 | return GetPayload(); |
| 385 | } |
| 386 | |
| 387 | private: |
| 388 | // Number of bits required to encode Kind value. |
| 389 | static constexpr uint32_t kBitsForKind = 4; |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 390 | static constexpr uint32_t kBitsForPayload = kBitsPerIntPtrT - kBitsForKind; |
| 391 | static constexpr uintptr_t kLocationConstantMask = 0x3; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 392 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 393 | explicit Location(uintptr_t value) : value_(value) {} |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 394 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 395 | Location(Kind kind, uintptr_t payload) |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 396 | : value_(KindField::Encode(kind) | PayloadField::Encode(payload)) {} |
| 397 | |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 398 | uintptr_t GetPayload() const { |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 399 | return PayloadField::Decode(value_); |
| 400 | } |
| 401 | |
| 402 | typedef BitField<Kind, 0, kBitsForKind> KindField; |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 403 | typedef BitField<uintptr_t, kBitsForKind, kBitsForPayload> PayloadField; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 404 | |
| 405 | // Layout for kUnallocated locations payload. |
| 406 | typedef BitField<Policy, 0, 3> PolicyField; |
| 407 | |
| 408 | // Layout for stack slots. |
| 409 | static const intptr_t kStackIndexBias = |
| 410 | static_cast<intptr_t>(1) << (kBitsForPayload - 1); |
| 411 | |
| 412 | // Location either contains kind and payload fields or a tagged handle for |
| 413 | // a constant locations. Values of enumeration Kind are selected in such a |
| 414 | // way that none of them can be interpreted as a kConstant tag. |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 415 | uintptr_t value_; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 416 | }; |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 417 | std::ostream& operator<<(std::ostream& os, const Location::Kind& rhs); |
| 418 | std::ostream& operator<<(std::ostream& os, const Location::Policy& rhs); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 419 | |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 420 | class RegisterSet : public ValueObject { |
| 421 | public: |
| 422 | RegisterSet() : core_registers_(0), floating_point_registers_(0) {} |
| 423 | |
| 424 | void Add(Location loc) { |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 425 | if (loc.IsRegister()) { |
| 426 | core_registers_ |= (1 << loc.reg()); |
| 427 | } else { |
| 428 | DCHECK(loc.IsFpuRegister()); |
| 429 | floating_point_registers_ |= (1 << loc.reg()); |
| 430 | } |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 431 | } |
| 432 | |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 433 | void Remove(Location loc) { |
| 434 | if (loc.IsRegister()) { |
| 435 | core_registers_ &= ~(1 << loc.reg()); |
| 436 | } else { |
Nicolas Geoffray | 424f676 | 2014-11-03 14:51:25 +0000 | [diff] [blame] | 437 | DCHECK(loc.IsFpuRegister()) << loc; |
Nicolas Geoffray | 19a19cf | 2014-10-22 16:07:05 +0100 | [diff] [blame] | 438 | floating_point_registers_ &= ~(1 << loc.reg()); |
| 439 | } |
| 440 | } |
| 441 | |
Nicolas Geoffray | 45b83af | 2015-07-06 15:12:53 +0000 | [diff] [blame] | 442 | bool ContainsCoreRegister(uint32_t id) const { |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 443 | return Contains(core_registers_, id); |
| 444 | } |
| 445 | |
Nicolas Geoffray | 45b83af | 2015-07-06 15:12:53 +0000 | [diff] [blame] | 446 | bool ContainsFloatingPointRegister(uint32_t id) const { |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 447 | return Contains(floating_point_registers_, id); |
| 448 | } |
| 449 | |
| 450 | static bool Contains(uint32_t register_set, uint32_t reg) { |
| 451 | return (register_set & (1 << reg)) != 0; |
| 452 | } |
| 453 | |
Nicolas Geoffray | 87d0376 | 2014-11-19 15:17:56 +0000 | [diff] [blame] | 454 | size_t GetNumberOfRegisters() const { |
| 455 | return __builtin_popcount(core_registers_) + __builtin_popcount(floating_point_registers_); |
| 456 | } |
| 457 | |
Nicolas Geoffray | 9889396 | 2015-01-21 12:32:32 +0000 | [diff] [blame] | 458 | uint32_t GetCoreRegisters() const { |
| 459 | return core_registers_; |
| 460 | } |
| 461 | |
| 462 | uint32_t GetFloatingPointRegisters() const { |
| 463 | return floating_point_registers_; |
| 464 | } |
| 465 | |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 466 | private: |
| 467 | uint32_t core_registers_; |
| 468 | uint32_t floating_point_registers_; |
| 469 | |
| 470 | DISALLOW_COPY_AND_ASSIGN(RegisterSet); |
| 471 | }; |
| 472 | |
Andreas Gampe | 878d58c | 2015-01-15 23:24:00 -0800 | [diff] [blame] | 473 | static constexpr bool kIntrinsified = true; |
| 474 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 475 | /** |
| 476 | * The code generator computes LocationSummary for each instruction so that |
| 477 | * the instruction itself knows what code to generate: where to find the inputs |
| 478 | * and where to place the result. |
| 479 | * |
| 480 | * The intent is to have the code for generating the instruction independent of |
| 481 | * register allocation. A register allocator just has to provide a LocationSummary. |
| 482 | */ |
Vladimir Marko | 5233f93 | 2015-09-29 19:01:15 +0100 | [diff] [blame] | 483 | class LocationSummary : public ArenaObject<kArenaAllocLocationSummary> { |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 484 | public: |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 485 | enum CallKind { |
| 486 | kNoCall, |
Serban Constantinescu | 806f012 | 2016-03-09 11:10:16 +0000 | [diff] [blame] | 487 | kCallOnMainAndSlowPath, |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 488 | kCallOnSlowPath, |
Serban Constantinescu | 54ff482 | 2016-07-07 18:03:19 +0100 | [diff] [blame] | 489 | kCallOnMainOnly |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 490 | }; |
| 491 | |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 492 | LocationSummary(HInstruction* instruction, |
| 493 | CallKind call_kind = kNoCall, |
| 494 | bool intrinsified = false); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 495 | |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 496 | void SetInAt(uint32_t at, Location location) { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 497 | inputs_[at] = location; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | Location InAt(uint32_t at) const { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 501 | return inputs_[at]; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | size_t GetInputCount() const { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 505 | return inputs_.size(); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 506 | } |
| 507 | |
Roland Levillain | 3d31242 | 2016-06-23 13:53:42 +0100 | [diff] [blame] | 508 | // Set the output location. Argument `overlaps` tells whether the |
| 509 | // output overlaps any of the inputs (if so, it cannot share the |
| 510 | // same register as one of the inputs); it is set to |
| 511 | // `Location::kOutputOverlap` by default for safety. |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 512 | void SetOut(Location location, Location::OutputOverlap overlaps = Location::kOutputOverlap) { |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 513 | DCHECK(output_.IsInvalid()); |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 514 | output_overlaps_ = overlaps; |
Nicolas Geoffray | f43083d | 2014-11-07 10:48:10 +0000 | [diff] [blame] | 515 | output_ = location; |
| 516 | } |
| 517 | |
| 518 | void UpdateOut(Location location) { |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 519 | // There are two reasons for updating an output: |
| 520 | // 1) Parameters, where we only know the exact stack slot after |
| 521 | // doing full register allocation. |
| 522 | // 2) Unallocated location. |
| 523 | DCHECK(output_.IsStackSlot() || output_.IsDoubleStackSlot() || output_.IsUnallocated()); |
Nicolas Geoffray | f43083d | 2014-11-07 10:48:10 +0000 | [diff] [blame] | 524 | output_ = location; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | void AddTemp(Location location) { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 528 | temps_.push_back(location); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | Location GetTemp(uint32_t at) const { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 532 | return temps_[at]; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | void SetTempAt(uint32_t at, Location location) { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 536 | DCHECK(temps_[at].IsUnallocated() || temps_[at].IsInvalid()); |
| 537 | temps_[at] = location; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | size_t GetTempCount() const { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 541 | return temps_.size(); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 542 | } |
| 543 | |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 544 | bool HasTemps() const { return !temps_.empty(); } |
Nicolas Geoffray | 94015b9 | 2015-06-04 18:21:04 +0100 | [diff] [blame] | 545 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 546 | Location Out() const { return output_; } |
| 547 | |
Serban Constantinescu | 806f012 | 2016-03-09 11:10:16 +0000 | [diff] [blame] | 548 | bool CanCall() const { |
| 549 | return call_kind_ != kNoCall; |
| 550 | } |
| 551 | |
| 552 | bool WillCall() const { |
| 553 | return call_kind_ == kCallOnMainOnly || call_kind_ == kCallOnMainAndSlowPath; |
| 554 | } |
| 555 | |
| 556 | bool CallsOnSlowPath() const { |
| 557 | return call_kind_ == kCallOnSlowPath || call_kind_ == kCallOnMainAndSlowPath; |
| 558 | } |
| 559 | |
| 560 | bool OnlyCallsOnSlowPath() const { |
| 561 | return call_kind_ == kCallOnSlowPath; |
| 562 | } |
| 563 | |
| 564 | bool CallsOnMainAndSlowPath() const { |
| 565 | return call_kind_ == kCallOnMainAndSlowPath; |
| 566 | } |
| 567 | |
| 568 | bool NeedsSafepoint() const { |
| 569 | return CanCall(); |
| 570 | } |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 571 | |
| 572 | void SetStackBit(uint32_t index) { |
| 573 | stack_mask_->SetBit(index); |
| 574 | } |
| 575 | |
Nicolas Geoffray | 3c04974 | 2014-09-24 18:10:46 +0100 | [diff] [blame] | 576 | void ClearStackBit(uint32_t index) { |
| 577 | stack_mask_->ClearBit(index); |
| 578 | } |
| 579 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 580 | void SetRegisterBit(uint32_t reg_id) { |
| 581 | register_mask_ |= (1 << reg_id); |
| 582 | } |
| 583 | |
Nicolas Geoffray | 9889396 | 2015-01-21 12:32:32 +0000 | [diff] [blame] | 584 | uint32_t GetRegisterMask() const { |
| 585 | return register_mask_; |
| 586 | } |
| 587 | |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 588 | bool RegisterContainsObject(uint32_t reg_id) { |
| 589 | return RegisterSet::Contains(register_mask_, reg_id); |
| 590 | } |
| 591 | |
| 592 | void AddLiveRegister(Location location) { |
| 593 | live_registers_.Add(location); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | BitVector* GetStackMask() const { |
| 597 | return stack_mask_; |
| 598 | } |
| 599 | |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 600 | RegisterSet* GetLiveRegisters() { |
| 601 | return &live_registers_; |
| 602 | } |
| 603 | |
Nicolas Geoffray | 87d0376 | 2014-11-19 15:17:56 +0000 | [diff] [blame] | 604 | size_t GetNumberOfLiveRegisters() const { |
| 605 | return live_registers_.GetNumberOfRegisters(); |
| 606 | } |
| 607 | |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 608 | bool OutputUsesSameAs(uint32_t input_index) const { |
| 609 | return (input_index == 0) |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 610 | && output_.IsUnallocated() |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 611 | && (output_.GetPolicy() == Location::kSameAsFirstInput); |
| 612 | } |
| 613 | |
| 614 | bool IsFixedInput(uint32_t input_index) const { |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 615 | Location input = inputs_[input_index]; |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 616 | return input.IsRegister() |
Nicolas Geoffray | 9889396 | 2015-01-21 12:32:32 +0000 | [diff] [blame] | 617 | || input.IsFpuRegister() |
| 618 | || input.IsPair() |
| 619 | || input.IsStackSlot() |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 620 | || input.IsDoubleStackSlot(); |
Nicolas Geoffray | 7690562 | 2014-09-25 14:39:26 +0100 | [diff] [blame] | 621 | } |
| 622 | |
Nicolas Geoffray | 829280c | 2015-01-28 10:20:37 +0000 | [diff] [blame] | 623 | bool OutputCanOverlapWithInputs() const { |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 624 | return output_overlaps_ == Location::kOutputOverlap; |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 625 | } |
| 626 | |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 627 | bool Intrinsified() const { |
| 628 | return intrinsified_; |
| 629 | } |
| 630 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 631 | void SetIntrinsified(bool intrinsified) { |
| 632 | intrinsified_ = intrinsified; |
| 633 | } |
| 634 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 635 | private: |
Vladimir Marko | 2aaa4b5 | 2015-09-17 17:03:26 +0100 | [diff] [blame] | 636 | ArenaVector<Location> inputs_; |
| 637 | ArenaVector<Location> temps_; |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 638 | // Whether the output overlaps with any of the inputs. If it overlaps, then it cannot |
| 639 | // share the same register as the inputs. |
Nicolas Geoffray | 6c2dff8 | 2015-01-21 14:56:54 +0000 | [diff] [blame] | 640 | Location::OutputOverlap output_overlaps_; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 641 | Location output_; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 642 | const CallKind call_kind_; |
| 643 | |
| 644 | // Mask of objects that live in the stack. |
| 645 | BitVector* stack_mask_; |
| 646 | |
| 647 | // Mask of objects that live in register. |
| 648 | uint32_t register_mask_; |
| 649 | |
| 650 | // Registers that are in use at this position. |
Nicolas Geoffray | 3bca0df | 2014-09-19 11:01:00 +0100 | [diff] [blame] | 651 | RegisterSet live_registers_; |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 652 | |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 653 | // Whether these are locations for an intrinsified call. |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 654 | bool intrinsified_; |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 655 | |
Nicolas Geoffray | f43083d | 2014-11-07 10:48:10 +0000 | [diff] [blame] | 656 | ART_FRIEND_TEST(RegisterAllocatorTest, ExpectedInRegisterHint); |
| 657 | ART_FRIEND_TEST(RegisterAllocatorTest, SameAsFirstInputHint); |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 658 | DISALLOW_COPY_AND_ASSIGN(LocationSummary); |
| 659 | }; |
| 660 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 661 | } // namespace art |
| 662 | |
| 663 | #endif // ART_COMPILER_OPTIMIZING_LOCATIONS_H_ |