Skip to content

Commit

Permalink
Merge branch 'merge-5.2-staging' into merge-5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mshinwell committed Sep 20, 2024
2 parents 8db5026 + e1ee26b commit d77aa48
Show file tree
Hide file tree
Showing 248 changed files with 13,540 additions and 11,203 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
build_ocamlparam: ''
ocamlparam: '_,O3=1'

- name: flambda2_o3_advanced_meet_frame_pointers_runtime5
config: --enable-middle-end=flambda2 --enable-frame-pointers --enable-runtime5
- name: flambda2_o3_advanced_meet_frame_pointers_runtime5_polling
config: --enable-middle-end=flambda2 --enable-frame-pointers --enable-runtime5 --enable-poll-insertion
os: ubuntu-latest
build_ocamlparam: ''
ocamlparam: '_,O3=1,flambda2-meet-algorithm=advanced'
Expand All @@ -67,7 +67,7 @@ jobs:
use_runtime: d
ocamlparam: '_,O3=1,flambda2-meet-algorithm=advanced'

- name: flambda2_frame_pointers_oclassic
- name: flambda2_frame_pointers_oclassic_polling
config: --enable-middle-end=flambda2 --enable-frame-pointers --enable-poll-insertion
os: ubuntu-latest
build_ocamlparam: ''
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ocamllabs.ocaml-platform"
]
}
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@
"pmmintrin.h": "c",
"*.tbl": "c",
"platform.h": "c"
}
},
"[ocaml]": {
"editor.defaultFormatter": "ocamllabs.ocaml-platform",
},
"[ocaml.interface]": {
"editor.defaultFormatter": "ocamllabs.ocaml-platform",
},
"makefile.configureOnOpen": false,
}
10 changes: 9 additions & 1 deletion backend/.ocamlformat-enable
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

amd64/cfg_selection.ml
amd64/selection.ml
amd64/selection_utils.ml
amd64/simd*.ml
amd64/stack_check.ml
arm64/cfg_selection.ml
arm64/selection.ml
arm64/selection_utils.ml
arm64/simd*.ml
arm64/stack_check.ml
asm_targets/**/*.ml
Expand All @@ -11,6 +14,9 @@ asmgen.ml
asmgen.mli
cfg/**/*.ml
cfg/**/*.mli
cfg_selectgen.ml
cfg_selectgen.mli
cfg_selection.mli
cmm_builtins.ml
cmm_builtins.mli
cmm_helpers.ml
Expand All @@ -25,6 +31,8 @@ peephole/**/*.ml
peephole/**/*.mli
regalloc/**/*.ml
regalloc/**/*.mli
select_utils.ml
select_utils.mli
selectgen.ml
selectgen.mli
selection.mli
Expand Down
82 changes: 82 additions & 0 deletions backend/amd64/arch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,85 @@ let equal_specific_operation left right =
Isextend32 | Izextend32 | Irdtsc | Irdpmc | Ilfence | Isfence | Imfence |
Ipause | Isimd _ | Iprefetch _), _ ->
false

(* addressing mode functions *)

let compare_addressing_mode_without_displ (addressing_mode_1: addressing_mode) (addressing_mode_2 : addressing_mode) =
(* Ignores displ when comparing to show that it is possible to calculate the offset *)
match addressing_mode_1, addressing_mode_2 with
| Ibased (symbol1, global1, _), Ibased (symbol2, global2, _) -> (
match global1, global2 with
| Global, Global | Local, Local ->
String.compare symbol1 symbol2
| Global, Local -> -1
| Local, Global -> 1)
| Ibased _, _ -> -1
| _, Ibased _ -> 1
| Iindexed _, Iindexed _ -> 0
| Iindexed _, _ -> -1
| _, Iindexed _ -> 1
| Iindexed2 _, Iindexed2 _ -> 0
| Iindexed2 _, _ -> -1
| _, Iindexed2 _ -> 1
| Iscaled (scale1, _), Iscaled (scale2, _) -> Int.compare scale1 scale2
| Iscaled _, _ -> -1
| _, Iscaled _ -> 1
| Iindexed2scaled (scale1, _), Iindexed2scaled (scale2, _) ->
Int.compare scale1 scale2

