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