Skip to content

[gen] Add pair-cell offset annotation for AArch64. - #1886

Merged
ShaleXIONG merged 4 commits into
herd:masterfrom
ShaleXIONG:pair-offset-read-write
Sep 14, 2026
Merged

ShaleXIONG merged 4 commits into
herd:masterfrom
ShaleXIONG:pair-offset-read-write

Conversation

@ShaleXIONG

@ShaleXIONG ShaleXIONG commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Expose a non-mixed AArch64 offset annotation to generate ordinary accesses to the second cell of a pair-backed location. The surface spelling follows the current natural type size.

  • with the default 32-bit int, the added annotation is w4
  • with -type int64_t, it is q8.

We also remove the synthetic ADD after AArch64 pair loads but check both register values in the final condition.
Given the new annotation and change, we can generate test, e.g. diyone7 -metadata false -arch AArch64 -oneloc Rfe PaIQ Fre w4 PosWW

AArch64 WW+R+posw4p+PaIQ
{
 int x[2]={0,0};
 uint32_t 0:X0=0; 0:X1=x;
 1:X1=x;
}
 P0                                                      | P1                ;
 MOV W0,#2                                               | LDIAPP W0,W2,[X1] ;
 STR W0,[X1,#4] (* w4 annotation to access second cell *)|                   ; (* Add W0,W0,W2 is removed *)
 MOV W2,#1                                               |                   ;
 STR W2,[X1]                                             |                   ;

exists (x={1,2} /\ 1:X0=1 /\ 1:X2=0) (* Value check for both 1:X0 and 1:X2 *)

@ShaleXIONG
ShaleXIONG requested a review from relokin June 25, 2026 13:55
@ShaleXIONG
ShaleXIONG force-pushed the pair-offset-read-write branch from bb96221 to 4aeba6b Compare June 29, 2026 16:16
@ShaleXIONG
ShaleXIONG force-pushed the pair-offset-read-write branch 3 times, most recently from fb65a22 to c90041b Compare August 11, 2026 15:49
@ShaleXIONG
ShaleXIONG force-pushed the pair-offset-read-write branch from 869d875 to efa6f2c Compare September 10, 2026 15:30

@relokin relokin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, I haven't had a very thorough look at the code but I am happy with the tests we can now generate. One issue that would be good to address is the type mismatch is tests like this:

$> diyone7 -arch AArch64 -metadata false w4 PosWW Rfe PaIQ Fre -oneloc
AArch64 WW+R+posw4p+PaIQ
{
 int x[2]={0,0};
 uint32_t 0:X0=0; 0:X1=x;
 1:X1=x;
}
 P0             | P1                ;
 MOV W0,#2      | LDIAPP W0,W2,[X1] ;
 STR W0,[X1,#4] |                   ;
 MOV W2,#1      |                   ;
 STR W2,[X1]    |                   ;

exists (x={1,2} /\ 1:X0=1 /\ 1:X2=0)

Notice that x is an array of int but 0:X0 and 0:X1 are uint32_t.

Do not emit redundant type initialisers for AArch64 registers whose values
are materialised by generated move instructions.
@ShaleXIONG

ShaleXIONG commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

This is great, I haven't had a very thorough look at the code but I am happy with the tests we can now generate. One issue that would be good to address is the type mismatch is tests like this:

$> diyone7 -arch AArch64 -metadata false w4 PosWW Rfe PaIQ Fre -oneloc
AArch64 WW+R+posw4p+PaIQ
{
 int x[2]={0,0};
 uint32_t 0:X0=0; 0:X1=x;
 1:X1=x;
}
 P0             | P1                ;
 MOV W0,#2      | LDIAPP W0,W2,[X1] ;
 STR W0,[X1,#4] |                   ;
 MOV W2,#1      |                   ;
 STR W2,[X1]    |                   ;

exists (x={1,2} /\ 1:X0=1 /\ 1:X2=0)

Notice that x is an array of int but 0:X0 and 0:X1 are uint32_t.

Should we remove unit32_t 0:X0=0 as there is a MOV W0 #2? So we keep it similar to the test that only change the first cell, which we can generate before this PR: diyone7 -arch AArch64 -metadata false PosWW Rfe PaIQ Fre -oneloc

AArch64 WW+R+PaIQ
{
 int x[2]={0,0};
 0:X1=x;
 1:X1=x;
}
 P0          | P1                ;
 MOV W0,#2   | LDIAPP W0,W2,[X1] ;
 STR W0,[X1] | ADD W0,W0,W2      ;
 MOV W2,#1   |                   ;
 STR W2,[X1] |                   ;

exists (x={2,0} /\ 1:X0=1)

If so, I think I fixed it in 4d72160.

@relokin relokin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Shale that fixes the problem.

@ShaleXIONG
ShaleXIONG merged commit aa10741 into herd:master Sep 14, 2026
7 of 8 checks passed
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