blob: b7cbea649e752faba622554ff2de2528aa7082be [file] [log] [blame]
Shih-wei Liao21d28f52012-06-12 05:55:00 -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#ifndef ART_SRC_GREENLAND_GBC_FUNCTION_H_
18#define ART_SRC_GREENLAND_GBC_FUNCTION_H_
19
20#include "gbc_context.h"
21
22namespace llvm {
23 class Function;
24} // namespace llvm
25
26namespace art {
27 class OatCompilationUnit;
28} // namespace art
29
30namespace art {
31namespace greenland {
32
33class GBCContext;
34
35class GBCFunction {
36 private:
37 // The GBCContext associated with this GBCFunction
38 GBCContext& context_;
39
40 // The LLVM Function in Greenland bitcode
41 llvm::Function& func_;
42
43 // The associated OatCompilationUnit
44 const OatCompilationUnit& cunit_;
45
46 public:
47 GBCFunction(GBCContext& context, llvm::Function& func,
48 const OatCompilationUnit& cunit)
49 : context_(context.IncRef()), func_(func), cunit_(cunit) { }
50
51 ~GBCFunction() {
52 context_.DecRef();
53 return;
54 }
55
56 IntrinsicHelper& GetIntrinsicHelper() {
57 return context_.GetIntrinsicHelper();
58 }
59 const IntrinsicHelper& GetIntrinsicHelper() const {
60 return context_.GetIntrinsicHelper();
61 }
62
63 llvm::Function& GetBitcode() {
64 return func_;
65 }
66 const llvm::Function& GetBitcode() const {
67 return func_;
68 }
69
70 const OatCompilationUnit& GetOatCompilationUnit() const {
71 return cunit_;
72 }
73};
74
75} // namespace greenland
76} // namespace art
77
78#endif // ART_SRC_GREENLAND_GBC_FUNCTION_H_