Skip to content

Commit f385281

Browse files
committed
Handle extended instruction length for dcl_function_table
1 parent d03dc8a commit f385281

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

mlir/lib/Target/DXSA/BinaryParser.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,18 @@ class Parser {
12701270
return success();
12711271
}
12721272

1273+
FailureOr<std::optional<uint32_t>> parseExtendedLength(uint32_t opcode) {
1274+
std::optional<uint32_t> result;
1275+
if (opcode != D3D11_SB_OPCODE_DCL_FUNCTION_TABLE) {
1276+
return success(result);
1277+
}
1278+
1279+
Token lengthToken = parseToken();
1280+
FAILURE_IF_FAILED(lengthToken);
1281+
result = *lengthToken;
1282+
return success(result);
1283+
}
1284+
12731285
FailureOr<Instruction> parseInstruction() {
12741286
size_t beginOffset = currentTokenOffset;
12751287
Token token = parseToken();
@@ -1284,11 +1296,14 @@ class Parser {
12841296
modifier.saturate = DECODE_IS_D3D10_SB_INSTRUCTION_SATURATE_ENABLED(*token);
12851297

12861298
uint32_t length = DECODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(*token);
1299+
if (DECODE_IS_D3D10_SB_OPCODE_EXTENDED(*token)) {
1300+
auto extLength = parseExtendedLength(opcode);
1301+
FAILURE_IF_FAILED(extLength);
1302+
length = extLength->value();
1303+
}
12871304

12881305
// TODO: extended instructions:
12891306
// BOOL b51PlusShader =
1290-
// BOOL bExtended = DECODE_IS_D3D10_SB_OPCODE_EXTENDED(Token)
1291-
// ...
12921307

12931308
if (opcode >= D3D10_SB_NUM_OPCODES) {
12941309
emitError(getLocation(), "unknown opcode");

mlir/test/Target/DXSA/dcl_function_table.mlir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22

33
// CHECK-LABEL: module
44
// CHECK-NEXT: dxsa.dcl_function_table 1, <functions = [0, 1]>
5+
6+
// Test extended instruction length:
7+
// CHECK-NEXT: dxsa.dcl_function_table 2, <functions = [0, 1]>
24 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)