[mlir][dxsa] Add dcl_function_body and dcl_function_table#134
Conversation
| let description = [{ | ||
|
|
||
| The `dxsa.dcl_function_body` declares a unique function body # | ||
| whose code will appear later in the program at `label fb#`. |
There was a problem hiding this comment.
Maybe remove references to "fb#" syntax as we are not using it in the mlir for now?
|
|
||
| // CHECK-LABEL: module | ||
|
|
||
| // dcl_function_body fb1 |
There was a problem hiding this comment.
Maybe it is worth no to mix the ops from prev asm with the current MLIR ops? This can be a bit misleading.
543afcc to
cfe95be
Compare
|
Also changed syntax a bit to spell out what the array means: |
cfe95be to
d03dc8a
Compare
| let arguments = (ins F32Attr:$max_tessfactor); | ||
| let assemblyFormat = "$max_tessfactor attr-dict"; | ||
| let hasVerifier = 1; | ||
| let arguments = (ins I32Attr:$index); |
There was a problem hiding this comment.
This argument is positive by design, I vote to restrict it.
| let arguments = (ins I32Attr:$index); | |
| let arguments = (ins ConfinedAttr<I32Attr, [IntNonNegative]>:$index); |
There was a problem hiding this comment.
Thank you. Added restriction.
| let assemblyFormat = | ||
| "$operand `,` $struct_byte_stride `,` $struct_count attr-dict"; | ||
| let hasVerifier = 1; | ||
| let arguments = (ins I32Attr:$index, DenseI32ArrayAttr:$functions); |
There was a problem hiding this comment.
| let arguments = (ins I32Attr:$index, DenseI32ArrayAttr:$functions); | |
| let arguments = (ins ConfinedAttr<I32Attr, [IntNonNegative]>:$index, DenseI32ArrayAttr:$functions); |
| return builder.buildDclHsJoinPhaseInstanceCount(*count, loc); | ||
| } | ||
| FailureOr<Instruction> parseDclFunctionTable(Location loc) { | ||
| auto index = parseToken(); |
There was a problem hiding this comment.
Extended length bit [31] for dcl_function_table is unhandled
The spec says the regular 7-bit length field can overflow, in which case bit [31] is set and the real length lives in the next DWORD:
d3d12TokenizedProgramFormat.hpp#L2486-L2490
// [30:24] Instruction length in DWORDs including the opcode token.
// [31] 0 normally. 1 if extended operand definition, meaning next DWORD
// contains extended operand description. If it is extended, then
// it contains the actual instruction length in DWORDs, since
// it may not fit into 7 bits if enough functions are defined.
DirectXShaderCompiler handles this explicitly ShaderBinary.cpp#L548-L558
Right now the parser ignores extended length bit for these opcodes and silently parses the next DWORD as function table identifier.
There was a problem hiding this comment.
Good catch! Added handling of extended length token.
f563c68 to
ea9b7f1
Compare
DX assembly programs support "virtual" inlining of subroutines by defining a set of functions that might be called for a call site.
The compiler then prepares an inlined specialization for every possible callee. The actual specialization is selected at runtime.
On DXBC level, functions are declared and identified by numbers, grouped into tables, and tables are grouped as interfaces:
This patchset adds only
dcl_function_bodyanddcl_function_table. Interfaces are going to be in a separate patch.