]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - src/ASM/MIPSOps.mli
Imported Upstream version 0.2
[pkg-cerco/acc.git] / src / ASM / MIPSOps.mli
1
2 (** This module defines the operators and branch conditions of the
3     MIPS processor. *)
4
5 (* Pasted from Pottier's PP compiler *)
6
7 (* These type definitions document the target processor's operators
8    and branch conditions. Here, the target processor is the MIPS. *)
9
10 (* The MIPS manual explains that some instructions are actual machine
11    instructions, while others are pseudo-instructions, which are
12    expanded away by the assembler. Do we need to be aware of the
13    distinction?
14
15    Ignoring the distinction is interesting. There are several
16    processors in the MIPS family, and the distinction between actual
17    instructions and pseudo-instructions might vary with the
18    processor. For instance, a future member of the MIPS family might
19    implement more instructions in hardware than its predecessors.
20
21    On the other hand, ignoring the distinction means that we cannot
22    use the hardware register [$at], which is reserved by the assembler
23    for translating some pseudo-instructions into actual instructions.
24
25    Our approach is to follow standard practice and to exploit
26    pseudo-instructions when desired. This means that we cannot use
27    register [$at]. *)
28
29 (* Immediate constants, used in the definition of some operators. They
30    must fit in 16 bits. *)
31
32 type immediate16 =
33    int32
34
35 (* Offsets, used as part of addressing modes. They are measured in
36    bytes and must fit in 16 bits. *)
37
38 type offset =
39    immediate16
40
41 (* Unary (integer arithmetic) operators. *)
42
43 type unop =
44   | UOpAddi of immediate16
45   | UOpSlti of immediate16 (* set on less than immediate *)
46   | UOpSltiu of immediate16
47   | UOpAndi of immediate16
48   | UOpOri of immediate16
49   | UOpXori of immediate16
50   | UOpNeg
51   | UOpNot
52
53 (* Binary (integer arithmetic or integer comparison) operators. Among
54    the comparison operators, only [OpLt] corresponds to a MIPS binary
55    comparison instruction, namely [slt]. All others correspond to
56    pseudo-instructions. They are exploited because they are
57    convenient. *)
58
59 type binop =
60   | OpAdd
61   | OpSub
62   | OpMul
63   | OpDiv
64   | OpDivu
65   | OpModu
66   | OpLt                    
67   | OpLtu
68   | OpLe
69   | OpLeu
70   | OpGt
71   | OpGtu
72   | OpGe
73   | OpGeu
74   | OpEq
75   | OpNe
76   | OpSllv
77   | OpSrav
78   | OpSrlv
79   | OpAnd
80   | OpOr
81   | OpXor
82
83 (* Unary branch conditions. *)
84
85 type uncon =
86
87     (* Greater than or equal to zero. *)
88
89   | UConGez
90
91     (* Greater than zero. *)
92
93   | UConGtz
94
95     (* Less than or equal to zero. *)
96
97   | UConLez
98
99     (* Less than zero. *)
100
101   | UConLtz
102
103 (* Binary branch conditions. *)
104
105 and bincon =
106
107     (* Equal. *)
108
109   | ConEq
110
111     (* Not equal. *)
112
113   | ConNe