Implementing cfg for risc
This commit is contained in:
@ -28,14 +28,14 @@ module type C = sig
|
||||
nodes: NodeSet.t;
|
||||
edges: (Node.t * (Node.t option)) NodeMap.t;
|
||||
reverseEdges: (Node.t list) NodeMap.t;
|
||||
inputVal: elt option;
|
||||
outputVal: elt option;
|
||||
inputVal: int option;
|
||||
inputOutputVar: (string * string) option;
|
||||
initial: Node.t option;
|
||||
terminal: Node.t option;
|
||||
content: elt list NodeMap.t
|
||||
}
|
||||
|
||||
val create : unit -> t
|
||||
val empty : t
|
||||
val merge : t -> t -> Node.t -> Node.t -> t
|
||||
val concat : t -> t -> t
|
||||
val addToLastNode : elt -> t -> t
|
||||
@ -50,20 +50,20 @@ module Make(M: PrintableType) = struct
|
||||
nodes: NodeSet.t;
|
||||
edges: (Node.t * (Node.t option)) NodeMap.t;
|
||||
reverseEdges: (Node.t list) NodeMap.t;
|
||||
inputVal: elt option;
|
||||
outputVal: elt option;
|
||||
inputVal: int option;
|
||||
inputOutputVar: (string * string) option;
|
||||
initial: Node.t option;
|
||||
terminal: Node.t option;
|
||||
content: elt list NodeMap.t
|
||||
}
|
||||
|
||||
let create () : t =
|
||||
let empty : t =
|
||||
{ empty = true;
|
||||
nodes = NodeSet.empty;
|
||||
edges = NodeMap.empty;
|
||||
reverseEdges = NodeMap.empty;
|
||||
inputVal = None;
|
||||
outputVal = None;
|
||||
inputOutputVar = None;
|
||||
initial = None;
|
||||
terminal = None;
|
||||
content = NodeMap.empty }
|
||||
@ -93,7 +93,7 @@ module Make(M: PrintableType) = struct
|
||||
NodeMap.add_to_list exitNode cfg1terminal |>
|
||||
NodeMap.add_to_list exitNode cfg2terminal;
|
||||
inputVal = cfg1.inputVal;
|
||||
outputVal = cfg1.outputVal;
|
||||
inputOutputVar = cfg1.inputOutputVar;
|
||||
initial = Some entryNode;
|
||||
terminal = Some exitNode;
|
||||
content = NodeMap.union (fun _ -> failwith "Failed merging code of cfg.")
|
||||
@ -118,7 +118,7 @@ module Make(M: PrintableType) = struct
|
||||
cfg1.reverseEdges cfg2.reverseEdges |>
|
||||
NodeMap.add_to_list cfg2initial cfg1terminal;
|
||||
inputVal = cfg1.inputVal;
|
||||
outputVal = cfg1.outputVal;
|
||||
inputOutputVar = cfg1.inputOutputVar;
|
||||
initial = Some cfg1initial;
|
||||
terminal = Some cfg2terminal;
|
||||
content = NodeMap.union (fun _ -> failwith "Failed merging code of cfg.")
|
||||
@ -133,7 +133,7 @@ module Make(M: PrintableType) = struct
|
||||
edges = NodeMap.empty;
|
||||
reverseEdges = NodeMap.empty;
|
||||
inputVal = None;
|
||||
outputVal = None;
|
||||
inputOutputVar = None;
|
||||
initial = Some newnode;
|
||||
terminal = Some newnode;
|
||||
content = NodeMap.singleton newnode [newcontent]
|
||||
@ -168,13 +168,13 @@ module Make(M: PrintableType) = struct
|
||||
|
||||
Printf.fprintf ppf "Input Value: ";
|
||||
(match c.inputVal with
|
||||
Some i -> Printf.fprintf ppf "%a" M.pp (i);
|
||||
Some i -> Printf.fprintf ppf "%d" i;
|
||||
| None -> Printf.fprintf ppf "None";);
|
||||
Printf.fprintf ppf "\n";
|
||||
|
||||
Printf.fprintf ppf "Output Value: ";
|
||||
(match c.outputVal with
|
||||
Some i -> Printf.fprintf ppf "%a" M.pp (i);
|
||||
Printf.fprintf ppf "Input and Output Vars: ";
|
||||
(match c.inputOutputVar with
|
||||
Some (i, o) -> Printf.fprintf ppf "(in: %s, out: %s)" i o;
|
||||
| None -> Printf.fprintf ppf "None";);
|
||||
Printf.fprintf ppf "\n";
|
||||
|
||||
|
||||
@ -5,7 +5,9 @@ module type PrintableType = sig
|
||||
end
|
||||
|
||||
module Node : sig
|
||||
type t
|
||||
type t = {
|
||||
id: int
|
||||
}
|
||||
val compare : t -> t -> int
|
||||
val create : unit -> t
|
||||
end
|
||||
@ -20,14 +22,14 @@ module type C = sig
|
||||
nodes: NodeSet.t;
|
||||
edges: (Node.t * (Node.t option)) NodeMap.t;
|
||||
reverseEdges: (Node.t list) NodeMap.t;
|
||||
inputVal: elt option;
|
||||
outputVal: elt option;
|
||||
inputVal: int option;
|
||||
inputOutputVar: (string * string) option;
|
||||
initial: Node.t option;
|
||||
terminal: Node.t option;
|
||||
content: elt list NodeMap.t
|
||||
}
|
||||
|
||||
val create : unit -> t
|
||||
val empty : t
|
||||
val merge : t -> t -> Node.t -> Node.t -> t
|
||||
val concat : t -> t -> t
|
||||
val addToLastNode : elt -> t -> t
|
||||
|
||||
Reference in New Issue
Block a user