Skip to content

Commit

Permalink
merged with origin/break-type-eq-between-boxed-and-unboxed
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanburen committed Dec 12, 2024
1 parent 9058c3f commit 09aef50
Show file tree
Hide file tree
Showing 29 changed files with 1,196 additions and 1,008 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,112 +10,112 @@ on:
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
runs-on: "${{ matrix.runs-on }}"

strategy:
fail-fast: false
matrix:
include:
- name: flambda2_runtime5
config: --enable-middle-end=flambda2 --enable-runtime5
os: ubuntu-latest
runs-on: linux-x64-1

- name: flambda2_dev
config: --enable-middle-end=flambda2 --enable-dev
os: ubuntu-latest
runs-on: linux-x64-1

- name: flambda2_dev_runtime5
config: --enable-middle-end=flambda2 --enable-dev --enable-runtime5
os: ubuntu-latest
runs-on: linux-x64-1

- name: flambda2_debug_runtime5
config: --enable-middle-end=flambda2 --enable-runtime5
os: ubuntu-latest
runs-on: linux-x64-2
build_ocamlparam: ''
use_runtime: d
ocamlrunparam: "v=0,V=1"

- name: flambda2_debug_runtime
config: --enable-middle-end=flambda2
os: ubuntu-latest
runs-on: linux-x64-2
build_ocamlparam: ''
use_runtime: d
ocamlrunparam: "v=0,V=1"

- name: flambda2_o3
config: --enable-middle-end=flambda2
os: ubuntu-latest
runs-on: linux-x64-2
build_ocamlparam: ''
ocamlparam: '_,O3=1'

- name: flambda2_o3_heap
config: --enable-middle-end=flambda2 --disable-stack-allocation
os: ubuntu-latest
runs-on: linux-x64-3
build_ocamlparam: ''
ocamlparam: '_,O3=1'

- name: flambda2_o3_advanced_meet_frame_pointers_runtime5_polling
config: --enable-middle-end=flambda2 --enable-frame-pointers --enable-runtime5 --enable-poll-insertion --enable-flambda-invariants
os: ubuntu-latest
runs-on: linux-x64-3
build_ocamlparam: ''
ocamlparam: '_,O3=1,flambda2-meet-algorithm=advanced,flambda2-expert-cont-lifting-budget=200'

- name: flambda2_o3_advanced_meet_frame_pointers_runtime5_debug
config: --enable-middle-end=flambda2 --enable-frame-pointers --enable-runtime5
os: ubuntu-latest
runs-on: linux-x64-3
build_ocamlparam: ''
use_runtime: d
ocamlparam: '_,O3=1,flambda2-meet-algorithm=advanced,flambda2-expert-cont-lifting-budget=200'

- name: flambda2_frame_pointers_oclassic_polling
config: --enable-middle-end=flambda2 --enable-frame-pointers --enable-poll-insertion --enable-flambda-invariants
os: ubuntu-latest
runs-on: linux-x64-4
build_ocamlparam: ''
ocamlparam: '_,Oclassic=1'
disable_testcases: 'testsuite/tests/typing-local/regression_cmm_unboxing.ml testsuite/tests/int64-unboxing/test.ml'

- name: flambda2_macos_arm64
config: --enable-middle-end=flambda2 --disable-warn-error
os: macos-latest
runs-on: macos-latest-xlarge

- name: irc
config: --enable-middle-end=flambda2
os: ubuntu-latest
runs-on: linux-x64-4
build_ocamlparam: '_,w=-46,regalloc=irc,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=IRC_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1'
ocamlparam: '_,w=-46,regalloc=irc,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=IRC_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1'
check_arch: true

- name: irc_polling
config: --enable-middle-end=flambda2 --enable-poll-insertion
os: ubuntu-latest
runs-on: linux-x64-4
build_ocamlparam: '_,w=-46,regalloc=irc,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=IRC_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1'
ocamlparam: '_,w=-46,regalloc=irc,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=IRC_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1'
check_arch: true

- name: irc_frame_pointers
config: --enable-middle-end=flambda2 --enable-frame-pointers
os: ubuntu-latest
runs-on: linux-x64-5
build_ocamlparam: '_,w=-46,regalloc=irc,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=IRC_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1'
ocamlparam: '_,w=-46,regalloc=irc,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=IRC_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1'
check_arch: true

- name: ls
config: --enable-middle-end=flambda2
os: ubuntu-latest
runs-on: linux-x64-5
build_ocamlparam: '_,w=-46,regalloc=ls,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=LS_ORDER:layout,regalloc-validate=1'
ocamlparam: '_,w=-46,regalloc=ls,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=LS_ORDER:layout,regalloc-validate=1'
check_arch: true

