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,
18 import PrimRep ( PrimRep(..) )
19 import SMRep ( SMRep(..), getSMRepClosureTypeInt )
20 import Stix -- all of it
21 import UniqSupply ( returnUs, UniqSM )
22 import Outputable ( int )
23 import BitSet ( intBS )
29 Generating code for info tables (arrays of data).
34 -> UniqSM StixTreeList
36 genCodeInfoTable (CClosureInfoAndCode cl_info _ _ srt cl_descr)
37 = returnUs (\xs -> StData PtrRep table : StLabel info_lbl : xs)
40 info_lbl = infoTableLabelFromCI cl_info
42 table = case srt_len of
44 _ -> srt_label : rest_of_table
48 {- par, prof, debug -}
49 StInt (toInteger layout_info)
50 , StInt (toInteger type_info)
53 -- sigh: building up the info table is endian-dependent.
54 -- ToDo: do this using .byte and .word directives.
56 #ifdef WORDS_BIGENDIAN
57 type_info = (fromInt flags `shiftL` 24) .|.
58 (fromInt closure_type `shiftL` 16) .|.
61 type_info = (fromInt flags) .|.
62 (fromInt closure_type `shiftL` 8) .|.
63 (fromInt srt_len `shiftL` 16)
68 (lbl, NoSRT) -> (StInt 0, 0)
70 (StIndex DataPtrRep (StCLbl lbl)
71 (StInt (toInteger off)), len)
74 #ifdef WORDS_BIGENDIAN
75 layout_info = (fromInt ptrs `shiftL` 16) .|. fromInt nptrs
77 layout_info = (fromInt ptrs) .|. (fromInt nptrs `shiftL` 16)
80 ptrs = closurePtrsSize cl_info
83 size = closureNonHdrSize cl_info
85 closure_type = getSMRepClosureTypeInt (closureSMRep cl_info)
94 -> Bool -- must include SRT field (i.e. it's a vector)
95 -> UniqSM StixTreeList
97 genBitmapInfoTable liveness srt closure_type include_srt
98 = returnUs (\xs -> StData PtrRep table : xs)
101 table = if srt_len == 0 && not include_srt then
104 srt_label : rest_of_table
108 {- par, prof, debug -}
110 , StInt (toInteger type_info)
113 layout_info = case liveness of
114 LvSmall mask -> StInt (toInteger (intBS mask))
115 LvLarge lbl -> StCLbl lbl
118 #ifdef WORDS_BIGENDIAN
119 type_info = (fromInt flags `shiftL` 24) .|.
120 (fromInt closure_type `shiftL` 16) .|.
123 type_info = (fromInt flags) .|.
124 (fromInt closure_type `shiftL` 8) .|.
125 (fromInt srt_len `shiftL` 16)
128 (srt_label,srt_len) =
130 (lbl, NoSRT) -> (StInt 0, 0)
131 (lbl, SRT off len) ->
132 (StIndex DataPtrRep (StCLbl lbl)
133 (StInt (toInteger off)), len)