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