|
15 | 15 | #define LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H
|
16 | 16 |
|
17 | 17 | #include "llvm/Frontend/HLSL/HLSLRootSignature.h"
|
| 18 | +#include "llvm/MC/DXContainerRootSignature.h" |
| 19 | +#include "llvm/IR/Function.h" |
| 20 | +#include "llvm/Support/Error.h" |
| 21 | +#include <unordered_map> |
18 | 22 |
|
19 | 23 | namespace llvm {
|
20 | 24 | class LLVMContext;
|
@@ -49,6 +53,37 @@ class MetadataBuilder {
|
49 | 53 | SmallVector<Metadata *> GeneratedMetadata;
|
50 | 54 | };
|
51 | 55 |
|
| 56 | +enum class RootSignatureElementKind { |
| 57 | + Error = 0, |
| 58 | + RootFlags = 1, |
| 59 | + RootConstants = 2, |
| 60 | + SRV = 3, |
| 61 | + UAV = 4, |
| 62 | + CBV = 5, |
| 63 | + DescriptorTable = 6, |
| 64 | + StaticSamplers = 7 |
| 65 | +}; |
| 66 | + |
| 67 | +class MetadataParser { |
| 68 | +public: |
| 69 | + using MapT = SmallDenseMap<const Function *, llvm::mcdxbc::RootSignatureDesc>; |
| 70 | + MetadataParser(llvm::LLVMContext &Ctx, MDNode* Root): Ctx(Ctx), Root(Root) {} |
| 71 | + |
| 72 | + /// Iterates through root signature and converts them into MapT |
| 73 | + LLVM_ABI llvm::Expected<MapT*> ParseRootSignature(); |
| 74 | + |
| 75 | +private: |
| 76 | + llvm::Error parseRootFlags(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD, MDNode *RootFlagNode); |
| 77 | + llvm::Error parseRootConstants(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD, MDNode *RootConstantNode); |
| 78 | + llvm::Error parseRootDescriptors(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD, MDNode *RootDescriptorNode, RootSignatureElementKind ElementKind); |
| 79 | + llvm::Error parseDescriptorRange(LLVMContext *Ctx, mcdxbc::DescriptorTable &Table, MDNode *RangeDescriptorNode); |
| 80 | + llvm::Error parseDescriptorTable(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD, MDNode *DescriptorTableNode); |
| 81 | + llvm::Error parseRootSignatureElement(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD, MDNode *Element); |
| 82 | + llvm::Error parseStaticSampler(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD, MDNode *StaticSamplerNode); |
| 83 | + llvm::LLVMContext &Ctx; |
| 84 | + MDNode* Root; |
| 85 | +}; |
| 86 | + |
52 | 87 | } // namespace rootsig
|
53 | 88 | } // namespace hlsl
|
54 | 89 | } // namespace llvm
|
|
0 commit comments