Skip to content

Use the new directives in Arm #3

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

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1f28753
Refactor Reg stamps & machine regs (#3780)
TheNumbat Apr 17, 2025
853cf51
Fix for data_flow: correctly handle continuations that are never call…
Gbury Apr 18, 2025
9bdf91b
Auto-generate SSE instructions (#3853)
TheNumbat Apr 18, 2025
90f6c2b
Revert "modalities zap to id for mli-less files" (#3894)
riaqn Apr 18, 2025
980f0d1
Add failing test case for internal ticket 4263 (#3890)
goldfirere Apr 18, 2025
40c7d3b
flambda2(types): Refactor `add_equation` (#3873)
bclement-ocp Apr 18, 2025
3f9a57e
Critical edges (CFG) (#3891)
xclerc Apr 18, 2025
02ac936
Register classes (#3898)
xclerc Apr 21, 2025
cad7b76
Ensure register location equality is correct (#3899)
xclerc Apr 21, 2025
6284de0
Refactor amd64 simd (#3907)
TheNumbat Apr 21, 2025
8ccf974
DLS.access takes closure at unyielding (#3908)
tdelvecchio-jsc Apr 22, 2025
87ed06d
Fix use of -eliminate-dead-trap-handlers (#3905)
gretay-js Apr 22, 2025
e23ff86
Revert order for frametable expression (#3902)
spiessimon Apr 22, 2025
7524bbb
Remove direct assignment of the form x = e (#3906)
spiessimon Apr 22, 2025
0f1d0aa
Disable macOS on x86 (#3904)
spiessimon Apr 22, 2025
689b66c
Initial stab at documenting the kind system (#3559)
ccasin Apr 22, 2025
4b42aa3
Fix register allocator selection (#3912)
xclerc Apr 22, 2025
79633d2
Tweak condition forcing linscan (register allocation) (#3913)
xclerc Apr 22, 2025
1b74be7
Revert "Disable macOS on x86" (#3916)
spiessimon Apr 23, 2025
03c8aa7
Change unreachable `assert` to `Misc.fatal_errorf` (debugging arm iss…
xclerc Apr 23, 2025
b9885fe
#3917 for upstream (#3918)
xclerc Apr 23, 2025
b768626
`DLS.access` allows once (#3921)
TheNumbat Apr 23, 2025
0e191f3
Fix stack offsets (#3909)
gretay-js Apr 24, 2025
f3124af
Cfg_invariant check for stack offsets (#3910)
gretay-js Apr 24, 2025
00da641
Use [Are_rebuilding_terms.t] in DE instead of bool + other small chan…
Gbury Apr 24, 2025
159c81b
Stable ordering for bound continuations (#3887)
Gbury Apr 24, 2025
1c732b7
Index lifted cont params by variables instead of custom indexes (#3303)
Gbury Apr 24, 2025
7d862d0
No unboxed versions for mixed-float records (#3915)
rtjoa Apr 24, 2025
48e006b
Do not add extra_params to the lifted_cont_params (#3885)
Gbury Apr 24, 2025
0ef22fb
Delete the FCM in the assembly emitters (#3892)
spiessimon Apr 25, 2025
ae0ac31
new directives on arm
spiessimon Apr 25, 2025
a8cb612
review
spiessimon Apr 25, 2025
5483be7
add CR
spiessimon Apr 25, 2025
8c134ae
typo
spiessimon Apr 25, 2025
3fedc44
typo
spiessimon Apr 25, 2025
cbc2114
typo
spiessimon Apr 25, 2025
e86eb0b
fix range bound
spiessimon Apr 25, 2025
7675f78
review
spiessimon Apr 25, 2025
a5bc18a
add CR
spiessimon Apr 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
id: cache
with:
path: ${{ github.workspace }}/ocaml-414/_install
key: ${{ matrix.os }}-cache-ocaml-414-dune-3152-menhir-20231231
key: ${{ matrix.os }}-cache-ocaml-414-patched-dune-3152-menhir-20231231

- name: Checkout OCaml 4.14
uses: actions/checkout@master
Expand All @@ -219,6 +219,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ocaml-414
run: |
patch -p1 < $GITHUB_WORKSPACE/flambda_backend/arm64-issue-debug-upstream.patch
./configure --prefix=$GITHUB_WORKSPACE/ocaml-414/_install
make -j $J world.opt
make install
Expand Down
67 changes: 67 additions & 0 deletions arm64-issue-debug-upstream.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
diff --git a/driver/compenv.ml b/driver/compenv.ml
index 8b1c4e5559..3e7de2533d 100644
--- a/driver/compenv.ml
+++ b/driver/compenv.ml
@@ -489,6 +489,7 @@ let read_one_param ppf position name v =
let read_OCAMLPARAM ppf position =
try
let s = Sys.getenv "OCAMLPARAM" in
+ Warnings.parsed_ocamlparam := s;
if s <> "" then
let (before, after) =
try
diff --git a/utils/warnings.ml b/utils/warnings.ml
index 895ef2be07..dc7a23b6c9 100644
--- a/utils/warnings.ml
+++ b/utils/warnings.ml
@@ -459,7 +459,10 @@ let name_to_number =

(* Must be the max number returned by the [number] function. *)

-let letter = function
+let parsed_ocamlparam = ref "<not-set>"
+
+(* CR-soon xclerc for xclerc: remove the `for_debug` parameter... *)
+let letter for_debug = function
| 'a' ->
let rec loop i = if i = 0 then [] else i :: loop (i - 1) in
loop last_warning_number
@@ -488,7 +491,9 @@ let letter = function
| 'x' -> [14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 30]
| 'y' -> [26]
| 'z' -> [27]
- | _ -> assert false
+ | chr ->
+ let ocamlparam_from_env = match Sys.getenv_opt "OCAMLPARAM" with None -> "-" | Some value -> value in
+ Misc.fatal_errorf "Warnings.letter %C (for_debug=%S, ocamlparam_from_env=%S ocamlparam_from_compenv=%S)" chr for_debug ocamlparam_from_env !parsed_ocamlparam
;;

type state =
@@ -745,7 +750,7 @@ let parse_opt error active errflag s =
| None -> if c = lc then Clear else Set
| Some m -> m
in
- List.iter (action modifier) (letter lc)
+ List.iter (action modifier) (letter s lc)
| Num(n1,n2,modifier) ->
for n = n1 to Int.min n2 last_warning_number do action modifier n done
in
@@ -1131,7 +1136,7 @@ let help_warnings () =
print_endline " A all warnings";
for i = Char.code 'b' to Char.code 'z' do
let c = Char.chr i in
- match letter c with
+ match letter "<help-warnings>" c with
| [] -> ()
| [n] ->
Printf.printf " %c Alias for warning %i.\n" (Char.uppercase_ascii c) n
diff --git a/utils/warnings.mli b/utils/warnings.mli
index 3d9ea91f38..70d17a9181 100644
--- a/utils/warnings.mli
+++ b/utils/warnings.mli
@@ -161,3 +161,5 @@ type description =
description : string; }

val descriptions : description list
+
+val parsed_ocamlparam : string ref
17 changes: 10 additions & 7 deletions asmcomp/asmgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,15 @@ let write_ir prefix =

let should_emit () = not (should_stop_after Compiler_pass.Linearization)

let should_use_linscan fun_codegen_options =
!use_linscan || List.mem Cmm.Use_linscan_regalloc fun_codegen_options
(* note: `should_use_linscan` relies on the state of the `Reg` module, as the
list of temporaries is retrieved to be compared to the threshold. *)
let should_use_linscan fd =
!use_linscan
|| List.mem Cmm.Use_linscan_regalloc fd.fun_codegen_options
|| List.compare_length_with
(Reg.all_relocatable_regs ())
!Flambda_backend_flags.regalloc_linscan_threshold
> 0

let if_emit_do f x = if should_emit () then f x else ()

Expand Down Expand Up @@ -288,15 +295,12 @@ type register_allocator =
| IRC
| LS

let default_allocator = IRC

let register_allocator fd : register_allocator =
match String.lowercase_ascii !Flambda_backend_flags.regalloc with
| "cfg" -> if should_use_linscan fd.fun_codegen_options then LS else IRC
| "" | "cfg" -> if should_use_linscan fd then LS else IRC
| "gi" -> GI
| "irc" -> IRC
| "ls" -> LS
| "" -> default_allocator
| other -> Misc.fatal_errorf "unknown register allocator (%S)" other

let available_regs ~stack_slots ~f x =
Expand Down Expand Up @@ -376,7 +380,6 @@ let compile_cfg ppf_dump ~funcnames fd_cmm cfg_with_layout =

let compile_fundecl ~ppf_dump ~funcnames fd_cmm =
let module Cfg_selection = Cfg_selectgen.Make (Cfg_selection) in
Proc.init ();
Reg.clear_relocatable_regs ();
fd_cmm
++ Profile.record ~accumulate:true "cmm_invariants" (cmm_invariants ppf_dump)
Expand Down
8 changes: 8 additions & 0 deletions backend/.ocamlformat-enable
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
; CR-soon gyorsh: format all files under arm64/amd64
amd64/cfg_selection.ml
amd64/emit.ml
amd64/reg_class.ml
amd64/reg_class.mli
amd64/selection.ml
amd64/selection_utils.ml
amd64/simd*.ml
amd64/stack_check.ml
amd64/stack_class.ml
amd64/vectorize_specific.ml
amd64/regalloc_stack_operands.ml
arm64/cfg_selection.ml
arm64/emit.ml
arm64/reg_class.ml
arm64/reg_class.mli
arm64/selection.ml
arm64/selection_utils.ml
arm64/simd*.ml
Expand Down Expand Up @@ -62,6 +67,9 @@ printoperation.ml
printoperation.mli
printreg.ml
printreg.mli
reg_class.mli
reg_class_utils.ml
reg_class_utils.mli
proc.mli
regalloc/**/*.ml
regalloc/**/*.mli
Expand Down
1 change: 1 addition & 0 deletions backend/amd64/CSE.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let class_of_operation (op : Operation.t)
| Ibswap _ -> Use_default
| Irdtsc | Irdpmc
| Ilfence | Isfence | Imfence -> Class Op_other
| Ipackf32 -> Class Op_pure
| Isimd op ->
Class (of_simd_class (Simd.class_of_operation op))
| Isimd_mem (op,_addr) ->
Expand Down
25 changes: 18 additions & 7 deletions backend/amd64/arch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type specific_operation =
| Isfence (* store fence *)
| Imfence (* memory fence *)
| Ipause (* hint for spin-wait loops *)
| Ipackf32 (* UNPCKLPS on registers; see Cpackf32 *)
| Isimd of Simd.operation (* SIMD instruction set operations *)
| Isimd_mem of Simd.Mem.operation * addressing_mode
(* SIMD instruction set operations
Expand Down Expand Up @@ -301,6 +302,8 @@ let print_specific_operation printreg op ppf arg =
fprintf ppf "mfence"
| Irdpmc ->
fprintf ppf "rdpmc %a" printreg arg.(0)
| Ipackf32 ->
fprintf ppf "packf32 %a %a" printreg arg.(0) printreg arg.(1)
| Isimd simd ->
Simd.print_operation printreg simd ppf arg
| Isimd_mem (simd, addr) ->
Expand Down Expand Up @@ -330,14 +333,16 @@ let operation_is_pure = function
| Ilfence | Isfence | Imfence
| Istore_int (_, _, _) | Ioffset_loc (_, _)
| Icldemote _ | Iprefetch _ -> false
| Isimd op -> Simd.is_pure op
| Isimd_mem (op, _addr) -> Simd.Mem.is_pure op
| Ipackf32 -> true
| Isimd op -> Simd.is_pure_operation op
| Isimd_mem (op, _addr) -> Simd.Mem.is_pure_operation op

(* Keep in sync with [Vectorize_specific] *)
let operation_allocates = function
| Ilea _ | Ibswap _ | Isextend32 | Izextend32
| Ifloatarithmem _
| Irdtsc | Irdpmc | Ipause | Isimd _ | Isimd_mem _
| Irdtsc | Irdpmc | Ipause | Ipackf32
| Isimd _ | Isimd_mem _
| Ilfence | Isfence | Imfence
| Istore_int (_, _, _) | Ioffset_loc (_, _)
| Icldemote _ | Iprefetch _ -> false
Expand Down Expand Up @@ -419,7 +424,10 @@ let equal_specific_operation left right =
true
| Imfence, Imfence ->
true
| Ipause, Ipause -> true
| Ipause, Ipause ->
true
| Ipackf32, Ipackf32 ->
true
| Icldemote x, Icldemote x' -> equal_addressing_mode x x'
| Iprefetch { is_write = left_is_write; locality = left_locality; addr = left_addr; },
Iprefetch { is_write = right_is_write; locality = right_locality; addr = right_addr; } ->
Expand All @@ -432,7 +440,7 @@ let equal_specific_operation left right =
Simd.Mem.equal_operation l r && equal_addressing_mode al ar
| (Ilea _ | Istore_int _ | Ioffset_loc _ | Ifloatarithmem _ | Ibswap _ |
Isextend32 | Izextend32 | Irdtsc | Irdpmc | Ilfence | Isfence | Imfence |
Ipause | Isimd _ | Isimd_mem _ | Icldemote _ | Iprefetch _), _ ->
Ipause | Ipackf32 | Isimd _ | Isimd_mem _ | Icldemote _ | Iprefetch _), _ ->
false

(* addressing mode functions *)
Expand Down Expand Up @@ -528,7 +536,10 @@ let isomorphic_specific_operation op1 op2 =
true
| Imfence, Imfence ->
true
| Ipause, Ipause -> true
| Ipause, Ipause ->
true
| Ipackf32, Ipackf32 ->
true
| Icldemote x, Icldemote x' -> equal_addressing_mode_without_displ x x'
| Iprefetch { is_write = left_is_write; locality = left_locality; addr = left_addr; },
Iprefetch { is_write = right_is_write; locality = right_locality; addr = right_addr; } ->
Expand All @@ -541,5 +552,5 @@ let isomorphic_specific_operation op1 op2 =
Simd.Mem.equal_operation l r && equal_addressing_mode_without_displ al ar
| (Ilea _ | Istore_int _ | Ioffset_loc _ | Ifloatarithmem _ | Ibswap _ |
Isextend32 | Izextend32 | Irdtsc | Irdpmc | Ilfence | Isfence | Imfence |
Ipause | Isimd _ | Isimd_mem _ | Icldemote _ | Iprefetch _), _ ->
Ipause | Ipackf32 | Isimd _ | Isimd_mem _ | Icldemote _ | Iprefetch _), _ ->
false
1 change: 1 addition & 0 deletions backend/amd64/arch.mli
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type specific_operation =
| Isfence (* store fence *)
| Imfence (* memory fence *)
| Ipause (* hint for spin-wait loops *)
| Ipackf32 (* UNPCKLPS on registers; see Cpackf32 *)
| Isimd of Simd.operation (* SIMD instruction set operations *)
| Isimd_mem of Simd.Mem.operation * addressing_mode
(* SIMD instruction set operations
Expand Down
14 changes: 5 additions & 9 deletions backend/amd64/cfg_selection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ let pseudoregs_for_operation op arg res =
match (op : Operation.t) with
(* Two-address binary operations: arg.(0) and res.(0) must be the same *)
| Intop (Iadd | Isub | Imul | Iand | Ior | Ixor)
| Floatop ((Float32 | Float64), (Iaddf | Isubf | Imulf | Idivf)) ->
| Floatop ((Float32 | Float64), (Iaddf | Isubf | Imulf | Idivf))
| Specific Ipackf32 ->
[| res.(0); arg.(1) |], res
| Intop_atomic { op = Compare_set; size = _; addr = _ } ->
(* first arg must be rax *)
Expand Down Expand Up @@ -192,14 +193,9 @@ let pseudoregs_for_operation op arg res =
edx (high) and eax (low). Make it simple and force the argument in rcx,
and rax and rdx clobbered *)
[| rcx |], res
| Specific (Isimd op) ->
Simd_selection.pseudoregs_for_operation
(Simd_proc.register_behavior op)
arg res
| Specific (Isimd op) -> Simd_selection.pseudoregs_for_operation op arg res
| Specific (Isimd_mem (op, _addr)) ->
Simd_selection.pseudoregs_for_operation
(Simd_proc.Mem.register_behavior op)
arg res
Simd_selection.pseudoregs_for_mem_operation op arg res
| Csel _ ->
(* last arg must be the same as res.(0) *)
let len = Array.length arg in
Expand Down Expand Up @@ -351,7 +347,7 @@ let select_operation
a float stack slot, the resulting UNPCKLPS instruction would enforce the
validity of loading it as a 128-bit memory location, even though it only
loads 64 bits. *)
Rewritten (specific (Isimd (SSE Interleave_low_32_regs)), args)
Rewritten (specific Ipackf32, args)
(* Special cases overriding C implementations (regardless of [@@builtin]). *)
| Cextcall { func = "sqrt" as func; _ }
(* x86 intrinsics ([@@builtin]) *)
Expand Down
Loading