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,
52 mkMainCapabilityLabel,
53 mkMAP_FROZEN_infoLabel,
54 mkMAP_DIRTY_infoLabel,
55 mkEMPTY_MVAR_infoLabel,
58 mkCAFBlackHoleInfoTableLabel,
59 mkSECAFBlackHoleInfoTableLabel,
61 mkRtsSlowTickyCtrLabel,
84 mkCCLabel, mkCCSLabel,
86 DynamicLinkerLabelInfo(..),
88 dynamicLinkerLabelInfo,
93 infoLblToEntryLbl, entryLblToInfoLbl,
94 needsCDecl, isAsmTemp, externallyVisibleCLabel,
95 CLabelType(..), labelType, labelDynamic,
101 #include "HsVersions.h"
103 import Packages ( HomeModules )
104 import StaticFlags ( opt_Static, opt_DoTickyProfiling )
105 import Packages ( isHomeModule, isDllName )
106 import DataCon ( ConTag )
107 import Module ( moduleFS, Module )
108 import Name ( Name, isExternalName )
109 import Unique ( pprUnique, Unique )
110 import PrimOp ( PrimOp )
111 import Config ( cLeadingUnderscore )
112 import CostCentre ( CostCentre, CostCentreStack )
116 -- -----------------------------------------------------------------------------
120 CLabel is an abstract type that supports the following operations:
124 - In a C file, does it need to be declared before use? (i.e. is it
125 guaranteed to be already in scope in the places we need to refer to it?)
127 - If it needs to be declared, what type (code or data) should it be
130 - Is it visible outside this object file or not?
132 - Is it "dynamic" (see details below)
134 - Eq and Ord, so that we can make sets of CLabels (currently only
135 used in outputting C as far as I can tell, to avoid generating
136 more than one declaration for any given label).
138 - Converting an info table label into an entry label.
142 = IdLabel -- A family of labels related to the
143 Name -- definition of a particular Id or Con
146 | DynIdLabel -- like IdLabel, but in a separate package,
147 Name -- and might therefore need a dynamic
148 IdLabelInfo -- reference.
150 | CaseLabel -- A family of labels related to a particular
152 {-# UNPACK #-} !Unique -- Unique says which case expression
156 {-# UNPACK #-} !Unique
159 {-# UNPACK #-} !Unique
162 Module -- the module name
164 Bool -- True <=> is in a different package
165 -- at some point we might want some kind of version number in
166 -- the module init label, to guard against compiling modules in
167 -- the wrong order. We can't use the interface file version however,
168 -- because we don't always recompile modules which depend on a module
169 -- whose version has changed.
171 | PlainModuleInitLabel -- without the vesrion & way info
173 Bool -- True <=> is in a different package
177 | RtsLabel RtsLabelInfo
179 | ForeignLabel FastString -- a 'C' (or otherwise foreign) label
180 (Maybe Int) -- possible '@n' suffix for stdcall functions
181 -- When generating C, the '@n' suffix is omitted, but when
182 -- generating assembler we must add it to the label.
183 Bool -- True <=> is dynamic
185 | CC_Label CostCentre
186 | CCS_Label CostCentreStack
188 -- Dynamic Linking in the NCG:
189 -- generated and used inside the NCG only,
190 -- see module PositionIndependentCode for details.
192 | DynamicLinkerLabel DynamicLinkerLabelInfo CLabel
193 -- special variants of a label used for dynamic linking
195 | PicBaseLabel -- a label used as a base for PIC calculations
196 -- on some platforms.
197 -- It takes the form of a local numeric
198 -- assembler label '1'; it is pretty-printed
199 -- as 1b, referring to the previous definition
200 -- of 1: in the assembler source file.
202 | DeadStripPreventer CLabel
203 -- label before an info table to prevent excessive dead-stripping on darwin
208 = Closure -- Label for closure
209 | SRT -- Static reference table
210 | SRTDesc -- Static reference table descriptor
211 | InfoTable -- Info tables for closures; always read-only
212 | Entry -- entry point
213 | Slow -- slow entry point
215 | RednCounts -- Label of place to keep Ticky-ticky info for
218 | Bitmap -- A bitmap (function or case return)
220 | ConEntry -- constructor entry point
221 | ConInfoTable -- corresponding info table
222 | StaticConEntry -- static constructor entry point
223 | StaticInfoTable -- corresponding info table
225 | ClosureTable -- table of closures for Enum tycons
239 = RtsSelectorInfoTable Bool{-updatable-} Int{-offset-} -- Selector thunks
240 | RtsSelectorEntry Bool{-updatable-} Int{-offset-}
242 | RtsApInfoTable Bool{-updatable-} Int{-arity-} -- AP thunks
243 | RtsApEntry Bool{-updatable-} Int{-arity-}
247 | RtsInfo LitString -- misc rts info tables
248 | RtsEntry LitString -- misc rts entry points
249 | RtsRetInfo LitString -- misc rts ret info tables
250 | RtsRet LitString -- misc rts return points
251 | RtsData LitString -- misc rts data bits, eg CHARLIKE_closure
252 | RtsCode LitString -- misc rts code
254 | RtsInfoFS FastString -- misc rts info tables
255 | RtsEntryFS FastString -- misc rts entry points
256 | RtsRetInfoFS FastString -- misc rts ret info tables
257 | RtsRetFS FastString -- misc rts return points
258 | RtsDataFS FastString -- misc rts data bits, eg CHARLIKE_closure
259 | RtsCodeFS FastString -- misc rts code
261 | RtsSlowTickyCtr String
264 -- NOTE: Eq on LitString compares the pointer only, so this isn't
267 data DynamicLinkerLabelInfo
268 = CodeStub -- MachO: Lfoo$stub, ELF: foo@plt
269 | SymbolPtr -- MachO: Lfoo$non_lazy_ptr, Windows: __imp_foo
270 | GotSymbolPtr -- ELF: foo@got
271 | GotSymbolOffset -- ELF: foo@gotoff
275 -- -----------------------------------------------------------------------------
276 -- Constructing CLabels
278 -- These are always local:
279 mkSRTLabel name = IdLabel name SRT
280 mkSRTDescLabel name = IdLabel name SRTDesc
281 mkSlowEntryLabel name = IdLabel name Slow
282 mkBitmapLabel name = IdLabel name Bitmap
283 mkRednCountsLabel name = IdLabel name RednCounts
285 -- These have local & (possibly) external variants:
286 mkLocalClosureLabel name = IdLabel name Closure
287 mkLocalInfoTableLabel name = IdLabel name InfoTable
288 mkLocalEntryLabel name = IdLabel name Entry
289 mkLocalClosureTableLabel name = IdLabel name ClosureTable
291 mkClosureLabel hmods name
292 | isDllName hmods name = DynIdLabel name Closure
293 | otherwise = IdLabel name Closure
295 mkInfoTableLabel hmods name
296 | isDllName hmods name = DynIdLabel name InfoTable
297 | otherwise = IdLabel name InfoTable
299 mkEntryLabel hmods name
300 | isDllName hmods name = DynIdLabel name Entry
301 | otherwise = IdLabel name Entry
303 mkClosureTableLabel hmods name
304 | isDllName hmods name = DynIdLabel name ClosureTable
305 | otherwise = IdLabel name ClosureTable
307 mkLocalConInfoTableLabel con = IdLabel con ConInfoTable
308 mkLocalConEntryLabel con = IdLabel con ConEntry
309 mkLocalStaticInfoTableLabel con = IdLabel con StaticInfoTable
310 mkLocalStaticConEntryLabel con = IdLabel con StaticConEntry
312 mkConInfoTableLabel name False = IdLabel name ConInfoTable
313 mkConInfoTableLabel name True = DynIdLabel name ConInfoTable
315 mkStaticInfoTableLabel name False = IdLabel name StaticInfoTable
316 mkStaticInfoTableLabel name True = DynIdLabel name StaticInfoTable
318 mkConEntryLabel hmods name
319 | isDllName hmods name = DynIdLabel name ConEntry
320 | otherwise = IdLabel name ConEntry
322 mkStaticConEntryLabel hmods name
323 | isDllName hmods name = DynIdLabel name StaticConEntry
324 | otherwise = IdLabel name StaticConEntry
327 mkReturnPtLabel uniq = CaseLabel uniq CaseReturnPt
328 mkReturnInfoLabel uniq = CaseLabel uniq CaseReturnInfo
329 mkAltLabel uniq tag = CaseLabel uniq (CaseAlt tag)
330 mkDefaultLabel uniq = CaseLabel uniq CaseDefault
332 mkStringLitLabel = StringLitLabel
333 mkAsmTempLabel = AsmTempLabel
335 mkModuleInitLabel :: HomeModules -> Module -> String -> CLabel
336 mkModuleInitLabel hmods mod way
337 = ModuleInitLabel mod way $! (not (isHomeModule hmods mod))
339 mkPlainModuleInitLabel :: HomeModules -> Module -> CLabel
340 mkPlainModuleInitLabel hmods mod
341 = PlainModuleInitLabel mod $! (not (isHomeModule hmods mod))
343 -- Some fixed runtime system labels
345 mkSplitMarkerLabel = RtsLabel (RtsCode SLIT("__stg_split_marker"))
346 mkUpdInfoLabel = RtsLabel (RtsInfo SLIT("stg_upd_frame"))
347 mkSeqInfoLabel = RtsLabel (RtsInfo SLIT("stg_seq_frame"))
348 mkIndStaticInfoLabel = RtsLabel (RtsInfo SLIT("stg_IND_STATIC"))
349 mkMainCapabilityLabel = RtsLabel (RtsData SLIT("MainCapability"))
350 mkMAP_FROZEN_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_FROZEN0"))
351 mkMAP_DIRTY_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_DIRTY"))
352 mkEMPTY_MVAR_infoLabel = RtsLabel (RtsInfo SLIT("stg_EMPTY_MVAR"))
354 mkTopTickyCtrLabel = RtsLabel (RtsData SLIT("top_ct"))
355 mkCAFBlackHoleInfoTableLabel = RtsLabel (RtsInfo SLIT("stg_CAF_BLACKHOLE"))
356 mkSECAFBlackHoleInfoTableLabel = if opt_DoTickyProfiling then
357 RtsLabel (RtsInfo SLIT("stg_SE_CAF_BLACKHOLE"))
358 else -- RTS won't have info table unless -ticky is on
359 panic "mkSECAFBlackHoleInfoTableLabel requires -ticky"
360 mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
362 moduleRegdLabel = ModuleRegdLabel
364 mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTable upd off)
365 mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
367 mkApInfoTableLabel upd off = RtsLabel (RtsApInfoTable upd off)
368 mkApEntryLabel upd off = RtsLabel (RtsApEntry upd off)
372 mkForeignLabel :: FastString -> Maybe Int -> Bool -> CLabel
373 mkForeignLabel str mb_sz is_dynamic = ForeignLabel str mb_sz is_dynamic
377 mkCCLabel cc = CC_Label cc
378 mkCCSLabel ccs = CCS_Label ccs
380 mkRtsInfoLabel str = RtsLabel (RtsInfo str)
381 mkRtsEntryLabel str = RtsLabel (RtsEntry str)
382 mkRtsRetInfoLabel str = RtsLabel (RtsRetInfo str)
383 mkRtsRetLabel str = RtsLabel (RtsRet str)
384 mkRtsCodeLabel str = RtsLabel (RtsCode str)
385 mkRtsDataLabel str = RtsLabel (RtsData str)
387 mkRtsInfoLabelFS str = RtsLabel (RtsInfoFS str)
388 mkRtsEntryLabelFS str = RtsLabel (RtsEntryFS str)
389 mkRtsRetInfoLabelFS str = RtsLabel (RtsRetInfoFS str)
390 mkRtsRetLabelFS str = RtsLabel (RtsRetFS str)
391 mkRtsCodeLabelFS str = RtsLabel (RtsCodeFS str)
392 mkRtsDataLabelFS str = RtsLabel (RtsDataFS str)
394 mkRtsSlowTickyCtrLabel :: String -> CLabel
395 mkRtsSlowTickyCtrLabel pat = RtsLabel (RtsSlowTickyCtr pat)
399 mkDynamicLinkerLabel :: DynamicLinkerLabelInfo -> CLabel -> CLabel
400 mkDynamicLinkerLabel = DynamicLinkerLabel
402 dynamicLinkerLabelInfo :: CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
403 dynamicLinkerLabelInfo (DynamicLinkerLabel info lbl) = Just (info, lbl)
404 dynamicLinkerLabelInfo _ = Nothing
406 -- Position independent code
408 mkPicBaseLabel :: CLabel
409 mkPicBaseLabel = PicBaseLabel
411 mkDeadStripPreventer :: CLabel -> CLabel
412 mkDeadStripPreventer lbl = DeadStripPreventer lbl
414 -- -----------------------------------------------------------------------------
415 -- Converting info labels to entry labels.
417 infoLblToEntryLbl :: CLabel -> CLabel
418 infoLblToEntryLbl (IdLabel n InfoTable) = IdLabel n Entry
419 infoLblToEntryLbl (IdLabel n ConInfoTable) = IdLabel n ConEntry
420 infoLblToEntryLbl (IdLabel n StaticInfoTable) = IdLabel n StaticConEntry
421 infoLblToEntryLbl (DynIdLabel n InfoTable) = DynIdLabel n Entry
422 infoLblToEntryLbl (DynIdLabel n ConInfoTable) = DynIdLabel n ConEntry
423 infoLblToEntryLbl (DynIdLabel n StaticInfoTable) = DynIdLabel n StaticConEntry
424 infoLblToEntryLbl (CaseLabel n CaseReturnInfo) = CaseLabel n CaseReturnPt
425 infoLblToEntryLbl (RtsLabel (RtsInfo s)) = RtsLabel (RtsEntry s)
426 infoLblToEntryLbl (RtsLabel (RtsRetInfo s)) = RtsLabel (RtsRet s)
427 infoLblToEntryLbl (RtsLabel (RtsInfoFS s)) = RtsLabel (RtsEntryFS s)
428 infoLblToEntryLbl (RtsLabel (RtsRetInfoFS s)) = RtsLabel (RtsRetFS s)
429 infoLblToEntryLbl _ = panic "CLabel.infoLblToEntryLbl"
431 entryLblToInfoLbl :: CLabel -> CLabel
432 entryLblToInfoLbl (IdLabel n Entry) = IdLabel n InfoTable
433 entryLblToInfoLbl (IdLabel n ConEntry) = IdLabel n ConInfoTable
434 entryLblToInfoLbl (IdLabel n StaticConEntry) = IdLabel n StaticInfoTable
435 entryLblToInfoLbl (DynIdLabel n Entry) = DynIdLabel n InfoTable
436 entryLblToInfoLbl (DynIdLabel n ConEntry) = DynIdLabel n ConInfoTable
437 entryLblToInfoLbl (DynIdLabel n StaticConEntry) = DynIdLabel n StaticInfoTable
438 entryLblToInfoLbl (CaseLabel n CaseReturnPt) = CaseLabel n CaseReturnInfo
439 entryLblToInfoLbl (RtsLabel (RtsEntry s)) = RtsLabel (RtsInfo s)
440 entryLblToInfoLbl (RtsLabel (RtsRet s)) = RtsLabel (RtsRetInfo s)
441 entryLblToInfoLbl (RtsLabel (RtsEntryFS s)) = RtsLabel (RtsInfoFS s)
442 entryLblToInfoLbl (RtsLabel (RtsRetFS s)) = RtsLabel (RtsRetInfoFS s)
443 entryLblToInfoLbl l = pprPanic "CLabel.entryLblToInfoLbl" (pprCLabel l)
445 -- -----------------------------------------------------------------------------
446 -- Does a CLabel need declaring before use or not?
448 needsCDecl :: CLabel -> Bool
449 -- False <=> it's pre-declared; don't bother
450 -- don't bother declaring SRT & Bitmap labels, we always make sure
451 -- they are defined before use.
452 needsCDecl (IdLabel _ SRT) = False
453 needsCDecl (IdLabel _ SRTDesc) = False
454 needsCDecl (IdLabel _ Bitmap) = False
455 needsCDecl (IdLabel _ _) = True
456 needsCDecl (DynIdLabel _ _) = True
457 needsCDecl (CaseLabel _ _) = True
458 needsCDecl (ModuleInitLabel _ _ _) = True
459 needsCDecl (PlainModuleInitLabel _ _) = True
460 needsCDecl ModuleRegdLabel = False
462 needsCDecl (StringLitLabel _) = False
463 needsCDecl (AsmTempLabel _) = False
464 needsCDecl (RtsLabel _) = False
465 needsCDecl (ForeignLabel _ _ _) = False
466 needsCDecl (CC_Label _) = True
467 needsCDecl (CCS_Label _) = True
469 -- Whether the label is an assembler temporary:
471 isAsmTemp :: CLabel -> Bool -- is a local temporary for native code generation
472 isAsmTemp (AsmTempLabel _) = True
475 -- -----------------------------------------------------------------------------
476 -- Is a CLabel visible outside this object file or not?
478 -- From the point of view of the code generator, a name is
479 -- externally visible if it has to be declared as exported
480 -- in the .o file's symbol table; that is, made non-static.
482 externallyVisibleCLabel :: CLabel -> Bool -- not C "static"
483 externallyVisibleCLabel (CaseLabel _ _) = False
484 externallyVisibleCLabel (StringLitLabel _) = False
485 externallyVisibleCLabel (AsmTempLabel _) = False
486 externallyVisibleCLabel (ModuleInitLabel _ _ _)= True
487 externallyVisibleCLabel (PlainModuleInitLabel _ _)= True
488 externallyVisibleCLabel ModuleRegdLabel = False
489 externallyVisibleCLabel (RtsLabel _) = True
490 externallyVisibleCLabel (ForeignLabel _ _ _) = True
491 externallyVisibleCLabel (IdLabel name _) = isExternalName name
492 externallyVisibleCLabel (DynIdLabel name _) = isExternalName name
493 externallyVisibleCLabel (CC_Label _) = True
494 externallyVisibleCLabel (CCS_Label _) = True
495 externallyVisibleCLabel (DynamicLinkerLabel _ _) = False
497 -- -----------------------------------------------------------------------------
498 -- Finding the "type" of a CLabel
500 -- For generating correct types in label declarations:
506 labelType :: CLabel -> CLabelType
507 labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
508 labelType (RtsLabel (RtsApInfoTable _ _)) = DataLabel
509 labelType (RtsLabel (RtsData _)) = DataLabel
510 labelType (RtsLabel (RtsCode _)) = CodeLabel
511 labelType (RtsLabel (RtsInfo _)) = DataLabel
512 labelType (RtsLabel (RtsEntry _)) = CodeLabel
513 labelType (RtsLabel (RtsRetInfo _)) = DataLabel
514 labelType (RtsLabel (RtsRet _)) = CodeLabel
515 labelType (RtsLabel (RtsDataFS _)) = DataLabel
516 labelType (RtsLabel (RtsCodeFS _)) = CodeLabel
517 labelType (RtsLabel (RtsInfoFS _)) = DataLabel
518 labelType (RtsLabel (RtsEntryFS _)) = CodeLabel
519 labelType (RtsLabel (RtsRetInfoFS _)) = DataLabel
520 labelType (RtsLabel (RtsRetFS _)) = CodeLabel
521 labelType (CaseLabel _ CaseReturnInfo) = DataLabel
522 labelType (CaseLabel _ _) = CodeLabel
523 labelType (ModuleInitLabel _ _ _) = CodeLabel
524 labelType (PlainModuleInitLabel _ _) = CodeLabel
526 labelType (IdLabel _ info) = idInfoLabelType info
527 labelType (DynIdLabel _ info) = idInfoLabelType info
528 labelType _ = DataLabel
530 idInfoLabelType info =
532 InfoTable -> DataLabel
535 ConInfoTable -> DataLabel
536 StaticInfoTable -> DataLabel
537 ClosureTable -> DataLabel
541 -- -----------------------------------------------------------------------------
542 -- Does a CLabel need dynamic linkage?
544 -- When referring to data in code, we need to know whether
545 -- that data resides in a DLL or not. [Win32 only.]
546 -- @labelDynamic@ returns @True@ if the label is located
547 -- in a DLL, be it a data reference or not.
549 labelDynamic :: CLabel -> Bool
552 RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
554 DynIdLabel n k -> True
555 #if mingw32_TARGET_OS
556 ForeignLabel _ _ d -> d
558 -- On Mac OS X and on ELF platforms, false positives are OK,
559 -- so we claim that all foreign imports come from dynamic libraries
560 ForeignLabel _ _ _ -> True
562 ModuleInitLabel m _ dyn -> not opt_Static && dyn
563 PlainModuleInitLabel m dyn -> not opt_Static && dyn
565 -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
569 OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
570 right places. It is used to detect when the abstractC statement of an
571 CCodeBlock actually contains the code for a slow entry point. -- HWL
573 We need at least @Eq@ for @CLabels@, because we want to avoid
574 duplicate declarations in generating C (see @labelSeenTE@ in
578 -----------------------------------------------------------------------------
579 -- Printing out CLabels.
586 where <name> is <Module>_<name> for external names and <unique> for
587 internal names. <type> is one of the following:
590 srt Static reference table
591 srtd Static reference table descriptor
592 entry Entry code (function, closure)
593 slow Slow entry code (if any)
594 ret Direct return address
596 <n>_alt Case alternative (tag n)
597 dflt Default case alternative
598 btm Large bitmap vector
599 closure Static closure
600 con_entry Dynamic Constructor entry code
601 con_info Dynamic Constructor info table
602 static_entry Static Constructor entry code
603 static_info Static Constructor info table
604 sel_info Selector info table
605 sel_entry Selector entry code
607 ccs Cost centre stack
609 Many of these distinctions are only for documentation reasons. For
610 example, _ret is only distinguished from _entry to make it easy to
611 tell whether a code fragment is a return point or a closure/function
615 pprCLabel :: CLabel -> SDoc
617 #if ! OMIT_NATIVE_CODEGEN
618 pprCLabel (AsmTempLabel u)
619 = getPprStyle $ \ sty ->
621 ptext asmTempLabelPrefix <> pprUnique u
623 char '_' <> pprUnique u
625 pprCLabel (DynamicLinkerLabel info lbl)
626 = pprDynamicLinkerAsmLabel info lbl
628 pprCLabel PicBaseLabel
631 pprCLabel (DeadStripPreventer lbl)
632 = pprCLabel lbl <> ptext SLIT("_dsp")
636 #if ! OMIT_NATIVE_CODEGEN
637 getPprStyle $ \ sty ->
639 maybe_underscore (pprAsmCLbl lbl)
645 | underscorePrefix = pp_cSEP <> doc
648 #ifdef mingw32_TARGET_OS
649 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel.
650 -- (The C compiler does this itself).
651 pprAsmCLbl (ForeignLabel fs (Just sz) _)
652 = ftext fs <> char '@' <> int sz
657 pprCLbl (StringLitLabel u)
658 = pprUnique u <> ptext SLIT("_str")
660 pprCLbl (CaseLabel u CaseReturnPt)
661 = hcat [pprUnique u, ptext SLIT("_ret")]
662 pprCLbl (CaseLabel u CaseReturnInfo)
663 = hcat [pprUnique u, ptext SLIT("_info")]
664 pprCLbl (CaseLabel u (CaseAlt tag))
665 = hcat [pprUnique u, pp_cSEP, int tag, ptext SLIT("_alt")]
666 pprCLbl (CaseLabel u CaseDefault)
667 = hcat [pprUnique u, ptext SLIT("_dflt")]
669 pprCLbl (RtsLabel (RtsCode str)) = ptext str
670 pprCLbl (RtsLabel (RtsData str)) = ptext str
671 pprCLbl (RtsLabel (RtsCodeFS str)) = ftext str
672 pprCLbl (RtsLabel (RtsDataFS str)) = ftext str
674 pprCLbl (RtsLabel (RtsSelectorInfoTable upd_reqd offset))
675 = hcat [ptext SLIT("stg_sel_"), text (show offset),
677 then SLIT("_upd_info")
678 else SLIT("_noupd_info"))
681 pprCLbl (RtsLabel (RtsSelectorEntry upd_reqd offset))
682 = hcat [ptext SLIT("stg_sel_"), text (show offset),
684 then SLIT("_upd_entry")
685 else SLIT("_noupd_entry"))
688 pprCLbl (RtsLabel (RtsApInfoTable upd_reqd arity))
689 = hcat [ptext SLIT("stg_ap_"), text (show arity),
691 then SLIT("_upd_info")
692 else SLIT("_noupd_info"))
695 pprCLbl (RtsLabel (RtsApEntry upd_reqd arity))
696 = hcat [ptext SLIT("stg_ap_"), text (show arity),
698 then SLIT("_upd_entry")
699 else SLIT("_noupd_entry"))
702 pprCLbl (RtsLabel (RtsInfo fs))
703 = ptext fs <> ptext SLIT("_info")
705 pprCLbl (RtsLabel (RtsEntry fs))
706 = ptext fs <> ptext SLIT("_entry")
708 pprCLbl (RtsLabel (RtsRetInfo fs))
709 = ptext fs <> ptext SLIT("_info")
711 pprCLbl (RtsLabel (RtsRet fs))
712 = ptext fs <> ptext SLIT("_ret")
714 pprCLbl (RtsLabel (RtsInfoFS fs))
715 = ftext fs <> ptext SLIT("_info")
717 pprCLbl (RtsLabel (RtsEntryFS fs))
718 = ftext fs <> ptext SLIT("_entry")
720 pprCLbl (RtsLabel (RtsRetInfoFS fs))
721 = ftext fs <> ptext SLIT("_info")
723 pprCLbl (RtsLabel (RtsRetFS fs))
724 = ftext fs <> ptext SLIT("_ret")
726 pprCLbl (RtsLabel (RtsPrimOp primop))
727 = ppr primop <> ptext SLIT("_fast")
729 pprCLbl (RtsLabel (RtsSlowTickyCtr pat))
730 = ptext SLIT("SLOW_CALL_") <> text pat <> ptext SLIT("_ctr")
732 pprCLbl ModuleRegdLabel
733 = ptext SLIT("_module_registered")
735 pprCLbl (ForeignLabel str _ _)
738 pprCLbl (IdLabel name flavor) = ppr name <> ppIdFlavor flavor
739 pprCLbl (DynIdLabel name flavor) = ppr name <> ppIdFlavor flavor
741 pprCLbl (CC_Label cc) = ppr cc
742 pprCLbl (CCS_Label ccs) = ppr ccs
744 pprCLbl (ModuleInitLabel mod way _)
745 = ptext SLIT("__stginit_") <> ppr mod
746 <> char '_' <> text way
747 pprCLbl (PlainModuleInitLabel mod _)
748 = ptext SLIT("__stginit_") <> ppr mod
750 ppIdFlavor :: IdLabelInfo -> SDoc
751 ppIdFlavor x = pp_cSEP <>
753 Closure -> ptext SLIT("closure")
754 SRT -> ptext SLIT("srt")
755 SRTDesc -> ptext SLIT("srtd")
756 InfoTable -> ptext SLIT("info")
757 Entry -> ptext SLIT("entry")
758 Slow -> ptext SLIT("slow")
759 RednCounts -> ptext SLIT("ct")
760 Bitmap -> ptext SLIT("btm")
761 ConEntry -> ptext SLIT("con_entry")
762 ConInfoTable -> ptext SLIT("con_info")
763 StaticConEntry -> ptext SLIT("static_entry")
764 StaticInfoTable -> ptext SLIT("static_info")
765 ClosureTable -> ptext SLIT("closure_tbl")
771 -- -----------------------------------------------------------------------------
772 -- Machine-dependent knowledge about labels.
774 underscorePrefix :: Bool -- leading underscore on assembler labels?
775 underscorePrefix = (cLeadingUnderscore == "YES")
777 asmTempLabelPrefix :: LitString -- for formatting labels
780 {- The alpha assembler likes temporary labels to look like $L123
781 instead of L123. (Don't toss the L, because then Lf28
785 #elif darwin_TARGET_OS
791 pprDynamicLinkerAsmLabel :: DynamicLinkerLabelInfo -> CLabel -> SDoc
794 pprDynamicLinkerAsmLabel SymbolPtr lbl
795 = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
796 pprDynamicLinkerAsmLabel CodeStub lbl
797 = char 'L' <> pprCLabel lbl <> text "$stub"
798 #elif powerpc_TARGET_ARCH && linux_TARGET_OS
799 pprDynamicLinkerAsmLabel CodeStub lbl
800 = pprCLabel lbl <> text "@plt"
801 pprDynamicLinkerAsmLabel SymbolPtr lbl
802 = text ".LC_" <> pprCLabel lbl
803 #elif linux_TARGET_OS
804 pprDynamicLinkerAsmLabel CodeStub lbl
805 = pprCLabel lbl <> text "@plt"
806 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
807 = pprCLabel lbl <> text "@got"
808 pprDynamicLinkerAsmLabel GotSymbolOffset lbl
809 = pprCLabel lbl <> text "@gotoff"
810 pprDynamicLinkerAsmLabel SymbolPtr lbl
811 = text ".LC_" <> pprCLabel lbl
812 #elif mingw32_TARGET_OS
813 pprDynamicLinkerAsmLabel SymbolPtr lbl
814 = text "__imp_" <> pprCLabel lbl
816 pprDynamicLinkerAsmLabel _ _
817 = panic "pprDynamicLinkerAsmLabel"