xref: /freebsd/contrib/llvm-project/llvm/lib/Target/DirectX/DXILResourceAnalysis.cpp (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1*bdd1243dSDimitry Andric //===- DXILResourceAnalysis.cpp - DXIL Resource analysis-------------------===//
2*bdd1243dSDimitry Andric //
3*bdd1243dSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*bdd1243dSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*bdd1243dSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*bdd1243dSDimitry Andric //
7*bdd1243dSDimitry Andric //===----------------------------------------------------------------------===//
8*bdd1243dSDimitry Andric ///
9*bdd1243dSDimitry Andric /// \file This file contains Analysis for information about DXIL resources.
10*bdd1243dSDimitry Andric ///
11*bdd1243dSDimitry Andric //===----------------------------------------------------------------------===//
12*bdd1243dSDimitry Andric 
13*bdd1243dSDimitry Andric #include "DXILResourceAnalysis.h"
14*bdd1243dSDimitry Andric #include "DirectX.h"
15*bdd1243dSDimitry Andric #include "llvm/IR/PassManager.h"
16*bdd1243dSDimitry Andric 
17*bdd1243dSDimitry Andric using namespace llvm;
18*bdd1243dSDimitry Andric 
19*bdd1243dSDimitry Andric #define DEBUG_TYPE "dxil-resource-analysis"
20*bdd1243dSDimitry Andric 
run(Module & M,ModuleAnalysisManager & AM)21*bdd1243dSDimitry Andric dxil::Resources DXILResourceAnalysis::run(Module &M,
22*bdd1243dSDimitry Andric                                           ModuleAnalysisManager &AM) {
23*bdd1243dSDimitry Andric   dxil::Resources R;
24*bdd1243dSDimitry Andric   R.collect(M);
25*bdd1243dSDimitry Andric   return R;
26*bdd1243dSDimitry Andric }
27*bdd1243dSDimitry Andric 
28*bdd1243dSDimitry Andric AnalysisKey DXILResourceAnalysis::Key;
29*bdd1243dSDimitry Andric 
run(Module & M,ModuleAnalysisManager & AM)30*bdd1243dSDimitry Andric PreservedAnalyses DXILResourcePrinterPass::run(Module &M,
31*bdd1243dSDimitry Andric                                                ModuleAnalysisManager &AM) {
32*bdd1243dSDimitry Andric   dxil::Resources Res = AM.getResult<DXILResourceAnalysis>(M);
33*bdd1243dSDimitry Andric   Res.print(OS);
34*bdd1243dSDimitry Andric   return PreservedAnalyses::all();
35*bdd1243dSDimitry Andric }
36*bdd1243dSDimitry Andric 
37*bdd1243dSDimitry Andric char DXILResourceWrapper::ID = 0;
38*bdd1243dSDimitry Andric INITIALIZE_PASS_BEGIN(DXILResourceWrapper, DEBUG_TYPE,
39*bdd1243dSDimitry Andric                       "DXIL resource Information", true, true)
40*bdd1243dSDimitry Andric INITIALIZE_PASS_END(DXILResourceWrapper, DEBUG_TYPE,
41*bdd1243dSDimitry Andric                     "DXIL resource Information", true, true)
42*bdd1243dSDimitry Andric 
runOnModule(Module & M)43*bdd1243dSDimitry Andric bool DXILResourceWrapper::runOnModule(Module &M) {
44*bdd1243dSDimitry Andric   Resources.collect(M);
45*bdd1243dSDimitry Andric   return false;
46*bdd1243dSDimitry Andric }
47*bdd1243dSDimitry Andric 
DXILResourceWrapper()48*bdd1243dSDimitry Andric DXILResourceWrapper::DXILResourceWrapper() : ModulePass(ID) {}
49*bdd1243dSDimitry Andric 
print(raw_ostream & OS,const Module *) const50*bdd1243dSDimitry Andric void DXILResourceWrapper::print(raw_ostream &OS, const Module *) const {
51*bdd1243dSDimitry Andric   Resources.print(OS);
52*bdd1243dSDimitry Andric }
53