2 % (c) The AQUA Project, Glasgow University, 1993-1998
6 module StixInfo ( genCodeInfoTable, genBitmapInfoTable ) where
8 #include "HsVersions.h"
10 import AbsCSyn ( AbstractC(..), Liveness(..) )
11 import CLabel ( CLabel )
12 import StgSyn ( SRT(..) )
13 import ClosureInfo ( closurePtrsSize,
14 closureNonHdrSize, closureSMRep,
17 import PrimRep ( PrimRep(..) )
18 import SMRep ( SMRep(..), getSMRepClosureTypeInt )
19 import Stix -- all of it
20 import UniqSupply ( returnUs, UniqSM )
21 import Outputable ( int )
22 import BitSet ( intBS )
28 Generating code for info tables (arrays of data).
33 -> UniqSM StixTreeList
35 genCodeInfoTable (CClosureInfoAndCode cl_info _ _ srt cl_descr)
36 = returnUs (\xs -> StData PtrRep table : StLabel info_lbl : xs)
39 info_lbl = infoTableLabelFromCI cl_info
41 table = case srt_len of
43 _ -> srt_label : rest_of_table
47 {- par, prof, debug -}
48 StInt (toInteger layout_info)
49 , StInt (toInteger type_info)
53 type_info = (fromInt flags `shiftL` 24) .|.
54 (fromInt closure_type `shiftL` 16) .|.
59 (lbl, NoSRT) -> (StInt 0, 0)
61 (StIndex DataPtrRep (StCLbl lbl)
62 (StInt (toInteger off)), len)
65 layout_info = (fromInt ptrs `shiftL` 16) .|. fromInt nptrs
67 ptrs = closurePtrsSize cl_info
70 size = closureNonHdrSize cl_info
72 closure_type = getSMRepClosureTypeInt (closureSMRep cl_info)
81 -> Bool -- must include SRT field (i.e. it's a vector)
82 -> UniqSM StixTreeList
84 genBitmapInfoTable liveness srt closure_type include_srt
85 = returnUs (\xs -> StData PtrRep table : xs)
88 table = if srt_len == 0 && not include_srt then
91 srt_label : rest_of_table
95 {- par, prof, debug -}
97 , StInt (toInteger type_info)
100 layout_info = case liveness of
101 LvSmall mask -> StInt (toInteger (intBS mask))
102 LvLarge lbl -> StCLbl lbl
105 type_info = (fromInt flags `shiftL` 24) .|.
106 (fromInt closure_type `shiftL` 16) .|.
109 (srt_label,srt_len) =
111 (lbl, NoSRT) -> (StInt 0, 0)
112 (lbl, SRT off len) ->
113 (StIndex DataPtrRep (StCLbl lbl)
114 (StInt (toInteger off)), len)