Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / Target / DirectX / DXILPrettyPrinter.cpp
blob7ae568c5ae53a3db3edd9c9bf77d00a0839de19c
1 //===- DXILPrettyPrinter.cpp - DXIL Resource helper objects ---------------===//
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 a pass for pretty printing DXIL metadata into IR
10 /// comments when printing assembly output.
11 ///
12 //===----------------------------------------------------------------------===//
14 #include "DXILResourceAnalysis.h"
15 #include "DirectX.h"
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/IR/PassManager.h"
18 #include "llvm/Pass.h"
19 #include "llvm/Support/raw_ostream.h"
21 using namespace llvm;
23 namespace {
24 class DXILPrettyPrinter : public llvm::ModulePass {
25 raw_ostream &OS; // raw_ostream to print to.
27 public:
28 static char ID;
29 DXILPrettyPrinter() : ModulePass(ID), OS(dbgs()) {
30 initializeDXILPrettyPrinterPass(*PassRegistry::getPassRegistry());
33 explicit DXILPrettyPrinter(raw_ostream &O) : ModulePass(ID), OS(O) {
34 initializeDXILPrettyPrinterPass(*PassRegistry::getPassRegistry());
37 StringRef getPassName() const override {
38 return "DXIL Metadata Pretty Printer";
41 bool runOnModule(Module &M) override;
42 void getAnalysisUsage(AnalysisUsage &AU) const override {
43 AU.setPreservesAll();
44 AU.addRequired<DXILResourceWrapper>();
47 } // namespace
49 char DXILPrettyPrinter::ID = 0;
50 INITIALIZE_PASS_BEGIN(DXILPrettyPrinter, "dxil-pretty-printer",
51 "DXIL Metadata Pretty Printer", true, true)
52 INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapper)
53 INITIALIZE_PASS_END(DXILPrettyPrinter, "dxil-pretty-printer",
54 "DXIL Metadata Pretty Printer", true, true)
56 bool DXILPrettyPrinter::runOnModule(Module &M) {
57 dxil::Resources &Res = getAnalysis<DXILResourceWrapper>().getDXILResource();
58 Res.print(OS);
59 return false;
62 ModulePass *llvm::createDXILPrettyPrinterPass(raw_ostream &OS) {
63 return new DXILPrettyPrinter(OS);