LLVM 24.0.0git
DXILSignatureAnalysis.h
Go to the documentation of this file.
1//===- DXILSignatureAnalysis.h - DXIL semantic signatures -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_TARGET_DIRECTX_DXILSIGNATUREANALYSIS_H
10#define LLVM_LIB_TARGET_DIRECTX_DXILSIGNATUREANALYSIS_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/StringSet.h"
15#include "llvm/IR/PassManager.h"
16#include "llvm/Pass.h"
18
19namespace llvm {
20class MDTuple;
21namespace mcdxbc {
22class Signature;
23struct PSVRuntimeInfo;
24} // namespace mcdxbc
25
26namespace dxil {
27
32 unsigned InputVectors = 0;
33 unsigned OutputVectors = 0;
35 bool UseNative16Bit = false;
36
37 /// Return the DXIL input/output/patch-constant signature triple. Empty input
38 /// and output lists become null operands; return null if both lists are
39 /// empty. ValidatorVersion controls which access-mask properties are emitted.
40 MDTuple *getAsMetadata(LLVMContext &Ctx, VersionTuple ValidatorVersion) const;
41
42 /// Append ISG1/OSG1 parameters to the supplied builders. ValidatorVersion
43 /// selects legacy component-type and exclusive-mask encoding conventions.
45 VersionTuple ValidatorVersion) const;
46
47 /// Append PSV signature elements and set vector extents, the dependency map,
48 /// and stage-specific signature flags. Does not finalize or serialize PSV.
50 VersionTuple ValidatorVersion) const;
51
52 /// Return the serialized dx.viewIdState words for this entry: input scalar
53 /// count, output scalar count, then the input/output dependency table. Scalar
54 /// counts include padding and equal four times the respective vector extent.
55 /// Each input scalar has ceil(output scalar count / 32) consecutive words,
56 /// where bit (4 * row + column) identifies an output scalar.
58 void print(raw_ostream &OS) const;
59};
60
62public:
68
71
72 const EntrySignature *get(const Function *F) const {
73 auto It = Entries.find(F);
74 return It == Entries.end() ? nullptr : &It->second;
75 }
76 void print(raw_ostream &OS, const Module &M) const;
77};
78
79class SignatureAnalysis : public AnalysisInfoMixin<SignatureAnalysis> {
81 static AnalysisKey Key;
82
83public:
86};
87
89 std::unique_ptr<ModuleSignatureInfo> Info;
90
91public:
92 static char ID;
94 const ModuleSignatureInfo &getSignatureInfo() const { return *Info; }
95 bool runOnModule(Module &M) override;
96 void getAnalysisUsage(AnalysisUsage &AU) const override;
97 void releaseMemory() override { Info.reset(); }
98 void print(raw_ostream &OS, const Module *M) const override;
99};
100
102 : public OptionalPassInfoMixin<SignatureAnalysisPrinter> {
103 raw_ostream &OS;
104
105public:
106 explicit SignatureAnalysisPrinter(raw_ostream &OS) : OS(OS) {}
108};
109
110} // namespace dxil
111} // namespace llvm
112
113#endif
This file defines the DenseMap class.
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
StringSet - A set-like wrapper for the StringMap.
Defines the llvm::VersionTuple class, which represents a version in the form major[....
The Input class is used to parse a yaml document into in-memory structs and vectors.
Represent the analysis usage information of a pass.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:71
Tuple of metadata.
Definition Metadata.h:1496
ModulePass(char &pid)
Definition Pass.h:257
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition StringSet.h:25
Represents a version number in the form major[.minor[.subminor[.build]]].
ModuleSignatureInfo(ModuleSignatureInfo &&)=default
const EntrySignature * get(const Function *F) const
ModuleSignatureInfo & operator=(ModuleSignatureInfo &&)=default
void print(raw_ostream &OS, const Module &M) const
ModuleSignatureInfo(const ModuleSignatureInfo &)=delete
DenseMap< const Function *, EntrySignature > Entries
ModuleSignatureInfo & operator=(const ModuleSignatureInfo &)=delete
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void print(raw_ostream &OS, const Module *M) const override
print - Print out the internal state of the pass.
const ModuleSignatureInfo & getSignatureInfo() const
Result run(Module &M, ModuleAnalysisManager &AM)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
A CRTP mix-in for passes that can be skipped.
SmallVector< hlsl::SemanticSignatureElement > Inputs
Triple::EnvironmentType Stage
void buildSignatures(mcdxbc::Signature &Input, mcdxbc::Signature &Output, VersionTuple ValidatorVersion) const
Append ISG1/OSG1 parameters to the supplied builders.
SmallVector< hlsl::SemanticSignatureElement > Outputs
void updatePSV(mcdxbc::PSVRuntimeInfo &PSV, VersionTuple ValidatorVersion) const
Append PSV signature elements and set vector extents, the dependency map, and stage-specific signatur...
MDTuple * getAsMetadata(LLVMContext &Ctx, VersionTuple ValidatorVersion) const
Return the DXIL input/output/patch-constant signature triple.
SmallVector< uint32_t > getDependencyState() const
Return the serialized dx.viewIdState words for this entry: input scalar count, output scalar count,...
SmallVector< uint32_t > InputOutputMap
void print(raw_ostream &OS) const