[mlir][dxsa] Add bfi instruction#201
Open
hvdijk wants to merge 4 commits into
Open
Conversation
This commit generalises the DXSA_*Op to allow arbitrary numbers of arguments.
Contributor
Author
|
I'm not sure if TableGen gives us a better way to avoid having to spell out a separate class for every possible number of arguments. Does this approach look okay or should we do it differently? |
tagolog
reviewed
Jun 25, 2026
| DXSA_DstOperandAttr:$dst, | ||
| DXSA_SrcOperandAttr:$src, | ||
| OptionalAttr<DXSA_ComponentMaskAttr>:$precise); | ||
| class DXSA_PlainOp<string mnemonic, int dsts, int srcs> : DXSA_Op<mnemonic> { |
There was a problem hiding this comment.
@asl could you take a look at the way the op is built here?
There was a problem hiding this comment.
@hvdijk, Thank you for the prototype. I would rather not land the generalized version of the DXSA_PlainOp. There are several reasons:
- Multi destination operations need semantic operand names and appropriate getter names:
sincos->$sin,$cos,$operandimul/umul->$hi,$lo,$lhs,$rhsudiv->$quot,$rem,$lhs,$rhsuaddc->$sum,$carry,$lhs,$rhsusubb->$diff,$borrow,$lhs,$rhsswapc->$dst0,$dst1,$cond,$src0,$src1
A genericDXSA_PlainOpgivesgetDst0()/getDst1()/getLhs()/getRhs()for all of them and loses the role. The only ways out are (a) more parametrisation by an explicit name list, or (b) keeping per-shape local classes anyway. We already do (b) forDXSA_SincosOpandDXSA_AtomicOp; it is 5-8 lines per shape.
- The chain of
!foldl/!setdagarg/!interleave/!rangeis effectively unreadable once written: any mistake shows up as a generated-C++ error with no trail back to the TableGen expression that caused it. - No MLIR dialect uses this idiom. SPIR-V, Arith, Math, MemRef, Vector, Affine, LLVM dialect, P4HIR, IREE VM all uses hand-written tablegen classes.
- About 225 operations (arithmetic, FP, bitwise, condition, conv, atomic) - Unary, Binary, Ternary gain nothing from generalisation. 13 operations with no operands can be covered with 5 lines of clear code - new
DXSA_NoOperandOpoperation (see [mlir][dxsa] Add control flow instructions #194). Multi destination arithmetic needing its own local class for semantic names - about 7 operations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit generalises the DXSA_*Op to allow arbitrary numbers of arguments.