- name: gi
config: --enable-middle-end=flambda2
os: ubuntu-latest
runs-on: linux-x64-5
build_ocamlparam: '_,w=-46,regalloc=gi,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=GI_PRIORITY_HEURISTICS:interval-length,regalloc-param=GI_SELECTION_HEURISTICS:first-available,regalloc-param=GI_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1,cfg-cse-optimize=1'
ocamlparam: '_,w=-46,regalloc=gi,regalloc-param=SPLIT_LIVE_RANGES:on,regalloc-param=GI_PRIORITY_HEURISTICS:interval-length,regalloc-param=GI_SELECTION_HEURISTICS:first-available,regalloc-param=GI_SPILLING_HEURISTICS:flat-uses,regalloc-validate=1,cfg-cse-optimize=1'
check_arch: true

- name: cfg-selection
config: --enable-middle-end=flambda2
os: ubuntu-latest
runs-on: linux-x64-5
build_ocamlparam: '_,w=-46,regalloc=cfg,cfg-cse-optimize=1,cfg-selection=1,cfg-zero-alloc-checker=1'
ocamlparam: '_,w=-46,regalloc=cfg,cfg-cse-optimize=1,cfg-selection=1,cfg-zero-alloc-checker=1'
check_arch: true
Expand All @@ -132,25 +132,25 @@ jobs:
path: 'flambda_backend'

- name: Install AFL (for Linux workers)
if: matrix.os == 'ubuntu-latest'
if: matrix.runs-on != 'macos-latest-xlarge'
run: sudo apt-get install afl++

- name: Install AFL (for macOS workers)
# The "afl-fuzz" package is deprecated (2023-10) and can no longer be installed
if: matrix.os == 'macos-latest'
if: matrix.runs-on == 'macos-latest-xlarge'
run: true
# run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install afl-fuzz

- name: Install autoconf (for macOS workers)
if: matrix.os == 'macos-latest'
if: matrix.runs-on == 'macos-latest-xlarge'
run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install autoconf

- name: Cache OCaml 4.14, dune and menhir
uses: actions/cache@v4
id: cache
with:
path: ${{ github.workspace }}/ocaml-414/_install
key: ${{ matrix.os }}-cache-ocaml-414-dune-3152-menhir-20231231
key: ${{ matrix.runs-on }}-cache-ocaml-414-dune-3152-menhir-20231231

- name: Checkout OCaml 4.14
uses: actions/checkout@master
Expand Down Expand Up @@ -209,7 +209,7 @@ jobs:
cat $SOURCE_DIR/menhirLib.ml > $TARGET_DIR/menhirLib.ml
- name: Install GNU parallel
if: matrix.os == 'macos-latest'
if: matrix.runs-on == 'macos-latest-xlarge'
run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install parallel

- name: Disable any testcases
Expand Down
42 changes: 22 additions & 20 deletions backend/cmm_builtins.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let if_operation_supported op ~f =
match Proc.operation_supported op with true -> Some (f ()) | false -> None

let if_operation_supported_bi bi op ~f =
if bi = Primitive.Pint64 && size_int = 4
if bi = Primitive.Unboxed_int64 && size_int = 4
then None
else if_operation_supported op ~f

Expand All @@ -72,13 +72,13 @@ let clz ~arg_is_non_zero bi arg dbg =
let op = Cclz { arg_is_non_zero } in
if_operation_supported_bi bi op ~f:(fun () ->
let res = Cop (op, [make_unsigned_int bi arg dbg], dbg) in
if bi = Primitive.Pint32 && size_int = 8
if bi = Primitive.Unboxed_int32 && size_int = 8
then Cop (Caddi, [res; Cconst_int (-32, dbg)], dbg)
else res)

