24#include "llvm/IR/IntrinsicsDirectX.h"
40 CSF.Doubles =
I.getType()->isDoubleTy();
43 for (
const Value *
Op :
I.operands()) {
44 if (
Op->getType()->isDoubleTy()) {
52 switch (
I.getOpcode()) {
53 case Instruction::FDiv:
54 case Instruction::UIToFP:
55 case Instruction::SIToFP:
56 case Instruction::FPToUI:
57 case Instruction::FPToSI:
58 CSF.DX11_1_DoubleExtensions =
true;
63 if (
auto *
II = dyn_cast<IntrinsicInst>(&
I)) {
64 switch (
II->getIntrinsicID()) {
67 case Intrinsic::dx_resource_load_typedbuffer: {
69 DRTM[cast<TargetExtType>(
II->getArgOperand(0)->getType())];
76 if (
auto *CI = dyn_cast<CallInst>(&
I)) {
77 const Function *CF = CI->getCalledFunction();
79 if (FunctionFlags.contains(CF))
80 CSF.
merge(FunctionFlags[CF]);
95 const std::vector<CallGraphNode *> &CurSCC = *SCCI;
107 if (
F->isDeclaration()) {
108 assert(!
F->getName().starts_with(
"dx.op.") &&
109 "DXIL Shader Flag analysis should not be run post-lowering.");
114 for (
const auto &BB : *
F)
115 for (
const auto &
I : BB)
116 updateFunctionFlags(CSF,
I, DRTM);
124 CombinedSFMask.
merge(SCCSF);
132 FunctionFlags[
F].merge(SCCSF);
138 OS <<
formatv(
"; Shader Flags Value: {0:x8}\n;\n", FlagVal);
141 OS <<
"; Note: shader requires additional functionality:\n";
142#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleNum, FlagName, Str) \
144 (OS << ";").indent(7) << Str << "\n";
145#include "llvm/BinaryFormat/DXContainerConstants.def"
146 OS <<
"; Note: extra DXIL module flags:\n";
147#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str) \
149 (OS << ";").indent(7) << Str << "\n";
150#include "llvm/BinaryFormat/DXContainerConstants.def"
157 auto Iter = FunctionFlags.find(Func);
158 assert((Iter != FunctionFlags.end() && Iter->first == Func) &&
159 "Get Shader Flags : No Shader Flags Mask exists for function");
183 OS <<
"; Combined Shader Flags for Module\n";
186 OS <<
"; Shader Flags for Module Functions\n";
187 for (
const auto &
F : M.getFunctionList()) {
188 if (
F.isDeclaration())
191 OS <<
formatv(
"; Function {0} : {1:x8}\n;\n",
F.getName(),
203 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
217 "DXIL Shader Flag Analysis",
true,
true)
block Block Frequency Analysis
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
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)
This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected components (SCCs) of a ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
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()
A node in the call graph for a module.
The basic data container for the call graph of a Module of IR.
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.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
Enumerate the SCCs of a directed graph in reverse topological order of the SCC DAG.
This is an optimization pass for GlobalISel generic memory operations.
scc_iterator< T > scc_begin(const T &G)
Construct the begin iterator for a deduced graph type T.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
A special type used by analysis passes to provide an address that identifies that particular analysis...
void merge(const ComputedShaderFlags CSF)
void print(raw_ostream &OS=dbgs()) const
const ComputedShaderFlags & getFunctionFlags(const Function *) const
Return the shader flags mask of the specified function Func.
void initialize(Module &, DXILResourceTypeMap &DRTM)
Construct ModuleShaderFlags for module Module M.
const ComputedShaderFlags & getCombinedFlags() const