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