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 | #include "locations.h" |
| 18 | |
| 19 | #include "nodes.h" |
| 20 | |
| 21 | namespace art { |
| 22 | |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 23 | LocationSummary::LocationSummary(HInstruction* instruction, |
| 24 | CallKind call_kind, |
| 25 | bool intrinsified) |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 26 | : inputs_(instruction->GetBlock()->GetGraph()->GetArena(), instruction->InputCount()), |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 27 | temps_(instruction->GetBlock()->GetGraph()->GetArena(), 0), |
| 28 | environment_(instruction->GetBlock()->GetGraph()->GetArena(), |
| 29 | instruction->EnvironmentSize()), |
Nicolas Geoffray | 8e3964b | 2014-10-17 11:06:38 +0100 | [diff] [blame] | 30 | output_overlaps_(true), |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 31 | call_kind_(call_kind), |
| 32 | stack_mask_(nullptr), |
| 33 | register_mask_(0), |
Andreas Gampe | 71fb52f | 2014-12-29 17:43:08 -0800 | [diff] [blame] | 34 | live_registers_(), |
| 35 | intrinsified_(intrinsified) { |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 36 | inputs_.SetSize(instruction->InputCount()); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 37 | for (size_t i = 0; i < instruction->InputCount(); ++i) { |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 38 | inputs_.Put(i, Location()); |
| 39 | } |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 40 | environment_.SetSize(instruction->EnvironmentSize()); |
| 41 | for (size_t i = 0; i < instruction->EnvironmentSize(); ++i) { |
| 42 | environment_.Put(i, Location()); |
| 43 | } |
| 44 | instruction->SetLocations(this); |
| 45 | |
| 46 | if (NeedsSafepoint()) { |
| 47 | ArenaAllocator* arena = instruction->GetBlock()->GetGraph()->GetArena(); |
| 48 | stack_mask_ = new (arena) ArenaBitVector(arena, 0, true); |
| 49 | } |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 50 | } |
| 51 | |
Nicolas Geoffray | 96f89a2 | 2014-07-11 10:57:49 +0100 | [diff] [blame] | 52 | |
| 53 | Location Location::RegisterOrConstant(HInstruction* instruction) { |
| 54 | return instruction->IsConstant() |
| 55 | ? Location::ConstantLocation(instruction->AsConstant()) |
| 56 | : Location::RequiresRegister(); |
| 57 | } |
| 58 | |
Nicolas Geoffray | 56b9ee6 | 2014-10-09 11:47:51 +0100 | [diff] [blame] | 59 | Location Location::ByteRegisterOrConstant(int reg, HInstruction* instruction) { |
Nicolas Geoffray | 26a25ef | 2014-09-30 13:54:09 +0100 | [diff] [blame] | 60 | return instruction->IsConstant() |
| 61 | ? Location::ConstantLocation(instruction->AsConstant()) |
| 62 | : Location::RegisterLocation(reg); |
| 63 | } |
| 64 | |
| 65 | std::ostream& operator<<(std::ostream& os, const Location& location) { |
| 66 | os << location.DebugString(); |
| 67 | return os; |
| 68 | } |
| 69 | |
Nicolas Geoffray | 76716a6 | 2014-05-23 10:14:19 +0100 | [diff] [blame] | 70 | } // namespace art |