Skip to content

[mlir-tblgen] Emit named operand indices #146839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Meinersbur
Copy link
Member

An operation's operands are defined by the arguments field in the tablegen definition. mlir-tblgen generates accessors for them: getXYZ() and setXYZ(...) to set an operation's operands without knowing the operand's index, but it does not expose the operand index itself. Yet some use cases requires knowing the operand index that is now covered by just getters and setters. For instance:

  • Given an mlir::OpOperand, find out whether it is a specific argument (from the arguments field in the .td file)
  • For operation with variable number of operands (variadic, AttrSizedOperandSegments), get the value to pass to getODSOperands or getODSOperandIndexAndLength.

Emitting a named constant avoids hardcoding the index in the source as magic constant, such as 2 in

getODSOperands(2).getTypes().front(), /*isAccumulator=*/true);

Extracted out of #144785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant