Added dataflow module

This commit is contained in:
elvis
2024-12-12 16:37:36 +01:00
parent 08a8d07422
commit 590123d988
17 changed files with 275 additions and 57 deletions

View File

@ -1,4 +1,5 @@
open Cfg
open Analysis
open Analysis.Cfg
module SimpleStatements = struct
type t =
@ -63,7 +64,7 @@ module SimpleStatements = struct
List.iter (fun x -> pp ppf x; Printf.printf "; ") c
end
module SSCfg = Cfg.Make(SimpleStatements)
module SSCfg = Cfg.Make(SimpleStatements)
let rec convert_c (prevcfg: SSCfg.t) (prg: Types.c_exp) : SSCfg.t =
let open SimpleStatements in

View File

@ -1,3 +1,5 @@
open Analysis
module SimpleStatements : sig
type t =
| SimpleSkip

View File

@ -1,3 +1,5 @@
open Analysis
module RISCSimpleStatements = struct
type register = {
index: string

View File

@ -1,3 +1,5 @@
open Analysis
module RISCSimpleStatements : sig
type register = {
index: string

View File

@ -1,3 +1,5 @@
open Analysis
let globalCounterLabel = ref 0
let nextLabel () : string =

View File

@ -0,0 +1,20 @@
open Analysis
module Variable = struct
type t = string
let pp (ppf: out_channel) (v: t) : unit =
Printf.fprintf ppf "%s" v
let pplist (ppf: out_channel) (vv: t list) : unit =
List.iter (Printf.fprintf ppf "%s, ") vv
end
module RISCCfg = CfgRISC.RISCCfg
module DVCfg = Dataflow.Make (CfgRISC.RISCSimpleStatements) (Variable)
let compute_defined_variables (cfg: RISCCfg.t) : DVCfg.t =
DVCfg.from_cfg cfg
let compute_cfg (dvcfg : DVCfg.t) : RISCCfg.t =
DVCfg.to_cfg dvcfg

View File

@ -0,0 +1,15 @@
open Analysis
module Variable : sig
type t
val pp : out_channel -> t -> unit
end
module RISCCfg = CfgRISC.RISCCfg
module DVCfg : Dataflow.C with type elt = CfgRISC.RISCSimpleStatements.t
and type internal = Variable.t
val compute_defined_variables : RISCCfg.t -> DVCfg.t
val compute_cfg : DVCfg.t -> RISCCfg.t

View File

@ -12,8 +12,8 @@
(public_name miniImp)
(modules Lexer Parser Types Semantics
CfgImp ReplacePowerMod
CfgRISC
CfgRISC DefinedVariables
RISC RISCSemantics)
(libraries cfg utility menhirLib))
(libraries analysis utility menhirLib))
(include_subdirs qualified)