26#include "llvm/IR/IntrinsicsDirectX.h"
42 CSF.Doubles =
I.getType()->isDoubleTy();
45 for (
const Value *
Op :
I.operands()) {
46 if (
Op->getType()->isDoubleTy()) {
54 switch (
I.getOpcode()) {
55 case Instruction::FDiv:
56 case Instruction::UIToFP:
57 case Instruction::SIToFP:
58 case Instruction::FPToUI:
59 case Instruction::FPToSI:
60 CSF.DX11_1_DoubleExtensions =
true;
65 if (
auto *
II = dyn_cast<IntrinsicInst>(&
I)) {
66 switch (
II->getIntrinsicID()) {
69 case Intrinsic::dx_resource_handlefrombinding:
70 switch (DRTM[cast<TargetExtType>(
II->getType())].getResourceKind()) {
73 CSF.EnableRawAndStructuredBuffers =
true;
79 case Intrinsic::dx_resource_load_typedbuffer: {
81 DRTM[cast<TargetExtType>(
II->getArgOperand(0)->getType())];
89 if (
auto *CI = dyn_cast<CallInst>(&
I)) {
90 const Function *CF = CI->getCalledFunction();
92 if (FunctionFlags.contains(CF))
93 CSF.
merge(FunctionFlags[CF]);
109 const std::vector<CallGraphNode *> &CurSCC = *SCCI;
121 if (
F->isDeclaration()) {
122 assert(!
F->getName().starts_with(
"dx.op.") &&
123 "DXIL Shader Flag analysis should not be run post-lowering.");
128 for (
const auto &BB : *
F)
129 for (
const auto &
I : BB)
130 updateFunctionFlags(CSF,
I, DRTM);
138 CombinedSFMask.
merge(SCCSF);
146 FunctionFlags[
F].merge(SCCSF);
152 CombinedSFMask.DisableOptimizations =
154 llvm::Attribute::OptimizeNone);
157 if (CombinedSFMask.DisableOptimizations !=
158 EntryFunProps.Entry->hasFnAttribute(llvm::Attribute::OptimizeNone))
160 *(EntryFunProps.Entry),
"Inconsistent optnone attribute "));
166 OS <<
formatv(
"; Shader Flags Value: {0:x8}\n;\n", FlagVal);
169 OS <<
"; Note: shader requires additional functionality:\n";
170#define SHADER_FEATURE_FLAG(FeatureBit, DxilModuleNum, FlagName, Str) \
172 (OS << ";").indent(7) << Str << "\n";
173#include "llvm/BinaryFormat/DXContainerConstants.def"
174 OS <<
"; Note: extra DXIL module flags:\n";
175#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str) \
177 (OS << ";").indent(7) << Str << "\n";
178#include "llvm/BinaryFormat/DXContainerConstants.def"
185 auto Iter = FunctionFlags.find(Func);
186 assert((Iter != FunctionFlags.end() && Iter->first == Func) &&
187 "Get Shader Flags : No Shader Flags Mask exists for function");
212 OS <<
"; Combined Shader Flags for Module\n";
215 OS <<
"; Shader Flags for Module Functions\n";
216 for (
const auto &
F : M.getFunctionList()) {
217 if (
F.isDeclaration())
220 OS <<
formatv(
"; Function {0} : {1:x8}\n;\n",
F.getName(),
232 getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
234 getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
249 "DXIL Shader Flag Analysis",
true,
true)
This file contains the simple types necessary to represent the attributes associated with functions a...
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.
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.
The basic data container for the call graph of a Module of IR.
This class represents an Operation in the Expression.
Diagnostic information for unsupported feature in backend.
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.
const ComputedShaderFlags & getCombinedFlags() const
void initialize(Module &, DXILResourceTypeMap &DRTM, const ModuleMetadataInfo &MMDI)
Construct ModuleShaderFlags for module Module M.