xref: /freebsd/contrib/llvm-project/llvm/lib/Target/DirectX/DXILResourceAnalysis.h (revision 02e9120893770924227138ba49df1edb3896112a)
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 DXILResourceAnalysis : public AnalysisInfoMixin<DXILResourceAnalysis> {
24   friend AnalysisInfoMixin<DXILResourceAnalysis>;
25   static AnalysisKey Key;
26 
27 public:
28   typedef dxil::Resources Result;
29   dxil::Resources run(Module &M, ModuleAnalysisManager &AM);
30 };
31 
32 /// Printer pass for the \c DXILResourceAnalysis results.
33 class DXILResourcePrinterPass : public PassInfoMixin<DXILResourcePrinterPass> {
34   raw_ostream &OS;
35 
36 public:
37   explicit DXILResourcePrinterPass(raw_ostream &OS) : OS(OS) {}
38   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
39 };
40 
41 /// The legacy pass manager's analysis pass to compute DXIL resource
42 /// information.
43 class DXILResourceWrapper : public ModulePass {
44   dxil::Resources Resources;
45 
46 public:
47   static char ID; // Pass identification, replacement for typeid
48 
49   DXILResourceWrapper();
50 
51   dxil::Resources &getDXILResource() { return Resources; }
52   const dxil::Resources &getDXILResource() const { return Resources; }
53 
54   /// Calculate the DXILResource for the module.
55   bool runOnModule(Module &M) override;
56 
57   void print(raw_ostream &O, const Module *M = nullptr) const override;
58 };
59 } // namespace llvm
60 
61 #endif // LLVM_TARGET_DIRECTX_DXILRESOURCEANALYSIS_H
62