blob: e6e5b05de6c2e1c77035d21540b0c9c74c01ab2d [file] [log] [blame]
Logan Chienc670a8d2011-12-20 21:25:56 +08001/*
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_COMPILER_LLVM_DALVIK_REG_H_
18#define ART_SRC_COMPILER_LLVM_DALVIK_REG_H_
19
20#include "backend_types.h"
21
22#include <stdint.h>
23
24namespace llvm {
25 class Type;
26 class Value;
27}
28
29namespace art {
30namespace compiler_llvm {
31
32class IRBuilder;
33class MethodCompiler;
34
35class DalvikReg {
36 public:
37 static DalvikReg* CreateLocalVarReg(MethodCompiler& method_compiler,
38 uint32_t reg_idx);
39
40 static DalvikReg* CreateRetValReg(MethodCompiler& method_compiler);
41
42 virtual ~DalvikReg();
43
44 llvm::Value* GetValue(JType jty, JTypeSpace space);
45
46 llvm::Value* GetValue(char shorty, JTypeSpace space) {
47 return GetValue(GetJTypeFromShorty(shorty), space);
48 }
49
50 void SetValue(JType jty, JTypeSpace space, llvm::Value* value);
51
52 void SetValue(char shorty, JTypeSpace space, llvm::Value* value) {
53 return SetValue(GetJTypeFromShorty(shorty), space, value);
54 }
55
56 protected:
57 DalvikReg(MethodCompiler& method_compiler);
58
59 private:
60 llvm::Value* GetAddr(JType jty, JTypeSpace space);
61
62 llvm::Value* RegCat1SExt(llvm::Value* value);
63 llvm::Value* RegCat1ZExt(llvm::Value* value);
64
65 llvm::Value* RegCat1Trunc(llvm::Value* value, llvm::Type* ty);
66
67 virtual llvm::Value* GetRawAddr(JType jty, JTypeSpace space) = 0;
68
69 protected:
70 MethodCompiler* method_compiler_;
71 IRBuilder& irb_;
72};
73
74} // namespace compiler_llvm
75} // namespace art
76
77#endif // ART_SRC_COMPILER_LLVM_DALVIK_REG_H_