Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 29 additions & 0 deletions mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ def DXSA_ComponentMaskAttr :
let assemblyFormat = "`<` $value `>`";
}

//===----------------------------------------------------------------------===//
// DXSA attribute Constraints
//===----------------------------------------------------------------------===//

// This constraint does not treat the most significant bit as a sign bit,
// so it is safe to use on unsigned integer attributes.
def DXSA_UIntNonZero : AttrConstraint<
CPred<"!::llvm::cast<::mlir::IntegerAttr>($_self).getValue().isZero()">,
"whose value is non-zero">;

//===----------------------------------------------------------------------===//
// DXSA op definitions
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -790,4 +800,23 @@ def DXSA_DclHsMaxTessFactor : DXSA_Op<"dcl_hs_max_tessfactor"> {
let hasVerifier = 1;
}

def DXSA_DclHsJoinPhaseInstanceCount :
DXSA_Op<"dcl_hs_join_phase_instance_count"> {
let summary = "declares the Join Phase instance count";
let description = [{
The `dxsa.dcl_hs_join_phase_instance_count` operation declares
the Join Phase instance count.

The `$count` must be a positive 32-bit unsigned integer in the range [1, 2^32 - 1].

Example:

```mlir
dxsa.dcl_hs_join_phase_instance_count 42
```
}];
let arguments = (ins ConfinedAttr<UI32Attr, [DXSA_UIntNonZero]>:$count);
let assemblyFormat = "$count attr-dict";
}

#endif // DXSA_OPS
14 changes: 14 additions & 0 deletions mlir/lib/Target/DXSA/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ class DXBuilder {
builder, loc, builder.getF32FloatAttr(maxTessFactor));
}

Instruction buildDclHsJoinPhaseInstanceCount(uint32_t count, Location loc) {
return dxsa::DclHsJoinPhaseInstanceCount::create(
builder, loc, builder.getUI32IntegerAttr(count));
}

private:
MLIRContext *context;
ModuleOp module;
Expand Down Expand Up @@ -1229,6 +1234,12 @@ class Parser {
return builder.buildDclHsMaxTessFactor(maxTessFactor, loc);
}

FailureOr<Instruction> parseDclHsJoinPhaseInstanceCount(Location loc) {
auto count = parseToken();
FAILURE_IF_FAILED(count);
return builder.buildDclHsJoinPhaseInstanceCount(*count, loc);
}

OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
Instruction &out) {
FailureOr<Instruction> result;
Expand Down Expand Up @@ -1287,6 +1298,9 @@ class Parser {
case D3D11_SB_OPCODE_DCL_HS_MAX_TESSFACTOR:
result = parseDclHsMaxTessFactor(loc);
break;
case D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT:
result = parseDclHsJoinPhaseInstanceCount(loc);
break;
default:
return std::nullopt;
}
Expand Down
5 changes: 5 additions & 0 deletions mlir/test/Target/DXSA/dcl_hs_join_phase_instance_count.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_hs_join_phase_instance_count.bin | FileCheck %s

// CHECK: module {
// CHECK-NEXT: dxsa.dcl_hs_join_phase_instance_count 42
// CHECK-NEXT: }
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics

// expected-error@+1 {{attribute 'count' failed to satisfy constraint: 32-bit unsigned integer attribute whose value is non-zero}}
dxsa.dcl_hs_join_phase_instance_count 0

// -----

// expected-error@+1 {{negative integer literal not valid for unsigned integer type}}
dxsa.dcl_hs_join_phase_instance_count -1

// -----

// expected-error@+1 {{integer constant out of range for attribute}}
dxsa.dcl_hs_join_phase_instance_count 4294967296
Binary file not shown.