summary refs log tree commit diff
path: root/source/mod_student
diff options
context:
space:
mode:
Diffstat (limited to 'source/mod_student')
-rw-r--r--source/mod_student/constant_folding.ml31
-rw-r--r--source/mod_student/constant_folding_analysis.ml31
2 files changed, 62 insertions, 0 deletions
diff --git a/source/mod_student/constant_folding.ml b/source/mod_student/constant_folding.ml
new file mode 100644
index 0000000..3bebcfa
--- /dev/null
+++ b/source/mod_student/constant_folding.ml
@@ -0,0 +1,31 @@
+open Xi_lib
+open Ir
+
+module Make(T:Iface.COMPILER_TOOLBOX) = struct
+
+  module Implementation(M:sig
+    val cfg : ControlFlowGraph.t 
+    val proc : procedure
+   end) = struct
+
+    open M
+
+    let cfa = T.ConstantFoldingAnalysis.analyse proc
+
+    let rewrite () = 
+      Logger.extra_debug begin fun () ->
+        Logger.dump_constant_folding "before-optimization" cfg cfa;
+      end;
+      failwith "not yet implemeneted"
+
+  end
+
+
+  let fold_constants proc = 
+    let module Instance = Implementation(struct
+      let proc = proc
+      let cfg = cfg_of_procedure proc
+    end) in
+    Instance.rewrite ()
+
+end
\ No newline at end of file
diff --git a/source/mod_student/constant_folding_analysis.ml b/source/mod_student/constant_folding_analysis.ml
new file mode 100644
index 0000000..40419cc
--- /dev/null
+++ b/source/mod_student/constant_folding_analysis.ml
@@ -0,0 +1,31 @@
+open Xi_lib
+open Ir
+open Ir_utils
+
+module Make() = struct
+
+  module Implementation(M:sig
+      val cfg: ControlFlowGraph.t
+      val initial: Analysis_domain.ConstantFolding.domain
+    end) = struct
+
+    open M
+
+    let analyse () = 
+      failwith "not yet implemented"
+  end
+
+
+
+  (* Skontruuj wartość ekstremalną *)
+  let make_initial n =
+    failwith "not yet implemented"
+
+  let analyse proc : Xi_lib.Analysis_domain.ConstantFolding.table =
+    let initial = make_initial @@ Ir.formal_parameters_of_procedure proc in
+    let cfg = Ir.cfg_of_procedure proc in
+    let module Instance = Implementation(struct let cfg = cfg let initial = initial end) in 
+    let result = Instance.analyse () in
+    result
+
+end
\ No newline at end of file