xref: /llvm-project/llvm/lib/Target/DirectX/DXILResourceAnalysis.h (revision 81ee38551f2c9d1677471ab59bdc800e667b9616)
1 //===- DXILResourceAnalysis.h   - DXIL Resource 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 /// \file This file contains Analysis for information about DXIL resources.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_TARGET_DIRECTX_DXILRESOURCEANALYSIS_H
14 #define LLVM_TARGET_DIRECTX_DXILRESOURCEANALYSIS_H
15 
16 #include "DXILResource.h"
17 #include "llvm/IR/PassManager.h"
18 #include "llvm/Pass.h"
19 #include <memory>
20 
21 namespace llvm {
22 /// Analysis pass that exposes the \c DXILResource for a module.
23 class DXILResourceMDAnalysis
24     : public AnalysisInfoMixin<DXILResourceMDAnalysis> {
25   friend AnalysisInfoMixin<DXILResourceMDAnalysis>;
26   static AnalysisKey Key;
27 
28 public:
29   typedef dxil::Resources Result;
30   dxil::Resources run(Module &M, ModuleAnalysisManager &AM);
31 };
32 
33 /// The legacy pass manager's analysis pass to compute DXIL resource
34 /// information.
35 class DXILResourceMDWrapper : public ModulePass {
36   dxil::Resources Resources;
37 
38 public:
39   static char ID; // Pass identification, replacement for typeid
40 
41   DXILResourceMDWrapper();
42 
43   dxil::Resources &getDXILResource() { return Resources; }
44   const dxil::Resources &getDXILResource() const { return Resources; }
45 
46   /// Calculate the DXILResource for the module.
47   bool runOnModule(Module &M) override;
48 
49   void getAnalysisUsage(AnalysisUsage &AU) const override {
50     AU.setPreservesAll();
51   }
52 };
53 } // namespace llvm
54 
55 #endif // LLVM_TARGET_DIRECTX_DXILRESOURCEANALYSIS_H
56