Skip to content

[all] Turn labels into symbols#1577

Merged
artkhyzha merged 1 commit intoherd:masterfrom
artkhyzha:labels-are-now-symbols
Dec 5, 2025
Merged

[all] Turn labels into symbols#1577
artkhyzha merged 1 commit intoherd:masterfrom
artkhyzha:labels-are-now-symbols

Conversation

@artkhyzha
Copy link
Copy Markdown
Collaborator

@artkhyzha artkhyzha commented Nov 18, 2025

This PR is a preparation for several strands of work, #1507 and #1518, which depend on treatment of labels as symbols rather than strings. With this PR, they would be treated more like virtual addresses, referred to as symbols like "x".

The use of labels in the syntax of litmus tests remains the same. No user-facing changes to the semantics of any feature of the tools are intended with this PR.

@artkhyzha
Copy link
Copy Markdown
Collaborator Author

In principle, the intent is to merge #1518 soon, but since there is a bit of work to do on it, and since this specific commit has been creating a massive amount of conflicts, and since it is useful for another PR, I quite like @murzinv's idea to merge it quicker.

@murzinv , @relokin -- what do you think, what do we need to merge this PR? My thinking is, this PR would likely affect:

  1. ifetch in herd7, but if the regressions pass, this seems okay
  2. ifetch in litmus7 -- let's try and run tests for extra assurance
  3. recent ASL-related changes (in case if conflicts were resolved not carefully enough)

@artkhyzha artkhyzha force-pushed the labels-are-now-symbols branch from 1e3da84 to 12e17be Compare November 19, 2025 13:17
@artkhyzha artkhyzha marked this pull request as ready for review November 24, 2025 09:50
@artkhyzha artkhyzha force-pushed the labels-are-now-symbols branch from 12e17be to 206f8e0 Compare November 25, 2025 18:31
@artkhyzha
Copy link
Copy Markdown
Collaborator Author

@maranget @relokin --

This PR, essentially, simply replaces treatment of labels as a special kind of constants with treatment of them as symbolic constants. (This is because we would like to extend the use of the syntax TTD(<symbol>)=(...) to them in other PRs, and also to use offsets for them much like we do for symbols like x.)

This is not meant to be a breaking change, but it conflicts with changes to constants, so to avoid repeated rebasing, there is an idea of merging this sooner rather than later. Please let me know if you have concerns.

@artkhyzha
Copy link
Copy Markdown
Collaborator Author

UPD. It occurred to me that the impact on litmus7 could be tested too -- and there are regressions that show up when tests from the catalogue are run:

File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+cachesync+switch-ctrl.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+cachesync+switch-ctrlisb.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+dc-dsb-ic-dsb+addr.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+dc-dsb-ic-dsb+ctrlisb.br.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/miniJit01.litmus" litmus cannot handle symbol '1:L0'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/miniJit02.litmus" litmus cannot handle symbol '1:L0'

Something to look into.

Copy link
Copy Markdown
Contributor

@diaolo01 diaolo01 left a comment

Choose a reason for hiding this comment

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

Hello @artkhyzha,
I had a look and the PR makes sense to me. I mostly focused on constant.ml and the parser changes, which seemed to be most significant.

(*vector metadata - prim size (arg1) and total array size (arg2) *)
(*needed for is-non-mixed-symbol and global vectors *)

module Symbol = struct
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if it would be worth moving this into a dedicated Symbol module, similar to how we treat PAC in the symbolic_data record.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I do not have a strong opinion. Right now the code uses Constant.Symbol in various places. I don't think it's fundamental for it to be exposed through the interface of constants though. It could be hidden in side Constant, with wrapper functions made available.

Presently I do not clearly see what would be an improvement, so I'd opt for no action.


let mk_sym_tagloc_zero s = do_mk_sym_tagloc s 0

let mk_sym_morello p s t =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same question as for mk_sym_tag.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same answer! Strictly speaking, this patch does not need this change, but when I picked up, it already moved some of these mk_* functions. This seems to be in line with constant.mli interface, so I am keeping the change as is unless there are strong opinions.

