1 -----------------------------------------------------------------------------
3 -- Object-file symbols (called CLabel for histerical raisins).
5 -- (c) The University of Glasgow 2004
7 -----------------------------------------------------------------------------
10 CLabel, -- abstract type
19 mkStaticConEntryLabel,
22 mkStaticInfoTableLabel,
28 mkLocalInfoTableLabel,
31 mkLocalStaticConEntryLabel,
32 mkLocalConInfoTableLabel,
33 mkLocalStaticInfoTableLabel,
34 mkLocalClosureTableLabel,
46 mkPlainModuleInitLabel,
49 mkDirty_MUT_VAR_Label,
53 mkMainCapabilityLabel,
54 mkMAP_FROZEN_infoLabel,
55 mkMAP_DIRTY_infoLabel,
56 mkEMPTY_MVAR_infoLabel,
59 mkCAFBlackHoleInfoTableLabel,
60 mkSECAFBlackHoleInfoTableLabel,
62 mkRtsSlowTickyCtrLabel,
85 mkCCLabel, mkCCSLabel,
87 DynamicLinkerLabelInfo(..),
89 dynamicLinkerLabelInfo,
94 infoLblToEntryLbl, entryLblToInfoLbl,
95 needsCDecl, isAsmTemp, externallyVisibleCLabel,
96 CLabelType(..), labelType, labelDynamic,
102 #include "HsVersions.h"
104 import Packages ( HomeModules )
105 import StaticFlags ( opt_Static, opt_DoTickyProfiling )
106 import Packages ( isHomeModule, isDllName )
107 import DataCon ( ConTag )
108 import Module ( moduleFS, Module )
109 import Name ( Name, isExternalName )
110 import Unique ( pprUnique, Unique )
111 import PrimOp ( PrimOp )
112 import Config ( cLeadingUnderscore )
113 import CostCentre ( CostCentre, CostCentreStack )
117 -- -----------------------------------------------------------------------------
121 CLabel is an abstract type that supports the following operations:
125 - In a C file, does it need to be declared before use? (i.e. is it
126 guaranteed to be already in scope in the places we need to refer to it?)
128 - If it needs to be declared, what type (code or data) should it be
131 - Is it visible outside this object file or not?
133 - Is it "dynamic" (see details below)
135 - Eq and Ord, so that we can make sets of CLabels (currently only
136 used in outputting C as far as I can tell, to avoid generating
137 more than one declaration for any given label).
139 - Converting an info table label into an entry label.
143 = IdLabel -- A family of labels related to the
144 Name -- definition of a particular Id or Con
147 | DynIdLabel -- like IdLabel, but in a separate package,
148 Name -- and might therefore need a dynamic
149 IdLabelInfo -- reference.
151 | CaseLabel -- A family of labels related to a particular
153 {-# UNPACK #-} !Unique -- Unique says which case expression
157 {-# UNPACK #-} !Unique
160 {-# UNPACK #-} !Unique
163 Module -- the module name
165 Bool -- True <=> is in a different package
166 -- at some point we might want some kind of version number in
167 -- the module init label, to guard against compiling modules in
168 -- the wrong order. We can't use the interface file version however,
169 -- because we don't always recompile modules which depend on a module
170 -- whose version has changed.
172 | PlainModuleInitLabel -- without the vesrion & way info
174 Bool -- True <=> is in a different package
178 | RtsLabel RtsLabelInfo
180 | ForeignLabel FastString -- a 'C' (or otherwise foreign) label
181 (Maybe Int) -- possible '@n' suffix for stdcall functions
182 -- When generating C, the '@n' suffix is omitted, but when
183 -- generating assembler we must add it to the label.
184 Bool -- True <=> is dynamic
186 | CC_Label CostCentre
187 | CCS_Label CostCentreStack
189 -- Dynamic Linking in the NCG:
190 -- generated and used inside the NCG only,
191 -- see module PositionIndependentCode for details.
193 | DynamicLinkerLabel DynamicLinkerLabelInfo CLabel
194 -- special variants of a label used for dynamic linking
196 | PicBaseLabel -- a label used as a base for PIC calculations
197 -- on some platforms.
198 -- It takes the form of a local numeric
199 -- assembler label '1'; it is pretty-printed
200 -- as 1b, referring to the previous definition
201 -- of 1: in the assembler source file.
203 | DeadStripPreventer CLabel
204 -- label before an info table to prevent excessive dead-stripping on darwin
209 = Closure -- Label for closure
210 | SRT -- Static reference table
211 | SRTDesc -- Static reference table descriptor
212 | InfoTable -- Info tables for closures; always read-only
213 | Entry -- entry point
214 | Slow -- slow entry point
216 | RednCounts -- Label of place to keep Ticky-ticky info for
219 | Bitmap -- A bitmap (function or case return)
221 | ConEntry -- constructor entry point
222 | ConInfoTable -- corresponding info table
223 | StaticConEntry -- static constructor entry point
224 | StaticInfoTable -- corresponding info table
226 | ClosureTable -- table of closures for Enum tycons
240 = RtsSelectorInfoTable Bool{-updatable-} Int{-offset-} -- Selector thunks
241 | RtsSelectorEntry Bool{-updatable-} Int{-offset-}
243 | RtsApInfoTable Bool{-updatable-} Int{-arity-} -- AP thunks
244 | RtsApEntry Bool{-updatable-} Int{-arity-}
248 | RtsInfo LitString -- misc rts info tables
249 | RtsEntry LitString -- misc rts entry points
250 | RtsRetInfo LitString -- misc rts ret info tables
251 | RtsRet LitString -- misc rts return points
252 | RtsData LitString -- misc rts data bits, eg CHARLIKE_closure
253 | RtsCode LitString -- misc rts code
255 | RtsInfoFS FastString -- misc rts info tables
256 | RtsEntryFS FastString -- misc rts entry points
257 | RtsRetInfoFS FastString -- misc rts ret info tables
258 | RtsRetFS FastString -- misc rts return points
259 | RtsDataFS FastString -- misc rts data bits, eg CHARLIKE_closure
260 | RtsCodeFS FastString -- misc rts code
262 | RtsSlowTickyCtr String
265 -- NOTE: Eq on LitString compares the pointer only, so this isn't
268 data DynamicLinkerLabelInfo
269 = CodeStub -- MachO: Lfoo$stub, ELF: foo@plt
270 | SymbolPtr -- MachO: Lfoo$non_lazy_ptr, Windows: __imp_foo
271 | GotSymbolPtr -- ELF: foo@got
272 | GotSymbolOffset -- ELF: foo@gotoff
276 -- -----------------------------------------------------------------------------
277 -- Constructing CLabels
279 -- These are always local:
280 mkSRTLabel name = IdLabel name SRT
281 mkSRTDescLabel name = IdLabel name SRTDesc
282 mkSlowEntryLabel name = IdLabel name Slow
283 mkBitmapLabel name = IdLabel name Bitmap
284 mkRednCountsLabel name = IdLabel name RednCounts
286 -- These have local & (possibly) external variants:
287 mkLocalClosureLabel name = IdLabel name Closure
288 mkLocalInfoTableLabel name = IdLabel name InfoTable
289 mkLocalEntryLabel name = IdLabel name Entry
290 mkLocalClosureTableLabel name = IdLabel name ClosureTable
292 mkClosureLabel hmods name
293 | isDllName hmods name = DynIdLabel name Closure
294 | otherwise = IdLabel name Closure
296 mkInfoTableLabel hmods name
297 | isDllName hmods name = DynIdLabel name InfoTable
298 | otherwise = IdLabel name InfoTable
300 mkEntryLabel hmods name
301 | isDllName hmods name = DynIdLabel name Entry
302 | otherwise = IdLabel name Entry
304 mkClosureTableLabel hmods name
305 | isDllName hmods name = DynIdLabel name ClosureTable
306 | otherwise = IdLabel name ClosureTable
308 mkLocalConInfoTableLabel con = IdLabel con ConInfoTable
309 mkLocalConEntryLabel con = IdLabel con ConEntry
310 mkLocalStaticInfoTableLabel con = IdLabel con StaticInfoTable
311 mkLocalStaticConEntryLabel con = IdLabel con StaticConEntry
313 mkConInfoTableLabel name False = IdLabel name ConInfoTable
314 mkConInfoTableLabel name True = DynIdLabel name ConInfoTable
316 mkStaticInfoTableLabel name False = IdLabel name StaticInfoTable
317 mkStaticInfoTableLabel name True = DynIdLabel name StaticInfoTable
319 mkConEntryLabel hmods name
320 | isDllName hmods name = DynIdLabel name ConEntry
321 | otherwise = IdLabel name ConEntry
323 mkStaticConEntryLabel hmods name
324 | isDllName hmods name = DynIdLabel name StaticConEntry
325 | otherwise = IdLabel name StaticConEntry
328 mkReturnPtLabel uniq = CaseLabel uniq CaseReturnPt
329 mkReturnInfoLabel uniq = CaseLabel uniq CaseReturnInfo
330 mkAltLabel uniq tag = CaseLabel uniq (CaseAlt tag)
331 mkDefaultLabel uniq = CaseLabel uniq CaseDefault
333 mkStringLitLabel = StringLitLabel
334 mkAsmTempLabel = AsmTempLabel
336 mkModuleInitLabel :: HomeModules -> Module -> String -> CLabel
337 mkModuleInitLabel hmods mod way
338 = ModuleInitLabel mod way $! (not (isHomeModule hmods mod))
340 mkPlainModuleInitLabel :: HomeModules -> Module -> CLabel
341 mkPlainModuleInitLabel hmods mod
342 = PlainModuleInitLabel mod $! (not (isHomeModule hmods mod))
344 -- Some fixed runtime system labels
346 mkSplitMarkerLabel = RtsLabel (RtsCode SLIT("__stg_split_marker"))
347 mkDirty_MUT_VAR_Label = RtsLabel (RtsCode SLIT("dirty_MUT_VAR"))
348 mkUpdInfoLabel = RtsLabel (RtsInfo SLIT("stg_upd_frame"))
349 mkSeqInfoLabel = RtsLabel (RtsInfo SLIT("stg_seq_frame"))
350 mkIndStaticInfoLabel = RtsLabel (RtsInfo SLIT("stg_IND_STATIC"))
351 mkMainCapabilityLabel = RtsLabel (RtsData SLIT("MainCapability"))
352 mkMAP_FROZEN_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_FROZEN0"))
353 mkMAP_DIRTY_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_DIRTY"))
354 mkEMPTY_MVAR_infoLabel = RtsLabel (RtsInfo SLIT("stg_EMPTY_MVAR"))
356 mkTopTickyCtrLabel = RtsLabel (RtsData SLIT("top_ct"))
357 mkCAFBlackHoleInfoTableLabel = RtsLabel (RtsInfo SLIT("stg_CAF_BLACKHOLE"))
358 mkSECAFBlackHoleInfoTableLabel = if opt_DoTickyProfiling then
359 RtsLabel (RtsInfo SLIT("stg_SE_CAF_BLACKHOLE"))
360 else -- RTS won't have info table unless -ticky is on
361 panic "mkSECAFBlackHoleInfoTableLabel requires -ticky"
362 mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
364 moduleRegdLabel = ModuleRegdLabel
366 mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTable upd off)
367 mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
369 mkApInfoTableLabel upd off = RtsLabel (RtsApInfoTable upd off)
370 mkApEntryLabel upd off = RtsLabel (RtsApEntry upd off)
374 mkForeignLabel :: FastString -> Maybe Int -> Bool -> CLabel
375 mkForeignLabel str mb_sz is_dynamic = ForeignLabel str mb_sz is_dynamic
379 mkCCLabel cc = CC_Label cc
380 mkCCSLabel ccs = CCS_Label ccs
382 mkRtsInfoLabel str = RtsLabel (RtsInfo str)
383 mkRtsEntryLabel str = RtsLabel (RtsEntry str)
384 mkRtsRetInfoLabel str = RtsLabel (RtsRetInfo str)
385 mkRtsRetLabel str = RtsLabel (RtsRet str)
386 mkRtsCodeLabel str = RtsLabel (RtsCode str)
387 mkRtsDataLabel str = RtsLabel (RtsData str)
389 mkRtsInfoLabelFS str = RtsLabel (RtsInfoFS str)
390 mkRtsEntryLabelFS str = RtsLabel (RtsEntryFS str)
391 mkRtsRetInfoLabelFS str = RtsLabel (RtsRetInfoFS str)
392 mkRtsRetLabelFS str = RtsLabel (RtsRetFS str)
393 mkRtsCodeLabelFS str = RtsLabel (RtsCodeFS str)
394 mkRtsDataLabelFS str = RtsLabel (RtsDataFS str)
396 mkRtsSlowTickyCtrLabel :: String -> CLabel
397 mkRtsSlowTickyCtrLabel pat = RtsLabel (RtsSlowTickyCtr pat)
401 mkDynamicLinkerLabel :: DynamicLinkerLabelInfo -> CLabel -> CLabel
402 mkDynamicLinkerLabel = DynamicLinkerLabel
404 dynamicLinkerLabelInfo :: CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
405 dynamicLinkerLabelInfo (DynamicLinkerLabel info lbl) = Just (info, lbl)
406 dynamicLinkerLabelInfo _ = Nothing
408 -- Position independent code
410 mkPicBaseLabel :: CLabel
411 mkPicBaseLabel = PicBaseLabel
413 mkDeadStripPreventer :: CLabel -> CLabel
414 mkDeadStripPreventer lbl = DeadStripPreventer lbl
416 -- -----------------------------------------------------------------------------
417 -- Converting info labels to entry labels.
419 infoLblToEntryLbl :: CLabel -> CLabel
420 infoLblToEntryLbl (IdLabel n InfoTable) = IdLabel n Entry
421 infoLblToEntryLbl (IdLabel n ConInfoTable) = IdLabel n ConEntry
422 infoLblToEntryLbl (IdLabel n StaticInfoTable) = IdLabel n StaticConEntry
423 infoLblToEntryLbl (DynIdLabel n InfoTable) = DynIdLabel n Entry
424 infoLblToEntryLbl (DynIdLabel n ConInfoTable) = DynIdLabel n ConEntry
425 infoLblToEntryLbl (DynIdLabel n StaticInfoTable) = DynIdLabel n StaticConEntry
426 infoLblToEntryLbl (CaseLabel n CaseReturnInfo) = CaseLabel n CaseReturnPt
427 infoLblToEntryLbl (RtsLabel (RtsInfo s)) = RtsLabel (RtsEntry s)
428 infoLblToEntryLbl (RtsLabel (RtsRetInfo s)) = RtsLabel (RtsRet s)
429 infoLblToEntryLbl (RtsLabel (RtsInfoFS s)) = RtsLabel (RtsEntryFS s)
430 infoLblToEntryLbl (RtsLabel (RtsRetInfoFS s)) = RtsLabel (RtsRetFS s)
431 infoLblToEntryLbl _ = panic "CLabel.infoLblToEntryLbl"
433 entryLblToInfoLbl :: CLabel -> CLabel
434 entryLblToInfoLbl (IdLabel n Entry) = IdLabel n InfoTable
435 entryLblToInfoLbl (IdLabel n ConEntry) = IdLabel n ConInfoTable
436 entryLblToInfoLbl (IdLabel n StaticConEntry) = IdLabel n StaticInfoTable
437 entryLblToInfoLbl (DynIdLabel n Entry) = DynIdLabel n InfoTable
438 entryLblToInfoLbl (DynIdLabel n ConEntry) = DynIdLabel n ConInfoTable
439 entryLblToInfoLbl (DynIdLabel n StaticConEntry) = DynIdLabel n StaticInfoTable
440 entryLblToInfoLbl (CaseLabel n CaseReturnPt) = CaseLabel n CaseReturnInfo
441 entryLblToInfoLbl (RtsLabel (RtsEntry s)) = RtsLabel (RtsInfo s)
442 entryLblToInfoLbl (RtsLabel (RtsRet s)) = RtsLabel (RtsRetInfo s)
443 entryLblToInfoLbl (RtsLabel (RtsEntryFS s)) = RtsLabel (RtsInfoFS s)
444 entryLblToInfoLbl (RtsLabel (RtsRetFS s)) = RtsLabel (RtsRetInfoFS s)
445 entryLblToInfoLbl l = pprPanic "CLabel.entryLblToInfoLbl" (pprCLabel l)
447 -- -----------------------------------------------------------------------------
448 -- Does a CLabel need declaring before use or not?
450 needsCDecl :: CLabel -> Bool
451 -- False <=> it's pre-declared; don't bother
452 -- don't bother declaring SRT & Bitmap labels, we always make sure
453 -- they are defined before use.
454 needsCDecl (IdLabel _ SRT) = False
455 needsCDecl (IdLabel _ SRTDesc) = False
456 needsCDecl (IdLabel _ Bitmap) = False
457 needsCDecl (IdLabel _ _) = True
458 needsCDecl (DynIdLabel _ _) = True
459 needsCDecl (CaseLabel _ _) = True
460 needsCDecl (ModuleInitLabel _ _ _) = True
461 needsCDecl (PlainModuleInitLabel _ _) = True
462 needsCDecl ModuleRegdLabel = False
464 needsCDecl (StringLitLabel _) = False
465 needsCDecl (AsmTempLabel _) = False
466 needsCDecl (RtsLabel _) = False
467 needsCDecl (ForeignLabel _ _ _) = False
468 needsCDecl (CC_Label _) = True
469 needsCDecl (CCS_Label _) = True
471 -- Whether the label is an assembler temporary:
473 isAsmTemp :: CLabel -> Bool -- is a local temporary for native code generation
474 isAsmTemp (AsmTempLabel _) = True
477 -- -----------------------------------------------------------------------------
478 -- Is a CLabel visible outside this object file or not?
480 -- From the point of view of the code generator, a name is
481 -- externally visible if it has to be declared as exported
482 -- in the .o file's symbol table; that is, made non-static.
484 externallyVisibleCLabel :: CLabel -> Bool -- not C "static"
485 externallyVisibleCLabel (CaseLabel _ _) = False
486 externallyVisibleCLabel (StringLitLabel _) = False
487 externallyVisibleCLabel (AsmTempLabel _) = False
488 externallyVisibleCLabel (ModuleInitLabel _ _ _)= True
489 externallyVisibleCLabel (PlainModuleInitLabel _ _)= True
490 externallyVisibleCLabel ModuleRegdLabel = False
491 externallyVisibleCLabel (RtsLabel _) = True
492 externallyVisibleCLabel (ForeignLabel _ _ _) = True
493 externallyVisibleCLabel (IdLabel name _) = isExternalName name
494 externallyVisibleCLabel (DynIdLabel name _) = isExternalName name
495 externallyVisibleCLabel (CC_Label _) = True
496 externallyVisibleCLabel (CCS_Label _) = True
497 externallyVisibleCLabel (DynamicLinkerLabel _ _) = False
499 -- -----------------------------------------------------------------------------
500 -- Finding the "type" of a CLabel
502 -- For generating correct types in label declarations:
508 labelType :: CLabel -> CLabelType
509 labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
510 labelType (RtsLabel (RtsApInfoTable _ _)) = DataLabel
511 labelType (RtsLabel (RtsData _)) = DataLabel
512 labelType (RtsLabel (RtsCode _)) = CodeLabel
513 labelType (RtsLabel (RtsInfo _)) = DataLabel
514 labelType (RtsLabel (RtsEntry _)) = CodeLabel
515 labelType (RtsLabel (RtsRetInfo _)) = DataLabel
516 labelType (RtsLabel (RtsRet _)) = CodeLabel
517 labelType (RtsLabel (RtsDataFS _)) = DataLabel
518 labelType (RtsLabel (RtsCodeFS _)) = CodeLabel
519 labelType (RtsLabel (RtsInfoFS _)) = DataLabel
520 labelType (RtsLabel (RtsEntryFS _)) = CodeLabel
521 labelType (RtsLabel (RtsRetInfoFS _)) = DataLabel
522 labelType (RtsLabel (RtsRetFS _)) = CodeLabel
523 labelType (CaseLabel _ CaseReturnInfo) = DataLabel
524 labelType (CaseLabel _ _) = CodeLabel
525 labelType (ModuleInitLabel _ _ _) = CodeLabel
526 labelType (PlainModuleInitLabel _ _) = CodeLabel
528 labelType (IdLabel _ info) = idInfoLabelType info
529 labelType (DynIdLabel _ info) = idInfoLabelType info
530 labelType _ = DataLabel
532 idInfoLabelType info =
534 InfoTable -> DataLabel
537 ConInfoTable -> DataLabel
538 StaticInfoTable -> DataLabel
539 ClosureTable -> DataLabel
543 -- -----------------------------------------------------------------------------
544 -- Does a CLabel need dynamic linkage?
546 -- When referring to data in code, we need to know whether
547 -- that data resides in a DLL or not. [Win32 only.]
548 -- @labelDynamic@ returns @True@ if the label is located
549 -- in a DLL, be it a data reference or not.
551 labelDynamic :: CLabel -> Bool
554 RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
556 DynIdLabel n k -> True
557 #if mingw32_TARGET_OS
558 ForeignLabel _ _ d -> d
560 -- On Mac OS X and on ELF platforms, false positives are OK,
561 -- so we claim that all foreign imports come from dynamic libraries
562 ForeignLabel _ _ _ -> True
564 ModuleInitLabel m _ dyn -> not opt_Static && dyn
565 PlainModuleInitLabel m dyn -> not opt_Static && dyn
567 -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
571 OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
572 right places. It is used to detect when the abstractC statement of an
573 CCodeBlock actually contains the code for a slow entry point. -- HWL
575 We need at least @Eq@ for @CLabels@, because we want to avoid
576 duplicate declarations in generating C (see @labelSeenTE@ in
580 -----------------------------------------------------------------------------
581 -- Printing out CLabels.
588 where <name> is <Module>_<name> for external names and <unique> for
589 internal names. <type> is one of the following:
592 srt Static reference table
593 srtd Static reference table descriptor
594 entry Entry code (function, closure)
595 slow Slow entry code (if any)
596 ret Direct return address
598 <n>_alt Case alternative (tag n)
599 dflt Default case alternative
600 btm Large bitmap vector
601 closure Static closure
602 con_entry Dynamic Constructor entry code
603 con_info Dynamic Constructor info table
604 static_entry Static Constructor entry code
605 static_info Static Constructor info table
606 sel_info Selector info table
607 sel_entry Selector entry code
609 ccs Cost centre stack
611 Many of these distinctions are only for documentation reasons. For
612 example, _ret is only distinguished from _entry to make it easy to
613 tell whether a code fragment is a return point or a closure/function
617 instance Outputable CLabel where
620 pprCLabel :: CLabel -> SDoc
622 #if ! OMIT_NATIVE_CODEGEN
623 pprCLabel (AsmTempLabel u)
624 = getPprStyle $ \ sty ->
626 ptext asmTempLabelPrefix <> pprUnique u
628 char '_' <> pprUnique u
630 pprCLabel (DynamicLinkerLabel info lbl)
631 = pprDynamicLinkerAsmLabel info lbl
633 pprCLabel PicBaseLabel
636 pprCLabel (DeadStripPreventer lbl)
637 = pprCLabel lbl <> ptext SLIT("_dsp")
641 #if ! OMIT_NATIVE_CODEGEN
642 getPprStyle $ \ sty ->
644 maybe_underscore (pprAsmCLbl lbl)
650 | underscorePrefix = pp_cSEP <> doc
653 #ifdef mingw32_TARGET_OS
654 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel.
655 -- (The C compiler does this itself).
656 pprAsmCLbl (ForeignLabel fs (Just sz) _)
657 = ftext fs <> char '@' <> int sz
662 pprCLbl (StringLitLabel u)
663 = pprUnique u <> ptext SLIT("_str")
665 pprCLbl (CaseLabel u CaseReturnPt)
666 = hcat [pprUnique u, ptext SLIT("_ret")]
667 pprCLbl (CaseLabel u CaseReturnInfo)
668 = hcat [pprUnique u, ptext SLIT("_info")]
669 pprCLbl (CaseLabel u (CaseAlt tag))
670 = hcat [pprUnique u, pp_cSEP, int tag, ptext SLIT("_alt")]
671 pprCLbl (CaseLabel u CaseDefault)
672 = hcat [pprUnique u, ptext SLIT("_dflt")]
674 pprCLbl (RtsLabel (RtsCode str)) = ptext str
675 pprCLbl (RtsLabel (RtsData str)) = ptext str
676 pprCLbl (RtsLabel (RtsCodeFS str)) = ftext str
677 pprCLbl (RtsLabel (RtsDataFS str)) = ftext str
679 pprCLbl (RtsLabel (RtsSelectorInfoTable upd_reqd offset))
680 = hcat [ptext SLIT("stg_sel_"), text (show offset),
682 then SLIT("_upd_info")
683 else SLIT("_noupd_info"))
686 pprCLbl (RtsLabel (RtsSelectorEntry upd_reqd offset))
687 = hcat [ptext SLIT("stg_sel_"), text (show offset),
689 then SLIT("_upd_entry")
690 else SLIT("_noupd_entry"))
693 pprCLbl (RtsLabel (RtsApInfoTable upd_reqd arity))
694 = hcat [ptext SLIT("stg_ap_"), text (show arity),
696 then SLIT("_upd_info")
697 else SLIT("_noupd_info"))
700 pprCLbl (RtsLabel (RtsApEntry upd_reqd arity))
701 = hcat [ptext SLIT("stg_ap_"), text (show arity),
703 then SLIT("_upd_entry")
704 else SLIT("_noupd_entry"))
707 pprCLbl (RtsLabel (RtsInfo fs))
708 = ptext fs <> ptext SLIT("_info")
710 pprCLbl (RtsLabel (RtsEntry fs))
711 = ptext fs <> ptext SLIT("_entry")
713 pprCLbl (RtsLabel (RtsRetInfo fs))
714 = ptext fs <> ptext SLIT("_info")
716 pprCLbl (RtsLabel (RtsRet fs))
717 = ptext fs <> ptext SLIT("_ret")
719 pprCLbl (RtsLabel (RtsInfoFS fs))
720 = ftext fs <> ptext SLIT("_info")
722 pprCLbl (RtsLabel (RtsEntryFS fs))
723 = ftext fs <> ptext SLIT("_entry")
725 pprCLbl (RtsLabel (RtsRetInfoFS fs))
726 = ftext fs <> ptext SLIT("_info")
728 pprCLbl (RtsLabel (RtsRetFS fs))
729 = ftext fs <> ptext SLIT("_ret")
731 pprCLbl (RtsLabel (RtsPrimOp primop))
732 = ppr primop <> ptext SLIT("_fast")
734 pprCLbl (RtsLabel (RtsSlowTickyCtr pat))
735 = ptext SLIT("SLOW_CALL_") <> text pat <> ptext SLIT("_ctr")
737 pprCLbl ModuleRegdLabel
738 = ptext SLIT("_module_registered")
740 pprCLbl (ForeignLabel str _ _)
743 pprCLbl (IdLabel name flavor) = ppr name <> ppIdFlavor flavor
744 pprCLbl (DynIdLabel name flavor) = ppr name <> ppIdFlavor flavor
746 pprCLbl (CC_Label cc) = ppr cc
747 pprCLbl (CCS_Label ccs) = ppr ccs
749 pprCLbl (ModuleInitLabel mod way _)
750 = ptext SLIT("__stginit_") <> ppr mod
751 <> char '_' <> text way
752 pprCLbl (PlainModuleInitLabel mod _)
753 = ptext SLIT("__stginit_") <> ppr mod
755 ppIdFlavor :: IdLabelInfo -> SDoc
756 ppIdFlavor x = pp_cSEP <>
758 Closure -> ptext SLIT("closure")
759 SRT -> ptext SLIT("srt")
760 SRTDesc -> ptext SLIT("srtd")
761 InfoTable -> ptext SLIT("info")
762 Entry -> ptext SLIT("entry")
763 Slow -> ptext SLIT("slow")
764 RednCounts -> ptext SLIT("ct")
765 Bitmap -> ptext SLIT("btm")
766 ConEntry -> ptext SLIT("con_entry")
767 ConInfoTable -> ptext SLIT("con_info")
768 StaticConEntry -> ptext SLIT("static_entry")
769 StaticInfoTable -> ptext SLIT("static_info")
770 ClosureTable -> ptext SLIT("closure_tbl")
776 -- -----------------------------------------------------------------------------
777 -- Machine-dependent knowledge about labels.
779 underscorePrefix :: Bool -- leading underscore on assembler labels?
780 underscorePrefix = (cLeadingUnderscore == "YES")
782 asmTempLabelPrefix :: LitString -- for formatting labels
785 {- The alpha assembler likes temporary labels to look like $L123
786 instead of L123. (Don't toss the L, because then Lf28
790 #elif darwin_TARGET_OS
796 pprDynamicLinkerAsmLabel :: DynamicLinkerLabelInfo -> CLabel -> SDoc
799 pprDynamicLinkerAsmLabel SymbolPtr lbl
800 = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
801 pprDynamicLinkerAsmLabel CodeStub lbl
802 = char 'L' <> pprCLabel lbl <> text "$stub"
803 #elif powerpc_TARGET_ARCH && linux_TARGET_OS
804 pprDynamicLinkerAsmLabel CodeStub lbl
805 = pprCLabel lbl <> text "@plt"
806 pprDynamicLinkerAsmLabel SymbolPtr lbl
807 = text ".LC_" <> pprCLabel lbl
808 #elif linux_TARGET_OS
809 pprDynamicLinkerAsmLabel CodeStub lbl
810 = pprCLabel lbl <> text "@plt"
811 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
812 = pprCLabel lbl <> text "@got"
813 pprDynamicLinkerAsmLabel GotSymbolOffset lbl
814 = pprCLabel lbl <> text "@gotoff"
815 pprDynamicLinkerAsmLabel SymbolPtr lbl
816 = text ".LC_" <> pprCLabel lbl
817 #elif mingw32_TARGET_OS
818 pprDynamicLinkerAsmLabel SymbolPtr lbl
819 = text "__imp_" <> pprCLabel lbl
821 pprDynamicLinkerAsmLabel _ _
822 = panic "pprDynamicLinkerAsmLabel"