TDYa127 | aba6112 | 2012-05-04 18:28:36 -0700 | [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_TBAA_INFO_H_ |
| 18 | #define ART_SRC_COMPILER_LLVM_TBAA_INFO_H_ |
| 19 | |
| 20 | #include "backend_types.h" |
| 21 | |
| 22 | #include <cstring> |
| 23 | |
| 24 | namespace llvm { |
| 25 | class LLVMContext; |
| 26 | class MDNode; |
| 27 | class StringRef; |
| 28 | } |
| 29 | |
| 30 | namespace art { |
| 31 | namespace compiler_llvm { |
| 32 | |
| 33 | |
| 34 | class TBAAInfo { |
| 35 | public: |
| 36 | TBAAInfo(llvm::LLVMContext& context) : context_(context), root_(NULL) { |
| 37 | std::memset(special_type_, 0, sizeof(special_type_)); |
TDYa127 | 706e7db | 2012-05-06 00:05:33 -0700 | [diff] [blame^] | 38 | std::memset(memory_jtype_, 0, sizeof(memory_jtype_)); |
TDYa127 | aba6112 | 2012-05-04 18:28:36 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | llvm::MDNode* GetRootType(); |
| 42 | |
| 43 | llvm::MDNode* GetSpecialType(TBAASpecialType special_ty); |
| 44 | |
TDYa127 | 706e7db | 2012-05-06 00:05:33 -0700 | [diff] [blame^] | 45 | llvm::MDNode* GetMemoryJType(TBAASpecialType special_ty, JType j_ty); |
| 46 | |
TDYa127 | aba6112 | 2012-05-04 18:28:36 -0700 | [diff] [blame] | 47 | llvm::MDNode* GenTBAANode(llvm::StringRef name, |
| 48 | llvm::MDNode* parent = NULL, |
| 49 | bool readonly = false); |
| 50 | |
| 51 | private: |
| 52 | llvm::LLVMContext& context_; |
| 53 | llvm::MDNode* root_; |
| 54 | llvm::MDNode* special_type_[MAX_TBAA_SPECIAL_TYPE]; |
TDYa127 | 706e7db | 2012-05-06 00:05:33 -0700 | [diff] [blame^] | 55 | // There are 3 categories of memory types will not alias: array element, identified field, and |
| 56 | // static field. |
| 57 | llvm::MDNode* memory_jtype_[3][MAX_JTYPE]; |
TDYa127 | aba6112 | 2012-05-04 18:28:36 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | |
| 61 | } // namespace compiler_llvm |
| 62 | } // namespace art |
| 63 | |
| 64 | #endif // ART_SRC_COMPILER_LLVM_TBAA_INFO_H_ |