1 //===- DXILResourceAnalysis.cpp - 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 "DXILResourceAnalysis.h"
14 #include "DirectX.h"
15 #include "llvm/IR/PassManager.h"
16 
17 using namespace llvm;
18 
19 #define DEBUG_TYPE "dxil-resource-analysis"
20 
21 dxil::Resources DXILResourceAnalysis::run(Module &M,
22                                           ModuleAnalysisManager &AM) {
23   dxil::Resources R;
24   R.collect(M);
25   return R;
26 }
27 
28 AnalysisKey DXILResourceAnalysis::Key;
29 
30 PreservedAnalyses DXILResourcePrinterPass::run(Module &M,
31                                                ModuleAnalysisManager &AM) {
32   dxil::Resources Res = AM.getResult<DXILResourceAnalysis>(M);
33   Res.print(OS);
34   return PreservedAnalyses::all();
35 }
36 
37 char DXILResourceWrapper::ID = 0;
38 INITIALIZE_PASS_BEGIN(DXILResourceWrapper, DEBUG_TYPE,
39                       "DXIL resource Information", true, true)
40 INITIALIZE_PASS_END(DXILResourceWrapper, DEBUG_TYPE,
41                     "DXIL resource Information", true, true)
42 
43 bool DXILResourceWrapper::runOnModule(Module &M) {
44   Resources.collect(M);
45   return false;
46 }
47 
48 DXILResourceWrapper::DXILResourceWrapper() : ModulePass(ID) {}
49 
50 void DXILResourceWrapper::print(raw_ostream &OS, const Module *) const {
51   Resources.print(OS);
52 }
53