Skip to content

Commit 791f112

Browse files
committed
Formatting
Signed-off-by: Lukasz Stafiniak <lukstafi@gmail.com>
1 parent 39f122f commit 791f112

16 files changed

+315
-214
lines changed

arrayjit/bin/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
(libraries utils)
55
(preprocess
66
(pps ppx_minidebug ppx_sexp_conv))
7-
(modes exe))
7+
(modes exe))

arrayjit/bin/read_config.ml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@ open Base
22
open Stdio
33

44
let extract_config arg =
5-
let prefixes = ["--read="; "--read-"; "--read_"] in
5+
let prefixes = [ "--read="; "--read-"; "--read_" ] in
66
List.find_map prefixes ~f:(fun prefix ->
7-
Option.map (String.chop_prefix arg ~prefix) ~f:(fun config -> config))
7+
Option.map (String.chop_prefix arg ~prefix) ~f:(fun config -> config))
88

99
let () =
10-
let config_opt =
11-
Array.find_map Stdlib.Sys.argv ~f:extract_config
12-
in
10+
let config_opt = Array.find_map Stdlib.Sys.argv ~f:extract_config in
1311
match config_opt with
14-
| Some config ->
12+
| Some config -> (
1513
let value = Utils.get_global_arg ~default:"" ~arg_name:config in
1614
let filename = "ocannl_" ^ config ^ ".txt" in
17-
(try
18-
Out_channel.write_all filename ~data:value;
19-
printf "Wrote value of '%s' to %s\n" config filename
20-
with exn ->
21-
eprintf "Error writing to %s: %s\n" filename (Exn.to_string exn))
22-
| None ->
23-
printf "No --read=<config>, --read-<config>, or --read_<config> argument found.\n"
15+
try
16+
Out_channel.write_all filename ~data:value;
17+
printf "Wrote value of '%s' to %s\n" config filename
18+
with exn -> eprintf "Error writing to %s: %s\n" filename (Exn.to_string exn))
19+
| None -> printf "No --read=<config>, --read-<config>, or --read_<config> argument found.\n"

