25 : Entry(M.getOrInsertNamedMetadata(
"dx.valver")) {}
71 NamedMDNode *Entry = M.getOrInsertNamedMetadata(
"dx.shaderModel");
72 Triple TT(M.getTargetTriple());
95 unsigned NumThreads[3];
99 : ShaderKind(ModuleShaderKind) {
101 if (ShaderKind == Triple::EnvironmentType::Library) {
102 Attribute EntryAttr =
F.getFnAttribute(
"hlsl.shader");
104 Triple T(
"",
"",
"", EntryProfile);
105 ShaderKind =
T.getEnvironment();
108 if (ShaderKind == Triple::EnvironmentType::Compute) {
110 F.getFnAttribute(
"hlsl.numthreads").getValueAsString();
112 NumThreadsStr.split(NumThreads,
',');
113 assert(NumThreads.
size() == 3 &&
"invalid numthreads");
116 for (
auto It : Zip) {
119 [[maybe_unused]]
bool Result = Str.getAsInteger(10, V);
120 assert(!Result &&
"Failed to parse numthreads");
122 unsigned &Num = std::get<1>(It);
123 Num =
V.getLimitedValue();
130 std::vector<Metadata *> MDVals;
132 if (RawShaderFlag != 0)
133 appendShaderFlags(MDVals, RawShaderFlag, Ctx);
136 if (IsLib && ShaderKind != Triple::EnvironmentType::Library)
137 appendShaderKind(MDVals, Ctx);
139 if (ShaderKind == Triple::EnvironmentType::Compute)
140 appendNumThreads(MDVals, Ctx);
148 if (RawShaderFlag == 0)
151 std::vector<Metadata *> MDVals;
153 appendShaderFlags(MDVals, RawShaderFlag, Ctx);
176 void appendNumThreads(std::vector<Metadata *> &MDVals,
LLVMContext &Ctx) {
180 std::vector<Metadata *> NumThreadVals;
184 MDVals.emplace_back(
MDNode::get(Ctx, NumThreadVals));
187 static void appendShaderFlags(std::vector<Metadata *> &MDVals,
195 void appendShaderKind(std::vector<Metadata *> &MDVals,
LLVMContext &Ctx) {
210 :
F(
F), Ctx(
F.getContext()), Props(
F, ModuleShaderKind) {}
216 return emitDxilEntryPointTuple(
218 Props.emitDXILEntryProps(RawShaderFlag, Ctx,
false), Ctx);
225 return emitDxilEntryPointTuple(
228 Props.emitDXILEntryProps(RawShaderFlag, Ctx,
true), Ctx);
236 return emitDxilEntryPointTuple(
238 EntryProps::emitEntryPropsForEmptyEntry(RawShaderFlag, Ctx), Ctx);
252 MDVals[4] = Properties;
260 for (
auto &
F : M.functions()) {
261 if (!
F.hasFnAttribute(
"hlsl.shader"))
266 auto &Ctx = M.getContext();
269 MDTuple *MDResources =
nullptr;
270 if (
auto *NamedResources = M.getNamedMetadata(
"dx.resources"))
271 MDResources = dyn_cast<MDTuple>(NamedResources->getOperand(0));
273 std::vector<MDNode *> Entries;
275 switch (
T.getEnvironment()) {
279 EntryMD::emitEmptyEntryForLib(MDResources, ShaderFlags, Ctx);
280 Entries.emplace_back(EmptyEntry);
283 EntryMD MD(*Entry,
T.getEnvironment());
284 Entries.emplace_back(MD.emitEntryTupleForLib(0));
296 "non-lib profiles should only have one entry");
297 EntryMD MD(*EntryList.
front(),
T.getEnvironment());
298 Entries.emplace_back(MD.emitEntryTuple(MDResources, ShaderFlags));
301 assert(0 &&
"invalid profile");
306 M.getOrInsertNamedMetadata(
"dx.entryPoints");
307 for (
auto *Entry : Entries)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const FuncProtoTy Signatures[]
Defines the llvm::VersionTuple class, which represents a version in the form major[....
Class for arbitrary precision integers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef getValueAsString() const
Return the attribute's value as a string.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given 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)
A Module instance is used to store all the information related to an LLVM module.
LLVMContext & getContext() const
Get the global data context.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
void setOperand(unsigned I, MDNode *New)
unsigned getNumOperands() const
Module * getParent()
Get the module that holds this named metadata collection.
void addOperand(MDNode *M)
reference emplace_back(ArgTypes &&... Args)
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.
Triple - Helper class for working with autoconf configuration names.
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
void update(VersionTuple ValidatorVer)
ValidatorVersionMD(Module &M)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void createShaderModelMD(Module &M)
void createEntryMD(Module &M, const uint64_t ShaderFlags)
This is an optimization pass for GlobalISel generic memory operations.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.