| 1 |
(* |
| 2 |
* Basic Instruction properties that must be supported on all architectures. |
| 3 |
* |
| 4 |
* -- Allen |
| 5 |
*) |
| 6 |
signature INSN_PROPERTIES = |
| 7 |
sig |
| 8 |
structure I : INSTRUCTIONS |
| 9 |
structure C : CELLS |
| 10 |
(* sharing I.C = C *) |
| 11 |
|
| 12 |
(* classify instructions *) |
| 13 |
datatype kind = IK_JUMP (* branches, including returns *) |
| 14 |
| IK_NOP (* no ops *) |
| 15 |
| IK_INSTR (* normal instructions *) |
| 16 |
| IK_COPY (* parallel copy *) |
| 17 |
| IK_CALL (* call instructions *) |
| 18 |
| IK_CALL_WITH_CUTS (* call with cut edges *) |
| 19 |
| IK_PHI (* A phi node (SSA) *) |
| 20 |
| IK_SINK (* A sink node (SSA) *) |
| 21 |
| IK_SOURCE (* A source node (SSA) *) |
| 22 |
|
| 23 |
val instrKind : I.instruction -> kind |
| 24 |
|
| 25 |
(* parallel moves *) |
| 26 |
val moveInstr : I.instruction -> bool |
| 27 |
val moveTmpR : I.instruction -> CellsBasis.cell option |
| 28 |
val moveDstSrc : I.instruction -> CellsBasis.cell list * CellsBasis.cell list |
| 29 |
|
| 30 |
(* no op *) |
| 31 |
val nop : unit -> I.instruction |
| 32 |
|
| 33 |
(* jump instruction *) |
| 34 |
val jump : Label.label -> I.instruction |
| 35 |
|
| 36 |
(* load immediate; must be within immedRange *) |
| 37 |
val immedRange : {lo:int, hi:int} |
| 38 |
val loadImmed : {immed:int, t:CellsBasis.cell} -> I.instruction |
| 39 |
val loadOperand : {opn:I.operand, t:CellsBasis.cell} -> I.instruction |
| 40 |
|
| 41 |
(* |
| 42 |
* Targets of a branch instruction |
| 43 |
* precondition: instruction must be of type IK_JUMP. |
| 44 |
*) |
| 45 |
datatype target = LABELLED of Label.label | FALLTHROUGH | ESCAPES |
| 46 |
val branchTargets : I.instruction -> target list |
| 47 |
|
| 48 |
(* Set the jump target; error if not a jump instruction. *) |
| 49 |
val setJumpTarget : I.instruction * Label.label -> I.instruction |
| 50 |
|
| 51 |
(* Set the branch target; error if not a branch instruction, t=true, f=false case *) |
| 52 |
val setBranchTargets : {i:I.instruction, t:Label.label, f:Label.label} -> I.instruction |
| 53 |
|
| 54 |
(* equality and hashing on operands *) |
| 55 |
val eqOpn : I.operand * I.operand -> bool |
| 56 |
val hashOpn : I.operand -> word |
| 57 |
|
| 58 |
(* Given a conditional jump instruction and label, return a conditional |
| 59 |
* jump that has the complimentary condition and that targets the given |
| 60 |
* label. If the given instruction is not a conditional jump, then |
| 61 |
* the NegateConditional exception is raised. |
| 62 |
*) |
| 63 |
exception NegateConditional |
| 64 |
val negateConditional : (I.instruction * Label.label) -> I.instruction |
| 65 |
|
| 66 |
(* definition/use for the RA *) |
| 67 |
val defUse : CellsBasis.cellkind -> |
| 68 |
I.instruction -> (CellsBasis.cell list * CellsBasis.cell list) |
| 69 |
|
| 70 |
(* annotations *) |
| 71 |
val getAnnotations : I.instruction -> |
| 72 |
I.instruction * Annotations.annotation list |
| 73 |
val annotate : I.instruction * Annotations.annotation -> I.instruction |
| 74 |
|
| 75 |
val replicate : I.instruction -> I.instruction |
| 76 |
end |
| 77 |
|