Skip to content

[DXIL][Analysis] Implement enough of DXILResourceAnalysis for buffers #100699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
13 changes: 8 additions & 5 deletions llvm/include/llvm/Analysis/DXILResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
namespace llvm {
class CallInst;
class MDTuple;
class TargetExtType;

namespace dxil {

class ResourceInfo {
struct ResourceBinding {
uint32_t UniqueID;
uint32_t RecordID;
uint32_t Space;
uint32_t LowerBound;
uint32_t Size;

bool operator==(const ResourceBinding &RHS) const {
return std::tie(UniqueID, Space, LowerBound, Size) ==
std::tie(RHS.UniqueID, RHS.Space, RHS.LowerBound, RHS.Size);
return std::tie(RecordID, Space, LowerBound, Size) ==
std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
}
bool operator!=(const ResourceBinding &RHS) const {
return !(*this == RHS);
Expand Down Expand Up @@ -128,9 +129,9 @@ class ResourceInfo {
bool isFeedback() const;
bool isMultiSample() const;

void bind(uint32_t UniqueID, uint32_t Space, uint32_t LowerBound,
void bind(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
uint32_t Size) {
Binding.UniqueID = UniqueID;
Binding.RecordID = RecordID;
Binding.Space = Space;
Binding.LowerBound = LowerBound;
Binding.Size = Size;
Expand Down Expand Up @@ -215,6 +216,8 @@ class ResourceInfo {

ResourceBinding getBinding() const { return Binding; }
std::pair<uint32_t, uint32_t> getAnnotateProps() const;

void print(raw_ostream &OS) const;
};

} // namespace dxil
Expand Down
10 changes: 10 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsDirectX.td
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ def int_dx_flattened_thread_id_in_group : Intrinsic<[llvm_i32_ty], [], [IntrNoMe
def int_dx_create_handle : ClangBuiltin<"__builtin_hlsl_create_handle">,
Intrinsic<[ llvm_ptr_ty ], [llvm_i8_ty], [IntrWillReturn]>;

// Create resource handle given binding information. Returns a `target("dx.")`
// type appropriate for the kind of resource given a register space ID, lower
// bound and range size of the binding, as well as an index and an indicator
// whether that index may be non-uniform.
def int_dx_handle_fromBinding
: DefaultAttrsIntrinsic<
[llvm_any_ty],
[llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i1_ty],
[IntrNoMem]>;

def int_dx_all : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty]>;
def int_dx_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty]>;
def int_dx_clamp : DefaultAttrsIntrinsic<[llvm_any_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
Expand Down
Loading
Loading