xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.h (revision fcaf7f8644a9988098ac6be2165bce3ea4786e91)
1 //===- AMDGPUMemoryUtils.h - Memory related helper functions -*- C++ -*----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H
10 #define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H
11 
12 #include <vector>
13 
14 namespace llvm {
15 
16 struct Align;
17 class AAResults;
18 class ConstantExpr;
19 class DataLayout;
20 class Function;
21 class GlobalVariable;
22 class LoadInst;
23 class MemoryDef;
24 class MemorySSA;
25 class Module;
26 class Value;
27 
28 namespace AMDGPU {
29 
30 Align getAlign(DataLayout const &DL, const GlobalVariable *GV);
31 
32 std::vector<GlobalVariable *> findVariablesToLower(Module &M,
33                                                    const Function *F);
34 
35 /// Replace all uses of constant \p C with instructions in \p F.
36 void replaceConstantUsesInFunction(ConstantExpr *C, const Function *F);
37 
38 /// Given a \p Def clobbering a load from \p Ptr according to the MSSA check
39 /// if this is actually a memory update or an artificial clobber to facilitate
40 /// ordering constraints.
41 bool isReallyAClobber(const Value *Ptr, MemoryDef *Def, AAResults *AA);
42 
43 /// Check is a \p Load is clobbered in its function.
44 bool isClobberedInFunction(const LoadInst *Load, MemorySSA *MSSA,
45                            AAResults *AA);
46 
47 } // end namespace AMDGPU
48 
49 } // end namespace llvm
50 
51 #endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H
52