48 DiagnosticInfoTranslateMD(
const Module &M,
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}));
146 case EntryPropsTag::ShaderFlags:
150 case EntryPropsTag::ShaderKind:
154 case EntryPropsTag::GSState:
155 case EntryPropsTag::DSState:
156 case EntryPropsTag::HSState:
157 case EntryPropsTag::NumThreads:
158 case EntryPropsTag::AutoBindingSpace:
159 case EntryPropsTag::RayPayloadSize:
160 case EntryPropsTag::RayAttribSize:
161 case EntryPropsTag::MSState:
162 case EntryPropsTag::ASStateTag:
163 case EntryPropsTag::WaveSize:
164 case EntryPropsTag::EntryRootSig:
175 if (EntryShaderFlags != 0)
177 EntryShaderFlags, Ctx));
179 if (EP.
Entry !=
nullptr) {
183 if (ShaderProfile == Triple::EnvironmentType::Library &&
184 EP.
ShaderStage != Triple::EnvironmentType::Library)
188 if (EP.
ShaderStage == Triple::EnvironmentType::Compute) {
219 MDVals[3] = Resources;
220 MDVals[4] = Properties;
245 NamedMDNode *ValVerNode = M.getOrInsertNamedMetadata(
"dx.valver");
260 NamedMDNode *SMMDNode = M.getOrInsertNamedMetadata(
"dx.shaderModel");
272 NamedMDNode *DXILVerMDNode = M.getOrInsertNamedMetadata(
"dx.version");
280 if (ShaderFlags != 0) {
296 Instruction *BBTerminatorInst = BB.getTerminator();
298 MDNode *HlslControlFlowMD =
299 BBTerminatorInst->
getMetadata(
"hlsl.controlflow.hint");
301 if (!HlslControlFlowMD)
305 "invalid operands for hlsl.controlflow.hint");
309 mdconst::extract<ConstantInt>(HlslControlFlowMD->
getOperand(1));
318 BBTerminatorInst->
setMetadata(
"hlsl.controlflow.hint",
nullptr);
336 (NamedResourceMD !=
nullptr) ? NamedResourceMD->
getOperand(0) :
nullptr;
341 if (MMDI.
ShaderProfile == Triple::EnvironmentType::Library) {
345 uint64_t CombinedMask = ShaderFlags.getCombinedFlags();
349 M.getContext().diagnose(DiagnosticInfoTranslateMD(
350 M,
"Non-library shader: One and only one entry expected"));
355 ShaderFlags.getFunctionFlags(EntryProp.
Entry);
360 if (MMDI.
ShaderProfile != Triple::EnvironmentType::Library) {
361 EntryShaderFlags = EntrySFMask;
363 M.getContext().diagnose(DiagnosticInfoTranslateMD(
368 "' different from specified target profile '" +
379 M.getOrInsertNamedMetadata(
"dx.entryPoints");
380 for (
auto *Entry : EntryFnMDNodes)
398class DXILTranslateMetadataLegacy :
public ModulePass {
401 explicit DXILTranslateMetadataLegacy() :
ModulePass(
ID) {}
403 StringRef getPassName()
const override {
return "DXIL Translate Metadata"; }
416 bool runOnModule(
Module &M)
override {
418 getAnalysis<DXILResourceWrapperPass>().getResourceMap();
420 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
422 getAnalysis<ShaderFlagsAnalysisWrapper>().getShaderFlags();
424 getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
434char DXILTranslateMetadataLegacy::ID = 0;
437 return new DXILTranslateMetadataLegacy();
441 "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.
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)
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 > 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.
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.
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 * getInt32Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt64Ty(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.
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