Pointer Tagging
[ghc-hetmet.git] / compiler / main / Constants.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
3 %
4 \section[Constants]{Info about this compilation}
5
6 \begin{code}
7 module Constants (module Constants) where
8
9 import Data.Bits (shiftL)
10
11 -- This magical #include brings in all the everybody-knows-these magic
12 -- constants unfortunately, we need to be *explicit* about which one
13 -- we want; if we just hope a -I... will get the right one, we could
14 -- be in trouble.
15
16 #include "HsVersions.h"
17 #include "../includes/MachRegs.h"
18 #include "../includes/Constants.h"
19 #include "../includes/MachDeps.h"
20 #include "../includes/DerivedConstants.h"
21
22 -- import Util
23 \end{code}
24
25 All pretty arbitrary:
26
27 \begin{code}
28 mAX_TUPLE_SIZE = (62 :: Int)    -- Should really match the number
29                                 -- of decls in Data.Tuple
30 mAX_CONTEXT_REDUCTION_DEPTH = (20 :: Int)
31 \end{code}
32
33
34 \begin{code}
35 -- specialised fun/thunk/constr closure types
36 mAX_SPEC_THUNK_SIZE   = (MAX_SPEC_THUNK_SIZE :: Int)
37 mAX_SPEC_FUN_SIZE     = (MAX_SPEC_FUN_SIZE :: Int)
38 mAX_SPEC_CONSTR_SIZE  = (MAX_SPEC_CONSTR_SIZE :: Int)
39
40 -- pre-compiled thunk types
41 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
42 mAX_SPEC_AP_SIZE        = (MAX_SPEC_AP_SIZE :: Int)
43
44 -- closure sizes: these do NOT include the header (see below for header sizes)
45 mIN_PAYLOAD_SIZE        = (MIN_PAYLOAD_SIZE::Int)
46 \end{code}
47
48 \begin{code}
49 mIN_INTLIKE, mAX_INTLIKE :: Int 
50 mIN_INTLIKE = MIN_INTLIKE
51 mAX_INTLIKE = MAX_INTLIKE
52
53 mIN_CHARLIKE, mAX_CHARLIKE :: Int
54 mIN_CHARLIKE = MIN_CHARLIKE
55 mAX_CHARLIKE = MAX_CHARLIKE
56 \end{code}
57
58 A section of code-generator-related MAGIC CONSTANTS.
59
60 \begin{code}
61 mAX_Vanilla_REG = (MAX_VANILLA_REG :: Int)
62 mAX_Float_REG   = (MAX_FLOAT_REG :: Int)
63 mAX_Double_REG  = (MAX_DOUBLE_REG :: Int)
64 mAX_Long_REG    = (MAX_LONG_REG  :: Int)
65
66 mAX_Real_Vanilla_REG    = (MAX_REAL_VANILLA_REG :: Int)
67 mAX_Real_Float_REG      = (MAX_REAL_FLOAT_REG :: Int)
68 mAX_Real_Double_REG     = (MAX_REAL_DOUBLE_REG :: Int)
69 #ifdef MAX_REAL_LONG_REG
70 mAX_Real_Long_REG       = (MAX_REAL_LONG_REG :: Int)
71 #else
72 mAX_Real_Long_REG       = (0::Int)
73 #endif
74 \end{code}
75
76 Closure header sizes.
77
78 \begin{code}
79 sTD_HDR_SIZE       = (STD_HDR_SIZE       :: Int)
80 pROF_HDR_SIZE      = (PROF_HDR_SIZE      :: Int)
81 gRAN_HDR_SIZE      = (GRAN_HDR_SIZE      :: Int)
82 \end{code}
83
84 Size of a double in StgWords.
85
86 \begin{code}
87 dOUBLE_SIZE     = SIZEOF_DOUBLE :: Int
88 wORD64_SIZE     = 8 :: Int
89 iNT64_SIZE      = wORD64_SIZE
90 \end{code}
91
92 This tells the native code generator the size of the spill
93 area is has available.
94
95 \begin{code}
96 rESERVED_C_STACK_BYTES = (RESERVED_C_STACK_BYTES :: Int)
97 \end{code}
98
99 The amount of (Haskell) stack to leave free for saving registers when
100 returning to the scheduler.
101
102 \begin{code}
103 rESERVED_STACK_WORDS = (RESERVED_STACK_WORDS :: Int)
104 \end{code}
105
106 Size of a word, in bytes
107
108 \begin{code}
109 wORD_SIZE = (SIZEOF_HSWORD :: Int)
110 wORD_SIZE_IN_BITS = wORD_SIZE * 8 :: Int
111 \end{code}
112
113 Amount of pointer bits used for semi-tagging constructor closures
114
115 \begin{code}
116 tAG_BITS    = (TAG_BITS :: Int)
117 tAG_MASK    = ((1 `shiftL` tAG_BITS) - 1) :: Int
118 mAX_PTR_TAG = tAG_MASK :: Int
119 \end{code}
120
121 Size of a C int, in bytes. May be smaller than wORD_SIZE.
122
123 \begin{code}
124 cINT_SIZE = (SIZEOF_INT :: Int)
125 \end{code}
126
127 Size of a storage manager block (in bytes).
128
129 \begin{code}
130 bLOCK_SIZE = (BLOCK_SIZE :: Int)
131 bLOCK_SIZE_W = (bLOCK_SIZE `quot` wORD_SIZE :: Int)
132 \end{code}
133
134 Number of bits to shift a bitfield left by in an info table.
135
136 \begin{code}
137 bITMAP_BITS_SHIFT = (BITMAP_BITS_SHIFT :: Int)
138 \end{code}
139
140 Constants derived from headers in ghc/includes, generated by the program
141 ../includes/mkDerivedConstants.c.
142
143 \begin{code}
144 #include "../includes/GHCConstants.h"
145 \end{code}