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 | |
| 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_ |