48 DiagnosticInfoTranslateMD(
const Module &M,
53 void print(DiagnosticPrinter &DP)
const override {
54 DP << Mod.getName() <<
": " << Msg <<
'\n';
58enum class EntryPropsTag {
83 DRTM[RI.getHandleTy()].createElementStruct(RI.getName()));
87 SRVs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
89 UAVs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
91 CBufs.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
93 Smps.
push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
103 NamedMDNode *ResourceMD = M.getOrInsertNamedMetadata(
"dx.resources");
105 MDNode::get(M.getContext(), {SRVMD, UAVMD, CBufMD, SmpMD}));
148 case EntryPropsTag::ShaderFlags:
152 case EntryPropsTag::ShaderKind:
156 case EntryPropsTag::GSState:
157 case EntryPropsTag::DSState:
158 case EntryPropsTag::HSState:
159 case EntryPropsTag::NumThreads:
160 case EntryPropsTag::AutoBindingSpace:
161 case EntryPropsTag::RayPayloadSize:
162 case EntryPropsTag::RayAttribSize:
163 case EntryPropsTag::MSState:
164 case EntryPropsTag::ASStateTag:
165 case EntryPropsTag::WaveSize:
166 case EntryPropsTag::EntryRootSig:
177 if (EntryShaderFlags != 0)
179 EntryShaderFlags, Ctx));
181 if (EP.
Entry !=
nullptr) {
221 MDVals[3] = Resources;
222 MDVals[4] = Properties;
247 NamedMDNode *ValVerNode = M.getOrInsertNamedMetadata(
"dx.valver");
262 NamedMDNode *SMMDNode = M.getOrInsertNamedMetadata(
"dx.shaderModel");
274 NamedMDNode *DXILVerMDNode = M.getOrInsertNamedMetadata(
"dx.version");
282 if (ShaderFlags != 0) {
298 Instruction *BBTerminatorInst = BB.getTerminator();
300 MDNode *HlslControlFlowMD =
301 BBTerminatorInst->
getMetadata(
"hlsl.controlflow.hint");
303 if (!HlslControlFlowMD)
307 "invalid operands for hlsl.controlflow.hint");
320 BBTerminatorInst->
setMetadata(
"hlsl.controlflow.hint",
nullptr);
338 (NamedResourceMD !=
nullptr) ? NamedResourceMD->
getOperand(0) :
nullptr;
347 uint64_t CombinedMask = ShaderFlags.getCombinedFlags();
351 M.getContext().diagnose(DiagnosticInfoTranslateMD(
352 M,
"Non-library shader: One and only one entry expected"));
357 ShaderFlags.getFunctionFlags(EntryProp.
Entry);
363 EntryShaderFlags = EntrySFMask;
365 M.getContext().diagnose(DiagnosticInfoTranslateMD(
370 "' different from specified target profile '" +
381 M.getOrInsertNamedMetadata(
"dx.entryPoints");
382 for (
auto *Entry : EntryFnMDNodes)
400class DXILTranslateMetadataLegacy :
public ModulePass {
403 explicit DXILTranslateMetadataLegacy() :
ModulePass(
ID) {}
405 StringRef getPassName()
const override {
return "DXIL Translate Metadata"; }
407 void getAnalysisUsage(AnalysisUsage &AU)
const override {
418 bool runOnModule(
Module &M)
override {
419 DXILResourceMap &DRM =
420 getAnalysis<DXILResourceWrapperPass>().getResourceMap();
421 DXILResourceTypeMap &DRTM =
422 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
423 const ModuleShaderFlags &ShaderFlags =
424 getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags();
425 dxil::ModuleMetadataInfo MMDI =
426 getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
436char DXILTranslateMetadataLegacy::ID = 0;
439 return new DXILTranslateMetadataLegacy();
443 "DXIL Translate Metadata",
false,
false)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_LIFETIME_BOUND
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.
Machine Check Debug Module
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.
static const FuncProtoTy Signatures[]
Defines the llvm::VersionTuple class, which represents a version in the form major[....
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 > samplers()
iterator_range< iterator > srvs()
iterator_range< iterator > cbuffers()
iterator_range< iterator > uavs()
This is the base abstract class for diagnostic reporting in the backend.
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.
LLVM_ABI 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.
LLVM_ABI ConstantAsMetadata * createConstant(Constant *C)
Return the given constant as metadata.
LLVM_ABI 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 LLVM_ABI 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.
LLVM_ABI MDNode * getOperand(unsigned i) const
LLVM_ABI void clearOperands()
Drop all references to this node's operands.
LLVM_ABI 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 LLVM_ABI 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 LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
LLVM_ABI 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.
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.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
ModulePass * createDXILTranslateMetadataLegacyPass()
Pass to emit metadata for DXIL.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Triple::EnvironmentType ShaderStage