blob: 5def2acfe3c800b2663a418ac6e0d5242e140b38 [file] [log] [blame]
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -07001/*
2 * Copyright (C) 2012 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 "lir_function.h"
18
19#include "lir_frame_info.h"
20
21#include "logging.h"
22
23namespace llvm {
24
25using art::greenland::LIR;
26using art::greenland::LIRFunction;
27
28void ilist_traits<LIR>::addNodeToList(LIR* lir) {
29 DCHECK(lir->GetParent() == 0) << "LIR already in a function";
30 // Update the LIR::parent_
31 lir->SetParent(parent_);
32 return;
33}
34
35void ilist_traits<LIR>::removeNodeFromList(LIR* lir) {
36 DCHECK(lir->GetParent() == 0) << "LIR is not in a function";
37 // Update the LIR::parent_
38 lir->SetParent(NULL);
39 return;
40}
41
42void ilist_traits<LIR>::transferNodesFromList(ilist_traits &src_traits,
43 ilist_iterator<LIR> first,
44 ilist_iterator<LIR> last) {
45 UNIMPLEMENTED(FATAL);
46 return;
47}
48
49void ilist_traits<LIR>::deleteNode(LIR* lir) {
50 CHECK(!lir->GetParent()) << "LIR is still in a block!";
51 parent_->DeleteLIR(lir);
52 return;
53}
54
55} // namespace llvm
56
57namespace art {
58namespace greenland {
59
60LIRFunction::LIRFunction() : frame_info_(NULL) {
61 lirs_.parent_ = this;
62 frame_info_ = new (allocator_) LIRFrameInfo();
63 return;
64}
65
66LIRFunction::~LIRFunction() {
67 lirs_.clear();
68 lir_recycler_.clear(allocator_);
69
70 frame_info_->~LIRFrameInfo();
71 allocator_.Deallocate(frame_info_);
72
73 return;
74}
75
76LIR* LIRFunction::CreateLIR(const LIRDesc& desc) {
77 return new (lir_recycler_.Allocate<LIR>(allocator_)) LIR(desc);
78}
79
80void LIRFunction::DeleteLIR(LIR* lir) {
81 lir->~LIR();
82 lir_recycler_.Deallocate(allocator_, lir);
83}
84
85} // namespace greenland
86} // namespace art