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