50 DiagnosticInfoTranslateMD(
const Module &M,
const Twine &Msg,
55 DP <<
Mod.getName() <<
": " << Msg <<
'\n';
59enum class EntryPropsTag {
84 RI.createSymbol(M, DRTM[RI.getHandleTy()].createElementStruct());
88 SRVs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
90 UAVs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
92 CBufs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
94 Smps.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
100 bool HasResources = !DBM.
empty();
103 assert(!UAVMD &&
"Old and new UAV representations can't coexist");
109 assert(!CBufMD &&
"Old and new cbuffer representations can't coexist");
117 NamedMDNode *ResourceMD = M.getOrInsertNamedMetadata(
"dx.resources");
119 MDNode::get(M.getContext(), {SRVMD, UAVMD, CBufMD, SmpMD}));
160 case EntryPropsTag::ShaderFlags:
164 case EntryPropsTag::ShaderKind:
168 case EntryPropsTag::GSState:
169 case EntryPropsTag::DSState:
170 case EntryPropsTag::HSState:
171 case EntryPropsTag::NumThreads:
172 case EntryPropsTag::AutoBindingSpace:
173 case EntryPropsTag::RayPayloadSize:
174 case EntryPropsTag::RayAttribSize:
175 case EntryPropsTag::MSState:
176 case EntryPropsTag::ASStateTag:
177 case EntryPropsTag::WaveSize:
178 case EntryPropsTag::EntryRootSig:
189 if (EntryShaderFlags != 0)
191 EntryShaderFlags, Ctx));
193 if (EP.
Entry !=
nullptr) {
197 if (ShaderProfile == Triple::EnvironmentType::Library &&
198 EP.
ShaderStage != Triple::EnvironmentType::Library)
202 if (EP.
ShaderStage == Triple::EnvironmentType::Compute) {
234 MDVals[4] = Properties;
259 NamedMDNode *ValVerNode = M.getOrInsertNamedMetadata(
"dx.valver");
274 NamedMDNode *SMMDNode = M.getOrInsertNamedMetadata(
"dx.shaderModel");
286 NamedMDNode *DXILVerMDNode = M.getOrInsertNamedMetadata(
"dx.version");
294 if (ShaderFlags != 0) {
310 Instruction *BBTerminatorInst = BB.getTerminator();
312 MDNode *HlslControlFlowMD =
313 BBTerminatorInst->
getMetadata(
"hlsl.controlflow.hint");
315 if (!HlslControlFlowMD)
319 "invalid operands for hlsl.controlflow.hint");
323 mdconst::extract<ConstantInt>(HlslControlFlowMD->
getOperand(1));
332 BBTerminatorInst->
setMetadata(
"hlsl.controlflow.hint",
nullptr);
352 (NamedResourceMD !=
nullptr) ? NamedResourceMD->
getOperand(0) :
nullptr;
357 if (MMDI.
ShaderProfile == Triple::EnvironmentType::Library) {
361 uint64_t CombinedMask = ShaderFlags.getCombinedFlags();
365 M.getContext().diagnose(DiagnosticInfoTranslateMD(
366 M,
"Non-library shader: One and only one entry expected"));
371 ShaderFlags.getFunctionFlags(EntryProp.
Entry);
376 if (MMDI.
ShaderProfile != Triple::EnvironmentType::Library) {
377 EntryShaderFlags = EntrySFMask;
379 M.getContext().diagnose(DiagnosticInfoTranslateMD(
384 "' different from specified target profile '" +
395 M.getOrInsertNamedMetadata(
"dx.entryPoints");
396 for (
auto *Entry : EntryFnMDNodes)
415class DXILTranslateMetadataLegacy :
public ModulePass {
418 explicit DXILTranslateMetadataLegacy() :
ModulePass(
ID) {}
420 StringRef getPassName()
const override {
return "DXIL Translate Metadata"; }
434 bool runOnModule(
Module &M)
override {
436 getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
438 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
440 getAnalysis<DXILResourceMDWrapper>().getDXILResource();
442 getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags();
444 getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
454char DXILTranslateMetadataLegacy::ID = 0;
457 return new DXILTranslateMetadataLegacy();
461 "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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
This is the shared class of boolean and integer constants.
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...
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
This is an important class for using LLVM in a threaded context.
ConstantAsMetadata * createConstant(Constant *C)
Return the given constant as metadata.
MDString * createString(StringRef Str)
Return the given string as metadata.
const MDOperand & getOperand(unsigned I) const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
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