Skip to content

Commit 58786c1

Browse files
committed
More of chacha compiling
1 parent 18353e8 commit 58786c1

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

lib/ClangToAst.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ let translate_fundecl (fdecl: function_decl) =
406406
| Some s -> translate_stmt env ret_type s.desc
407407
in
408408
let decl = Ast.(DFunction (None, [], 0, 0, ret_type, ([], name), args, body)) in
409-
KPrint.bprintf "Resulting decl %a\n" PrintAst.pdecl decl;
409+
(* KPrint.bprintf "Resulting decl %a\n" PrintAst.pdecl decl; *)
410410
decl
411411

412412
(* Returning an option is only a hack to make progress.
@@ -419,7 +419,7 @@ let translate_decl (decl: decl) = match decl.desc with
419419
let file_loc = loc.filename in
420420
(* TODO: Support multiple files *)
421421
if file_loc = "test.c" then (
422-
Printf.printf "Translating function %s\n" name;
422+
(* Printf.printf "Translating function %s\n" name; *)
423423
Some (translate_fundecl fdecl)
424424
) else None
425425
| _ -> None
@@ -428,7 +428,7 @@ let read_file () =
428428
let command_line_args = ["-DKRML_UNROLL_MAX 0"] in
429429
let ast = parse_file ~command_line_args "test.c" in
430430
(* Format.printf "@[%a@]@." (Refl.pp [%refl: Clang.Ast.translation_unit] []) ast; *)
431-
Printf.printf "Trying file %s\n" ast.desc.filename;
431+
(* Printf.printf "Trying file %s\n" ast.desc.filename; *)
432432
let decls = List.filter_map translate_decl ast.desc.items in
433433
let files = ["test", decls] in
434434
let files = Simplify.sequence_to_let#visit_files () files in

test.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ static inline void rounds(uint32_t *st)
7878
double_round(st);
7979
}
8080

81-
// static inline void chacha20_core(uint32_t *k, uint32_t *ctx, uint32_t ctr)
82-
// {
83-
// memcpy(k, ctx, 16U * sizeof (uint32_t));
84-
// uint32_t ctr_u32 = ctr;
85-
// k[12U] = k[12U] + ctr_u32;
86-
// rounds(k);
87-
// KRML_MAYBE_FOR16(i,
88-
// 0U,
89-
// 32U,
90-
// 1U,
91-
// uint32_t x = k[i] + ctx[i];
92-
// uint32_t *os = k;
93-
// os[i] = x;);
94-
// k[12U] = k[12U] + ctr_u32;
95-
// }
81+
static inline void chacha20_core(uint32_t *k, uint32_t *ctx, uint32_t ctr)
82+
{
83+
memcpy(k, ctx, 16U * sizeof (uint32_t));
84+
uint32_t ctr_u32 = ctr;
85+
k[12U] = k[12U] + ctr_u32;
86+
rounds(k);
87+
KRML_MAYBE_FOR16(i,
88+
0U,
89+
16U,
90+
1U,
91+
uint32_t x = k[i] + ctx[i];
92+
uint32_t *os = k;
93+
os[i] = x;);
94+
k[12U] = k[12U] + ctr_u32;
95+
}

0 commit comments

Comments
 (0)