Skip to content

Commit 4646c2e

Browse files
committed
flambda-backend: Merge ocaml-jst
2 parents e62f2b1 + a7d005a commit 4646c2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+237
-2033
lines changed

.github/workflows/build.yml

+19
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ jobs:
2121
use_runtime: d
2222
ocamlrunparam: "v=0,V=1"
2323

24+
- name: i386
25+
config: --enable-stack-allocation=no CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
26+
os: ubuntu-20.04
27+
ocamlparam: ''
28+
boot_config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
29+
boot_cachekey: 32bit
30+
2431
env:
2532
J: "3"
2633

@@ -29,6 +36,11 @@ jobs:
2936
if: matrix.os == 'macos-latest'
3037
run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install parallel
3138

39+
- name: Install GCC 32-bit libraries
40+
if: matrix.name == 'i386'
41+
run: |
42+
sudo apt-get install gcc-multilib gfortran-multilib
43+
3244
- name: Checkout the ocaml-jst repo
3345
uses: actions/checkout@master
3446
with:
@@ -49,6 +61,13 @@ jobs:
4961
path: 'ocaml-414'
5062
ref: '4.14'
5163

64+
- name: Setup 32-bit C compiler
65+
if: matrix.name == 'i386' && steps.cache.outputs.cache-hit != 'true'
66+
run: |
67+
mkdir -p ocaml-414/_install/bin
68+
{ echo '#!/bin/sh'; echo 'exec gcc -m32 "$@"'; } > ocaml-414/_install/bin/cc32
69+
chmod +x ocaml-414/_install/bin/cc32
70+
5271
- name: Build OCaml 4.14
5372
if: steps.cache.outputs.cache-hit != 'true'
5473
working-directory: ocaml-414

asmcomp/afl_instrument.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ and instrument = function
8888
Ccatch (isrec, cases, instrument body, kind)
8989
| Cexit (ex, args) -> Cexit (ex, List.map instrument args)
9090
| Cregion e -> Cregion (instrument e)
91-
| Cexclave e -> Cexclave (instrument e)
91+
| Ctail e -> Ctail (instrument e)
9292

9393
(* these are base cases and have no logging *)
9494
| Cconst_int _ | Cconst_natint _ | Cconst_float _

asmcomp/cmm.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ type expression =
206206
| Ctrywith of expression * Backend_var.With_provenance.t * expression
207207
* Debuginfo.t * kind_for_unboxing
208208
| Cregion of expression
209-
| Cexclave of expression
209+
| Ctail of expression
210210

211211
type codegen_option =
212212
| Reduce_code_size
@@ -270,7 +270,7 @@ let iter_shallow_tail f = function
270270
| Cexit _ | Cop (Craise _, _, _) ->
271271
true
272272
| Cregion _
273-
| Cexclave _
273+
| Ctail _
274274
| Cconst_int _
275275
| Cconst_natint _
276276
| Cconst_float _
@@ -312,7 +312,7 @@ let map_shallow_tail ?kind f = function
312312
| Cexit _ | Cop (Craise _, _, _) as cmm ->
313313
cmm
314314
| Cregion _
315-
| Cexclave _
315+
| Ctail _
316316
| Cconst_int _
317317
| Cconst_natint _
318318
| Cconst_float _
@@ -325,7 +325,7 @@ let map_shallow_tail ?kind f = function
325325
let map_tail ?kind f =
326326
let rec loop = function
327327
| Cregion _
328-
| Cexclave _
328+
| Ctail _
329329
| Cconst_int _
330330
| Cconst_natint _
331331
| Cconst_float _
@@ -367,7 +367,7 @@ let iter_shallow f = function
367367
f e1; f e2
368368
| Cregion e ->
369369
f e
370-
| Cexclave e ->
370+
| Ctail e ->
371371
f e
372372
| Cconst_int _
373373
| Cconst_natint _
@@ -404,8 +404,8 @@ let map_shallow f = function
404404
Ctrywith (f e1, id, f e2, dbg, value_kind)
405405
| Cregion e ->
406406
Cregion (f e)
407-
| Cexclave e ->
408-
Cexclave (f e)
407+
| Ctail e ->
408+
Ctail (f e)
409409
| Cconst_int _
410410
| Cconst_natint _
411411
| Cconst_float _

asmcomp/cmm.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ type expression =
210210
| Ctrywith of expression * Backend_var.With_provenance.t * expression
211211
* Debuginfo.t * kind_for_unboxing
212212
| Cregion of expression
213-
| Cexclave of expression
213+
| Ctail of expression
214214

