Module Ertltree

module Ertltree: sig .. end

Explicit Register Transfer Language (ERTL)


type ident = string 

uniquement pour les fonctions

type register = Register.t 
type label = Label.t 
type instr = 
| Econst of int32 * register * label
| Eload of register * int * register * label
| Estore of register * register * int * label
| Emunop of Ops.munop * register * label
| Embinop of Ops.mbinop * register * register * label
| Emubranch of Ops.mubranch * register * label * label
| Embbranch of Ops.mbbranch * register * register * label
* label
| Egoto of label
| Ecall of ident * int * label (*

l'entier est le nombre de paramètres passés dans des registres

*)
| Ealloc_frame of label
| Edelete_frame of label
| Eget_param of int * register * label (*

r <- ofs(rbp)

*)
| Epush_param of register * label
| Ereturn

Les différentes instructions ERTL

type cfg = instr Label.map 

Un graphe de flot de contrôle est un dictionnaire associant à des étiquettes des instructions ERTL.

type deffun = {
   fun_name : ident;
   fun_formals : int;
   fun_locals : Register.set;
   fun_entry : label;
   fun_body : cfg;
}

Une fonction ERTL.

type file = {
   funs : deffun list;
}

Un programme ERTL.

Quelques fonctions qui seront utiles pour la phase suivante

val succ : instr -> label list

successeurs dans le graphe

val def_use : instr -> register list * register list

calcul des définitions et utilisations de chaque instruction

val visit : (label -> instr -> unit) ->
cfg -> label -> unit

visite le graphe de flot de contrôle à partir d'une étiquette donnée

Fonctions d'impression, pour debugger

val print_instr : Stdlib.Format.formatter -> instr -> unit
val print_graph : Stdlib.Format.formatter -> cfg -> label -> unit
val print_deffun : Stdlib.Format.formatter -> deffun -> unit
val print_file : Stdlib.Format.formatter -> file -> unit