Skip to content

Dot2desc multiple reg alternatives - #1931

Open
TiberiuBucur wants to merge 3 commits into
herd:masterfrom
TiberiuBucur:dot2desc_multiple_reg_sizes
Open

Dot2desc multiple reg alternatives#1931
TiberiuBucur wants to merge 3 commits into
herd:masterfrom
TiberiuBucur:dot2desc_multiple_reg_sizes

Conversation

@TiberiuBucur

@TiberiuBucur TiberiuBucur commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This patch adds the ability for dot2desc to accept multiple registers as operands of an instruction passed through the -instr parameter.

Take as an example the execution graph produced by herd on a simple CSEL instruction:

AArch64 CSEL-success
{
 0:X1=1; 0:X2=2;
}
 P0               ;
 CSEL W0,W1,W2,NE ;

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:

-   D~2~: There is an Intrinsic Data Dependency from the Register Read Effect of X~n~ to the Register Write Effect of X~d~.

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:

-   D~2~: There is an Intrinsic Data Dependency from the Register Read Effect of X~n~ or W~n~ to the Register Write Effect of X~d~ or W~d~.

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 -wbfname parameter 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).

@TiberiuBucur
TiberiuBucur requested a review from relokin July 28, 2026 11:16
@ShaleXIONG
ShaleXIONG self-requested a review July 29, 2026 10:07
Comment thread tools/dot2desc.ml Outdated
Comment thread tools/dot2desc.ml
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
TiberiuBucur force-pushed the dot2desc_multiple_reg_sizes branch from fd5c92d to 0a70437 Compare July 29, 2026 14:19
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.

2 participants