| 1 |
(* |
| 2 |
* A table for storing operands for a compilation unit. |
| 3 |
* We give each distinct operand a unique (negative) value number. |
| 4 |
*) |
| 5 |
signature OPERAND_TABLE = |
| 6 |
sig |
| 7 |
|
| 8 |
structure I : INSTRUCTIONS |
| 9 |
|
| 10 |
type operandTable |
| 11 |
type valueNumber = I.C.cell |
| 12 |
|
| 13 |
datatype const = |
| 14 |
INT of int (* small integer operand *) |
| 15 |
| INTINF of MachineInt.machine_int (* large integer operand *) |
| 16 |
| OPERAND of I.operand (* other operand *) |
| 17 |
|
| 18 |
datatype valueNumberMethods = |
| 19 |
VALUE_NUMBERING of |
| 20 |
{ int : int -> valueNumber, |
| 21 |
word : word -> valueNumber, |
| 22 |
word32 : Word32.word -> valueNumber, |
| 23 |
int32 : Int32.int -> valueNumber, |
| 24 |
intinf : IntInf.int -> valueNumber, |
| 25 |
operand : I.operand -> valueNumber |
| 26 |
} |
| 27 |
|
| 28 |
exception NoOperand |
| 29 |
exception NoInt |
| 30 |
exception NoIntInf |
| 31 |
exception NoConst |
| 32 |
|
| 33 |
(* Special values *) |
| 34 |
val bot : valueNumber |
| 35 |
val top : valueNumber |
| 36 |
val volatile : valueNumber |
| 37 |
|
| 38 |
(* Create a new table *) |
| 39 |
val create : int ref -> operandTable |
| 40 |
|
| 41 |
(* Lookup methods *) |
| 42 |
|
| 43 |
(* Value number -> int/operand/label *) |
| 44 |
val const : valueNumber -> const |
| 45 |
val int : operandTable -> int -> valueNumber |
| 46 |
val word : operandTable -> word -> valueNumber |
| 47 |
val int32 : operandTable -> Int32.int -> valueNumber |
| 48 |
val word32 : operandTable -> Word32.word -> valueNumber |
| 49 |
val intinf : operandTable -> IntInf.int -> valueNumber |
| 50 |
val operand : operandTable -> I.operand -> valueNumber |
| 51 |
|
| 52 |
(* Create new value numbers *) |
| 53 |
val makeNewValueNumbers : operandTable -> valueNumberMethods |
| 54 |
|
| 55 |
(* Lookup but don't create *) |
| 56 |
val lookupValueNumbers : operandTable -> valueNumberMethods |
| 57 |
|
| 58 |
|
| 59 |
end |