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