blob: 5b5b8180a0ff7b54977db82ae7b795dc815978c7 [file] [log] [blame]
Yang Ni6749f542016-11-07 20:20:49 -08001/*
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
24namespace llvm {
25class CallInst;
26class GlobalVariable;
27class Module;
28class Type;
29}
30
31namespace rs2spirv {
32
33struct RSAllocationInfo {
34 std::string VarName;
35 llvm::Optional<std::string> RSElementType;
36 llvm::GlobalVariable *GlobalVar;
37};
38
39enum class RSAllocAccessKind { GEA, SEA };
40
41struct RSAllocationCallInfo {
42 RSAllocationInfo &RSAlloc;
43 llvm::CallInst *FCall;
44 RSAllocAccessKind Kind;
45 std::string RSElementTy;
46};
47
48bool isRSAllocation(const llvm::GlobalVariable &GV);
49llvm::Optional<llvm::StringRef> getRSTypeName(const llvm::GlobalVariable &GV);
50bool getRSAllocationInfo(llvm::Module &M,
51 llvm::SmallVectorImpl<RSAllocationInfo> &Allocs);
52bool getRSAllocAccesses(llvm::SmallVectorImpl<RSAllocationInfo> &Allocs,
53 llvm::SmallVectorImpl<RSAllocationCallInfo> &Calls);
54bool solidifyRSAllocAccess(llvm::Module &M, RSAllocationCallInfo CallInfo);
55
56} // namespace rs2spirv
57
58#endif