llvm-project/llvm/lib/Target/DirectX/DXILTranslateMetadata.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

76 lines
2.3 KiB
C++

//===- DXILTranslateMetadata.cpp - Pass to emit DXIL metadata ---*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
///
//===----------------------------------------------------------------------===//
#include "DXILMetadata.h"
#include "DXILResource.h"
#include "DXILResourceAnalysis.h"
#include "DXILShaderFlags.h"
#include "DirectX.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/Pass.h"
#include "llvm/TargetParser/Triple.h"
using namespace llvm;
using namespace llvm::dxil;
namespace {
class DXILTranslateMetadata : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
explicit DXILTranslateMetadata() : ModulePass(ID) {}
StringRef getPassName() const override { return "DXIL Metadata Emit"; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
AU.addRequired<DXILResourceMDWrapper>();
AU.addRequired<ShaderFlagsAnalysisWrapper>();
}
bool runOnModule(Module &M) override;
};
} // namespace
bool DXILTranslateMetadata::runOnModule(Module &M) {
dxil::ValidatorVersionMD ValVerMD(M);
if (ValVerMD.isEmpty())
ValVerMD.update(VersionTuple(1, 0));
dxil::createShaderModelMD(M);
dxil::createDXILVersionMD(M);
const dxil::Resources &Res =
getAnalysis<DXILResourceMDWrapper>().getDXILResource();
Res.write(M);
const uint64_t Flags = static_cast<uint64_t>(
getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags());
dxil::createEntryMD(M, Flags);
return false;
}
char DXILTranslateMetadata::ID = 0;
ModulePass *llvm::createDXILTranslateMetadataPass() {
return new DXILTranslateMetadata();
}
INITIALIZE_PASS_BEGIN(DXILTranslateMetadata, "dxil-metadata-emit",
"DXIL Metadata Emit", false, false)
INITIALIZE_PASS_DEPENDENCY(DXILResourceMDWrapper)
INITIALIZE_PASS_DEPENDENCY(ShaderFlagsAnalysisWrapper)
INITIALIZE_PASS_END(DXILTranslateMetadata, "dxil-metadata-emit",
"DXIL Metadata Emit", false, false)