215215
type codegen_option =
216216
| Reduce_code_size

asmcomp/cmm_helpers.ml

+8-4
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,13 @@ let rec unbox_float dbg =
619619
map_tail ~kind:Any
620620
(function
621621
| Cop (Capply (_, Rc_close_at_apply), _, _) -> raise Exit
622+
| Ctail e -> Ctail (unbox_float dbg e)
622623
| e -> unbox_float dbg e)
623624
e
624625
with
625626
| e -> Cregion e
626627
| exception Exit -> Cop (Cload (Double, Immutable), [cmm], dbg))
628+
| Ctail e -> Ctail (unbox_float dbg e)
627629
| cmm -> Cop(Cload (Double, Immutable), [cmm], dbg)
628630
)
629631

@@ -1307,11 +1309,13 @@ let rec unbox_int dbg bi =
13071309
map_tail ~kind:Any
13081310
(function
13091311
| Cop (Capply (_, Rc_close_at_apply), _, _) -> raise Exit
1312+
| Ctail e -> Ctail (unbox_int dbg bi e)
13101313
| e -> unbox_int dbg bi e)
13111314
e
13121315
with
13131316
| e -> Cregion e
13141317
| exception Exit -> default cmm)
1318+
| Ctail e -> Ctail (unbox_int dbg bi e)
13151319
| cmm ->
13161320
default cmm
13171321
)
@@ -2014,15 +2018,15 @@ let has_local_allocs e =
20142018
let rec loop = function
20152019
| Cregion e ->
20162020
(* Local allocations within a nested region do not affect this region,
2017-
except inside a Cexclave block *)
2021+
except inside a Ctail block *)
20182022
loop_until_tail e
20192023
| Cop (Calloc Alloc_local, _, _)
20202024
| Cop ((Cextcall _ | Capply _), _, _) ->
20212025
raise Exit
20222026
| e ->
20232027
iter_shallow loop e
20242028
and loop_until_tail = function
2025-
| Cexclave e -> loop e
2029+
| Ctail e -> loop e
20262030
| Cregion _ -> ()
20272031
| e -> ignore (iter_shallow_tail loop_until_tail e)
20282032
in
@@ -2032,13 +2036,13 @@ let has_local_allocs e =
20322036

20332037
let remove_region_tail e =
20342038
let rec has_tail = function
2035-
| Cexclave _
2039+
| Ctail _
20362040
| Cop(Capply(_, Rc_close_at_apply), _, _) -> raise Exit
20372041
| Cregion _ -> ()
20382042
| e -> ignore (iter_shallow_tail has_tail e)
20392043
in
20402044
let rec remove_tail = function
2041-
| Cexclave e -> e
2045+
| Ctail e -> e
20422046
| Cop(Capply(mach, Rc_close_at_apply), args, dbg) ->
20432047
Cop(Capply(mach, Rc_normal), args, dbg)
20442048
| Cregion _ as e -> e

asmcomp/cmm_invariants.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ let rec check env (expr : Cmm.expression) =
174174
check env body;
175175
check env handler
176176
| Cregion e -> check env e
177-
| Cexclave e -> check env e
177+
| Ctail e -> check env e
178178

179179
let run ppf (fundecl : Cmm.fundecl) =
180180
let env = Env.init () in

asmcomp/cmmgen.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ let rec expr_size env = function
190190
| _ -> assert false)
191191
| Uregion exp ->
192192
expr_size env exp
193-
| Uexclave exp ->
193+
| Utail exp ->
194194
expr_size env exp
195195
| _ -> RHS_nonrec
196196

@@ -368,7 +368,7 @@ let is_unboxed_number_cmm ~strict cmm =
368368
| _ ->
369369
notify No_unboxing
370370
end
371-
| Cregion e ->
371+
| Cregion e | Ctail e ->
372372
aux e
373373
| l ->
374374
if not (Cmm.iter_shallow_tail aux l) then
@@ -748,8 +748,8 @@ let rec transl env e =
748748
Cop(Cload (Word_int, Mutable), [Cconst_int (0, dbg)], dbg)
749749
| Uregion e ->
750750
region (transl env e)
751-
| Uexclave e ->
752-
Cexclave (transl env e)
751+
| Utail e ->
752+
Ctail (transl env e)
753753

