Skip to content
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

[DirectX] Lower @llvm.dx.typedBufferStore to DXIL ops #104253

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions llvm/docs/DirectX/DXILOpTableGenDesign.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,14 @@ properties are specified as fields of the ``DXILOp`` class as described below.
class DXILOpClass;

Concrete operation records, such as ``unary`` are defined by inheriting from ``DXILOpClass``.
6. Return type of the operation is represented as ``LLVMType``.
7. Operation arguments are represented as a list of ``LLVMType`` with each type
corresponding to the argument position. An overload type, if supported by the operation, is
denoted as the positional type ``overloadTy`` in the argument or in the result, where
``overloadTy`` is defined to be synonymous to ``llvm_any_ty``.

.. code-block::

defvar overloadTy = llvm_any_ty

Empty list, ``[]`` represents an operation with no arguments.

6. A set of type names are defined that represent return and argument types,
which all inherit from ``DXILOpParamType``. These represent simple types
like ``int32Ty``, DXIL types like ``dx.types.Handle``, and a special
``overloadTy`` which can be any type allowed by ``Overloads``, described
below.
7. Operation return type is represented as a ``DXILOpParamType``, and arguments
are represented as a list of the same. An operation with no return value
shall specify ``VoidTy`` as its return.
8. Valid operation overload types predicated on DXIL version are specified as
a list of ``Overloads`` records. Representation of ``Overloads``
class is described in a later section.
Expand Down Expand Up @@ -145,10 +141,10 @@ TableGen representations of its properties described above.
Intrinsic LLVMIntrinsic = ?;

// Result type of the op.
LLVMType result;
DXILOpParamType result;

// List of argument types of the op. Default to 0 arguments.
list<LLVMType> arguments = [];
list<DXILOpParamType> arguments = [];

// List of valid overload types predicated by DXIL version
list<Overloads> overloads;
Expand Down Expand Up @@ -233,9 +229,9 @@ overloads predicated on DXIL version as list of records of the following class

.. code-block::

class Overloads<Version minver, list<LLVMType> ols> {
class Overloads<Version minver, list<DXILOpParamType> ols> {
Version dxil_version = minver;
list<LLVMType> overload_types = ols;
list<DXILOpParamType> overload_types = ols;
}

Following is an example specification of valid overload types for ``DXIL1_0`` and
Expand Down
6 changes: 3 additions & 3 deletions llvm/docs/DirectX/DXILResources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,11 @@ Examples:

.. code-block:: llvm

call void @llvm.dx.bufferStore.tdx.Buffer_f32_1_0t(
call void @llvm.dx.typedBufferStore.tdx.Buffer_v4f32_1_0_0t(
target("dx.TypedBuffer", f32, 1, 0) %buf, i32 %index, <4 x f32> %data)
call void @llvm.dx.bufferStore.tdx.Buffer_f16_1_0t(
call void @llvm.dx.typedBufferStore.tdx.Buffer_v4f16_1_0_0t(
target("dx.TypedBuffer", f16, 1, 0) %buf, i32 %index, <4 x f16> %data)
call void @llvm.dx.bufferStore.tdx.Buffer_f64_1_0t(
call void @llvm.dx.typedBufferStore.tdx.Buffer_v2f64_1_0_0t(
target("dx.TypedBuffer", f64, 1, 0) %buf, i32 %index, <2 x f64> %data)

.. list-table:: ``@llvm.dx.rawBufferPtr``
Expand Down
8 changes: 8 additions & 0 deletions llvm/include/llvm/Analysis/DXILResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TargetExtType;
namespace dxil {

class ResourceInfo {
public:
struct ResourceBinding {
uint32_t RecordID;
uint32_t Space;
Expand Down Expand Up @@ -89,6 +90,7 @@ class ResourceInfo {
bool operator!=(const FeedbackInfo &RHS) const { return !(*this == RHS); }
};

private:
// Universal properties.
Value *Symbol;
StringRef Name;
Expand All @@ -115,6 +117,10 @@ class ResourceInfo {

MSInfo MultiSample;

// We need a default constructor if we want to insert this in a MapVector.
ResourceInfo() {}
friend class MapVector<CallInst *, ResourceInfo>;

public:
ResourceInfo(dxil::ResourceClass RC, dxil::ResourceKind Kind, Value *Symbol,
StringRef Name)
Expand Down Expand Up @@ -166,6 +172,8 @@ class ResourceInfo {
MultiSample.Count = Count;
}

dxil::ResourceClass getResourceClass() const { return RC; }

bool operator==(const ResourceInfo &RHS) const;

static ResourceInfo SRV(Value *Symbol, StringRef Name,
Expand Down
8 changes: 8 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsDirectX.td
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def int_dx_handle_fromBinding
[llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i1_ty],
[IntrNoMem]>;

def int_dx_typedBufferLoad
: DefaultAttrsIntrinsic<[llvm_anyvector_ty], [llvm_any_ty, llvm_i32_ty]>;
def int_dx_typedBufferStore
: DefaultAttrsIntrinsic<[], [llvm_any_ty, llvm_i32_ty, llvm_anyvector_ty]>;

// Cast between target extension handle types and dxil-style opaque handles
def int_dx_cast_handle : Intrinsic<[llvm_any_ty], [llvm_any_ty]>;

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
17 changes: 0 additions & 17 deletions llvm/include/llvm/Support/DXILABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,6 @@
namespace llvm {
namespace dxil {

enum class ParameterKind : uint8_t {
Invalid = 0,
Void,
Half,
Float,
Double,
I1,
I8,
I16,
I32,
I64,
Overload,
CBufferRet,
ResourceRet,
DXILHandle,
};

enum class ResourceClass : uint8_t {
SRV = 0,
UAV,
Expand Down
Loading
Loading