LLVM  16.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"
13 #include "DXILResourceAnalysis.h"
14 #include "DirectX.h"
15 #include "llvm/ADT/StringSet.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/Metadata.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/Pass.h"
21 
22 using namespace llvm;
23 
24 namespace {
25 class DXILTranslateMetadata : public ModulePass {
26 public:
27  static char ID; // Pass identification, replacement for typeid
28  explicit DXILTranslateMetadata() : ModulePass(ID) {}
29 
30  StringRef getPassName() const override { return "DXIL Metadata Emit"; }
31 
32  void getAnalysisUsage(AnalysisUsage &AU) const override {
33  AU.setPreservesAll();
35  }
36 
37  bool runOnModule(Module &M) override;
38 };
39 
40 } // namespace
41 
42 bool DXILTranslateMetadata::runOnModule(Module &M) {
43 
44  dxil::ValidatorVersionMD ValVerMD(M);
45  if (ValVerMD.isEmpty())
46  ValVerMD.update(VersionTuple(1, 0));
48 
49  const dxil::Resources &Res =
50  getAnalysis<DXILResourceWrapper>().getDXILResource();
51  Res.write(M);
52  return false;
53 }
54 
56 
58  return new DXILTranslateMetadata();
59 }
60 
61 INITIALIZE_PASS_BEGIN(DXILTranslateMetadata, "dxil-metadata-emit",
62  "DXIL Metadata Emit", false, false)
64 INITIALIZE_PASS_END(DXILTranslateMetadata, "dxil-metadata-emit",
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::AArch64PACKey::ID
ID
Definition: AArch64BaseInfo.h:818
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(DXILTranslateMetadata, "dxil-metadata-emit", "DXIL Metadata Emit", false, false) INITIALIZE_PASS_END(DXILTranslateMetadata
Metadata.h
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:248
Pass.h
llvm::DXILResourceWrapper
The legacy pass manager's analysis pass to compute DXIL resource information.
Definition: DXILResourceAnalysis.h:40
Module.h
llvm::dxil::Resources::write
void write(Module &M) const
Definition: DXILResource.cpp:318
DXILMetadata.h
DXILResourceAnalysis.h
DirectX.h
llvm::createDXILTranslateMetadataPass
ModulePass * createDXILTranslateMetadataPass()
Pass to emit metadata for DXIL.
Definition: DXILTranslateMetadata.cpp:57
Constants.h
Emit
dxil metadata DXIL Metadata Emit
Definition: DXILTranslateMetadata.cpp:65
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
false
Definition: StackSlotColoring.cpp:141
metadata
Add AMDGPU uniform metadata
Definition: AMDGPUAnnotateUniformValues.cpp:76
emit
dxil metadata emit
Definition: DXILTranslateMetadata.cpp:64
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::dxil::ValidatorVersionMD
Definition: DXILMetadata.h:22
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Triple.h
llvm::dxil::Resources
Definition: DXILResource.h:115
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
StringSet.h
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::dxil::createShaderModelMD
void createShaderModelMD(Module &M)
Definition: DXILMetadata.cpp:70
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
DXILResource.h