2 % (c) The AQUA Project, Glasgow University, 1993-1998
6 module StixInfo ( genCodeInfoTable, genBitmapInfoTable ) where
8 #include "HsVersions.h"
9 #include "../includes/config.h"
11 import AbsCSyn ( AbstractC(..), Liveness(..) )
12 import CLabel ( CLabel )
13 import StgSyn ( SRT(..) )
14 import ClosureInfo ( closurePtrsSize,
15 closureNonHdrSize, closureSMRep,
17 infoTblNeedsSRT, getSRTInfo, closureSemiTag
19 import PrimRep ( PrimRep(..) )
20 import SMRep ( getSMRepClosureTypeInt )
21 import Stix -- all of it
22 import UniqSupply ( returnUs, UniqSM )
23 import BitSet ( intBS )
24 import Maybes ( maybeToBool )
29 #if __GLASGOW_HASKELL__ >= 404
30 import GlaExts ( fromInt )
34 Generating code for info tables (arrays of data).
39 -> UniqSM StixTreeList
41 genCodeInfoTable (CClosureInfoAndCode cl_info _ _ cl_descr)
42 = returnUs (\xs -> StData PtrRep table : StLabel info_lbl : xs)
45 info_lbl = infoTableLabelFromCI cl_info
46 needs_srt = infoTblNeedsSRT cl_info
48 table | needs_srt = srt_label : rest_of_table
49 | otherwise = rest_of_table
53 {- par, prof, debug -}
54 StInt (toInteger layout_info)
55 , StInt (toInteger type_info)
58 -- sigh: building up the info table is endian-dependent.
59 -- ToDo: do this using .byte and .word directives.
61 #ifdef WORDS_BIGENDIAN
62 type_info = (fromInt closure_type `shiftL` 16) .|.
65 type_info = (fromInt closure_type) .|.
66 (fromInt srt_len `shiftL` 16)
68 srt = getSRTInfo cl_info
76 (StIndex DataPtrRep (StCLbl lbl)
77 (StInt (toInteger off)), len)
81 maybe_tag = closureSemiTag cl_info
82 is_constr = maybeToBool maybe_tag
83 (Just tag) = maybe_tag
86 #ifdef WORDS_BIGENDIAN
87 layout_info = (fromInt ptrs `shiftL` 16) .|. fromInt nptrs
89 layout_info = (fromInt ptrs) .|. (fromInt nptrs `shiftL` 16)
92 ptrs = closurePtrsSize cl_info
95 size = closureNonHdrSize cl_info
97 closure_type = getSMRepClosureTypeInt (closureSMRep cl_info)
105 -> Bool -- must include SRT field (i.e. it's a vector)
106 -> UniqSM StixTreeList
108 genBitmapInfoTable liveness srt closure_type include_srt
109 = returnUs (\xs -> StData PtrRep table : xs)
112 table = if srt_len == 0 && not include_srt then
115 srt_label : rest_of_table
119 {- par, prof, debug -}
121 , StInt (toInteger type_info)
124 layout_info = case liveness of
125 LvSmall mask -> StInt (toInteger (intBS mask))
126 LvLarge lbl -> StCLbl lbl
129 #ifdef WORDS_BIGENDIAN
130 type_info = (fromInt closure_type `shiftL` 16) .|.
133 type_info = (fromInt closure_type) .|.
134 (fromInt srt_len `shiftL` 16)
137 (srt_label,srt_len) =
139 (lbl, NoSRT) -> (StInt 0, 0)
140 (lbl, SRT off len) ->
141 (StIndex DataPtrRep (StCLbl lbl)
142 (StInt (toInteger off)), len)