let compare_addressing_mode_displ (addressing_mode_1: addressing_mode) (addressing_mode_2 : addressing_mode) =
match addressing_mode_1, addressing_mode_2 with
| Ibased (symbol1, global1, n1), Ibased (symbol2, global2, n2) -> (
match global1, global2 with
| Global, Global | Local, Local ->
if symbol1 = symbol2 then Some (Int.compare n1 n2) else None
| Global, Local | Local, Global -> None)
| Iindexed n1, Iindexed n2 -> Some (Int.compare n1 n2)
| Iindexed2 n1, Iindexed2 n2 -> Some (Int.compare n1 n2)
| Iscaled (scale1, n1), Iscaled (scale2, n2) ->
let scale_compare = scale1 - scale2 in
if scale_compare = 0 then Some (Int.compare n1 n2) else None
| Iindexed2scaled (scale1, n1), Iindexed2scaled (scale2, n2) ->
let scale_compare = scale1 - scale2 in
if scale_compare = 0 then Some (Int.compare n1 n2) else None
| Ibased _, _ -> None
| Iindexed _, _ -> None
| Iindexed2 _, _ -> None
| Iscaled _, _ -> None
| Iindexed2scaled _, _ -> None

let addressing_offset_in_bytes (addressing_mode_1: addressing_mode) (addressing_mode_2 : addressing_mode) =
match addressing_mode_1, addressing_mode_2 with
| Ibased (symbol1, global1, n1), Ibased (symbol2, global2, n2) -> (
match global1, global2 with
| Global, Global | Local, Local ->
if symbol1 = symbol2 then Some (n2 - n1) else None
| Global, Local | Local, Global -> None)
| Iindexed n1, Iindexed n2 -> Some (n2 - n1)
| Iindexed2 n1, Iindexed2 n2 -> Some (n2 - n1)
| Iscaled (scale1, n1), Iscaled (scale2, n2) ->
let scale_compare = scale1 - scale2 in
if scale_compare = 0 then Some (n2 - n1) else None
| Iindexed2scaled (scale1, n1), Iindexed2scaled (scale2, n2) ->
let scale_compare = scale1 - scale2 in
if scale_compare = 0 then Some (n2 - n1) else None
| Ibased _, _ -> None
| Iindexed _, _ -> None
| Iindexed2 _, _ -> None
| Iscaled _, _ -> None
| Iindexed2scaled _, _ -> None

let can_cross_loads_or_stores (specific_operation : specific_operation) =
match specific_operation with
| Ilea _ | Istore_int _ | Ioffset_loc _ | Ifloatarithmem _ | Isimd _ | Iprefetch _ ->
false
| Ibswap _ | Isextend32 | Izextend32 | Irdtsc | Irdpmc | Ilfence | Isfence | Imfence
| Ipause ->
true

let may_break_alloc_freshness (specific_operation : specific_operation) =
match specific_operation with
| Isimd _ -> true
| Ilea _ | Istore_int _ | Ioffset_loc _ | Ifloatarithmem _ | Ibswap _ | Isextend32
| Izextend32 | Irdtsc | Irdpmc | Ilfence | Isfence | Imfence | Ipause | Iprefetch _ ->
false
12 changes: 12 additions & 0 deletions backend/amd64/arch.mli
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,15 @@ val operation_allocates : specific_operation -> bool

val float_cond_and_need_swap
: Lambda.float_comparison -> X86_ast.float_condition * bool

(* addressing mode functions *)

val compare_addressing_mode_without_displ : addressing_mode -> addressing_mode -> int

val compare_addressing_mode_displ : addressing_mode -> addressing_mode -> int option

val addressing_offset_in_bytes : addressing_mode -> addressing_mode -> int option

val can_cross_loads_or_stores : specific_operation -> bool

val may_break_alloc_freshness : specific_operation -> bool
Loading

0 comments on commit d77aa48

Please sign in to comment.