LLVM: lib/Target/DirectX/DXContainerGlobals.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

29

30using namespace llvm;

33

34namespace {

36

45 void addPipelineStateValidationInfo(Module &M,

47

48public:

49 static char ID;

52 }

53

55 return "DXContainer Global Emitter";

56 }

57

59

66 }

67};

68

69}

70

71bool DXContainerGlobals::runOnModule(Module &M) {

73 Globals.push_back(getFeatureFlags(M));

74 Globals.push_back(computeShaderHash(M));

75 addSignature(M, Globals);

76 addPipelineStateValidationInfo(M, Globals);

78 return true;

79}

80

82 uint64_t CombinedFeatureFlags = getAnalysis()

83 .getShaderFlags()

84 .getCombinedFlags()

85 .getFeatureFlags();

86

87 Constant *FeatureFlagsConstant =

88 ConstantInt::get(M.getContext(), APInt(64, CombinedFeatureFlags));

89 return buildContainerGlobal(M, FeatureFlagsConstant, "dx.sfi0", "SFI0");

90}

91

93 auto *DXILConstant =

94 cast(M.getNamedGlobal("dx.dxil")->getInitializer());

95 MD5 Digest;

96 Digest.update(DXILConstant->getRawDataValues());

98

100

101

102 if (M.debug_compile_units_begin() != M.debug_compile_units_end())

103 HashData.Flags = static_cast<uint32_t>(dxbc::HashFlags::IncludesSource);

104

105 memcpy(reinterpret_cast<void *>(&HashData.Digest), Result.data(), 16);

109

112 return buildContainerGlobal(M, ModuleConstant, "dx.hash", "HASH");

113}

114

115GlobalVariable *DXContainerGlobals::buildContainerGlobal(

120 GV->setAlignment(Align(4));

121 return GV;

122}

123

133}

134

135void DXContainerGlobals::addSignature(Module &M,

137

138

139

141 Globals.emplace_back(buildSignature(M, InputSig, "dx.isg1", "ISG1"));

142

144 Globals.emplace_back(buildSignature(M, OutputSig, "dx.osg1", "OSG1"));

145}

146

149 getAnalysis().getBindingMap();

151 getAnalysis().getResourceTypeMap();

152

155 RBI.getBinding();

160

163 bool IsUAV = TypeInfo.getResourceClass() == dxil::ResourceClass::UAV;

165 case dxil::ResourceKind::Sampler:

166 ResType = dxbc::PSV::ResourceType::Sampler;

167 break;

168 case dxil::ResourceKind::CBuffer:

169 ResType = dxbc::PSV::ResourceType::CBV;

170 break;

171 case dxil::ResourceKind::StructuredBuffer:

172 ResType = IsUAV ? dxbc::PSV::ResourceType::UAVStructured

173 : dxbc::PSV::ResourceType::SRVStructured;

175 ResType = dxbc::PSV::ResourceType::UAVStructuredWithCounter;

176 break;

177 case dxil::ResourceKind::RTAccelerationStructure:

178 ResType = dxbc::PSV::ResourceType::SRVRaw;

179 break;

180 case dxil::ResourceKind::RawBuffer:

181 ResType = IsUAV ? dxbc::PSV::ResourceType::UAVRaw

182 : dxbc::PSV::ResourceType::SRVRaw;

183 break;

184 default:

185 ResType = IsUAV ? dxbc::PSV::ResourceType::UAVTyped

186 : dxbc::PSV::ResourceType::SRVTyped;

187 break;

188 }

189 BindInfo.Type = ResType;

190

191 BindInfo.Kind =

193

194

196

197 PSV.Resources.emplace_back(BindInfo);

198 }

199}

200

201void DXContainerGlobals::addPipelineStateValidationInfo(

208

210 getAnalysis().getModuleMetadata();

215

216 addResourcesForPSV(M, PSV);

217

218

219

220

221

222

228 break;

229 default:

230 break;

231 }

232

235

241}

242

243char DXContainerGlobals::ID = 0;

245 "DXContainer Global Emitter", false, true)

252

254 return new DXContainerGlobals();

255}

This file contains the declarations for the subclasses of Constant, which represent the different fla...

dxil DXContainer Global Emitter

Module.h This file contains the declarations for the Module class.

#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())

This file defines the SmallVector class.

Class for arbitrary precision integers.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

void setPreservesAll()

Set by analyses that do not transform their input at all.

static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)

This method constructs a CDS and initializes it with a text string.

static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)

get() constructor - Return a constant with array type with an element count and element type matching...

This is an important base class in LLVM.

@ PrivateLinkage

Like Internal, but omit from symbol table.

void update(ArrayRef< uint8_t > Data)

Updates the hash for the byte stream provided.

void final(MD5Result &Result)

Finishes off the hash and puts the result in result.

ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...

virtual bool runOnModule(Module &M)=0

runOnModule - Virtual method overriden by subclasses to process the module being operated on.

A Module instance is used to store all the information related to an LLVM module.

static PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

virtual void getAnalysisUsage(AnalysisUsage &) const

getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...

virtual StringRef getPassName() const

getPassName - Return a nice clean name for a pass.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

reference emplace_back(ArgTypes &&... Args)

void push_back(const T &Elt)

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.

dxil::ResourceClass getResourceClass() const

dxil::ResourceKind getResourceKind() const

Wrapper pass for the legacy pass manager.

void write(raw_ostream &OS)

A raw_ostream that writes to an SmallVector or SmallString.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

constexpr bool IsBigEndianHost

This is an optimization pass for GlobalISel generic memory operations.

ModulePass * createDXContainerGlobalsPass()

Pass for generating DXContainer part globals.

@ Global

Append to llvm.global_dtors.

void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)

Adds global values to the llvm.compiler.used list.

void initializeDXContainerGlobalsPass(PassRegistry &)

Initializer for DXContainerGlobals pass.

This struct is a compact representation of a valid (non-zero power of two) alignment.

uint32_t MaximumWaveLaneCount

uint32_t MinimumWaveLaneCount

dxbc::PSV::v3::RuntimeInfo BaseData

llvm::StringRef EntryName

SmallVector< dxbc::PSV::v2::ResourceBindInfo > Resources

void finalize(Triple::EnvironmentType Stage)

void write(raw_ostream &OS, uint32_t Version=std::numeric_limits< uint32_t >::max()) const