Skip to content

Commit cac4349

Browse files
committed
[mlir][dxsa] Add dcl_input and dcl_output instructions
Example: dxsa.dcl_input %v0 dxsa.dcl_output %o0 Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
1 parent fdd3b7d commit cac4349

6 files changed

Lines changed: 91 additions & 0 deletions

File tree

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,41 @@ def DXSA_DclInputPsSgv : DXSA_Op<"dcl_input_ps_sgv"> {
534534
let assemblyFormat = "$operand `,` $name attr-dict";
535535
}
536536

537+
def DXSA_DclInput : DXSA_Op<"dcl_input"> {
538+
let summary = "declares a shader input register";
539+
let description = [{
540+
The `dxsa.dcl_input` operation declares a shader input register.
541+
542+
The register operand can be either an indexed input register
543+
or a special scalar input.
544+
545+
Example:
546+
547+
```mlir
548+
549+
dxsa.dcl_input %v0
550+
```
551+
}];
552+
let arguments = (ins DXSA_OperandType:$operand);
553+
let assemblyFormat = "$operand attr-dict";
554+
}
555+
556+
def DXSA_DclOutput : DXSA_Op<"dcl_output"> {
557+
let summary = "declares a shader output register";
558+
let description = [{
559+
The `dxsa.dcl_output` operation declares a shader output register.
560+
561+
The register operand can be either an indexed output register
562+
or a special scalar output.
563+
564+
Example:
565+
566+
```mlir
567+
dxsa.dcl_output %o0
568+
```
569+
}];
570+
let arguments = (ins DXSA_OperandType:$operand);
571+
let assemblyFormat = "$operand attr-dict";
572+
}
573+
537574
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@ class DXBuilder {
597597
systemValueNameAttr);
598598
}
599599

600+
Instruction buildDclInput(Operand operand, Location loc) {
601+
return dxsa::DclInput::create(builder, loc, operand);
602+
}
603+
604+
Instruction buildDclOutput(Operand operand, Location loc) {
605+
return dxsa::DclOutput::create(builder, loc, operand);
606+
}
607+
600608
private:
601609
MLIRContext *context;
602610
ModuleOp module;
@@ -1076,6 +1084,20 @@ class Parser {
10761084
return builder.buildDclInputPsSgv(*operand, *systemValueName, loc);
10771085
}
10781086

1087+
FailureOr<Instruction> parseDclInput(Location loc) {
1088+
auto operand = parseOperand();
1089+
if (failed(operand))
1090+
return failure();
1091+
return builder.buildDclInput(*operand, loc);
1092+
}
1093+
1094+
FailureOr<Instruction> parseDclOutput(Location loc) {
1095+
auto operand = parseOperand();
1096+
if (failed(operand))
1097+
return failure();
1098+
return builder.buildDclOutput(*operand, loc);
1099+
}
1100+
10791101
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
10801102
Instruction &out) {
10811103
FailureOr<Instruction> result;
@@ -1116,6 +1138,12 @@ class Parser {
11161138
case D3D10_SB_OPCODE_DCL_INPUT_PS_SGV:
11171139
result = parseDclInputPsSgv(loc);
11181140
break;
1141+
case D3D10_SB_OPCODE_DCL_INPUT:
1142+
result = parseDclInput(loc);
1143+
break;
1144+
case D3D10_SB_OPCODE_DCL_OUTPUT:
1145+
result = parseDclOutput(loc);
1146+
break;
11191147
default:
11201148
return std::nullopt;
11211149
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_input.bin | FileCheck %s
2+
3+
// CHECK-LABEL: module
4+
module {
5+
// dcl_input v0.x
6+
// CHECK: %0 = dxsa.index.imm {imm = 0 : i32}
7+
// CHECK-NEXT: %1 = dxsa.operand %0 {mask = 16 : i32, num_components = 4 : i32, type = 1 : i32}
8+
// CHECK-NEXT: dxsa.dcl_input %1
9+
10+
// dcl_input vOutputControlPointID
11+
// CHECK-NEXT: %2 = dxsa.operand {num_components = 1 : i32, type = 22 : i32}
12+
// CHECK-NEXT: dxsa.dcl_input %2
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/dcl_output.bin | FileCheck %s
2+
3+
// CHECK-LABEL: module
4+
module {
5+
// dcl_output o0.xyzw
6+
// CHECK: %0 = dxsa.index.imm {imm = 0 : i32}
7+
// CHECK-NEXT: %1 = dxsa.operand %0 {mask = 240 : i32, num_components = 4 : i32, type = 2 : i32}
8+
// CHECK-NEXT: dxsa.dcl_output %1
9+
10+
// dcl_output oDepth
11+
// CHECK-NEXT: %2 = dxsa.operand {num_components = 1 : i32, type = 12 : i32}
12+
// CHECK-NEXT: dxsa.dcl_output %2
13+
}
20 Bytes
Binary file not shown.
20 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)