LLVM 24.0.0git
DXILShaderFlags.cpp
Go to the documentation of this file.
1//===- DXILShaderFlags.cpp - DXIL Shader Flags helper objects -------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file This file contains helper objects and APIs for working with DXIL
10/// Shader Flags.
11///
12//===----------------------------------------------------------------------===//
13
14#include "DXILShaderFlags.h"
16#include "DirectX.h"
21#include "llvm/IR/Attributes.h"
23#include "llvm/IR/Instruction.h"
26#include "llvm/IR/Intrinsics.h"
27#include "llvm/IR/IntrinsicsDirectX.h"
28#include "llvm/IR/Module.h"
32
33using namespace llvm;
34using namespace llvm::dxil;
35
36static bool hasUAVsAtEveryStage(const DXILResourceMap &DRM,
37 const ModuleMetadataInfo &MMDI) {
38 // Heap resources do not count towards hasUAVsAtEveryStage.
39 bool HasUAVWithBinding = any_of(
40 DRM.uavs(), [](const ResourceInfo &RI) { return RI.hasBinding(); });
41 if (!HasUAVWithBinding)
42 return false;
43
44 switch (MMDI.ShaderProfile) {
45 default:
46 return false;
49 return false;
54 return true;
64 return MMDI.ValidatorVersion < VersionTuple(1, 8);
65 }
66}
67
68static bool checkWaveOps(Intrinsic::ID IID) {
69 // Currently unsupported intrinsics
70 // case Intrinsic::dx_wave_readfirst:
71 // case Intrinsic::dx_wave_reduce.and:
72 // case Intrinsic::dx_wave_reduce.or:
73 // case Intrinsic::dx_wave_reduce.xor:
74 // case Intrinsic::dx_wave_prefixop:
75 // case Intrinsic::dx_quad.readat:
76 // case Intrinsic::dx_quad.readacrossy:
77 // case Intrinsic::dx_quad.readacrossdiagonal:
78 // case Intrinsic::dx_wave_prefixballot:
79 // case Intrinsic::dx_wave_match:
80 // case Intrinsic::dx_wavemulti.*:
81 // case Intrinsic::dx_wavemulti.ballot:
82 switch (IID) {
83 default:
84 return false;
85 case Intrinsic::dx_wave_is_first_lane:
86 case Intrinsic::dx_wave_getlaneindex:
87 case Intrinsic::dx_wave_get_lane_count:
88 case Intrinsic::dx_wave_any:
89 case Intrinsic::dx_wave_all_equal:
90 case Intrinsic::dx_wave_all:
91 case Intrinsic::dx_wave_readlane:
92 case Intrinsic::dx_wave_readlane_first:
93 case Intrinsic::dx_wave_active_countbits:
94 case Intrinsic::dx_wave_ballot:
95 case Intrinsic::dx_wave_prefix_bit_count:
96 // Wave Active Op Variants
97 case Intrinsic::dx_wave_reduce_or:
98 case Intrinsic::dx_wave_reduce_xor:
99 case Intrinsic::dx_wave_reduce_and:
100 case Intrinsic::dx_wave_reduce_sum:
101 case Intrinsic::dx_wave_reduce_usum:
102 case Intrinsic::dx_wave_product:
103 case Intrinsic::dx_wave_uproduct:
104 case Intrinsic::dx_wave_reduce_max:
105 case Intrinsic::dx_wave_reduce_umax:
106 case Intrinsic::dx_wave_reduce_min:
107 case Intrinsic::dx_wave_reduce_umin:
108 // Wave Prefix Op Variants
109 case Intrinsic::dx_wave_prefix_sum:
110 case Intrinsic::dx_wave_prefix_usum:
111 case Intrinsic::dx_wave_prefix_product:
112 case Intrinsic::dx_wave_prefix_uproduct:
113 case Intrinsic::dx_wave_multi_prefix_bit_and:
114 case Intrinsic::dx_wave_multi_prefix_bit_or:
115 case Intrinsic::dx_wave_multi_prefix_bit_xor:
116 case Intrinsic::dx_wave_multi_prefix_bit_count:
117 case Intrinsic::dx_wave_multi_prefix_product:
118 case Intrinsic::dx_wave_multi_prefix_uproduct:
119 case Intrinsic::dx_wave_multi_prefix_sum:
120 case Intrinsic::dx_wave_multi_prefix_usum:
121 // Quad Op Variants
122 case Intrinsic::dx_quad_all:
123 case Intrinsic::dx_quad_read_across_x:
124 case Intrinsic::dx_quad_read_across_y:
125 case Intrinsic::dx_quad_read_across_diagonal:
126 return true;
127 }
128}
129
131 switch (IID) {
132 default:
133 return false;
134 case Intrinsic::fma:
135 return true;
136 }
137}
138
139/// Texture load and sample operations accept "programmable offsets", i.e.
140/// offsets that are not compile-time constants. Such offsets require the
141/// AdvancedTextureOps shader feature flag. Returns true if \p II is one of
142/// those operations and its offsets operand is not a constant.
144 // TODO: (#116137) Several other DXIL ops also require this feature flag, but
145 // none of them can be generated yet:
146 // - SampleCmp, SampleCmpBias, SampleCmpGrad and SampleCmpLevelZero set the
147 // flag for non-constant offsets, exactly like the ops handled below.
148 // - SampleCmpLevel, TextureGatherRaw and TextureStoreSample set the flag
149 // unconditionally, and have no intrinsics yet.
150
151 // The offsets operand index differs between the intrinsics.
152 unsigned OffsetsIdx;
153 switch (II.getIntrinsicID()) {
154 default:
155 return false;
156 case Intrinsic::dx_resource_load_level:
157 case Intrinsic::dx_resource_sample:
158 case Intrinsic::dx_resource_sample_clamp:
159 OffsetsIdx = 3;
160 break;
161 case Intrinsic::dx_resource_samplebias:
162 case Intrinsic::dx_resource_samplebias_clamp:
163 case Intrinsic::dx_resource_samplelevel:
164 OffsetsIdx = 4;
165 break;
166 case Intrinsic::dx_resource_samplegrad:
167 case Intrinsic::dx_resource_samplegrad_clamp:
168 OffsetsIdx = 5;
169 break;
170 }
171 return !isa<Constant>(II.getArgOperand(OffsetsIdx));
172}
173
174static bool isOptimizationDisabled(const Module &M) {
175 const StringRef Key = "dx.disable_optimizations";
176 if (auto *Flag = mdconst::extract_or_null<ConstantInt>(M.getModuleFlag(Key)))
177 return Flag->getValue().getBoolValue();
178 return false;
179}
180
181// Checks to see if the status bit from a load with status
182// instruction is ever extracted. If it is, the module needs
183// to have the TiledResources shader flag set.
185 [[maybe_unused]] Intrinsic::ID IID = II.getIntrinsicID();
186 assert(IID == Intrinsic::dx_resource_load_typedbuffer ||
187 IID == Intrinsic::dx_resource_load_rawbuffer &&
188 "unexpected intrinsic ID");
189 for (const User *U : II.users()) {
190 if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(U)) {
191 // Resource load operations return a {result, status} pair.
192 // Check if we extract the status
193 if (EVI->getNumIndices() == 1 && EVI->getIndices()[0] == 1)
194 return true;
195 }
196 }
197
198 return false;
199}
200
201/// Returns true if the LOD clamp argument of \p II is neither constant zero
202/// nor undef.
203static bool hasLODClamp(const IntrinsicInst &II) {
204 const Value *Clamp = II.getArgOperand(II.arg_size() - 1);
205 if (const auto *C = dyn_cast<ConstantFP>(Clamp))
206 return !C->isZero();
207 return !isa<UndefValue>(Clamp);
208}
209
210/// Update the shader flags mask based on the given instruction.
211/// \param CSF Shader flags mask to update.
212/// \param I Instruction to check.
213void ModuleShaderFlags::updateFunctionFlags(ComputedShaderFlags &CSF,
214 const Instruction &I,
216 const ModuleMetadataInfo &MMDI) {
217 if (!CSF.Doubles)
218 CSF.Doubles = I.getType()->getScalarType()->isDoubleTy();
219
220 if (!CSF.Doubles) {
221 for (const Value *Op : I.operands()) {
222 if (Op->getType()->getScalarType()->isDoubleTy()) {
223 CSF.Doubles = true;
224 break;
225 }
226 }
227 }
228
229 if (CSF.Doubles) {
230 switch (I.getOpcode()) {
231 case Instruction::FDiv:
232 case Instruction::UIToFP:
233 case Instruction::SIToFP:
234 case Instruction::FPToUI:
235 case Instruction::FPToSI:
236 CSF.DX11_1_DoubleExtensions = true;
237 break;
238 }
239 }
240
241 if (!CSF.LowPrecisionPresent)
242 CSF.LowPrecisionPresent = I.getType()->getScalarType()->isIntegerTy(16) ||
243 I.getType()->getScalarType()->isHalfTy();
244
245 if (!CSF.LowPrecisionPresent) {
246 for (const Value *Op : I.operands()) {
247 if (Op->getType()->getScalarType()->isIntegerTy(16) ||
248 Op->getType()->getScalarType()->isHalfTy()) {
249 CSF.LowPrecisionPresent = true;
250 break;
251 }
252 }
253 }
254
255 if (CSF.LowPrecisionPresent) {
256 if (CSF.NativeLowPrecisionMode)
257 CSF.NativeLowPrecision = true;
258 else
259 CSF.MinimumPrecision = true;
260 }
261
262 if (!CSF.Int64Ops)
263 CSF.Int64Ops = I.getType()->getScalarType()->isIntegerTy(64);
264
265 if (!CSF.Int64Ops && !isa<LifetimeIntrinsic>(&I)) {
266 for (const Value *Op : I.operands()) {
267 if (Op->getType()->getScalarType()->isIntegerTy(64)) {
268 CSF.Int64Ops = true;
269 break;
270 }
271 }
272 }
273
274 if (const auto *II = dyn_cast<IntrinsicInst>(&I)) {
275 CSF.AdvancedTextureOps |= checkAdvancedTextureOps(*II);
276
277 switch (II->getIntrinsicID()) {
278 default:
279 break;
280 case Intrinsic::dx_start_vertex_location:
281 case Intrinsic::dx_start_instance_location:
282 CSF.ExtendedCommandInfo = true;
283 break;
284 case Intrinsic::dx_view_id:
285 CSF.ViewID = true;
286 break;
287 case Intrinsic::dx_inner_coverage:
288 CSF.InnerCoverage = true;
289 break;
290 case Intrinsic::dx_resource_handlefrombinding: {
291 dxil::ResourceTypeInfo &RTI = DRTM[cast<TargetExtType>(II->getType())];
292
293 // Set ResMayNotAlias if DXIL validator version >= 1.8 and the function
294 // uses UAVs
295 if (!CSF.ResMayNotAlias && CanSetResMayNotAlias &&
296 MMDI.ValidatorVersion >= VersionTuple(1, 8) && RTI.isUAV())
297 CSF.ResMayNotAlias = true;
298
299 switch (RTI.getResourceKind()) {
302 CSF.EnableRawAndStructuredBuffers = true;
303 break;
304 default:
305 break;
306 }
307 break;
308 }
309 case Intrinsic::dx_resource_handlefromheap: {
310 dxil::ResourceTypeInfo &RTI = DRTM[cast<TargetExtType>(II->getType())];
311 bool IsSamplerHeap = RTI.isSampler();
312 CSF.SamplerDescriptorHeapIndexing |= IsSamplerHeap;
313 CSF.ResourceDescriptorHeapIndexing |= !IsSamplerHeap;
314
315 if (!CSF.ResMayNotAlias && CanSetResMayNotAlias && RTI.isUAV() &&
316 MMDI.ValidatorVersion >= VersionTuple(1, 8)) {
317 CSF.ResMayNotAlias = true;
318 }
319 break;
320 }
321 case Intrinsic::dx_resource_load_level:
322 case Intrinsic::dx_resource_load_typedbuffer: {
323 dxil::ResourceTypeInfo &RTI =
324 DRTM[cast<TargetExtType>(II->getArgOperand(0)->getType())];
325 if (RTI.isTyped() && RTI.isUAV())
326 CSF.TypedUAVLoadAdditionalFormats |= RTI.getTyped().ElementCount > 1;
327 if (II->getIntrinsicID() == Intrinsic::dx_resource_load_typedbuffer &&
328 !CSF.TiledResources && checkIfStatusIsExtracted(*II))
329 CSF.TiledResources = true;
330 break;
331 }
332 case Intrinsic::dx_resource_load_rawbuffer: {
333 if (!CSF.TiledResources && checkIfStatusIsExtracted(*II))
334 CSF.TiledResources = true;
335 break;
336 }
337 case Intrinsic::dx_resource_sample_clamp:
338 case Intrinsic::dx_resource_samplebias_clamp:
339 case Intrinsic::dx_resource_samplegrad_clamp:
340 // DXIL validator 1.7 does not expect TiledResources for LOD clamps.
341 if (!CSF.TiledResources && MMDI.ValidatorVersion >= VersionTuple(1, 8))
342 CSF.TiledResources = hasLODClamp(*II);
343 break;
344 case Intrinsic::dx_resource_atomic_binop:
345 case Intrinsic::dx_resource_atomic_compare_exchange: {
346 if (II->getType()->isIntegerTy(64)) {
347 dxil::ResourceTypeInfo &RTI =
348 DRTM[cast<TargetExtType>(II->getArgOperand(0)->getType())];
349 if (RTI.isTyped())
350 CSF.AtomicInt64OnTypedResource = true;
351 // TODO(https://github.com/llvm/llvm-project/issues/116152): Set
352 // AtomicInt64OnHeapResource when heap-resource intrinsics are added.
353 }
354 break;
355 }
356 }
357 }
358 // 64-bit atomics on groupshared memory (address space 3).
359 if (const auto *ARMW = dyn_cast<AtomicRMWInst>(&I)) {
360 if (ARMW->getValOperand()->getType()->isIntegerTy(64) &&
361 ARMW->getPointerAddressSpace() == 3)
362 CSF.AtomicInt64OnGroupShared = true;
363 } else if (const auto *AXCG = dyn_cast<AtomicCmpXchgInst>(&I)) {
364 if (AXCG->getNewValOperand()->getType()->isIntegerTy(64) &&
365 AXCG->getPointerAddressSpace() == 3)
366 CSF.AtomicInt64OnGroupShared = true;
367 }
368 // Handle call instructions
369 if (auto *CI = dyn_cast<CallInst>(&I)) {
370 const Function *CF = CI->getCalledFunction();
371 // Merge-in shader flags mask of the called function in the current module
372 if (FunctionFlags.contains(CF))
373 CSF.merge(FunctionFlags[CF]);
374
375 CSF.DX11_1_DoubleExtensions |=
376 checkDoubleExtensionOps(CI->getIntrinsicID());
377 CSF.WaveOps |= checkWaveOps(CI->getIntrinsicID());
378 }
379}
380
381/// Set shader flags that apply to all functions within the module
383ModuleShaderFlags::gatherGlobalModuleFlags(const Module &M,
384 const DXILResourceMap &DRM,
385 const ModuleMetadataInfo &MMDI) {
386
387 ComputedShaderFlags CSF;
388
389 CSF.DisableOptimizations = isOptimizationDisabled(M);
390
391 CSF.UAVsAtEveryStage = hasUAVsAtEveryStage(DRM, MMDI);
392
393 // Set the Max64UAVs flag if the number of UAVs is > 8
394 uint32_t NumUAVs = 0;
395 for (auto &UAV : DRM.uavs()) {
396 // Heap resources do not count towards Max64UAVs flag.
397 if (!UAV.hasBinding())
398 continue;
399 if (MMDI.ValidatorVersion < VersionTuple(1, 6)) {
400 NumUAVs++;
401 } else { // MMDI.ValidatorVersion >= VersionTuple(1, 6)
402 uint32_t Size = UAV.getSize();
403 uint32_t NewNum = NumUAVs + (Size == 0 ? ~0U : Size);
404 if (NewNum < NumUAVs)
405 NewNum = ~0U;
406 NumUAVs = NewNum;
407 }
408 }
409 if (NumUAVs > 8)
410 CSF.Max64UAVs = true;
411
412 // Set the module flag that enables native low-precision execution mode.
413 // NativeLowPrecisionMode can only be set when the command line option
414 // -enable-16bit-types is provided. This is indicated by the dx.nativelowprec
415 // module flag being set
416 // This flag is needed even if the module does not use 16-bit types because a
417 // corresponding debug module may include 16-bit types, and tools that use the
418 // debug module may expect it to have the same flags as the original
419 if (auto *NativeLowPrec = mdconst::extract_or_null<ConstantInt>(
420 M.getModuleFlag("dx.nativelowprec")))
421 if (MMDI.ShaderModelVersion >= VersionTuple(6, 2))
422 CSF.NativeLowPrecisionMode = NativeLowPrec->getValue().getBoolValue();
423
424 // Set ResMayNotAlias to true if DXIL validator version < 1.8 and there
425 // are UAVs present globally.
426 if (CanSetResMayNotAlias && MMDI.ValidatorVersion < VersionTuple(1, 8))
427 CSF.ResMayNotAlias = !DRM.uavs().empty();
428
429 // The command line option -all-resources-bound will set the
430 // dx.allresourcesbound module flag to 1
431 if (auto *AllResourcesBound = mdconst::extract_or_null<ConstantInt>(
432 M.getModuleFlag("dx.allresourcesbound")))
433 if (AllResourcesBound->getValue().getBoolValue())
434 CSF.AllResourcesBound = true;
435
436 return CSF;
437}
438
439/// Construct ModuleShaderFlags for module Module M
441 const DXILResourceMap &DRM,
442 const ModuleMetadataInfo &MMDI,
443 const ModuleSignatureInfo &Signatures) {
444
445 CanSetResMayNotAlias = MMDI.DXILVersion >= VersionTuple(1, 7);
446 // The command line option -res-may-alias will set the dx.resmayalias module
447 // flag to 1, thereby disabling the ability to set the ResMayNotAlias flag
448 if (auto *ResMayAlias = mdconst::extract_or_null<ConstantInt>(
449 M.getModuleFlag("dx.resmayalias")))
450 if (ResMayAlias->getValue().getBoolValue())
451 CanSetResMayNotAlias = false;
452
453 ComputedShaderFlags GlobalSFMask = gatherGlobalModuleFlags(M, DRM, MMDI);
454
455 CallGraph CG(M);
456
457 // Compute Shader Flags Mask for all functions using post-order visit of SCC
458 // of the call graph.
459 for (scc_iterator<CallGraph *> SCCI = scc_begin(&CG); !SCCI.isAtEnd();
460 ++SCCI) {
461 const std::vector<CallGraphNode *> &CurSCC = *SCCI;
462
463 // Union of shader masks of all functions in CurSCC
465 // List of functions in CurSCC that are neither external nor declarations
466 // and hence whose flags are collected
467 SmallVector<Function *> CurSCCFuncs;
468 for (CallGraphNode *CGN : CurSCC) {
469 Function *F = CGN->getFunction();
470 if (!F)
471 continue;
472
473 if (F->isDeclaration()) {
474 assert(!F->getName().starts_with("dx.op.") &&
475 "DXIL Shader Flag analysis should not be run post-lowering.");
476 continue;
477 }
478
479 ComputedShaderFlags CSF = GlobalSFMask;
480 for (const auto &BB : *F)
481 for (const auto &I : BB)
482 updateFunctionFlags(CSF, I, DRTM, MMDI);
483 // An unused signature element still contributes to the shader's type
484 // requirements even when no instruction uses that component type.
485 if (const EntrySignature *Sig = Signatures.get(F)) {
486 CSF.Barycentrics |= llvm::any_of(Sig->Inputs, [](const auto &E) {
487 return E.SemanticKind == dxbc::PSV::SemanticKind::Barycentrics;
488 });
489 CSF.StencilRef |= llvm::any_of(Sig->Outputs, [](const auto &E) {
490 return E.SemanticKind == dxbc::PSV::SemanticKind::StencilRef;
491 });
492 // Only the pixel shader reads the index as an input, which does not
493 // require the feature.
494 if (Sig->Stage == Triple::Vertex)
495 CSF.ViewportAndRTArrayIndexFromAnyShaderFeedingRasterizer |=
496 llvm::any_of(Sig->Outputs, [](const auto &E) {
497 return E.SemanticKind ==
498 dxbc::PSV::SemanticKind::ViewPortArrayIndex ||
499 E.SemanticKind ==
500 dxbc::PSV::SemanticKind::RenderTargetArrayIndex;
501 });
502 // Unallocated elements do not occupy signature registers. Their type
503 // requirements come from the instructions that access them.
504 auto HasLowPrecision = [](const auto &Elements) {
505 return llvm::any_of(Elements, [](const auto &E) {
506 return E.isAllocated() && (E.CompType == ElementType::F16 ||
507 E.CompType == ElementType::I16 ||
508 E.CompType == ElementType::U16);
509 });
510 };
511 if (HasLowPrecision(Sig->Inputs) || HasLowPrecision(Sig->Outputs)) {
512 CSF.LowPrecisionPresent = true;
513 if (Sig->UseNative16Bit)
514 CSF.NativeLowPrecision = true;
515 else
516 CSF.MinimumPrecision = true;
517 }
518 // Declaring SV_ShadingRate in either signature requires the feature,
519 // regardless of whether it is accessed.
520 auto HasShadingRate = [](const auto &Elements) {
521 return llvm::any_of(Elements, [](const auto &E) {
522 return E.SemanticKind == dxbc::PSV::SemanticKind::ShadingRate;
523 });
524 };
525 if (HasShadingRate(Sig->Inputs) || HasShadingRate(Sig->Outputs))
526 CSF.ShadingRate = true;
527 }
528 // Update combined shader flags mask for all functions in this SCC
529 SCCSF.merge(CSF);
530
531 CurSCCFuncs.push_back(F);
532 }
533
534 // Update combined shader flags mask for all functions of the module
535 CombinedSFMask.merge(SCCSF);
536
537 // Shader flags mask of each of the functions in an SCC of the call graph is
538 // the union of all functions in the SCC. Update shader flags masks of
539 // functions in CurSCC accordingly. This is trivially true if SCC contains
540 // one function.
541 for (Function *F : CurSCCFuncs)
542 // Merge SCCSF with that of F
543 FunctionFlags[F].merge(SCCSF);
544 }
545}
546
548 uint64_t FlagVal = (uint64_t) * this;
549 OS << formatv("; Shader Flags Value: {0:x8}\n;\n", FlagVal);
550 if (FlagVal == 0)
551 return;
552 OS << "; Note: shader requires additional functionality:\n";
553#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleNum, FlagName, Str) \
554 if (FlagName) \
555 (OS << ";").indent(7) << Str << "\n";
556#include "llvm/BinaryFormat/DXContainerConstants.def"
557 OS << "; Note: extra DXIL module flags:\n";
558#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str) \
559 if (FlagName) \
560 (OS << ";").indent(7) << Str << "\n";
561#include "llvm/BinaryFormat/DXContainerConstants.def"
562 OS << ";\n";
563}
564
565/// Return the shader flags mask of the specified function Func.
568 auto Iter = FunctionFlags.find(Func);
569 assert((Iter != FunctionFlags.end() && Iter->first == Func) &&
570 "Get Shader Flags : No Shader Flags Mask exists for function");
571 return Iter->second;
572}
573
574//===----------------------------------------------------------------------===//
575// ShaderFlagsAnalysis and ShaderFlagsAnalysisPrinterPass
576
577// Provide an explicit template instantiation for the static ID.
578AnalysisKey ShaderFlagsAnalysis::Key;
579
591
594 const ModuleShaderFlags &FlagsInfo = AM.getResult<ShaderFlagsAnalysis>(M);
595 // Print description of combined shader flags for all module functions
596 OS << "; Combined Shader Flags for Module\n";
597 FlagsInfo.getCombinedFlags().print(OS);
598 // Print shader flags mask for each of the module functions
599 OS << "; Shader Flags for Module Functions\n";
600 for (const auto &F : M.getFunctionList()) {
601 if (F.isDeclaration())
602 continue;
603 const ComputedShaderFlags &SFMask = FlagsInfo.getFunctionFlags(&F);
604 OS << formatv("; Function {0} : {1:x8}\n;\n", F.getName(),
605 (uint64_t)(SFMask));
606 }
607
608 return PreservedAnalyses::all();
609}
610
611//===----------------------------------------------------------------------===//
612// ShaderFlagsAnalysis and ShaderFlagsAnalysisPrinterPass
613
615 DXILResourceTypeMap &DRTM =
616 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
617 DXILResourceMap &DRM =
618 getAnalysis<DXILResourceWrapperPass>().getResourceMap();
619 const ModuleMetadataInfo MMDI =
621
622 MSFI.initialize(M, DRTM, DRM, MMDI,
623 getAnalysis<SignatureAnalysisWrapper>().getSignatureInfo());
624 return false;
625}
626
634
636
638 "DXIL Shader Flag Analysis", true, true)
643 "DXIL Shader Flag Analysis", true, true)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
bool checkIfStatusIsExtracted(const IntrinsicInst &II)
static bool isOptimizationDisabled(const Module &M)
static bool hasUAVsAtEveryStage(const DXILResourceMap &DRM, const ModuleMetadataInfo &MMDI)
static bool hasLODClamp(const IntrinsicInst &II)
Returns true if the LOD clamp argument of II is neither constant zero nor undef.
static bool checkDoubleExtensionOps(Intrinsic::ID IID)
static bool checkAdvancedTextureOps(const IntrinsicInst &II)
Texture load and sample operations accept "programmable offsets", i.e.
static bool checkWaveOps(Intrinsic::ID IID)
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected components (SCCs) of a ...
This file defines the SmallVector class.
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()
void setPreservesAll()
Set by analyses that do not transform their input at all.
AnalysisUsage & addRequiredTransitive()
A node in the call graph for a module.
Definition CallGraph.h:162
The basic data container for the call graph of a Module of IR.
Definition CallGraph.h:72
iterator_range< iterator > uavs()
This instruction extracts a struct member or array element value from an aggregate value.
A wrapper class for inspecting calls to intrinsic functions.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
@ RayGeneration
Definition Triple.h:408
@ Amplification
Definition Triple.h:415
LLVM Value Representation.
Definition Value.h:75
Represents a version number in the form major[.minor[.subminor[.build]]].
const EntrySignature * get(const Function *F) const
LLVM_ABI bool isUAV() const
LLVM_ABI bool isSampler() const
LLVM_ABI bool isTyped() const
LLVM_ABI TypedInfo getTyped() const
dxil::ResourceKind getResourceKind() const
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Wrapper pass for the legacy pass manager.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
ModuleShaderFlags run(Module &M, ModuleAnalysisManager &AM)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
Enumerate the SCCs of a directed graph in reverse topological order of the SCC DAG.
Definition SCCIterator.h:48
bool isAtEnd() const
Direct loop termination test which is more efficient than comparison with end().
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
Definition Metadata.h:695
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
scc_iterator< T > scc_begin(const T &G)
Construct the begin iterator for a deduced graph type T.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1762
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
void merge(const ComputedShaderFlags CSF)
void print(raw_ostream &OS=dbgs()) const
Triple::EnvironmentType ShaderProfile
const ComputedShaderFlags & getFunctionFlags(const Function *) const
Return the shader flags mask of the specified function Func.
void initialize(Module &, DXILResourceTypeMap &DRTM, const DXILResourceMap &DRM, const ModuleMetadataInfo &MMDI, const ModuleSignatureInfo &Signatures)
Construct ModuleShaderFlags for module Module M.
const ComputedShaderFlags & getCombinedFlags() const