1//===- HLSLResource.h - HLSL Resource helper objects ----------------------===//
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/// \file This file contains helper objects for working with HLSL Resources.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_FRONTEND_HLSL_HLSLRESOURCE_H
14#define LLVM_FRONTEND_HLSL_HLSLRESOURCE_H
15
16#include "llvm/IR/Metadata.h"
17#include "llvm/Support/DXILABI.h"
18
19namespace llvm {
20class GlobalVariable;
21
22namespace hlsl {
23
24enum class ResourceClass : uint8_t {
25 SRV = 0,
26 UAV,
27 CBuffer,
28 Sampler,
29 Invalid,
30 NumClasses = Invalid,
31};
32
33// For now we use DXIL ABI enum values directly. This may change in the future.
34using dxil::ElementType;
35using dxil::ResourceKind;
36
37class FrontendResource {
38 MDNode *Entry;
39
40public:
41 FrontendResource(MDNode *E) : Entry(E) {
42 assert(Entry->getNumOperands() == 6 && "Unexpected metadata shape");
43 }
44
45 FrontendResource(GlobalVariable *GV, ResourceKind RK, ElementType ElTy,
46 bool IsROV, uint32_t ResIndex, uint32_t Space);
47
48 GlobalVariable *getGlobalVariable();
49 StringRef getSourceType();
50 ResourceKind getResourceKind();
51 ElementType getElementType();
52 bool getIsROV();
53 uint32_t getResourceIndex();
54 uint32_t getSpace();
55 MDNode *getMetadata() { return Entry; }
56};
57} // namespace hlsl
58} // namespace llvm
59
60#endif // LLVM_FRONTEND_HLSL_HLSLRESOURCE_H
61

source code of llvm/include/llvm/Frontend/HLSL/HLSLResource.h