comparison lab4/mach.ml @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 (* lab4/mach.ml *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 (* |metrics| -- target representation of data object *)
5 type metrics =
6 { r_size: int; (* Size of object *)
7 r_align: int } (* Address must be multiple of this *)
8
9 let int_rep = { r_size = 4; r_align = 4 }
10 let char_rep = { r_size = 1; r_align = 1 }
11 let bool_rep = { r_size = 1; r_align = 1 }
12 let void_rep = { r_size = 0; r_align = 1 }
13 let addr_rep = { r_size = 4; r_align = 4 }
14 let proc_rep = { r_size = 8; r_align = 4 }
15 let param_rep = { r_size = 4; r_align = 4 }
16 let max_align = 4
17
18 (*
19 Frame layout:
20
21 arg n \
22 ... > Stored by caller
23 arg 4 /
24 arg 3 \
25 > Saved by prolog
26 +40 arg 0 /
27 ----------------
28 +36 return address
29 +32 saved sp
30 +28 dynamic link
31 +24 static link
32 +20 saved r9
33 ...
34 +4 saved r5
35 fp: saved r4
36 ----------------
37 -4 local 1
38 ...
39 local m
40 ----------------
41 outgoing arg a
42 ...
43 +4 outgoing arg 5
44 sp: outgoing arg 4
45 *)
46
47 let param_base = 40
48 let local_base = 0
49 let stat_link = 24
50 let nregvars = 3
51 let share_globals = true
52
53 let comment = "@ "