Skip to content

Commit 97fccf1

Browse files
committed
[mlir][dxsa] Add interface_call
1 parent 534a8b0 commit 97fccf1

5 files changed

Lines changed: 75 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
@@ -1072,4 +1072,33 @@ def DXSA_DclStream : DXSA_Op<"dcl_stream"> {
10721072
let assemblyFormat = [{ $index attr-dict }];
10731073
}
10741074

1075+
def DXSA_InterfaceCall : DXSA_Op<"interface_call"> {
1076+
let summary = "interface function call (fcall)";
1077+
let description = [{
1078+
Call the function body at the following location:
1079+
- Interface `operand` selects a function table from an interface.
1080+
- `call_site` is an immediate unsigned integer offset into the selected
1081+
function table, selecting a function body # to execute.
1082+
1083+
If the interface is declared with `access = dynamic` attribute, the operand
1084+
can use relative indexing.
1085+
1086+
Example:
1087+
```mlir
1088+
module {
1089+
%0 = dxsa.index.imm {imm = 0 : i32}
1090+
%1 = dxsa.index.imm {imm = 0 : i32}
1091+
%2 = dxsa.operand %1 {num_components = 4 : i32, one = 0 : i32, type = 0 : i32}
1092+
%3 = dxsa.index.rel %2
1093+
%4 = dxsa.operand %0, %3 {num_components = 0 : i32, type = 19 : i32}
1094+
dxsa.interface_call %4, <call_site = 0>
1095+
}
1096+
```
1097+
}];
1098+
let arguments = (ins DXSA_OperandType:$operand, ConfinedAttr<I32Attr, [IntNonNegative]>:$call_site);
1099+
let assemblyFormat = [{ $operand `,` `<`
1100+
`call_site` `=` $call_site `>` attr-dict
1101+
}];
1102+
}
1103+
10751104
#endif // DXSA_OPS

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,11 @@ class DXBuilder {
733733
optionalToAttr(space));
734734
}
735735

736+
Instruction buildInterfaceCall(Operand operand, uint32_t callSite,
737+
Location loc) {
738+
return dxsa::InterfaceCall::create(builder, loc, operand, callSite);
739+
}
740+
736741
private:
737742
MLIRContext *context;
738743
ModuleOp module;
@@ -1476,6 +1481,22 @@ class Parser {
14761481
return builder.buildDclSampler(id, lbound, ubound, space, *mode, loc);
14771482
}
14781483

1484+
FailureOr<Instruction> parseInterfaceCall(uint32_t opcodeToken,
1485+
Location loc) {
1486+
if (DECODE_IS_D3D10_SB_OPCODE_EXTENDED(opcodeToken)) {
1487+
return emitError(getLocation(),
1488+
"extended interface calls are not supported");
1489+
}
1490+
1491+
auto callSite = parseToken();
1492+
FAILURE_IF_FAILED(callSite);
1493+
1494+
auto operand = parseOperand();
1495+
FAILURE_IF_FAILED(operand);
1496+
1497+
return builder.buildInterfaceCall(*operand, *callSite, loc);
1498+
}
1499+
14791500
OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
14801501
Instruction &out) {
14811502
FailureOr<Instruction> result;
@@ -1567,6 +1588,9 @@ class Parser {
15671588
case D3D10_SB_OPCODE_DCL_SAMPLER:
15681589
result = parseDclSampler(opcodeToken, loc);
15691590
break;
1591+
case D3D11_SB_OPCODE_INTERFACE_CALL:
1592+
result = parseInterfaceCall(opcodeToken, loc);
1593+
break;
15701594
default:
15711595
return std::nullopt;
15721596
}
24 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: mlir-translate --import-dxsa-bin %S/inputs/interface_call.bin | FileCheck %s
2+
3+
// CHECK-LABEL: module {
4+
// CHECK-NEXT: %0 = dxsa.index.imm {imm = 0 : i32}
5+
// CHECK-NEXT: %1 = dxsa.index.imm {imm = 0 : i32}
6+
// CHECK-NEXT: %2 = dxsa.operand %1 {num_components = 4 : i32, one = 0 : i32, type = 0 : i32}
7+
// CHECK-NEXT: %3 = dxsa.index.rel %2
8+
// CHECK-NEXT: %4 = dxsa.operand %0, %3 {num_components = 0 : i32, type = 19 : i32}
9+
// CHECK-NEXT: dxsa.interface_call %4, <call_site = 0>
10+
// CHECK-NEXT: }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2+
3+
module {
4+
%0 = dxsa.index.imm {imm = 0 : i32}
5+
%1 = dxsa.index.imm {imm = 0 : i32}
6+
%2 = dxsa.operand %1 {num_components = 4 : i32, one = 0 : i32, type = 0 : i32}
7+
%3 = dxsa.index.rel %2
8+
%4 = dxsa.operand %0, %3 {num_components = 0 : i32, type = 19 : i32}
9+
10+
// expected-error@+1 {{attribute 'call_site' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative}}
11+
dxsa.interface_call %4, <call_site = -1>
12+
}

0 commit comments

Comments
 (0)