754754
and transl_catch (kind : Cmm.kind_for_unboxing) env nfail ids body handler dbg =
755755
let ids = List.map (fun (id, kind) -> (id, kind, ref No_result)) ids in

asmcomp/printcmm.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ let rec expr ppf = function
272272
sequence e1 VP.print id sequence e2
273273
| Cregion e ->
274274
fprintf ppf "@[<2>(region@ %a)@]" sequence e
275-
| Cexclave e ->
276-
fprintf ppf "@[<2>(exclave@ %a)@]" sequence e
275+
| Ctail e ->
276+
fprintf ppf "@[<2>(tail@ %a)@]" sequence e
277277

278278
and sequence ppf = function
279279
| Csequence(e1, e2) -> fprintf ppf "%a@ %a" sequence e1 sequence e2

asmcomp/selectgen.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ method is_simple_expr = function
388388
| Ccmpf _ -> List.for_all self#is_simple_expr args
389389
end
390390
| Cassign _ | Cifthenelse _ | Cswitch _ | Ccatch _ | Cexit _
391-
| Ctrywith _ | Cregion _ | Cexclave _ -> false
391+
| Ctrywith _ | Cregion _ | Ctail _ -> false
392392

393393
(* Analyses the effects and coeffects of an expression. This is used across
394394
a whole list of expressions with a view to determining which expressions
@@ -435,7 +435,7 @@ method effects_of exp =
435435
in
436436
EC.join from_op (EC.join_list_map args self#effects_of)
437437
| Cassign _ | Cswitch _ | Ccatch _ | Cexit _ | Ctrywith _
438-
| Cregion _ | Cexclave _ ->
438+
| Cregion _ | Ctail _ ->
439439
EC.arbitrary
440440

441441
(* Says whether an integer constant is a suitable immediate argument for
@@ -974,9 +974,9 @@ method emit_expr_aux (env:environment) exp :
974974
assert (List.length unclosed <= List.length old_regions);
975975
Some (rd, unclosed)
976976
end
977-
| Cexclave e ->
977+
| Ctail e ->
978978
begin match env.regions with
979-
| [] -> Misc.fatal_error "Selectgen.emit_expr: Cexclave but not in tail of a region"
979+
| [] -> Misc.fatal_error "Selectgen.emit_expr: Ctail but not in tail of a region"
980980
| cl :: rest ->
981981
self#insert_endregions env [cl];
982982
self#emit_expr_aux { env with regions = rest } e
@@ -1320,9 +1320,9 @@ method emit_tail (env:environment) exp =
13201320
let reg = self#regs_for typ_int in
13211321
self#insert env (Iop Ibeginregion) [| |] reg;
13221322
self#emit_tail {env with regions = reg::env.regions} e
1323-
| Cexclave e ->
1323+
| Ctail e ->
13241324
begin match env.regions with
1325-
| [] -> Misc.fatal_error "Selectgen.emit_tail: Cexclave not inside Cregion"
1325+
| [] -> Misc.fatal_error "Selectgen.emit_tail: Ctail not inside Cregion"
13261326
| reg :: regions ->
13271327
self#insert_endregions env [reg];
13281328
self#emit_tail { env with regions } e

bytecomp/bytegen.ml

-2
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,6 @@ let rec comp_expr env exp sz cont =
10291029
comp_expr env exp sz cont
10301030
| Lregion (exp, _) ->
10311031
comp_expr env exp sz cont
1032-
| Lexclave exp ->
1033-
comp_expr env exp sz cont
10341032

10351033
(* Compile a list of arguments [e1; ...; eN] to a primitive operation.
10361034
The values of eN ... e2 are pushed on the stack, e2 at top of stack,

dune

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
;; CR gyorsh: it is not clear what the ":standard" flags are, and they
2626
;; may change depending on the version of dune.
2727
;; Consider hard-coded flags, such as -O3.
28-
(:standard -zero-alloc-check)))
28+
(:standard -zero-alloc-check -caml-apply-inline-fast-path)))
2929
(boot
3030
(flags
3131
(:standard -warn-error +A))))
@@ -150,7 +150,7 @@
150150
(action
151151
(no-infer
152152
(progn
153-
(chdir yacc (run make -s OCAMLYACC_INCLUDE_PATH=%{ocaml_where}))
153+
(chdir yacc (run make -sj8 OCAMLYACC_INCLUDE_PATH=%{ocaml_where}))
154154
(copy yacc/ocamlyacc ocamlyacc)))))
155155

156156
(install

0 commit comments

Comments
 (0)