Files
clang-p2996/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
Justin Bogner 1c5f6cfc35 [DirectX] Rename backend DXIL resource analysis passes to DXILResourceMD*. NFC
These passes will be replaced soon as we move to the target extension based
resource handling in the DirectX backend, but removing them now before the
replacement stuff is all up and running would be very disruptive. However, we
do need to move these passes out of the way to avoid symbol conflicts with the
new DXILResourceAnalysis in the Analysis library.

Note: I tried an even simpler hack in #100698 but it doesn't really work. A
rename is the most expedient path forward here.

Pull Request: https://github.com/llvm/llvm-project/pull/101393
2024-07-31 17:29:15 -07:00

65 lines
2.0 KiB
C++

//===- DXILPrettyPrinter.cpp - DXIL Resource helper objects ---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file This file contains a pass for pretty printing DXIL metadata into IR
/// comments when printing assembly output.
///
//===----------------------------------------------------------------------===//
#include "DXILResourceAnalysis.h"
#include "DirectX.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
namespace {
class DXILPrettyPrinter : public llvm::ModulePass {
raw_ostream &OS; // raw_ostream to print to.
public:
static char ID;
DXILPrettyPrinter() : ModulePass(ID), OS(dbgs()) {
initializeDXILPrettyPrinterPass(*PassRegistry::getPassRegistry());
}
explicit DXILPrettyPrinter(raw_ostream &O) : ModulePass(ID), OS(O) {
initializeDXILPrettyPrinterPass(*PassRegistry::getPassRegistry());
}
StringRef getPassName() const override {
return "DXIL Metadata Pretty Printer";
}
bool runOnModule(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
AU.addRequired<DXILResourceMDWrapper>();
}
};
} // namespace
char DXILPrettyPrinter::ID = 0;
INITIALIZE_PASS_BEGIN(DXILPrettyPrinter, "dxil-pretty-printer",
"DXIL Metadata Pretty Printer", true, true)
INITIALIZE_PASS_DEPENDENCY(DXILResourceMDWrapper)
INITIALIZE_PASS_END(DXILPrettyPrinter, "dxil-pretty-printer",
"DXIL Metadata Pretty Printer", true, true)
bool DXILPrettyPrinter::runOnModule(Module &M) {
dxil::Resources &Res = getAnalysis<DXILResourceMDWrapper>().getDXILResource();
Res.print(OS);
return false;
}
ModulePass *llvm::createDXILPrettyPrinterPass(raw_ostream &OS) {
return new DXILPrettyPrinter(OS);
}