1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
//===- DXILRootSignature.h - DXIL Root Signature helper objects -----------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file This file contains helper objects and APIs for working with DXIL
/// Root Signatures.
///
//===----------------------------------------------------------------------===//
#include "llvm/ADT/DenseMap.h"
#include "llvm/Analysis/DXILMetadataAnalysis.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Pass.h"
#include <optional>
namespace llvm {
namespace dxil {
enum class RootSignatureElementKind {
Error = 0,
RootFlags = 1,
RootConstants = 2,
SRV = 3,
UAV = 4,
CBV = 5,
DescriptorTable = 6,
StaticSamplers = 7
};
class RootSignatureAnalysis : public AnalysisInfoMixin<RootSignatureAnalysis> {
friend AnalysisInfoMixin<RootSignatureAnalysis>;
static AnalysisKey Key;
public:
RootSignatureAnalysis() = default;
using Result = SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc>;
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc>
run(Module &M, ModuleAnalysisManager &AM);
};
/// Wrapper pass for the legacy pass manager.
///
/// This is required because the passes that will depend on this are codegen
/// passes which run through the legacy pass manager.
class RootSignatureAnalysisWrapper : public ModulePass {
private:
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc> FuncToRsMap;
public:
static char ID;
RootSignatureAnalysisWrapper() : ModulePass(ID) {}
using iterator =
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc>::iterator;
iterator find(const Function *F) { return FuncToRsMap.find(F); }
iterator end() { return FuncToRsMap.end(); }
bool runOnModule(Module &M) override;
void getAnalysisUsage(AnalysisUsage &AU) const override;
};
/// Printer pass for RootSignatureAnalysis results.
class RootSignatureAnalysisPrinter
: public PassInfoMixin<RootSignatureAnalysisPrinter> {
raw_ostream &OS;
public:
explicit RootSignatureAnalysisPrinter(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};
} // namespace dxil
} // namespace llvm
|