Skip to content
Open
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 @@ -1072,4 +1072,33 @@ def DXSA_DclStream : DXSA_Op<"dcl_stream"> {
let assemblyFormat = [{ $index attr-dict }];
}

def DXSA_InterfaceCall : DXSA_Op<"interface_call"> {
let summary = "interface function call (fcall)";
let description = [{
Call the function body at the following location:
- Interface `operand` selects a function table from an interface.
- `call_site` is an immediate unsigned integer offset into the selected
function table, selecting a function body # to execute.

If the interface is declared with `access = dynamic` attribute, the operand
can use relative indexing.

Example:
```mlir
module {
%0 = dxsa.index.imm {imm = 0 : i32}
%1 = dxsa.index.imm {imm = 0 : i32}
%2 = dxsa.operand %1 {num_components = 4 : i32, one = 0 : i32, type = 0 : i32}
%3 = dxsa.index.rel %2
%4 = dxsa.operand %0, %3 {num_components = 0 : i32, type = 19 : i32}
dxsa.interface_call %4, <call_site = 0>
}
```
}];
let arguments = (ins DXSA_OperandType:$operand, ConfinedAttr<I32Attr, [IntNonNegative]>:$call_site);
let assemblyFormat = [{ $operand `,` `<`
`call_site` `=` $call_site `>` attr-dict
}];
}

#endif // DXSA_OPS
24 changes: 24 additions & 0 deletions mlir/lib/Target/DXSA/BinaryParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ class DXBuilder {
optionalToAttr(space));
}

Instruction buildInterfaceCall(Operand operand, uint32_t callSite,
Location loc) {
return dxsa::InterfaceCall::create(builder, loc, operand, callSite);
}

private:
MLIRContext *context;
ModuleOp module;
Expand Down Expand Up @@ -1476,6 +1481,22 @@ class Parser {
return builder.buildDclSampler(id, lbound, ubound, space, *mode, loc);
}

FailureOr<Instruction> parseInterfaceCall(uint32_t opcodeToken,
Location loc) {
if (DECODE_IS_D3D10_SB_OPCODE_EXTENDED(opcodeToken)) {
return emitError(getLocation(),
"extended interface calls are not supported");
}

auto callSite = parseToken();
FAILURE_IF_FAILED(callSite);

auto operand = parseOperand();
FAILURE_IF_FAILED(operand);

return builder.buildInterfaceCall(*operand, *callSite, loc);
}

OptionalParseResult parseDclInstruction(uint32_t opcodeToken, Location loc,
Instruction &out) {
FailureOr<Instruction> result;
Expand Down Expand Up @@ -1567,6 +1588,9 @@ class Parser {
case D3D10_SB_OPCODE_DCL_SAMPLER:
result = parseDclSampler(opcodeToken, loc);
break;
case D3D11_SB_OPCODE_INTERFACE_CALL:
result = parseInterfaceCall(opcodeToken, loc);
break;
default:
return std::nullopt;
}
Expand Down
Binary file added mlir/test/Target/DXSA/inputs/interface_call.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions mlir/test/Target/DXSA/interface_call.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: mlir-translate --import-dxsa-bin %S/inputs/interface_call.bin | FileCheck %s

// CHECK-LABEL: module {
// CHECK-NEXT: %0 = dxsa.index.imm {imm = 0 : i32}
// CHECK-NEXT: %1 = dxsa.index.imm {imm = 0 : i32}
// CHECK-NEXT: %2 = dxsa.operand %1 {num_components = 4 : i32, one = 0 : i32, type = 0 : i32}
// CHECK-NEXT: %3 = dxsa.index.rel %2
// CHECK-NEXT: %4 = dxsa.operand %0, %3 {num_components = 0 : i32, type = 19 : i32}
// CHECK-NEXT: dxsa.interface_call %4, <call_site = 0>
// CHECK-NEXT: }
12 changes: 12 additions & 0 deletions mlir/test/Target/DXSA/interface_call_invalid.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: mlir-opt %s -split-input-file -verify-diagnostics

module {
%0 = dxsa.index.imm {imm = 0 : i32}
%1 = dxsa.index.imm {imm = 0 : i32}
%2 = dxsa.operand %1 {num_components = 4 : i32, one = 0 : i32, type = 0 : i32}
%3 = dxsa.index.rel %2
%4 = dxsa.operand %0, %3 {num_components = 0 : i32, type = 19 : i32}

// expected-error@+1 {{attribute 'call_site' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative}}
dxsa.interface_call %4, <call_site = -1>
}