1 //===- Target/DirectX/PointerTypeAnalysis.h - PointerType analysis --------===//
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 // Analysis pass to assign types to opaque pointers.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_TARGET_DIRECTX_POINTERTYPEANALYSIS_H
14 #define LLVM_TARGET_DIRECTX_POINTERTYPEANALYSIS_H
15 
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/IR/PassManager.h"
18 #include "llvm/IR/TypedPointerType.h"
19 
20 namespace llvm {
21 
22 namespace dxil {
23 
24 // Store the underlying type and the number of pointer indirections
25 using PointerTypeMap = DenseMap<const Value *, Type *>;
26 
27 /// An analysis to compute the \c PointerTypes for pointers in a \c Module.
28 /// Since this analysis is only run during codegen and the new pass manager
29 /// doesn't support codegen passes, this is wrtten as a function in a namespace.
30 /// It is very simple to transform it into a proper analysis pass.
31 /// This code relies on typed pointers existing as LLVM types, but could be
32 /// migrated to a custom Type if PointerType loses typed support.
33 namespace PointerTypeAnalysis {
34 
35 /// Compute the \c PointerTypeMap for the module \c M.
36 PointerTypeMap run(const Module &M);
37 } // namespace PointerTypeAnalysis
38 
39 } // namespace dxil
40 
41 } // namespace llvm
42 
43 #endif // LLVM_TARGET_DIRECTX_POINTERTYPEANALYSIS_H
44