Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid polymorphic comparison in backend #3649

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

xclerc
Copy link
Contributor

@xclerc xclerc commented Mar 4, 2025

(As per title.)

@xclerc xclerc added cfg backend non-material change Formatting, renaming, etc. but no semantic or public API changes labels Mar 4, 2025
Copy link

github-actions bot commented Mar 4, 2025

Selection Change Check

This PR modifies the original selection pass (targeting Mach).
Please check whether the changes should also be applied to the
CFG variant of the pass.

@xclerc xclerc force-pushed the shadow-poly-compare-further4 branch from f542d6e to 074c7f8 Compare March 4, 2025 16:25
@xclerc xclerc marked this pull request as ready for review March 4, 2025 17:16
@xclerc xclerc requested a review from gretay-js March 4, 2025 17:16
@xclerc xclerc force-pushed the shadow-poly-compare-further4 branch from adb2b97 to 1195cf7 Compare March 5, 2025 13:39
@@ -181,6 +188,8 @@ type emit_frame_actions =
efa_string : string -> unit
}

let is_empty = function [] -> true | _ :: _ -> false
Copy link
Contributor

Choose a reason for hiding this comment

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

Another use of Misc.List.is_empty.

@@ -223,7 +224,7 @@ let reset() =
soft pseudo-registers *)
if !first_virtual_reg_stamp = -1 then begin
first_virtual_reg_stamp := !currstamp;
assert (!reg_list = []) (* Only hard regs created before now *)
assert (match !reg_list with [] -> true | _ :: _ -> false) (* Only hard regs created before now *)
Copy link
Contributor

Choose a reason for hiding this comment

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

Misc.List.is_empty ?

@@ -2133,6 +2134,10 @@ let assemble_instr b loc = function
| TZCNT (src, dst) -> emit_tzcnt b ~dst ~src
| LZCNT (src, dst) -> emit_lzcnt b ~dst ~src

let is_win32 = function
Copy link
Contributor

Choose a reason for hiding this comment

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

I think one of the prevous PRs added it (or similar functions) somewhere. It would be nice to put them all together in one of X86_* files.

@@ -478,7 +479,7 @@ let emit_prefix_modrm b opcodes rm reg ~prefix =
let idx_reg = idx in
let idx = rd_of_reg64 idx in
if scale = 0 then (
assert (base = None && arch = X86);
assert (Option.is_none base && (match arch with X86 -> true | X64 -> false));
Copy link
Contributor

Choose a reason for hiding this comment

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

consider factoring out this match into a separate function.

@@ -108,15 +109,18 @@ let windows =
| _ -> false

let string_of_substring_literal k n s =
let between x low high =
Copy link
Contributor

Choose a reason for hiding this comment

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

This string_of_substring_literal is very similar to emit_aux , I don't remember why we have both, maybe we can refactor it (in a separate PR, I added a note to "The list").

let n =
match system with
| S_macosx -> Misc.log2 n
| _ -> n
Copy link
Contributor

Choose a reason for hiding this comment

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

We should turn on warnings here I guess? Maybe just fix this new _ for now and we can have separate PR later to turn on the warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I think we already have is_macosx helper somewhere.

if system = S_solaris then bprintf b "\t.zero\t%d" n
else bprintf b "\t.space\t%d" n
(match system with
| S_solaris -> bprintf b "\t.zero\t%d" n
Copy link
Contributor

Choose a reason for hiding this comment

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

do we still need S_solaris ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend cfg non-material change Formatting, renaming, etc. but no semantic or public API changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants