2 % (c) The AQUA Project, Glasgow University, 1993-1995
6 #include "HsVersions.h"
15 import Maybes ( maybeToBool, Maybe(..) )
16 import SMRep ( SMRep(..), SMSpecRepKind(..), SMUpdateKind(..) )
25 Generating code for info tables (arrays of data).
28 static___rtbl = sStLitLbl SLIT("Static___rtbl") -- out here to avoid CAF (sigh)
29 const___rtbl = sStLitLbl SLIT("Const___rtbl")
30 charlike___rtbl = sStLitLbl SLIT("CharLike___rtbl")
31 intlike___rtbl = sStLitLbl SLIT("IntLike___rtbl")
32 gen_N___rtbl = sStLitLbl SLIT("Gen_N___rtbl")
33 gen_S___rtbl = sStLitLbl SLIT("Gen_S___rtbl")
34 gen_U___rtbl = sStLitLbl SLIT("Gen_U___rtbl")
35 tuple___rtbl = sStLitLbl SLIT("Tuple___rtbl")
36 data___rtbl = sStLitLbl SLIT("Data___rtbl")
37 dyn___rtbl = sStLitLbl SLIT("Dyn___rtbl")
42 -> SUniqSM StixTreeList
44 genCodeInfoTable target (CClosureInfoAndCode cl_info _ _ upd cl_descr) =
45 returnSUs (\xs -> info : lbl : xs)
48 info = StData PtrKind table
49 lbl = StLabel info_lbl
51 table = case sm_rep of
53 StInt (toInteger ptrs),
54 StInt (toInteger size),
59 SpecialisedRep ConstantRep _ _ _ -> [
65 SpecialisedRep CharLikeRep _ _ _ -> [
70 SpecialisedRep IntLikeRep _ _ _ -> [
75 SpecialisedRep _ _ _ updatable ->
76 let rtbl = uppBesides (
78 [uppPStr SLIT("Select__"),
80 uppPStr SLIT("_rtbl")]
82 [uppPStr (case updatable of
83 SMNormalForm -> SLIT("Spec_N_")
84 SMSingleEntry -> SLIT("Spec_S_")
85 SMUpdatable -> SLIT("Spec_U_")
90 uppPStr SLIT("_rtbl")])
93 SMNormalForm -> [upd_code, StLitLbl rtbl, tag]
94 _ -> [StLitLbl rtbl, tag]
96 GenericRep _ _ updatable ->
97 let rtbl = case updatable of
98 SMNormalForm -> gen_N___rtbl
99 SMSingleEntry -> gen_S___rtbl
100 SMUpdatable -> gen_U___rtbl
102 StInt (toInteger ptrs),
103 StInt (toInteger size),
120 info_unused, -- no rep table
123 info_lbl = infoTableLabelFromCI cl_info
124 closure_lbl = closureLabelFromCI cl_info
126 sm_rep = closureSMRep cl_info
127 maybe_selector = maybeSelectorInfo cl_info
128 is_selector = maybeToBool maybe_selector
129 (Just (_, select_word)) = maybe_selector
131 tag = StInt (toInteger (closureSemiTag cl_info))
133 size = if isSpecRep sm_rep
134 then closureNonHdrSize cl_info
135 else hpRel target (closureSizeWithoutFixedHdr cl_info)
136 ptrs = closurePtrsSize cl_info
138 upd_code = amodeToStix target upd
140 info_unused = StInt (-1)