Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 1 | /* |
| 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> |
TDYa127 | e210214 | 2012-05-26 10:27:38 -0700 | [diff] [blame] | 23 | #include <string> |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | class Type; |
| 27 | class Value; |
| 28 | } |
| 29 | |
| 30 | namespace art { |
| 31 | namespace compiler_llvm { |
| 32 | |
| 33 | class IRBuilder; |
| 34 | class MethodCompiler; |
| 35 | |
| 36 | class DalvikReg { |
| 37 | public: |
TDYa127 | 67ae8ff | 2012-05-02 19:08:02 -0700 | [diff] [blame] | 38 | static llvm::Type* GetRegCategoryEquivSizeTy(IRBuilder& irb, RegCategory reg_cat); |
| 39 | |
| 40 | static char GetRegCategoryNamePrefix(RegCategory reg_cat); |
| 41 | |
TDYa127 | 8e950c1 | 2012-11-02 09:58:19 -0700 | [diff] [blame] | 42 | DalvikReg(MethodCompiler& method_compiler, const std::string& name, llvm::Value* vreg); |
TDYa127 | e210214 | 2012-05-26 10:27:38 -0700 | [diff] [blame] | 43 | |
| 44 | ~DalvikReg(); |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 45 | |
| 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 | |
TDYa127 | e210214 | 2012-05-26 10:27:38 -0700 | [diff] [blame] | 52 | void SetValue(JType jty, JTypeSpace space, llvm::Value* value); |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 53 | |
| 54 | void SetValue(char shorty, JTypeSpace space, llvm::Value* value) { |
| 55 | return SetValue(GetJTypeFromShorty(shorty), space, value); |
| 56 | } |
| 57 | |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 58 | private: |
TDYa127 | e210214 | 2012-05-26 10:27:38 -0700 | [diff] [blame] | 59 | llvm::Value* GetAddr(JType jty); |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 60 | |
| 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 Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 66 | MethodCompiler* method_compiler_; |
| 67 | IRBuilder& irb_; |
TDYa127 | e210214 | 2012-05-26 10:27:38 -0700 | [diff] [blame] | 68 | |
| 69 | std::string reg_name_; |
| 70 | llvm::Value* reg_32_; |
| 71 | llvm::Value* reg_64_; |
| 72 | llvm::Value* reg_obj_; |
TDYa127 | 8e950c1 | 2012-11-02 09:58:19 -0700 | [diff] [blame] | 73 | llvm::Value* vreg_; |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | } // namespace compiler_llvm |
| 77 | } // namespace art |
| 78 | |
| 79 | #endif // ART_SRC_COMPILER_LLVM_DALVIK_REG_H_ |