blob: ac0f421e7516713a12dc435547220cc3e02b5d0b [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>
TDYa127e2102142012-05-26 10:27:38 -070023#include <string>
Logan Chienc670a8d2011-12-20 21:25:56 +080024
25namespace llvm {
26 class Type;
27 class Value;
28}
29
30namespace art {
31namespace compiler_llvm {
32
33class IRBuilder;
34class MethodCompiler;
35
36class DalvikReg {
37 public:
TDYa12767ae8ff2012-05-02 19:08:02 -070038 static llvm::Type* GetRegCategoryEquivSizeTy(IRBuilder& irb, RegCategory reg_cat);
39
40 static char GetRegCategoryNamePrefix(RegCategory reg_cat);
41
TDYa1278e950c12012-11-02 09:58:19 -070042 DalvikReg(MethodCompiler& method_compiler, const std::string& name, llvm::Value* vreg);
TDYa127e2102142012-05-26 10:27:38 -070043
44 ~DalvikReg();
Logan Chienc670a8d2011-12-20 21:25:56 +080045
46 llvm::Value* GetValue(JType jty, JTypeSpace space);
47
48 llvm::Value* GetValue(char shorty, JTypeSpace space) {
49 return GetValue(GetJTypeFromShorty(shorty), space);
50 }
51
TDYa127e2102142012-05-26 10:27:38 -070052 void SetValue(JType jty, JTypeSpace space, llvm::Value* value);
Logan Chienc670a8d2011-12-20 21:25:56 +080053
54 void SetValue(char shorty, JTypeSpace space, llvm::Value* value) {
55 return SetValue(GetJTypeFromShorty(shorty), space, value);
56 }
57
Logan Chienc670a8d2011-12-20 21:25:56 +080058 private:
TDYa127e2102142012-05-26 10:27:38 -070059 llvm::Value* GetAddr(JType jty);
Logan Chienc670a8d2011-12-20 21:25:56 +080060
61 llvm::Value* RegCat1SExt(llvm::Value* value);
62 llvm::Value* RegCat1ZExt(llvm::Value* value);
63
64 llvm::Value* RegCat1Trunc(llvm::Value* value, llvm::Type* ty);
65
Logan Chienc670a8d2011-12-20 21:25:56 +080066 MethodCompiler* method_compiler_;
67 IRBuilder& irb_;
TDYa127e2102142012-05-26 10:27:38 -070068
69 std::string reg_name_;
70 llvm::Value* reg_32_;
71 llvm::Value* reg_64_;
72 llvm::Value* reg_obj_;
TDYa1278e950c12012-11-02 09:58:19 -070073 llvm::Value* vreg_;
Logan Chienc670a8d2011-12-20 21:25:56 +080074};
75
76} // namespace compiler_llvm
77} // namespace art
78
79#endif // ART_SRC_COMPILER_LLVM_DALVIK_REG_H_