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> |
| 23 | |
| 24 | namespace llvm { |
| 25 | class Type; |
| 26 | class Value; |
| 27 | } |
| 28 | |
| 29 | namespace art { |
| 30 | namespace compiler_llvm { |
| 31 | |
| 32 | class IRBuilder; |
| 33 | class MethodCompiler; |
| 34 | |
| 35 | class DalvikReg { |
| 36 | public: |
| 37 | static DalvikReg* CreateLocalVarReg(MethodCompiler& method_compiler, |
| 38 | uint32_t reg_idx); |
| 39 | |
| 40 | static DalvikReg* CreateRetValReg(MethodCompiler& method_compiler); |
| 41 | |
TDYa127 | 67ae8ff | 2012-05-02 19:08:02 -0700 | [diff] [blame^] | 42 | static llvm::Type* GetRegCategoryEquivSizeTy(IRBuilder& irb, RegCategory reg_cat); |
| 43 | |
| 44 | static char GetRegCategoryNamePrefix(RegCategory reg_cat); |
| 45 | |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 46 | 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 | |
TDYa127 | 7f5b9be | 2012-04-29 01:31:49 -0700 | [diff] [blame] | 54 | virtual void SetValue(JType jty, JTypeSpace space, llvm::Value* value); |
Logan Chien | c670a8d | 2011-12-20 21:25:56 +0800 | [diff] [blame] | 55 | |
| 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_ |