LLVM: lib/Analysis/DXILMetadataAnalysis.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

19

20#define DEBUG_TYPE "dxil-metadata-analysis"

21

22using namespace llvm;

23using namespace dxil;

24

27 const Triple &TT = M.getTargetTriple();

31 NamedMDNode *ValidatorVerNode = M.getNamedMetadata("dx.valver");

32 if (ValidatorVerNode) {

37 VersionTuple(MajorMD->getZExtValue(), MinorMD->getZExtValue());

38 }

39

40

41 for (auto &F : M.functions()) {

42 if (F.hasFnAttribute("hlsl.shader"))

43 continue;

44

46

47 Attribute EntryAttr = F.getFnAttribute("hlsl.shader");

49 "Invalid value specified for HLSL function attribute hlsl.shader");

51 Triple T("", "", "", EntryProfile);

53

55 F.getFnAttribute("hlsl.numthreads").getValueAsString();

56 if (!NumThreadsStr.empty()) {

58 NumThreadsStr.split(NumThreadsVec, ',');

59 assert(NumThreadsVec.size() == 3 && "Invalid numthreads specified");

60

61 [[maybe_unused]] bool Success =

63 assert(Success && "Failed to parse X component of numthreads");

65 assert(Success && "Failed to parse Y component of numthreads");

67 assert(Success && "Failed to parse Z component of numthreads");

68 }

69

71 F.getFnAttribute("hlsl.wavesize").getValueAsString();

72 if (!WaveSizeStr.empty()) {

74 WaveSizeStr.split(WaveSizeVec, ',');

75 assert(WaveSizeVec.size() == 3 && "Invalid wavesize specified");

76

77 [[maybe_unused]] bool Success =

79 assert(Success && "Failed to parse Min component of wavesize");

81 assert(Success && "Failed to parse Max component of wavesize");

83 assert(Success && "Failed to parse Preferred component of wavesize");

84 }

86 }

87 return MMDAI;

88}

89

91 OS << "Shader Model Version : " << ShaderModelVersion.getAsString() << "\n";

92 OS << "DXIL Version : " << DXILVersion.getAsString() << "\n";

93 OS << "Target Shader Stage : "

95 OS << "Validator Version : " << ValidatorVersion.getAsString() << "\n";

97 OS << " " << EP.Entry->getName() << "\n";

98 OS << " Function Shader Stage : "

100 OS << " NumThreads: " << EP.NumThreadsX << "," << EP.NumThreadsY << ","

101 << EP.NumThreadsZ << "\n";

102 }

103}

104

105

106

107

108

110

115

119

120 Data.print(OS);

122}

123

124

125

126

129

131

136

141

143

145 const Module *) const {

146 if (!MetadataInfo) {

147 OS << "No module metadata info has been built!\n";

148 return;

149 }

150 MetadataInfo->print(dbgs());

151}

152

153#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

156#endif

157

159 "DXIL Module Metadata analysis", false, true)

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file implements a class to represent arbitrary precision integral constant values and operations...

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

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

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

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

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.

Functions, function parameters, and return types can have attributes to indicate how they should be t...

LLVM_ABI StringRef getValueAsString() const

Return the attribute's value as a string.

bool isValid() const

Return true if the attribute is any kind of attribute.

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

LLVM_ABI MDNode * getOperand(unsigned i) const

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.

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.

std::pair< StringRef, StringRef > split(char Separator) const

Split into two substrings around the first occurrence of a separator character.

constexpr bool empty() const

empty - Check if the string is empty.

Triple - Helper class for working with autoconf configuration names.

static LLVM_ABI StringRef getEnvironmentTypeName(EnvironmentType Kind)

Get the canonical name for the Kind environment.

Represents a version number in the form major[.minor[.subminor[.build]]].

This class implements an extremely fast bulk output stream that can only output to a stream.

unsigned ID

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

std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)

Extract a Value from Metadata.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

bool to_integer(StringRef S, N &Num, unsigned Base=0)

Convert the string S to an integer of the specified type using the radix Base. If Base is 0,...

AnalysisManager< Module > ModuleAnalysisManager

Convenience typedef for the Module analysis manager.

A special type used by analysis passes to provide an address that identifies that particular analysis...

Triple::EnvironmentType ShaderStage