47 "dx-Zss",
cl::desc(
"Compute Shader Hash considering source information"));
50 cl::desc(
"Store PDB in private user data"));
53class DXILContainerGlobalsLegacy :
public ModulePass {
56 DXILContainerGlobalsLegacy() :
ModulePass(ID) {}
58 StringRef getPassName()
const override {
59 return "DXContainer Global Emitter";
62 bool runOnModule(
Module &M)
override;
64 void getAnalysisUsage(AnalysisUsage &AU)
const override {
83 GV->setAlignment(
Align(4));
91 GetShaderFlags().getCombinedFlags().getFeatureFlags();
94 ConstantInt::get(M.getContext(),
APInt(64, CombinedFeatureFlags));
102 M.getContext(), SectionData,
false);
103 Globals.emplace_back(
114 if (
auto *ILDB = M.getNamedGlobal(
"dx.ildb")) {
128 memcpy(
reinterpret_cast<void *
>(&HashData.
Digest),
MD5.data(), 16);
135 Globals.emplace_back(
138 if (M.debug_compile_units().empty())
143 DebugNameStr +=
".pdb";
151 AbsoluteDebugName = DebugFile;
155 DebugNameStr = DebugFile;
156 AbsoluteDebugName = DebugNameStr;
160 addSection(M, Globals, AbsoluteDebugName,
"dx.pdb.name",
176 addSection(M, Globals, ILDNData,
"dx.ildn",
"ILDN");
203 Globals.emplace_back(
buildSignature(M, InputSig,
"dx.isg1",
"ISG1", MMI));
204 Globals.emplace_back(
buildSignature(M, OutputSig,
"dx.osg1",
"OSG1", MMI));
219 const Function *EntryFunction =
nullptr;
255 "Resource range is too large");
261 BindInfo.
Flags = Flags;
266 if (!RI.hasBinding())
273 if (!RI.hasBinding())
277 dxbc::PSV::ResourceType::Sampler,
281 if (!RI.hasBinding())
288 ResType = dxbc::PSV::ResourceType::SRVStructured;
290 ResType = dxbc::PSV::ResourceType::SRVTyped;
292 ResType = dxbc::PSV::ResourceType::SRVRaw;
298 if (!RI.hasBinding())
305 ResType = dxbc::PSV::ResourceType::UAVStructuredWithCounter;
307 ResType = dxbc::PSV::ResourceType::UAVStructured;
309 ResType = dxbc::PSV::ResourceType::UAVTyped;
311 ResType = dxbc::PSV::ResourceType::UAVRaw;
314 Flags.
Bits.UsedByAtomic64 = RI.HasAtomic64Use;
342 unsigned PSVVersion = 3;
346 bool UsesViewID = GetModuleShaderFlags().getFunctionFlags(Entry).ViewID;
349 if (
const auto *Sig = Signatures.
get(Entry)) {
354 if ((!Sig->Inputs.empty() || !Sig->Outputs.empty()) && !
V.empty() &&
390 PSV.
write(OS, PSVVersion);
395 if (M.debug_compile_units().empty())
431 addSignature(M, Globals, GetModuleMetadataInfo, GetModuleSignatureInfo);
433 GetRootSignatureBindingInfo);
435 GetResourceMap, GetResourceTypeMap,
436 GetModuleShaderFlags, GetModuleSignatureInfo);
443bool DXILContainerGlobalsLegacy::runOnModule(
Module &M) {
446 [&]() -> ModuleMetadataInfo & {
447 return getAnalysis<DXILMetadataAnalysisWrapperPass>()
448 .getModuleMetadata();
450 [&]() -> DXILResourceMap & {
451 return getAnalysis<DXILResourceWrapperPass>().getResourceMap();
453 [&]() -> DXILResourceTypeMap & {
454 return getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
456 [&]() ->
const ModuleShaderFlags & {
457 return getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags();
459 [&]() ->
const ModuleSignatureInfo & {
460 return getAnalysis<SignatureAnalysisWrapper>().getSignatureInfo();
462 [&]() -> RootSignatureBindingInfo & {
463 return getAnalysis<RootSignatureAnalysisWrapper>().getRSInfo();
492char DXILContainerGlobalsLegacy::ID = 0;
494 "DXContainer Global Emitter",
false,
true)
504 return new DXILContainerGlobalsLegacy();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static GlobalVariable * buildContainerGlobal(Module &M, Constant *Content, StringRef Name, StringRef SectionName)
static void addCompilerVersion(Module &M, SmallVector< GlobalValue * > &Globals)
static void addSourceInfo(Module &M, SmallVector< GlobalValue * > &Globals, function_ref< dxil::ModuleMetadataInfo &()> GetModuleMetadataInfo)
static GlobalVariable * buildSignature(Module &M, Signature &Sig, StringRef Name, StringRef SectionName, const dxil::ModuleMetadataInfo &MMI)
static void computeShaderHashAndDebugName(Module &M, SmallVector< GlobalValue * > &Globals)
static GlobalVariable * getFeatureFlags(Module &M, function_ref< const ModuleShaderFlags &()> GetShaderFlags)
static void addSection(Module &M, SmallVector< GlobalValue * > &Globals, StringRef SectionData, StringRef MetadataName, StringRef SectionName)
static void addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV, function_ref< DXILResourceMap &()> GetResourceMap, function_ref< DXILResourceTypeMap &()> GetResourceTypeMap)
static void addRootSignature(Module &M, SmallVector< GlobalValue * > &Globals, function_ref< dxil::ModuleMetadataInfo &()> GetModuleMetadataInfo, function_ref< RootSignatureBindingInfo &()> GetRootSignatureBindingInfo)
static void addPipelineStateValidationInfo(Module &M, SmallVector< GlobalValue * > &Globals, function_ref< dxil::ModuleMetadataInfo &()> GetModuleMetadataInfo, function_ref< DXILResourceMap &()> GetResourceMap, function_ref< DXILResourceTypeMap &()> GetResourceTypeMap, function_ref< const ModuleShaderFlags &()> GetModuleShaderFlags, function_ref< const ModuleSignatureInfo &()> GetModuleSignatureInfo)
static cl::opt< bool > ShaderHashDependsOnSource("dx-Zss", cl::desc("Compute Shader Hash considering source information"))
static void addSignature(Module &M, SmallVector< GlobalValue * > &Globals, function_ref< dxil::ModuleMetadataInfo &()> GetModuleMetadataInfo, function_ref< const ModuleSignatureInfo &()> GetSignatureInfo)
static bool runContainerGlobalsOnModule(Module &M, function_ref< dxil::ModuleMetadataInfo &()> GetModuleMetadataInfo, function_ref< DXILResourceMap &()> GetResourceMap, function_ref< DXILResourceTypeMap &()> GetResourceTypeMap, function_ref< const ModuleShaderFlags &()> GetModuleShaderFlags, function_ref< const ModuleSignatureInfo &()> GetModuleSignatureInfo, function_ref< RootSignatureBindingInfo &()> GetRootSignatureBindingInfo)
DXIL Resource Implicit Binding
This file provides a bitcode writing pass.
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
ModuleAnalysisManager MAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file defines the SmallVector class.
Class for arbitrary precision integers.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
An array constant whose element type is a simple 1/2/4/8-byte integer, bytes or float/double,...
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true, bool ByteString=false)
This method constructs a CDS and initializes it with a text string.
LLVM_ABI StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
This is an important base class in LLVM.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
iterator_range< iterator > samplers()
iterator_range< iterator > srvs()
iterator_range< iterator > cbuffers()
iterator_range< iterator > uavs()
@ PrivateLinkage
Like Internal, but omit from symbol table.
LLVM_ABI void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
static LLVM_ABI void stringifyResult(MD5Result &Result, SmallVectorImpl< char > &Str)
Translates the bytes in Res to a hex string that is deposited into Str.
LLVM_ABI void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
char back() const
Get the last character in the string.
The instances of the Type class are immutable: once they are created, they are never changed.
Type * getType() const
All values are typed, get the type of this value.
Represents a version number in the form major[.minor[.subminor[.build]]].
const EntrySignature * get(const Function *F) const
LLVM_ABI bool isTyped() const
LLVM_ABI bool isStruct() const
dxil::ResourceKind getResourceKind() const
mcdxbc::RootSignatureDesc * getDescForFunction(const Function *F)
Wrapper pass for the legacy pass manager.
An efficient, type-erasing, non-owning reference to a callable.
LLVM_ABI void write(raw_ostream &OS, bool PadToDword=true)
Legacy validator versions through 1.6 require unpadded signature parts.
A raw_ostream that writes to an SmallVector or SmallString.
Pass manager infrastructure for declaring and invalidating analyses.
ResourceKind
The kind of resource for an SRV or UAV resource.
cl::opt< std::string > PdbDebugPath
cl::opt< bool > PdbInPrivate
cl::opt< bool > SourceInDebugModule
LLVM_ABI void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
LLVM_ABI bool is_separator(char value, Style style=Style::native)
Check whether the given char is a path separator on the host OS.
constexpr bool IsBigEndianHost
This is an optimization pass for GlobalISel generic memory operations.
ArrayRef< CharT > arrayRefFromStringRef(StringRef Input)
Construct an array ref of bytes from a string ref.
static constexpr StringLiteral ModuleHashSectionName
Contains module hash.
LLVM_ABI void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
ModulePass * createDXILContainerGlobalsLegacyPass()
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
static constexpr StringLiteral PdbFileNameSectionName
Contains PDB output file name.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint32_t MaximumWaveLaneCount
uint32_t MinimumWaveLaneCount
LLVM_ABI void write(raw_ostream &OS) const
LLVM_ABI void setFilename(StringRef DebugFilename)
LLVM_ABI void write(raw_ostream &OS) const
dxbc::PSV::v3::RuntimeInfo BaseData
SmallVector< dxbc::PSV::v2::ResourceBindInfo > Resources
LLVM_ABI void finalize(Triple::EnvironmentType Stage, uint32_t Version=std::numeric_limits< uint32_t >::max())
LLVM_ABI void write(raw_ostream &OS, uint32_t Version=std::numeric_limits< uint32_t >::max()) const