llvm / llvm/llvm-project

[DirectX] Validate constant DXIL op arguments

Open
#217,423 3 comments 0 reactions 0 assignees View on GitHub
backend:DirectX
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Certain arguments of DXIL operations are expected to be constant, and we need to validate that.

For example, the binding register, space and binding size on `dx.op.createHandle` need to be constant and known at compile time, and the same for `isSamplerHeap` argument on `dx.op.createHandleFromHeap`.

We can validate that at LLVM intrinsics level by marking each argument that needs to be constant with `ImmArg` in `IntrinsicsDirectX.td`.

For example this makes sure the first three arguments of `llvm.dx.resource.handlefrombinding` are constant values (the space, register lower bound, and range size):
```
def int_dx_resource_handlefrombinding
: DefaultAttrsIntrinsic<
[llvm_any_ty],
[llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty],
[IntrNoMem, ImmArg>, ImmArg>, ImmArg>]>;
```

We need to review all of the LLVM intrinsics we have added so far and mark their arguments which are required to be constant.

Contributor guide

Open the contributing guide

Research direction

Start in IntrinsicsDirectX.td and review the LLVM DirectX intrinsics added so far, using the llvm.dx.resource.handlefrombinding example as a guide. Identify arguments that must be compile-time constants and mark them with ImmArg; done means all required constant arguments are represented in the intrinsic definitions.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.