Skip to content

Print final register and memory states#96

Open
s-prism wants to merge 6 commits intomainfrom
x86-print-final-states
Open

Print final register and memory states#96
s-prism wants to merge 6 commits intomainfrom
x86-print-final-states

Conversation

@s-prism
Copy link
Copy Markdown
Collaborator

@s-prism s-prism commented Mar 27, 2026

  • Can now pass the print-final-states flag on the command line
  • If this flag is passed, prints all possible final states of the register and memory locations that the test is concerned with. Also print relevant statistics that mcompare wants.
    • Currently, arm register names start with 'R' and not 'X' or 'W'. This won't match other litmus testing tools.
  • Example structure of what we print:
    Test MP Allowed
    States 3
    1:rax=0; 1:rbx=0;
    1:rax=0; 1:rbx=1;
    1:rax=1; 1:rbx=1;
    No (allowed not found)
    Observation MP Never 0 3

@s-prism s-prism force-pushed the x86-print-final-states branch from be15e47 to a7e0546 Compare April 1, 2026 15:30
@s-prism s-prism changed the title Print final register states, and in progress for memory states Print final register and memory states Apr 1, 2026
@s-prism s-prism marked this pull request as ready for review April 2, 2026 22:22
Copy link
Copy Markdown
Collaborator

@tperami tperami left a comment

Choose a reason for hiding this comment

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

Sorry I forgot to click "Submit review"

@tperami
Copy link
Copy Markdown
Collaborator

tperami commented Apr 3, 2026

Also waiting on #102

@s-prism s-prism force-pushed the x86-print-final-states branch from a7e0546 to fd886c0 Compare April 3, 2026 20:19
@s-prism s-prism force-pushed the x86-print-final-states branch from 309e179 to 1e12b40 Compare April 8, 2026 12:47
(conds : (Testrepr.thread_cond list * Testrepr.mem_cond list) list) :
(int * string) list * Testrepr.mem_cond list
=
(* Assuming that each (Testrepr.thread_cond list * Testrepr.mem_cond list) already contains unique values *)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That might not be the case, but on the other hand that's irrelevant to the code below

(fun (acc_reg_cond, acc_mem_cond) (reg_cond, mem_cond) ->
let new_reg_cond = get_thread_regname_pairs reg_cond in
( List.sort_uniq compare (acc_reg_cond @ new_reg_cond),
List.sort_uniq compare_mem_id (acc_mem_cond @ mem_cond)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is resorting the list for every thread. Why don't you collect all and then run the sort at the end?

in
assert_equal Runner.Expected result
);
("EOR Expected with seq model"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Those tests are getting removed in another PR, so please remove them, sorry

@@ -0,0 +1,108 @@
type reg_state =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This module needs top-level documentation and a copyright header (Please run make headers for that)

In particular, it needs to mention this if for mcompare-compatible output

)
states

let compare_minimised_states
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I had no idea what this function did until I spend 5 min reading it, it needs a detailed comment

(List.length state_list - obs_count)
test_name

let run_executions print_final_states model init fuel term test =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you make print_final_states a label argument? Raw boolean are hard to maintain.

Suggested change
let run_executions print_final_states model init fuel term test =
let run_executions ~print_final_states model init fuel term test =

Comment on lines +159 to +169
- List.length
(List.fold_left
(fun unmatched_state_list (cond, mem_cond) ->
List.filter
(fun fs ->
not (check_outcome fs cond && check_mem_outcome fs mem_cond)
)
unmatched_state_list
)
state_list conds
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You should not have to recompute this

)
reg_cond

let compare_mem_id
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let compare_mem_id
let compare_mem_sym

Comment on lines +225 to +230
let conds = observable @ unobservable in
let unique_cond = MinimiseState.get_unique_conds_ignoring_value conds in
let minimised_fs = MinimiseState.minimise_states unique_cond final_states in
let unique_minimised_fs =
List.sort_uniq MinimiseState.compare_minimised_states minimised_fs
in
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be a function in minState.ml

)
else msg "ERROR: no conditions to observe"
)
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Most of this code should move to a separate function

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.

3 participants