Copy link
Copy Markdown
Collaborator

@murzinv murzinv left a comment

Choose a reason for hiding this comment

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

UPD. It occurred to me that the impact on litmus7 could be tested too -- and there are regressions that show up when tests from the catalogue are run:

File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+cachesync+switch-ctrl.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+cachesync+switch-ctrlisb.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+dc-dsb-ic-dsb+addr.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/MP.RF+dc-dsb-ic-dsb+ctrlisb.br.litmus" litmus cannot handle symbol '1:Lend'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/miniJit01.litmus" litmus cannot handle symbol '1:L0'
File "catalogue/aarch64-ifetch/tests/DIC0-IDC0/miniJit02.litmus" litmus cannot handle symbol '1:L0'

Something to look into.

Here is (slightly tested) diff which makes problem go away

diff --git a/litmus/compile.ml b/litmus/compile.ml
index 60c986d9d..60d227cd3 100644
--- a/litmus/compile.ml
+++ b/litmus/compile.ml
@@ -210,7 +210,7 @@ module Generic
         List.fold_left
           (fun env (loc,(t,v)) -> match loc,v with
           | _,Constant.Concrete _ -> env
-          | A.Location_global _,Symbolic s ->
+          | A.Location_global _,Symbolic s when not (Constant.is_label v) ->
               let a = A.Location_global (G.tr_symbol s) in
               begin try
                 ignore (A.LocMap.find a env) ;
diff --git a/litmus/skel.ml b/litmus/skel.ml
index 91d83289e..088c30055 100644
--- a/litmus/skel.ml
+++ b/litmus/skel.ml
@@ -368,11 +368,8 @@ module Make
 (* Right value, all cases *)
       let rec dump_a_v = function
         | Concrete i ->  A.V.Scalar.pp  Cfg.hexa i
-        | Symbolic _ as v when is_label v ->
-           Warn.user_error
-             "Labels cannot be used as initial values of memory locations"
-        | Symbolic (Virtual {name=s;tag=None; offset=0;_}) ->
-            dump_a_addr (Symbol.pp s)
+        | Symbolic (Virtual {name=Symbol.Data s;tag=None; offset=0;_}) ->
+            dump_a_addr s
         | ConcreteVector vs ->
            let pps =
              List.map

@artkhyzha artkhyzha force-pushed the labels-are-now-symbols branch 2 times, most recently from dea88e3 to 3e66500 Compare November 28, 2025 10:00
@artkhyzha
Copy link
Copy Markdown
Collaborator Author

artkhyzha commented Nov 28, 2025

Thank you, @murzinv, for the patch -- it indeed solves the regressions in litmus7.
Thank you, @diaolo01, for the comments -- I also updated the PR to account for those.

@artkhyzha
Copy link
Copy Markdown
Collaborator Author

This PR currently passes herd7 regressions and appears to have the same behaviour in litmus7. I suggest considering this ready for merging.

@maranget, would you have time to have a quick look at this PR? Essentially, the last concern I have is that this PR had conflicts with the changes that have been happening due to ASL+VMSA (I think). It would be helpful to know if any special care was needed in resolving the conflicts.

@artkhyzha artkhyzha force-pushed the labels-are-now-symbols branch 3 times, most recently from 9c2ad51 to 0d90624 Compare December 4, 2025 16:59
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Co-authored-by: Vladimir Murzin <vladimir.murzin@arm.com>
@artkhyzha artkhyzha force-pushed the labels-are-now-symbols branch from 0d90624 to dd1bfd5 Compare December 5, 2025 07:44
@artkhyzha artkhyzha merged commit cefb4e8 into herd:master Dec 5, 2025
5 checks passed
@artkhyzha
Copy link
Copy Markdown
Collaborator Author

Merged after a bit of grace period.

Thank you, @diaolo01 and @murzinv, for the reviews, and for preparing these changes, @relokin and @murzinv.

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.

4 participants