f5538ce500708a03e28ee40eef79e60dd837dbf3
[ghc-hetmet.git] / ghc / compiler / main / Constants.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1994
3 %
4 \section[Constants]{Info about this compilation}
5
6 !!!!! THIS CODE MUST AGREE WITH SMinterface.h !!!!!!
7
8 *** This SHOULD BE the only module that is CPP'd with "stgdefs.h" stuff.
9
10 \begin{code}
11 module Constants (
12         uNFOLDING_USE_THRESHOLD,
13         uNFOLDING_CREATION_THRESHOLD,
14         iNTERFACE_UNFOLD_THRESHOLD,
15         lIBERATE_CASE_THRESHOLD,
16         uNFOLDING_CHEAP_OP_COST,
17         uNFOLDING_DEAR_OP_COST,
18         uNFOLDING_NOREP_LIT_COST,
19         uNFOLDING_CON_DISCOUNT_WEIGHT,
20         uNFOLDING_KEENESS_FACTOR,
21
22         mAX_SPEC_ALL_PTRS,
23         mAX_SPEC_ALL_NONPTRS,
24         mAX_SPEC_MIXED_FIELDS,
25         mAX_SPEC_SELECTEE_SIZE,
26
27         tARGET_MIN_INT, tARGET_MAX_INT,
28
29         mIN_UPD_SIZE,
30         mIN_SIZE_NonUpdHeapObject,
31         mIN_SIZE_NonUpdStaticHeapObject,
32
33         mAX_FAMILY_SIZE_FOR_VEC_RETURNS,
34
35         sTD_UF_SIZE,     cON_UF_SIZE,
36         sCC_STD_UF_SIZE, sCC_CON_UF_SIZE,
37         uF_RET,
38         uF_SUB,
39         uF_SUA,
40         uF_UPDATEE,
41         uF_COST_CENTRE,
42
43         mAX_Vanilla_REG,
44         mAX_Float_REG,
45         mAX_Double_REG,
46         mAX_Long_REG,
47
48         mIN_MP_INT_SIZE,
49         mP_STRUCT_SIZE,
50
51         oTHER_TAG, iND_TAG,     -- semi-tagging stuff
52
53         lIVENESS_R1,
54         lIVENESS_R2,
55         lIVENESS_R3,
56         lIVENESS_R4,
57         lIVENESS_R5,
58         lIVENESS_R6,
59         lIVENESS_R7,
60         lIVENESS_R8,
61
62         mAX_INTLIKE, mIN_INTLIKE,
63
64
65         spARelToInt,
66         spBRelToInt
67     ) where
68
69 -- This magical #include brings in all the everybody-knows-these magic
70 -- constants unfortunately, we need to be *explicit* about which one
71 -- we want; if we just hope a -I... will get the right one, we could
72 -- be in trouble.
73
74 #include "HsVersions.h"
75 #include "../../includes/GhcConstants.h"
76
77 import Util
78 \end{code}
79
80 All pretty arbitrary:
81 \begin{code}
82 uNFOLDING_USE_THRESHOLD       = ( 8 :: Int)
83 uNFOLDING_CREATION_THRESHOLD  = (30 :: Int)     -- Discounts can be big
84 iNTERFACE_UNFOLD_THRESHOLD    = (30 :: Int)
85 lIBERATE_CASE_THRESHOLD       = (10 :: Int)
86
87 uNFOLDING_CHEAP_OP_COST       = ( 1 :: Int)
88 uNFOLDING_DEAR_OP_COST        = ( 4 :: Int)
89 uNFOLDING_NOREP_LIT_COST      = ( 20 :: Int)    -- Strings can be pretty big
90 uNFOLDING_CON_DISCOUNT_WEIGHT = ( 3 :: Int)
91 uNFOLDING_KEENESS_FACTOR      = ( 2.0 :: Float)
92 \end{code}
93
94 \begin{code}
95 mAX_SPEC_ALL_PTRS       = (MAX_SPEC_ALL_PTRS :: Int)
96 mAX_SPEC_ALL_NONPTRS    = (MAX_SPEC_ALL_NONPTRS :: Int)
97 mAX_SPEC_MIXED_FIELDS   = (MAX_SPEC_OTHER_SIZE :: Int)
98 mAX_SPEC_SELECTEE_SIZE  = (MAX_SPEC_SELECTEE_SIZE :: Int)
99
100 -- closure sizes: these do NOT include the header
101 mIN_UPD_SIZE                    = (MIN_UPD_SIZE::Int)
102 mIN_SIZE_NonUpdHeapObject       = (MIN_NONUPD_SIZE::Int)
103 mIN_SIZE_NonUpdStaticHeapObject = (0::Int)
104 \end{code}
105
106 Sizes of gmp objects:
107 \begin{code}
108 mIN_MP_INT_SIZE = (MIN_MP_INT_SIZE :: Int)
109 mP_STRUCT_SIZE = (MP_STRUCT_SIZE :: Int)
110 \end{code}
111
112 \begin{code}
113 tARGET_MIN_INT, tARGET_MAX_INT :: Integer
114 tARGET_MIN_INT = -536870912
115 tARGET_MAX_INT =  536870912
116 \end{code}
117  
118 Constants for semi-tagging; the tags associated with the data
119 constructors will start at 0 and go up.
120 \begin{code}
121 oTHER_TAG = (INFO_OTHER_TAG :: Integer) -- (-1) unevaluated, probably
122 iND_TAG   = (INFO_IND_TAG   :: Integer) -- (-2) NOT USED, REALLY
123 \end{code}
124
125 Stuff for liveness masks:
126 \begin{code}
127 lIVENESS_R1     = (LIVENESS_R1 :: Int)
128 lIVENESS_R2     = (LIVENESS_R2 :: Int)
129 lIVENESS_R3     = (LIVENESS_R3 :: Int)
130 lIVENESS_R4     = (LIVENESS_R4 :: Int)
131 lIVENESS_R5     = (LIVENESS_R5 :: Int)
132 lIVENESS_R6     = (LIVENESS_R6 :: Int)
133 lIVENESS_R7     = (LIVENESS_R7 :: Int)
134 lIVENESS_R8     = (LIVENESS_R8 :: Int)
135 \end{code}
136
137 \begin{code}
138 mIN_INTLIKE, mAX_INTLIKE :: Integer     -- Only used to compare with (MachInt Integer)
139 mIN_INTLIKE = MIN_INTLIKE
140 mAX_INTLIKE = MAX_INTLIKE
141 \end{code}
142
143 \begin{code}
144 -- THESE ARE DIRECTION SENSITIVE!
145 spARelToInt :: Int{-VirtualSpAOffset-} -> Int{-VirtualSpAOffset-} -> Int
146 spBRelToInt :: Int{-VirtualSpBOffset-} -> Int{-VirtualSpBOffset-} -> Int
147
148 spARelToInt spA off = spA - off -- equiv to: AREL(spA - off)
149 spBRelToInt spB off = off - spB -- equiv to: BREL(spB - off)
150 \end{code}
151
152 A section of code-generator-related MAGIC CONSTANTS.
153 \begin{code}
154 mAX_FAMILY_SIZE_FOR_VEC_RETURNS = (MAX_VECTORED_RTN::Int)  -- pretty arbitrary
155 -- If you change this, you may need to change runtimes/standard/Update.lhc
156
157 -- The update frame sizes
158 sTD_UF_SIZE     = (NOSCC_STD_UF_SIZE::Int)
159 cON_UF_SIZE     = (NOSCC_CON_UF_SIZE::Int)
160
161 -- Same again, with profiling
162 sCC_STD_UF_SIZE = (SCC_STD_UF_SIZE::Int)
163 sCC_CON_UF_SIZE = (SCC_CON_UF_SIZE::Int)
164
165 -- Offsets in an update frame.  They don't change with profiling!
166 uF_RET = (UF_RET::Int)
167 uF_SUB = (UF_SUB::Int)
168 uF_SUA = (UF_SUA::Int)
169 uF_UPDATEE = (UF_UPDATEE::Int)
170 uF_COST_CENTRE = (UF_COST_CENTRE::Int)
171 \end{code}
172
173 \begin{code}
174 mAX_Vanilla_REG = (MAX_VANILLA_REG :: Int)
175 mAX_Float_REG   = (MAX_FLOAT_REG :: Int)
176 mAX_Double_REG  = (MAX_DOUBLE_REG :: Int)
177 mAX_Long_REG    = (MAX_LONG_REG   :: Int)
178 \end{code}