48 DiagnosticInfoTranslateMD(
const Module &M,
const Twine &Msg,
53 DP <<
Mod.getName() <<
": " << Msg <<
'\n';
57enum class EntryPropsTag {
82 RI.createSymbol(M, DRTM[RI.getHandleTy()].createElementStruct());
86 SRVs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
88 UAVs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
90 CBufs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
92 Smps.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
98 bool HasResources = !DBM.
empty();
101 assert(!UAVMD &&
"Old and new UAV representations can't coexist");
107 assert(!CBufMD &&
"Old and new cbuffer representations can't coexist");
115 NamedMDNode *ResourceMD = M.getOrInsertNamedMetadata(
"dx.resources");
117 MDNode::get(M.getContext(), {SRVMD, UAVMD, CBufMD, SmpMD}));
158 case EntryPropsTag::ShaderFlags:
162 case EntryPropsTag::ShaderKind:
166 case EntryPropsTag::GSState:
167 case EntryPropsTag::DSState:
168 case EntryPropsTag::HSState:
169 case EntryPropsTag::NumThreads:
170 case EntryPropsTag::AutoBindingSpace:
171 case EntryPropsTag::RayPayloadSize:
172 case EntryPropsTag::RayAttribSize:
173 case EntryPropsTag::MSState:
174 case EntryPropsTag::ASStateTag:
175 case EntryPropsTag::WaveSize:
176 case EntryPropsTag::EntryRootSig:
187 if (EntryShaderFlags != 0)
189 EntryShaderFlags, Ctx));
191 if (EP.
Entry !=
nullptr) {
195 if (ShaderProfile == Triple::EnvironmentType::Library &&
196 EP.
ShaderStage != Triple::EnvironmentType::Library)
200 if (EP.
ShaderStage == Triple::EnvironmentType::Compute) {
232 MDVals[4] = Properties;
257 NamedMDNode *ValVerNode = M.getOrInsertNamedMetadata(
"dx.valver");
272 NamedMDNode *SMMDNode = M.getOrInsertNamedMetadata(
"dx.shaderModel");
284 NamedMDNode *DXILVerMDNode = M.getOrInsertNamedMetadata(
"dx.version");
292 if (ShaderFlags != 0) {
318 (NamedResourceMD !=
nullptr) ? NamedResourceMD->
getOperand(0) :
nullptr;
323 if (MMDI.
ShaderProfile == Triple::EnvironmentType::Library) {
327 uint64_t CombinedMask = ShaderFlags.getCombinedFlags();
331 M.getContext().diagnose(DiagnosticInfoTranslateMD(
332 M,
"Non-library shader: One and only one entry expected"));
337 ShaderFlags.getFunctionFlags(EntryProp.
Entry);
342 if (MMDI.
ShaderProfile != Triple::EnvironmentType::Library) {
343 EntryShaderFlags = EntrySFMask;
345 M.getContext().diagnose(DiagnosticInfoTranslateMD(
350 "' different from specified target profile '" +
361 M.getOrInsertNamedMetadata(
"dx.entryPoints");
362 for (
auto *Entry : EntryFnMDNodes)
380class DXILTranslateMetadataLegacy :
public ModulePass {
383 explicit DXILTranslateMetadataLegacy() :
ModulePass(
ID) {}
385 StringRef getPassName()
const override {
return "DXIL Translate Metadata"; }
399 bool runOnModule(
Module &M)
override {
401 getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
403 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
405 getAnalysis<DXILResourceMDWrapper>().getDXILResource();
407 getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags();
409 getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
418char DXILTranslateMetadataLegacy::ID = 0;
421 return new DXILTranslateMetadataLegacy();
425 "DXIL Translate Metadata",
false,
false)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static const FuncProtoTy Signatures[]
Defines the llvm::VersionTuple class, which represents a version in the form major[....
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
iterator_range< iterator > cbuffers()
iterator_range< iterator > srvs()
iterator_range< iterator > samplers()
iterator_range< iterator > uavs()
Analysis pass that exposes the DXILResource for a module.
The legacy pass manager's analysis pass to compute DXIL resource information.
This is the base abstract class for diagnostic reporting in the backend.
virtual void print(DiagnosticPrinter &DP) const =0
Print using the given DP a user-friendly message.
Interface for custom diagnostic printing.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This is an important class for using LLVM in a threaded context.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDString * get(LLVMContext &Context, StringRef Str)
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.
MDNode * getOperand(unsigned i) const
void clearOperands()
Drop all references to this node's operands.
void addOperand(MDNode *M)
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.
reference emplace_back(ArgTypes &&... Args)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
static StringRef getEnvironmentTypeName(EnvironmentType Kind)
Get the canonical name for the Kind environment.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
LLVM Value Representation.
StringRef getName() const
Return a constant reference to the value's name.
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
Metadata * writeUAVs(Module &M) const
Metadata * writeCBuffers(Module &M) const
Wrapper pass for the legacy pass manager.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
ModulePass * createDXILTranslateMetadataLegacyPass()
Pass to emit metadata for DXIL.
@ Mod
The access may modify the value stored in memory.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Triple::EnvironmentType ShaderStage