1 | |
---|
2 | include Arch.S |
---|
3 | |
---|
4 | (* |
---|
5 | (* Adapted from Pottier's PP compiler *) |
---|
6 | |
---|
7 | (** This module defines the physical registers of the MIPS processor |
---|
8 | and their conventional use. *) |
---|
9 | |
---|
10 | (* This is the size of a machine word in bytes. *) |
---|
11 | |
---|
12 | val word: int32 |
---|
13 | |
---|
14 | (* This is the type of hardware registers. *) |
---|
15 | |
---|
16 | type register |
---|
17 | |
---|
18 | val equal: register -> register -> bool |
---|
19 | (* Names *) |
---|
20 | val print: register -> string |
---|
21 | (* Number *) |
---|
22 | val print2: register -> string |
---|
23 | |
---|
24 | (* A list of the registers used for passing function parameters. *) |
---|
25 | |
---|
26 | val parameters: register list |
---|
27 | |
---|
28 | (* The register used for returning function results. *) |
---|
29 | |
---|
30 | val result: register |
---|
31 | |
---|
32 | (* The return address register. It is best thought of as a register |
---|
33 | that is used to pass a parameter (namely, the return address). *) |
---|
34 | |
---|
35 | val ra: register |
---|
36 | |
---|
37 | (* The zero register always holds the value 0. Although it is a |
---|
38 | special register, it is considered allocatable; see module [Zero] |
---|
39 | for an explanation. *) |
---|
40 | |
---|
41 | val zero: register |
---|
42 | |
---|
43 | (* Sets of hardware registers. *) |
---|
44 | |
---|
45 | module RegisterSet : sig |
---|
46 | include Set.S with type elt = register |
---|
47 | val disjoint: t -> t -> bool |
---|
48 | val of_list: elt list -> t |
---|
49 | end |
---|
50 | |
---|
51 | (* Maps over hardware registers. *) |
---|
52 | |
---|
53 | module RegisterMap : sig |
---|
54 | |
---|
55 | include Map.S with type key = register |
---|
56 | |
---|
57 | (* [lift f s] turns the set [s] into a map where every element [x] |
---|
58 | is mapped to [f x]. *) |
---|
59 | |
---|
60 | val lift: (key -> 'a) -> RegisterSet.t -> 'a t |
---|
61 | |
---|
62 | end |
---|
63 | |
---|
64 | (* A set of all allocatable hardware registers, that is, of all |
---|
65 | registers that are available for use by the register allocator -- |
---|
66 | as opposed to reserved for some fixed use. *) |
---|
67 | |
---|
68 | val allocatable: RegisterSet.t |
---|
69 | |
---|
70 | (* A set of all allocatable ``caller-saved'' hardware registers, that |
---|
71 | is, of all allocatable registers that might be overwritten during a |
---|
72 | function call. This includes the so-called ``caller-saved temporary |
---|
73 | registers'' [$t0-$t9] as well as the registers used to implement |
---|
74 | the calling convention, namely [$a0-$a3], [$v0], and [$ra]. *) |
---|
75 | |
---|
76 | val caller_saved: RegisterSet.t |
---|
77 | |
---|
78 | (* A set of all allocatable ``callee-saved'' hardware registers, that |
---|
79 | is, of all allocatable registers that must be preserved by function |
---|
80 | calls. *) |
---|
81 | |
---|
82 | val callee_saved: RegisterSet.t |
---|
83 | |
---|
84 | (* Two non-allocatable registers, reserved for transferring spilled |
---|
85 | pseudo-registers to and from the stack. *) |
---|
86 | |
---|
87 | val st0: register |
---|
88 | val st1: register |
---|
89 | |
---|
90 | (* The stack pointer register. *) |
---|
91 | |
---|
92 | val sp: register |
---|
93 | |
---|
94 | (* The global pointer register. *) |
---|
95 | |
---|
96 | val gp_mips: register |
---|
97 | val gp_gnu: register |
---|
98 | |
---|
99 | (* A set of all registers that are used in the code that we generate. |
---|
100 | This includes all allocatable registers, plus the four special |
---|
101 | registers mentioned above. *) |
---|
102 | |
---|
103 | val registers: RegisterSet.t |
---|
104 | |
---|
105 | *) |
---|