LLVM 19.0.0git
DXILTranslateMetadata.cpp
Go to the documentation of this file.
1//===- DXILTranslateMetadata.cpp - Pass to emit DXIL metadata ---*- C++ -*-===//
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//===----------------------------------------------------------------------===//
10
11#include "DXILMetadata.h"
12#include "DXILResource.h"
14#include "DXILShaderFlags.h"
15#include "DirectX.h"
16#include "llvm/ADT/StringSet.h"
17#include "llvm/IR/Constants.h"
18#include "llvm/IR/Metadata.h"
19#include "llvm/IR/Module.h"
20#include "llvm/Pass.h"
22
23using namespace llvm;
24using namespace llvm::dxil;
25
26namespace {
27class DXILTranslateMetadata : public ModulePass {
28public:
29 static char ID; // Pass identification, replacement for typeid
30 explicit DXILTranslateMetadata() : ModulePass(ID) {}
31
32 StringRef getPassName() const override { return "DXIL Metadata Emit"; }
33
34 void getAnalysisUsage(AnalysisUsage &AU) const override {
35 AU.setPreservesAll();
38 }
39
40 bool runOnModule(Module &M) override;
41};
42
43} // namespace
44
45bool DXILTranslateMetadata::runOnModule(Module &M) {
46
47 dxil::ValidatorVersionMD ValVerMD(M);
48 if (ValVerMD.isEmpty())
49 ValVerMD.update(VersionTuple(1, 0));
51
52 const dxil::Resources &Res =
53 getAnalysis<DXILResourceWrapper>().getDXILResource();
54 Res.write(M);
55
56 const uint64_t Flags = static_cast<uint64_t>(
57 getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags());
58 dxil::createEntryMD(M, Flags);
59
60 return false;
61}
62
63char DXILTranslateMetadata::ID = 0;
64
66 return new DXILTranslateMetadata();
67}
68
69INITIALIZE_PASS_BEGIN(DXILTranslateMetadata, "dxil-metadata-emit",
70 "DXIL Metadata Emit", false, false)
73INITIALIZE_PASS_END(DXILTranslateMetadata, "dxil-metadata-emit",
Add AMDGPU uniform metadata
This file contains the declarations for the subclasses of Constant, which represent the different fla...
dxil metadata emit
dxil metadata DXIL Metadata Emit
This file contains the declarations for metadata subclasses.
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:55
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:59
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:52
StringSet - A set-like wrapper for the StringMap.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
The legacy pass manager's analysis pass to compute DXIL resource information.
Root of the metadata hierarchy.
Definition: Metadata.h:62
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:251
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: Pass.cpp:98
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Definition: Pass.cpp:81
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
void write(Module &M) const
Wrapper pass for the legacy pass manager.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
void createShaderModelMD(Module &M)
void createEntryMD(Module &M, const uint64_t ShaderFlags)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ModulePass * createDXILTranslateMetadataPass()
Pass to emit metadata for DXIL.