blob: ed5e260a5bf770518ea26b8bdfd8fe455de14e4f [file] [log] [blame]
Nicolas Geoffray76716a62014-05-23 10:14:19 +01001 /*
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
21namespace art {
22
Nicolas Geoffray39468442014-09-02 15:17:15 +010023LocationSummary::LocationSummary(HInstruction* instruction, CallKind call_kind)
Nicolas Geoffray76716a62014-05-23 10:14:19 +010024 : inputs_(instruction->GetBlock()->GetGraph()->GetArena(), instruction->InputCount()),
Nicolas Geoffray39468442014-09-02 15:17:15 +010025 temps_(instruction->GetBlock()->GetGraph()->GetArena(), 0),
26 environment_(instruction->GetBlock()->GetGraph()->GetArena(),
27 instruction->EnvironmentSize()),
Nicolas Geoffray8e3964b2014-10-17 11:06:38 +010028 output_overlaps_(true),
Nicolas Geoffray39468442014-09-02 15:17:15 +010029 call_kind_(call_kind),
30 stack_mask_(nullptr),
31 register_mask_(0),
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +010032 live_registers_() {
Nicolas Geoffray76716a62014-05-23 10:14:19 +010033 inputs_.SetSize(instruction->InputCount());
Nicolas Geoffray39468442014-09-02 15:17:15 +010034 for (size_t i = 0; i < instruction->InputCount(); ++i) {
Nicolas Geoffray76716a62014-05-23 10:14:19 +010035 inputs_.Put(i, Location());
36 }
Nicolas Geoffray39468442014-09-02 15:17:15 +010037 environment_.SetSize(instruction->EnvironmentSize());
38 for (size_t i = 0; i < instruction->EnvironmentSize(); ++i) {
39 environment_.Put(i, Location());
40 }
41 instruction->SetLocations(this);
42
43 if (NeedsSafepoint()) {
44 ArenaAllocator* arena = instruction->GetBlock()->GetGraph()->GetArena();
45 stack_mask_ = new (arena) ArenaBitVector(arena, 0, true);
46 }
Nicolas Geoffray76716a62014-05-23 10:14:19 +010047}
48
Nicolas Geoffray96f89a22014-07-11 10:57:49 +010049
50Location Location::RegisterOrConstant(HInstruction* instruction) {
51 return instruction->IsConstant()
52 ? Location::ConstantLocation(instruction->AsConstant())
53 : Location::RequiresRegister();
54}
55
Nicolas Geoffray56b9ee62014-10-09 11:47:51 +010056Location Location::ByteRegisterOrConstant(int reg, HInstruction* instruction) {
Nicolas Geoffray26a25ef2014-09-30 13:54:09 +010057 return instruction->IsConstant()
58 ? Location::ConstantLocation(instruction->AsConstant())
59 : Location::RegisterLocation(reg);
60}
61
62std::ostream& operator<<(std::ostream& os, const Location& location) {
63 os << location.DebugString();
64 return os;
65}
66
Nicolas Geoffray76716a62014-05-23 10:14:19 +010067} // namespace art