diff --git a/mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td b/mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td index d718879c353d..7b103dfe3248 100644 --- a/mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td +++ b/mlir/include/mlir/Dialect/DXSA/IR/DXSAOps.td @@ -759,6 +759,24 @@ def DXSA_DclIndexRange : DXSA_Op<"dcl_index_range"> { let hasVerifier = 1; } +def DXSA_DclInputSgv : DXSA_Op<"dcl_input_sgv"> { + let summary = "declares an input register as a System Generated Value"; + let description = [{ + The `dxsa.dcl_input_sgv` operation declares an input register + that expects a System Generated Value to be provided + from the upstream stage. + + Example: + + ```mlir + dxsa.dcl_input_sgv , index = [0]>, + ``` + }]; + let arguments = (ins DXSA_InlineOperandAttr:$operand, + DXSA_SystemValueNameAttr:$name); + let assemblyFormat = "$operand `,` $name attr-dict"; +} + def DXSA_DclOutputSgv : DXSA_Op<"dcl_output_sgv"> { let summary = "declares an output as a System Generated Value"; let description = [{ diff --git a/mlir/lib/Target/DXSA/BinaryParser.cpp b/mlir/lib/Target/DXSA/BinaryParser.cpp index 9227e71d4e8a..f77ac68e7025 100644 --- a/mlir/lib/Target/DXSA/BinaryParser.cpp +++ b/mlir/lib/Target/DXSA/BinaryParser.cpp @@ -651,6 +651,12 @@ class DXBuilder { builder.getI32IntegerAttr(count)); } + Instruction buildDclInputSgv(dxsa::InlineOperandAttr operand, + dxsa::SystemValueName name, Location loc) { + auto nameAttr = dxsa::SystemValueNameAttr::get(builder.getContext(), name); + return dxsa::DclInputSgv::create(builder, loc, operand, nameAttr); + } + Instruction buildDclOutputSgv(dxsa::InlineOperandAttr operand, dxsa::SystemValueName name, Location loc) { auto nameAttr = dxsa::SystemValueNameAttr::get(builder.getContext(), name); @@ -1291,6 +1297,14 @@ class Parser { return builder.buildDclOutputSiv(*operand, *name, loc); } + FailureOr parseDclInputSgv(Location loc) { + auto operand = parseInlineOperand(); + FAILURE_IF_FAILED(operand); + auto name = parseSystemValueName(getLocation()); + FAILURE_IF_FAILED(name); + return builder.buildDclInputSgv(*operand, *name, loc); + } + FailureOr parseDclHsMaxTessFactor(Location loc) { auto token = parseToken(); FAILURE_IF_FAILED(token); @@ -1441,6 +1455,9 @@ class Parser { case D3D10_SB_OPCODE_DCL_INDEX_RANGE: result = parseDclIndexRange(loc); break; + case D3D10_SB_OPCODE_DCL_INPUT_SGV: + result = parseDclInputSgv(loc); + break; case D3D10_SB_OPCODE_DCL_OUTPUT_SGV: result = parseDclOutputSgv(loc); break; diff --git a/mlir/test/Target/DXSA/dcl_input_sgv.mlir b/mlir/test/Target/DXSA/dcl_input_sgv.mlir new file mode 100644 index 000000000000..38fdae078eaa --- /dev/null +++ b/mlir/test/Target/DXSA/dcl_input_sgv.mlir @@ -0,0 +1,8 @@ +// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_input_sgv.bin | FileCheck %s + +// CHECK: module { +// CHECK-NEXT: dxsa.dcl_input_sgv , index = [0]>, +// CHECK-NEXT: dxsa.dcl_input_sgv , index = [0]>, +// CHECK-NEXT: dxsa.dcl_input_sgv , index = [1]>, +// CHECK-NEXT: dxsa.dcl_input_sgv , index = [1]>, +// CHECK-NEXT: } diff --git a/mlir/test/Target/DXSA/inputs/dcl_input_sgv.bin b/mlir/test/Target/DXSA/inputs/dcl_input_sgv.bin new file mode 100644 index 000000000000..33bb43b65c5c Binary files /dev/null and b/mlir/test/Target/DXSA/inputs/dcl_input_sgv.bin differ