| Yang Ni | 6749f54 | 2016-11-07 20:20:49 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016, 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 RS2SPIRV_RS_ALLOCATION_UTILS_H |
| 18 | #define RS2SPIRV_RS_ALLOCATION_UTILS_H |
| 19 | |
| 20 | #include "llvm/ADT/Optional.h" |
| 21 | #include "llvm/ADT/SmallVector.h" |
| 22 | #include "llvm/ADT/StringRef.h" |
| 23 | |
| 24 | namespace llvm { |
| 25 | class CallInst; |
| 26 | class GlobalVariable; |
| 27 | class Module; |
| 28 | class Type; |
| 29 | } |
| 30 | |
| 31 | namespace rs2spirv { |
| 32 | |
| 33 | struct RSAllocationInfo { |
| 34 | std::string VarName; |
| 35 | llvm::Optional<std::string> RSElementType; |
| 36 | llvm::GlobalVariable *GlobalVar; |
| 37 | }; |
| 38 | |
| 39 | enum class RSAllocAccessKind { GEA, SEA }; |
| 40 | |
| 41 | struct RSAllocationCallInfo { |
| 42 | RSAllocationInfo &RSAlloc; |
| 43 | llvm::CallInst *FCall; |
| 44 | RSAllocAccessKind Kind; |
| 45 | std::string RSElementTy; |
| 46 | }; |
| 47 | |
| 48 | bool isRSAllocation(const llvm::GlobalVariable &GV); |
| 49 | llvm::Optional<llvm::StringRef> getRSTypeName(const llvm::GlobalVariable &GV); |
| 50 | bool getRSAllocationInfo(llvm::Module &M, |
| 51 | llvm::SmallVectorImpl<RSAllocationInfo> &Allocs); |
| 52 | bool getRSAllocAccesses(llvm::SmallVectorImpl<RSAllocationInfo> &Allocs, |
| 53 | llvm::SmallVectorImpl<RSAllocationCallInfo> &Calls); |
| 54 | bool solidifyRSAllocAccess(llvm::Module &M, RSAllocationCallInfo CallInfo); |
| 55 | |
| 56 | } // namespace rs2spirv |
| 57 | |
| 58 | #endif |