<commit_before>open Ir
open Ir_printer
open Cg_llvm
open Llvm
open Llvm_executionengine
open Vectorize
open Unroll
open Split
open Constant_fold
open Schedule
open Lower
open Schedule_transforms
open Util

let compilation_cache = 
  Hashtbl.create 16

let codegen_to_c_callable e =
  let module Cg = Cg_for_target in
  let (c,m,f) = Cg.codegen_entry e in
  let w = Cg.codegen_c_wrapper c m f in
  (c,m,w)

let lower (f:string) (env:environment) (sched: schedule_tree) =
  (* Printexc.record_backtrace true; *)

  begin
    dbg 1 "Lowering function\n";
    let lowered = lower_function f env sched in
    (* Printf.printf "Breaking false dependences\n";
     let lowered = Break_false_dependence.break_false_dependence_stmt lowered in 
     Printf.printf "Constant folding\n";
     let lowered = Constant_fold.constant_fold_stmt lowered in
     Printf.printf "Breaking false dependences\n";
     let lowered = Break_false_dependence.break_false_dependence_stmt lowered in  *)
    dbg 0 "Before constant folding:\n%s\n" (string_of_stmt lowered);
    let lowered = Constant_fold.constant_fold_stmt lowered in 
    dbg 1 "Resulting stmt:\n%s\n" (string_of_stmt lowered);
    lowered
  end

  (* with x -> begin
    Printf.printf "Compilation failed. Backtrace:\n%s\n%!" (Printexc.get_backtrace ());
    raise x
  end *)

let compile name args stmt =

  Printexc.record_backtrace true;


  (* TODO: Canonicalize names. Variables get renamed to v0 v1
     v2... depending on the order in which they're found, arguments to
     a0, a1, a2, depending on the order that they occur in the
     arguments list. This is done to assist hashing. *)
<commit_msg>Dump <func>.lowered on lowering from C++<commit_after>open Ir
open Ir_printer
open Cg_llvm
open Llvm
open Llvm_executionengine
open Vectorize
open Unroll
open Split
open Constant_fold
open Schedule
open Lower
open Schedule_transforms
open Util

let compilation_cache = 
  Hashtbl.create 16

let codegen_to_c_callable e =
  let module Cg = Cg_for_target in
  let (c,m,f) = Cg.codegen_entry e in
  let w = Cg.codegen_c_wrapper c m f in
  (c,m,w)

let lower (f:string) (env:environment) (sched: schedule_tree) =
  (* Printexc.record_backtrace true; *)

  begin
    dbg 1 "Lowering function\n";
    let lowered = lower_function f env sched in
    (* Printf.printf "Breaking false dependences\n";
     let lowered = Break_false_dependence.break_false_dependence_stmt lowered in 
     Printf.printf "Constant folding\n";
     let lowered = Constant_fold.constant_fold_stmt lowered in
     Printf.printf "Breaking false dependences\n";
     let lowered = Break_false_dependence.break_false_dependence_stmt lowered in  *)
    dbg 0 "Before constant folding:\n%s\n" (string_of_stmt lowered);
    let lowered = Constant_fold.constant_fold_stmt lowered in 
    dbg 1 "Resulting stmt:\n%s\n" (string_of_stmt lowered);
    Printf.fprintf (open_out (f^".lowered")) "%s%!" (string_of_stmt lowered);
    lowered
  end

  (* with x -> begin
    Printf.printf "Compilation failed. Backtrace:\n%s\n%!" (Printexc.get_backtrace ());
    raise x
  end *)

let compile name args stmt =

  Printexc.record_backtrace true;


  (* TODO: Canonicalize names. Variables get renamed to v0 v1
     v2... depending on the order in which they're found, arguments to
     a0, a1, a2, depending on the order that they occur in the
     arguments list. This is done to assist hashing. *)

{'fraction_non_alphanumeric': 0.08061194468961459, 'fraction_numerical': 0.006472491909385114, 'mean_word_length': 3.8364153627311524, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '610111', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1097, 'n_words': 361}