21#include "llvm/IR/IntrinsicsDirectX.h"
33 CSF.Doubles =
I.getType()->isDoubleTy();
37 CSF.Doubles |=
Op->getType()->isDoubleTy();
40 switch (
I.getOpcode()) {
41 case Instruction::FDiv:
42 case Instruction::UIToFP:
43 case Instruction::SIToFP:
44 case Instruction::FPToUI:
45 case Instruction::FPToSI:
48 CSF.DX11_1_DoubleExtensions =
true;
53 if (
auto *
II = dyn_cast<IntrinsicInst>(&
I)) {
54 switch (
II->getIntrinsicID()) {
57 case Intrinsic::dx_resource_load_typedbuffer: {
59 DRTM[cast<TargetExtType>(
II->getArgOperand(0)->getType())];
70 for (
const auto &
F : M.getFunctionList()) {
71 if (
F.isDeclaration()) {
72 assert(!
F.getName().starts_with(
"dx.op.") &&
73 "DXIL Shader Flag analysis should not be run post-lowering.");
77 for (
const auto &BB :
F)
78 for (
const auto &
I : BB)
81 FunctionFlags.push_back({&
F, CSF});
83 CombinedSFMask.
merge(CSF);
90 OS <<
formatv(
"; Shader Flags Value: {0:x8}\n;\n", FlagVal);
93 OS <<
"; Note: shader requires additional functionality:\n";
94#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleNum, FlagName, Str) \
96 (OS << ";").indent(7) << Str << "\n";
97#include "llvm/BinaryFormat/DXContainerConstants.def"
98 OS <<
"; Note: extra DXIL module flags:\n";
99#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str) \
101 (OS << ";").indent(7) << Str << "\n";
102#include "llvm/BinaryFormat/DXContainerConstants.def"
111 [](
const std::pair<const Function *, ComputedShaderFlags> FSM,
112 const Function *FindFunc) {
return (FSM.first < FindFunc); });
113 assert((Iter != FunctionFlags.end() && Iter->first == Func) &&
114 "No Shader Flags Mask exists for function");
138 OS <<
"; Combined Shader Flags for Module\n";
141 OS <<
"; Shader Flags for Module Functions\n";
142 for (
const auto &
F : M.getFunctionList()) {
143 if (
F.isDeclaration())
146 OS <<
formatv(
"; Function {0} : {1:x8}\n;\n",
F.getName(),
158 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
172 "DXIL Shader Flag Analysis",
true,
true)
block Block Frequency Analysis
static void updateFunctionFlags(ComputedShaderFlags &CSF, const Instruction &I, DXILResourceTypeMap &DRTM)
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
#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())
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.
void setPreservesAll()
Set by analyses that do not transform their input at all.
AnalysisUsage & addRequiredTransitive()
This class represents an Operation in the Expression.
A Module instance is used to store all the information related to an LLVM module.
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.
LLVM Value Representation.
TypedInfo getTyped() 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.
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
A special type used by analysis passes to provide an address that identifies that particular analysis...
void merge(const uint64_t IVal)
void print(raw_ostream &OS=dbgs()) const
const ComputedShaderFlags & getFunctionFlags(const Function *) const
Return the shader flags mask of the specified function Func.
const ComputedShaderFlags & getCombinedFlags() const
void initialize(const Module &, DXILResourceTypeMap &DRTM)