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
19 import PrimRep ( PrimRep(..) )
20 import SMRep ( SMRep(..), getSMRepClosureTypeInt )
21 import Stix -- all of it
22 import UniqSupply ( returnUs, UniqSM )
23 import Outputable ( int )
24 import BitSet ( intBS )
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
74 (StIndex DataPtrRep (StCLbl lbl)
75 (StInt (toInteger off)), len)
80 #ifdef WORDS_BIGENDIAN
81 layout_info = (fromInt ptrs `shiftL` 16) .|. fromInt nptrs
83 layout_info = (fromInt ptrs) .|. (fromInt nptrs `shiftL` 16)
86 ptrs = closurePtrsSize cl_info
89 size = closureNonHdrSize cl_info
91 closure_type = getSMRepClosureTypeInt (closureSMRep cl_info)
99 -> Bool -- must include SRT field (i.e. it's a vector)
100 -> UniqSM StixTreeList
102 genBitmapInfoTable liveness srt closure_type include_srt
103 = returnUs (\xs -> StData PtrRep table : xs)
106 table = if srt_len == 0 && not include_srt then
109 srt_label : rest_of_table
113 {- par, prof, debug -}
115 , StInt (toInteger type_info)
118 layout_info = case liveness of
119 LvSmall mask -> StInt (toInteger (intBS mask))
120 LvLarge lbl -> StCLbl lbl
123 #ifdef WORDS_BIGENDIAN
124 type_info = (fromInt closure_type `shiftL` 16) .|.
127 type_info = (fromInt closure_type) .|.
128 (fromInt srt_len `shiftL` 16)
131 (srt_label,srt_len) =
133 (lbl, NoSRT) -> (StInt 0, 0)
134 (lbl, SRT off len) ->
135 (StIndex DataPtrRep (StCLbl lbl)
136 (StInt (toInteger off)), len)