Skip to content

Commit 039bec8

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 00b41ee commit 039bec8

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
//===----------------------------------------------------------------------===//
@@ -790,4 +800,23 @@ def DXSA_DclHsMaxTessFactor : DXSA_Op<"dcl_hs_max_tessfactor"> {
790800
let hasVerifier = 1;
791801
}
792802

803+
def DXSA_DclHsJoinPhaseInstanceCount :
804+
DXSA_Op<"dcl_hs_join_phase_instance_count"> {
805+
let summary = "declares the Join Phase instance count";
806+
let description = [{
807+
The `dxsa.dcl_hs_join_phase_instance_count` operation declares
808+
the Join Phase instance count.
809+
810+
The `$count` must be a positive 32-bit unsigned integer in the range [1, 2^32 - 1].
811+
812+
Example:
813+
814+
```mlir
815+
dxsa.dcl_hs_join_phase_instance_count 42
816+
```
817+
}];
818+
let arguments = (ins ConfinedAttr<UI32Attr, [DXSA_UIntNonZero]>:$count);
819+
let assemblyFormat = "$count attr-dict";
820+
}
821+
793822
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ class DXBuilder {
659659
builder, loc, builder.getF32FloatAttr(maxTessFactor));
660660
}
661661

662+
Instruction buildDclHsJoinPhaseInstanceCount(uint32_t count, Location loc) {
663+
return dxsa::DclHsJoinPhaseInstanceCount::create(
664+
builder, loc, builder.getUI32IntegerAttr(count));
665+
}
666+
662667
private:
663668
MLIRContext *context;
664669
ModuleOp module;
@@ -1229,6 +1234,12 @@ class Parser {
12291234
return builder.buildDclHsMaxTessFactor(maxTessFactor, loc);
12301235
}
12311236

1237+
FailureOr<Instruction> parseDclHsJoinPhaseInstanceCount(Location loc) {
1238+
auto count = parseToken();
1239+
FAILURE_IF_FAILED(count);
1240+
return builder.buildDclHsJoinPhaseInstanceCount(*count, loc);
1241+
}
1242+
12321243
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
12331244
Instruction &out) {
12341245
FailureOr<Instruction> result;
@@ -1287,6 +1298,9 @@ class Parser {
12871298
case D3D11_SB_OPCODE_DCL_HS_MAX_TESSFACTOR:
12881299
result = parseDclHsMaxTessFactor(loc);
12891300
break;
1301+
case D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT:
1302+
result = parseDclHsJoinPhaseInstanceCount(loc);
1303+
break;
12901304
default:
12911305
return std::nullopt;
12921306
}
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)