Dot2desc multiple reg alternatives - #1931
Open
TiberiuBucur wants to merge 3 commits into
Open
Conversation
ShaleXIONG
self-requested a review
July 29, 2026 10:07
ShaleXIONG
reviewed
Jul 29, 2026
ShaleXIONG
reviewed
Jul 29, 2026
This commit adds the option for dot2desc to receive multiple alternatives for an operand in the -instr flag. Instead of simply being able to parse instructions like CSEL Xd,Xn,Xm,cond', now dot2desc can receive 'CSEL Xd|Wd,Xn|Wn,Xm|Wm,cond', and the resulting translation will contain 'X~d~ or W~d~' in the places where, before, it only used to say `X~d~'.
Before this patch, if a dot graph contained W0:X0q as a pattern, meaning a write effect by thread 0 to register X0, dot2desc would mistakenly identify W0 as a register and replace it according to the corresponding operand passed through -instr. This patch fixes this by breaking the replacement strategy in two steps. 1. The Read/Write identifiers are separated from the accessed register 2. The concrete register name is replaced (if necessary) with the architectural name
…cesses Before this patch, accesses like R0:PSTATE.Zq in CSEL, or R[tag(x)]NExpq in MTE LDR kept the 'q' access size qualifier even with -wbfname passed. After this patch, when -wbfname is passed, the resulting graph will say R PSTATE.Z and R[tag(x)]NExp.
TiberiuBucur
force-pushed
the
dot2desc_multiple_reg_sizes
branch
from
July 29, 2026 14:19
fd5c92d to
0a70437
Compare
ShaleXIONG
approved these changes
Jul 29, 2026
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 patch adds the ability for dot2desc to accept multiple registers as operands of an instruction passed through the
-instrparameter.Take as an example the execution graph produced by herd on a simple CSEL instruction:
and let's run dot2desc with
-instr "CSEL Xd,Xn,Xm,cond". The final markdown produced by dot2desc (and pandoc) will contain phrases describing the architectural registers passed through-instr:After this patch, dot2desc can accept multiple registers for the same operand. This is useful when one instruction has the same dependencies for multiple register sizes. In the case of CSEL, the execution graph is the same. However, now executing dot2desc with
-instr "CSEL Xd|Wd,Xn|Wn,Xm|Wm,cond"produces phrases describing all alternative registers in place of their respective operands:Alternatives for a single operand are separated by the
|character. This applies to memory address registers as well, in which case the|can sit either inside or outside the memory addressing syntax ([]). For example, a load instruction can be passed as both-instr "LDR Xt,[Xn|Wn]"or-instr "LDR Xt,[Xn]|[Wn]", although using a word (32bit) sized register as an address register does not make sense in practice. This also highlights that one operand can have only 1 possible option, while another can have multiple.Malformed inputs include using the
|operator without providing an alternative (eg.-instr "BLR Xn|"). In such cases, dot2desc will fail with "Invalid empty operand in instr parameter".It is worth mentioning that if the
-wbfnameparameter is used, the written-back dot graph will contain effects describing only the first alternative of an operand (in the case described above, the Xn and Xd registers).