arrayjit/lib/assignments.ml

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ let get_ident_within_code ?no_dots c =
282282
let to_doc ?name ?static_indices () c =
283283
let ident = get_ident_within_code c in
284284
let buffer_ident = function Node tn -> ident tn | Merge_buffer tn -> ident tn ^ ".merge" in
285-
285+
286286
let open PPrint in
287287
let doc_of_fetch_op (op : fetch_op) =
288288
match op with
@@ -298,76 +298,83 @@ let to_doc ?name ?static_indices () c =
298298
| Embed_symbol { static_symbol; static_range = _ } ->
299299
string ("!@" ^ Indexing.symbol_ident static_symbol)
300300
in
301-
301+
302302
let rec doc_of_code = function
303303
| Noop -> empty
304-
| Seq (c1, c2) ->
305-
doc_of_code c1 ^^ doc_of_code c2
304+
| Seq (c1, c2) -> doc_of_code c1 ^^ doc_of_code c2
306305
| Block_comment (s, Noop) -> string ("# \"" ^ s ^ "\";") ^^ break 1
307-
| Block_comment (s, c) ->
308-
string ("# \"" ^ s ^ "\";") ^^ break 1 ^^ doc_of_code c
306+
| Block_comment (s, c) -> string ("# \"" ^ s ^ "\";") ^^ break 1 ^^ doc_of_code c
309307
| Accum_ternop { initialize_neutral; accum; op; lhs; rhs1; rhs2; rhs3; projections } ->
310308
let proj_spec =
311309
if Lazy.is_val projections then (Lazy.force projections).debug_info.spec
312310
else "<not-in-yet>"
313311
in
314312
(* Uncurried syntax for ternary operations. *)
315-
string (ident lhs) ^^ space ^^
316-
string (Ops.assign_op_cd_syntax ~initialize_neutral accum) ^^ space ^^
317-
string (Ops.ternop_cd_syntax op) ^^
318-
string "(" ^^ string (buffer_ident rhs1) ^^ string ", " ^^
319-
string (buffer_ident rhs2) ^^ string ", " ^^
320-
string (buffer_ident rhs3) ^^ string ")" ^^
321-
(if not (String.equal proj_spec ".") then
322-
string (" ~logic:\"" ^ proj_spec ^ "\"")
323-
else empty) ^^
324-
string ";" ^^ break 1
313+
string (ident lhs)
314+
^^ space
315+
^^ string (Ops.assign_op_cd_syntax ~initialize_neutral accum)
316+
^^ space
317+
^^ string (Ops.ternop_cd_syntax op)
318+
^^ string "("
319+
^^ string (buffer_ident rhs1)
320+
^^ string ", "
321+
^^ string (buffer_ident rhs2)
322+
^^ string ", "
323+
^^ string (buffer_ident rhs3)
324+
^^ string ")"
325+
^^ (if not (String.equal proj_spec ".") then string (" ~logic:\"" ^ proj_spec ^ "\"")
326+
else empty)
327+
^^ string ";" ^^ break 1
325328
| Accum_binop { initialize_neutral; accum; op; lhs; rhs1; rhs2; projections } ->
326329
let proj_spec =
327330
if Lazy.is_val projections then (Lazy.force projections).debug_info.spec
328331
else "<not-in-yet>"
329332
in
330-
string (ident lhs) ^^ space ^^
331-
string (Ops.assign_op_cd_syntax ~initialize_neutral accum) ^^ space ^^
332-
string (buffer_ident rhs1) ^^ space ^^
333-
string (Ops.binop_cd_syntax op) ^^ space ^^
334-
string (buffer_ident rhs2) ^^
335-
(if (not (String.equal proj_spec ".")) ||
336-
List.mem ~equal:Ops.equal_binop Ops.[ Mul; Div ] op
337-
then string (" ~logic:\"" ^ proj_spec ^ "\"")
338-
else empty) ^^
339-
string ";" ^^ break 1
333+
string (ident lhs)
334+
^^ space
335+
^^ string (Ops.assign_op_cd_syntax ~initialize_neutral accum)
336+
^^ space
337+
^^ string (buffer_ident rhs1)
338+
^^ space
339+
^^ string (Ops.binop_cd_syntax op)
340+
^^ space
341+
^^ string (buffer_ident rhs2)
342+
^^ (if
343+
(not (String.equal proj_spec "."))
344+
|| List.mem ~equal:Ops.equal_binop Ops.[ Mul; Div ] op
345+
then string (" ~logic:\"" ^ proj_spec ^ "\"")
346+
else empty)
347+
^^ string ";" ^^ break 1
340348
| Accum_unop { initialize_neutral; accum; op; lhs; rhs; projections } ->
341349
let proj_spec =
342350
if Lazy.is_val projections then (Lazy.force projections).debug_info.spec
343351
else "<not-in-yet>"
344352
in
345-
string (ident lhs) ^^ space ^^
346-
string (Ops.assign_op_cd_syntax ~initialize_neutral accum) ^^ space ^^
347-
(if not @@ Ops.equal_unop op Ops.Identity then
348-
string (Ops.unop_cd_syntax op ^ " ")
349-
else empty) ^^
350-
string (buffer_ident rhs) ^^
351-
(if not (String.equal proj_spec ".") then
352-
string (" ~logic:\"" ^ proj_spec ^ "\"")
353-
else empty) ^^
354-
string ";" ^^ break 1
353+
string (ident lhs)
354+
^^ space
355+
^^ string (Ops.assign_op_cd_syntax ~initialize_neutral accum)
356+
^^ space
357+
^^ (if not @@ Ops.equal_unop op Ops.Identity then string (Ops.unop_cd_syntax op ^ " ")
358+
else empty)
359+
^^ string (buffer_ident rhs)
360+
^^ (if not (String.equal proj_spec ".") then string (" ~logic:\"" ^ proj_spec ^ "\"")
361+
else empty)
362+
^^ string ";" ^^ break 1
355363
| Fetch { array; fetch_op; dims = _ } ->
356364
string (ident array) ^^ string " := " ^^ doc_of_fetch_op fetch_op ^^ string ";" ^^ break 1
357365
in
358-
366+
359367
(* Create the header document *)
360-
let header_doc =
361-
match name, static_indices with
362-
| Some n, Some si ->
363-
string (n ^ " (") ^^
364-
separate (comma ^^ space)
365-
(List.map si ~f:Indexing.Doc_helpers.pp_static_symbol) ^^
366-
string "):" ^^ space
368+
let header_doc =
369+
match (name, static_indices) with
370+
| Some n, Some si ->
371+
string (n ^ " (")
372+
^^ separate (comma ^^ space) (List.map si ~f:Indexing.Doc_helpers.pp_static_symbol)
373+
^^ string "):" ^^ space
367374
| Some n, None -> string (n ^ ":") ^^ space
368375
| _ -> empty
369376
in
370-
377+
371378
header_doc ^^ nest 2 (doc_of_code c)
372379

373380
let%track6_sexp lower ~unoptim_ll_source ~ll_source ~cd_source ~name static_indices (proc : t) :

0 commit comments

Comments
 (0)