blob: 7356c87efb1e909ea17c052a4015ee08cd19bb5a [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
TDYa12767ae8ff2012-05-02 19:08:02 -070042 static llvm::Type* GetRegCategoryEquivSizeTy(IRBuilder& irb, RegCategory reg_cat);
43
44 static char GetRegCategoryNamePrefix(RegCategory reg_cat);
45
Logan Chienc670a8d2011-12-20 21:25:56 +080046 virtual ~DalvikReg();
47
48 llvm::Value* GetValue(JType jty, JTypeSpace space);
49
50 llvm::Value* GetValue(char shorty, JTypeSpace space) {
51 return GetValue(GetJTypeFromShorty(shorty), space);
52 }
53
TDYa1277f5b9be2012-04-29 01:31:49 -070054 virtual void SetValue(JType jty, JTypeSpace space, llvm::Value* value);
Logan Chienc670a8d2011-12-20 21:25:56 +080055
56 void SetValue(char shorty, JTypeSpace space, llvm::Value* value) {
57 return SetValue(GetJTypeFromShorty(shorty), space, value);
58 }
59
60 protected:
61 DalvikReg(MethodCompiler& method_compiler);
62
63 private:
64 llvm::Value* GetAddr(JType jty, JTypeSpace space);
65
66 llvm::Value* RegCat1SExt(llvm::Value* value);
67 llvm::Value* RegCat1ZExt(llvm::Value* value);
68
69 llvm::Value* RegCat1Trunc(llvm::Value* value, llvm::Type* ty);
70
71 virtual llvm::Value* GetRawAddr(JType jty, JTypeSpace space) = 0;
72
73 protected:
74 MethodCompiler* method_compiler_;
75 IRBuilder& irb_;
76};
77
78} // namespace compiler_llvm
79} // namespace art
80
81#endif // ART_SRC_COMPILER_LLVM_DALVIK_REG_H_