48 "dx-Zss",
cl::desc(
"Compute Shader Hash considering source information"));
51 cl::desc(
"Store PDB in private user data"));
54class DXILContainerGlobalsLegacy :
public ModulePass {
57 DXILContainerGlobalsLegacy() :
ModulePass(ID) {}
59 StringRef getPassName()
const override {
60 return "DXContainer Global Emitter";
63 bool runOnModule(
Module &M)
override;
65 void getAnalysisUsage(AnalysisUsage &AU)
const override {
84 GV->setAlignment(
Align(4));
92 GetShaderFlags().getCombinedFlags().getFeatureFlags();
95 ConstantInt::get(M.getContext(),
APInt(64, CombinedFeatureFlags));
103 M.getContext(), SectionData,
false);
104 Globals.emplace_back(
115 if (
auto *ILDB = M.getNamedGlobal(
"dx.ildb")) {
129 memcpy(
reinterpret_cast<void *
>(&HashData.
Digest),
MD5.data(), 16);
136 Globals.emplace_back(
139 if (M.debug_compile_units().empty())
144 DebugNameStr +=
".pdb";
152 AbsoluteDebugName = DebugFile;
156 DebugNameStr = DebugFile;
157 AbsoluteDebugName = DebugNameStr;
161 addSection(M, Globals, AbsoluteDebugName,
"dx.pdb.name",
177 addSection(M, Globals, ILDNData,
"dx.ildn",
"ILDN");
204 Globals.emplace_back(
buildSignature(M, InputSig,
"dx.isg1",
"ISG1", MMI));
205 Globals.emplace_back(
buildSignature(M, OutputSig,
"dx.osg1",
"OSG1", MMI));
220 const Function *EntryFunction =
nullptr;
256 "Resource range is too large");
262 BindInfo.
Flags = Flags;
267 if (!RI.hasBinding())
274 if (!RI.hasBinding())
278 dxbc::PSV::ResourceType::Sampler,
282 if (!RI.hasBinding())
289 ResType = dxbc::PSV::ResourceType::SRVStructured;
291 ResType = dxbc::PSV::ResourceType::SRVTyped;
293 ResType = dxbc::PSV::ResourceType::SRVRaw;
299 if (!RI.hasBinding())
306 ResType = dxbc::PSV::ResourceType::UAVStructuredWithCounter;
308 ResType = dxbc::PSV::ResourceType::UAVStructured;
310 ResType = dxbc::PSV::ResourceType::UAVTyped;
312 ResType = dxbc::PSV::ResourceType::UAVRaw;
315 Flags.
Bits.UsedByAtomic64 = RI.HasAtomic64Use;
343 unsigned PSVVersion = 3;
347 bool UsesViewID = GetModuleShaderFlags().getFunctionFlags(Entry).ViewID;
350 if (
const auto *Sig = Signatures.
get(Entry)) {
355 if ((!Sig->Inputs.empty() || !Sig->Outputs.empty()) && !V.empty() &&
391 PSV.
write(OS, PSVVersion);
396 if (M.debug_compile_units().empty())
432 addSignature(M, Globals, GetModuleMetadataInfo, GetModuleSignatureInfo);
434 GetRootSignatureBindingInfo);
436 GetResourceMap, GetResourceTypeMap,
437 GetModuleShaderFlags, GetModuleSignatureInfo);
444bool DXILContainerGlobalsLegacy::runOnModule(
Module &M) {
447 [&]() -> ModuleMetadataInfo & {
448 return getAnalysis<DXILMetadataAnalysisWrapperPass>()
449 .getModuleMetadata();
451 [&]() -> DXILResourceMap & {
452 return getAnalysis<DXILResourceWrapperPass>().getResourceMap();
454 [&]() -> DXILResourceTypeMap & {
455 return getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
457 [&]() ->
const ModuleShaderFlags & {
458 return getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags();
460 [&]() ->
const ModuleSignatureInfo & {
461 return getAnalysis<SignatureAnalysisWrapper>().getSignatureInfo();
463 [&]() -> RootSignatureBindingInfo & {
464 return getAnalysis<RootSignatureAnalysisWrapper>().getRSInfo();
493char DXILContainerGlobalsLegacy::ID = 0;
495 "DXContainer Global Emitter",
false,
true)
505 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