Skip to content

Commit f7e0032

Browse files
committed
[mlir][dxsa] Add dcl_hs_fork_phase_instance_count instruction
Example: dxsa.dcl_hs_fork_phase_instance_count 42 Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent 039bec8 commit f7e0032

5 files changed

Lines changed: 52 additions & 0 deletions

File tree

mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,4 +819,23 @@ def DXSA_DclHsJoinPhaseInstanceCount :
819819
let assemblyFormat = "$count attr-dict";
820820
}
821821

822+
def DXSA_DclHsForkPhaseInstanceCount :
823+
DXSA_Op<"dcl_hs_fork_phase_instance_count"> {
824+
let summary = "declares the Fork Phase instance count";
825+
let description = [{
826+
The `dxsa.dcl_hs_fork_phase_instance_count` operation declares
827+
the Fork Phase instance count.
828+
829+
The `$count` must be a positive 32-bit unsigned integer in the range [1, 2^32 - 1].
830+
831+
Example:
832+
833+
```mlir
834+
dxsa.dcl_hs_fork_phase_instance_count 42
835+
```
836+
}];
837+
let arguments = (ins ConfinedAttr<UI32Attr, [DXSA_UIntNonZero]>:$count);
838+
let assemblyFormat = "$count attr-dict";
839+
}
840+
822841
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@ class DXBuilder {
664664
builder, loc, builder.getUI32IntegerAttr(count));
665665
}
666666

667+
Instruction buildDclHsForkPhaseInstanceCount(uint32_t count, Location loc) {
668+
return dxsa::DclHsForkPhaseInstanceCount::create(
669+
builder, loc, builder.getUI32IntegerAttr(count));
670+
}
671+
667672
private:
668673
MLIRContext *context;
669674
ModuleOp module;
@@ -1240,6 +1245,12 @@ class Parser {
12401245
return builder.buildDclHsJoinPhaseInstanceCount(*count, loc);
12411246
}
12421247

1248+
FailureOr<Instruction> parseDclHsForkPhaseInstanceCount(Location loc) {
1249+
auto count = parseToken();
1250+
FAILURE_IF_FAILED(count);
1251+
return builder.buildDclHsForkPhaseInstanceCount(*count, loc);
1252+
}
1253+
12431254
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
12441255
Instruction &out) {
12451256
FailureOr<Instruction> result;
@@ -1301,6 +1312,9 @@ class Parser {
13011312
case D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT:
13021313
result = parseDclHsJoinPhaseInstanceCount(loc);
13031314
break;
1315+
case D3D11_SB_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT:
1316+
result = parseDclHsForkPhaseInstanceCount(loc);
1317+
break;
13041318
default:
13051319
return std::nullopt;
13061320
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_hs_fork_phase_instance_count.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_hs_fork_phase_instance_count 42
5+
// CHECK-NEXT: }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2+
3+
// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit unsigned integer attribute whose value is non-zero}}
4+
dxsa.dcl_hs_fork_phase_instance_count 0
5+
6+
// -----
7+
8+
// expected-error@+1 {{negative integer literal not valid for unsigned integer type}}
9+
dxsa.dcl_hs_fork_phase_instance_count -1
10+
11+
// -----
12+
13+
// expected-error@+1 {{integer constant out of range for attribute}}
14+
dxsa.dcl_hs_fork_phase_instance_count 4294967296
Binary file not shown.

0 commit comments

Comments
 (0)