| 1 |
(* |
| 2 |
* This module implements the MLRISC annotations for describing |
| 3 |
* memory aliasing and control dependence. |
| 4 |
* |
| 5 |
* -- Allen |
| 6 |
*) |
| 7 |
|
| 8 |
structure MLRiscRegion :> MLRISC_REGION = |
| 9 |
struct |
| 10 |
|
| 11 |
datatype mutability = READONLY | IMMUTABLE | MUTABLE |
| 12 |
datatype region = ROOT |
| 13 |
| REGION of int * mutability * string * region |
| 14 |
| UNION of region list |
| 15 |
|
| 16 |
val counter = ref 0 |
| 17 |
|
| 18 |
val memory = ROOT |
| 19 |
fun new(name,mut,parent) = |
| 20 |
let val id = !counter |
| 21 |
in counter := id + 1; |
| 22 |
REGION(!counter,mut,name,parent) |
| 23 |
end |
| 24 |
|
| 25 |
val union = UNION |
| 26 |
val stack = new("stack",MUTABLE,memory) |
| 27 |
val heap = new("heap",MUTABLE,memory) |
| 28 |
val data = new("data",MUTABLE,memory) |
| 29 |
val readonly = new("readonly",READONLY,data) |
| 30 |
|
| 31 |
fun toString ROOT = "root" |
| 32 |
| toString(REGION(_,_,name,ROOT)) = name |
| 33 |
| toString(REGION(_,_,name,parent)) = toString parent^"."^name |
| 34 |
| toString(UNION rs) = |
| 35 |
String.concat(foldr (fn (r,[]) => [toString r] |
| 36 |
| (r,s) => toString r::"+"::s) [] rs) |
| 37 |
|
| 38 |
end |