let ctz ~arg_is_non_zero bi arg dbg =
let arg = make_unsigned_int bi arg dbg in
if bi = Primitive.Pint32 && size_int = 8
if bi = Primitive.Unboxed_int32 && size_int = 8
then
(* regardless of the value of the argument [arg_is_non_zero], always set the
corresponding field to [true], because we make it non-zero below by
Expand Down Expand Up @@ -439,17 +439,17 @@ let transl_builtin name args dbg typ_res =
let arg = clear_sign_bit (one_arg name args) dbg in
Cop (Caddi, [Cop (op, [arg], dbg); Cconst_int (-1, dbg)], dbg))
| "caml_int64_clz_unboxed_to_untagged" ->
clz ~arg_is_non_zero:false Pint64 (one_arg name args) dbg
clz ~arg_is_non_zero:false Unboxed_int64 (one_arg name args) dbg
| "caml_int32_clz_unboxed_to_untagged" ->
clz ~arg_is_non_zero:false Pint32 (one_arg name args) dbg
clz ~arg_is_non_zero:false Unboxed_int32 (one_arg name args) dbg
| "caml_nativeint_clz_unboxed_to_untagged" ->
clz ~arg_is_non_zero:false Pnativeint (one_arg name args) dbg
clz ~arg_is_non_zero:false Unboxed_nativeint (one_arg name args) dbg
| "caml_int64_clz_nonzero_unboxed_to_untagged" ->
clz ~arg_is_non_zero:true Pint64 (one_arg name args) dbg
clz ~arg_is_non_zero:true Unboxed_int64 (one_arg name args) dbg
| "caml_int32_clz_nonzero_unboxed_to_untagged" ->
clz ~arg_is_non_zero:true Pint32 (one_arg name args) dbg
clz ~arg_is_non_zero:true Unboxed_int32 (one_arg name args) dbg
| "caml_nativeint_clz_nonzero_unboxed_to_untagged" ->
clz ~arg_is_non_zero:true Pnativeint (one_arg name args) dbg
clz ~arg_is_non_zero:true Unboxed_nativeint (one_arg name args) dbg
| "caml_int_popcnt_tagged_to_untagged" ->
if_operation_supported Cpopcnt ~f:(fun () ->
(* Having the argument tagged saves a shift, but there is one extra
Expand All @@ -462,11 +462,11 @@ let transl_builtin name args dbg typ_res =
let arg = clear_sign_bit (one_arg name args) dbg in
Cop (Cpopcnt, [arg], dbg))
| "caml_int64_popcnt_unboxed_to_untagged" ->
popcnt Pint64 (one_arg name args) dbg
popcnt Unboxed_int64 (one_arg name args) dbg
| "caml_int32_popcnt_unboxed_to_untagged" ->
popcnt Pint32 (one_arg name args) dbg
popcnt Unboxed_int32 (one_arg name args) dbg
| "caml_nativeint_popcnt_unboxed_to_untagged" ->
popcnt Pnativeint (one_arg name args) dbg
popcnt Unboxed_nativeint (one_arg name args) dbg
| "caml_int_ctz_untagged_to_untagged" ->
(* Assuming a 64-bit x86-64 target:
Expand Down Expand Up @@ -496,19 +496,21 @@ let transl_builtin name args dbg typ_res =
in
Cop (op, [Cop (Cor, [one_arg name args; c], dbg)], dbg))
| "caml_int32_ctz_unboxed_to_untagged" ->
ctz ~arg_is_non_zero:false Pint32 (one_arg name args) dbg
ctz ~arg_is_non_zero:false Unboxed_int32 (one_arg name args) dbg
| "caml_int64_ctz_unboxed_to_untagged" ->
ctz ~arg_is_non_zero:false Pint64 (one_arg name args) dbg
ctz ~arg_is_non_zero:false Unboxed_int64 (one_arg name args) dbg
| "caml_nativeint_ctz_unboxed_to_untagged" ->
ctz ~arg_is_non_zero:false Pnativeint (one_arg name args) dbg
ctz ~arg_is_non_zero:false Unboxed_nativeint (one_arg name args) dbg
| "caml_int32_ctz_nonzero_unboxed_to_untagged" ->
ctz ~arg_is_non_zero:true Pint32 (one_arg name args) dbg
ctz ~arg_is_non_zero:true Unboxed_int32 (one_arg name args) dbg
| "caml_int64_ctz_nonzero_unboxed_to_untagged" ->
ctz ~arg_is_non_zero:true Pint64 (one_arg name args) dbg
ctz ~arg_is_non_zero:true Unboxed_int64 (one_arg name args) dbg
| "caml_nativeint_ctz_nonzero_unboxed_to_untagged" ->
ctz ~arg_is_non_zero:true Pnativeint (one_arg name args) dbg
| "caml_signed_int64_mulh_unboxed" -> mulhi ~signed:true Pint64 args dbg
| "caml_unsigned_int64_mulh_unboxed" -> mulhi ~signed:false Pint64 args dbg
ctz ~arg_is_non_zero:true Unboxed_nativeint (one_arg name args) dbg
| "caml_signed_int64_mulh_unboxed" ->
mulhi ~signed:true Unboxed_int64 args dbg
| "caml_unsigned_int64_mulh_unboxed" ->
mulhi ~signed:false Unboxed_int64 args dbg
| "caml_int32_unsigned_to_int_trunc_unboxed_to_untagged" ->
Some (zero_extend_32 dbg (one_arg name args))
| "caml_csel_value" | "caml_csel_int_untagged" | "caml_csel_int64_unboxed"
Expand Down
Loading

0 comments on commit 09aef50

Please sign in to comment.