blob: 1c36cdf77c7e986d5ccbe4f8853f59dd48cc8d4e [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()),
28 call_kind_(call_kind),
29 stack_mask_(nullptr),
30 register_mask_(0),
Nicolas Geoffray3bca0df2014-09-19 11:01:00 +010031 live_registers_() {
Nicolas Geoffray76716a62014-05-23 10:14:19 +010032 inputs_.SetSize(instruction->InputCount());
Nicolas Geoffray39468442014-09-02 15:17:15 +010033 for (size_t i = 0; i < instruction->InputCount(); ++i) {
Nicolas Geoffray76716a62014-05-23 10:14:19 +010034 inputs_.Put(i, Location());
35 }
Nicolas Geoffray39468442014-09-02 15:17:15 +010036 environment_.SetSize(instruction->EnvironmentSize());
37 for (size_t i = 0; i < instruction->EnvironmentSize(); ++i) {
38 environment_.Put(i, Location());
39 }
40 instruction->SetLocations(this);
41
42 if (NeedsSafepoint()) {
43 ArenaAllocator* arena = instruction->GetBlock()->GetGraph()->GetArena();
44 stack_mask_ = new (arena) ArenaBitVector(arena, 0, true);
45 }
Nicolas Geoffray76716a62014-05-23 10:14:19 +010046}
47
Nicolas Geoffray96f89a22014-07-11 10:57:49 +010048
49Location Location::RegisterOrConstant(HInstruction* instruction) {
50 return instruction->IsConstant()
51 ? Location::ConstantLocation(instruction->AsConstant())
52 : Location::RequiresRegister();
53}
54
Nicolas Geoffray76716a62014-05-23 10:14:19 +010055} // namespace art