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