Skip to content

Commit d3a9b2b

Browse files
committed
[mlir][dxsa] Add dcl_hs_join_phase_instance_count instruction
Example: dxsa.dcl_hs_join_phase_instance_count 42 Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent 014c7b3 commit d3a9b2b

5 files changed

Lines changed: 62 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,16 @@ def DXSA_ComponentMaskAttr :
281281
let assemblyFormat = "`<` $value `>`";
282282
}
283283

284+
//===----------------------------------------------------------------------===//
285+
// DXSA attribute Constraints
286+
//===----------------------------------------------------------------------===//
287+
288+
// This constraint does not treat the most significant bit as a sign bit,
289+
// so it is safe to use on unsigned integer attributes.
290+
def DXSA_UIntNonZero : AttrConstraint<
291+
CPred<"!::llvm::cast<::mlir::IntegerAttr>($_self).getValue().isZero()">,
292+
"whose value is non-zero">;
293+
284294
//===----------------------------------------------------------------------===//
285295
// DXSA op definitions
286296
//===----------------------------------------------------------------------===//
@@ -719,4 +729,23 @@ def DXSA_DclOutput : DXSA_Op<"dcl_output"> {
719729
let assemblyFormat = "$operand attr-dict";
720730
}
721731

732+
def DXSA_DclHsJoinPhaseInstanceCount :
733+
DXSA_Op<"dcl_hs_join_phase_instance_count"> {
734+
let summary = "declares the Join Phase instance count";
735+
let description = [{
736+
The `dxsa.dcl_hs_join_phase_instance_count` operation declares
737+
the Join Phase instance count.
738+
739+
The `$count` must be a positive 32-bit unsigned integer in the range [1, 2^32 - 1].
740+
741+
Example:
742+
743+
```mlir
744+
dxsa.dcl_hs_join_phase_instance_count 42
745+
```
746+
}];
747+
let arguments = (ins ConfinedAttr<UI32Attr, [DXSA_UIntNonZero]>:$count);
748+
let assemblyFormat = "$count attr-dict";
749+
}
750+
722751
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,11 @@ class DXBuilder {
635635
return dxsa::DclOutput::create(builder, loc, operand);
636636
}
637637

638+
Instruction buildDclHsJoinPhaseInstanceCount(uint32_t count, Location loc) {
639+
return dxsa::DclHsJoinPhaseInstanceCount::create(
640+
builder, loc, builder.getUI32IntegerAttr(count));
641+
}
642+
638643
private:
639644
MLIRContext *context;
640645
ModuleOp module;
@@ -1174,6 +1179,12 @@ class Parser {
11741179
return builder.buildDclOutput(*operand, loc);
11751180
}
11761181

1182+
FailureOr<Instruction> parseDclHsJoinPhaseInstanceCount(Location loc) {
1183+
auto count = parseToken();
1184+
FAILURE_IF_FAILED(count);
1185+
return builder.buildDclHsJoinPhaseInstanceCount(*count, loc);
1186+
}
1187+
11771188
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
11781189
Instruction &out) {
11791190
FailureOr<Instruction> result;
@@ -1220,6 +1231,9 @@ class Parser {
12201231
case D3D10_SB_OPCODE_DCL_OUTPUT:
12211232
result = parseDclOutput(loc);
12221233
break;
1234+
case D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT:
1235+
result = parseDclHsJoinPhaseInstanceCount(loc);
1236+
break;
12231237
default:
12241238
return std::nullopt;
12251239
}
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_join_phase_instance_count.bin | FileCheck %s
2+
3+
// CHECK: module {
4+
// CHECK-NEXT: dxsa.dcl_hs_join_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_join_phase_instance_count 0
5+
6+
// -----
7+
8+
// expected-error@+1 {{negative integer literal not valid for unsigned integer type}}
9+
dxsa.dcl_hs_join_phase_instance_count -1
10+
11+
// -----
12+
13+
// expected-error@+1 {{integer constant out of range for attribute}}
14+
dxsa.dcl_hs_join_phase_instance_count 4294967296
Binary file not shown.

0 commit comments

Comments
 (0)