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,
87 mkCCLabel, mkCCSLabel,
89 DynamicLinkerLabelInfo(..),
91 dynamicLinkerLabelInfo,
96 infoLblToEntryLbl, entryLblToInfoLbl,
97 needsCDecl, isAsmTemp, externallyVisibleCLabel,
98 CLabelType(..), labelType, labelDynamic,
104 #include "HsVersions.h"
106 import Packages ( HomeModules )
107 import StaticFlags ( opt_Static, opt_DoTickyProfiling )
108 import Packages ( isHomeModule, isDllName )
109 import DataCon ( ConTag )
110 import Module ( moduleFS, Module )
111 import Name ( Name, isExternalName )
112 import Unique ( pprUnique, Unique )
113 import PrimOp ( PrimOp )
114 import Config ( cLeadingUnderscore )
115 import CostCentre ( CostCentre, CostCentreStack )
119 -- -----------------------------------------------------------------------------
123 CLabel is an abstract type that supports the following operations:
127 - In a C file, does it need to be declared before use? (i.e. is it
128 guaranteed to be already in scope in the places we need to refer to it?)
130 - If it needs to be declared, what type (code or data) should it be
133 - Is it visible outside this object file or not?
135 - Is it "dynamic" (see details below)
137 - Eq and Ord, so that we can make sets of CLabels (currently only
138 used in outputting C as far as I can tell, to avoid generating
139 more than one declaration for any given label).
141 - Converting an info table label into an entry label.
145 = IdLabel -- A family of labels related to the
146 Name -- definition of a particular Id or Con
149 | DynIdLabel -- like IdLabel, but in a separate package,
150 Name -- and might therefore need a dynamic
151 IdLabelInfo -- reference.
153 | CaseLabel -- A family of labels related to a particular
155 {-# UNPACK #-} !Unique -- Unique says which case expression
159 {-# UNPACK #-} !Unique
162 {-# UNPACK #-} !Unique
165 Module -- the module name
167 Bool -- True <=> is in a different package
168 -- at some point we might want some kind of version number in
169 -- the module init label, to guard against compiling modules in
170 -- the wrong order. We can't use the interface file version however,
171 -- because we don't always recompile modules which depend on a module
172 -- whose version has changed.
174 | PlainModuleInitLabel -- without the vesrion & way info
176 Bool -- True <=> is in a different package
180 | RtsLabel RtsLabelInfo
182 | ForeignLabel FastString -- a 'C' (or otherwise foreign) label
183 (Maybe Int) -- possible '@n' suffix for stdcall functions
184 -- When generating C, the '@n' suffix is omitted, but when
185 -- generating assembler we must add it to the label.
186 Bool -- True <=> is dynamic
188 | CC_Label CostCentre
189 | CCS_Label CostCentreStack
191 -- Dynamic Linking in the NCG:
192 -- generated and used inside the NCG only,
193 -- see module PositionIndependentCode for details.
195 | DynamicLinkerLabel DynamicLinkerLabelInfo CLabel
196 -- special variants of a label used for dynamic linking
198 | PicBaseLabel -- a label used as a base for PIC calculations
199 -- on some platforms.
200 -- It takes the form of a local numeric
201 -- assembler label '1'; it is pretty-printed
202 -- as 1b, referring to the previous definition
203 -- of 1: in the assembler source file.
205 | DeadStripPreventer CLabel
206 -- label before an info table to prevent excessive dead-stripping on darwin
211 = Closure -- Label for closure
212 | SRT -- Static reference table
213 | SRTDesc -- Static reference table descriptor
214 | InfoTable -- Info tables for closures; always read-only
215 | Entry -- entry point
216 | Slow -- slow entry point
218 | RednCounts -- Label of place to keep Ticky-ticky info for
221 | Bitmap -- A bitmap (function or case return)
223 | ConEntry -- constructor entry point
224 | ConInfoTable -- corresponding info table
225 | StaticConEntry -- static constructor entry point
226 | StaticInfoTable -- corresponding info table
228 | ClosureTable -- table of closures for Enum tycons
242 = RtsSelectorInfoTable Bool{-updatable-} Int{-offset-} -- Selector thunks
243 | RtsSelectorEntry Bool{-updatable-} Int{-offset-}
245 | RtsApInfoTable Bool{-updatable-} Int{-arity-} -- AP thunks
246 | RtsApEntry Bool{-updatable-} Int{-arity-}
250 | RtsInfo LitString -- misc rts info tables
251 | RtsEntry LitString -- misc rts entry points
252 | RtsRetInfo LitString -- misc rts ret info tables
253 | RtsRet LitString -- misc rts return points
254 | RtsData LitString -- misc rts data bits, eg CHARLIKE_closure
255 | RtsCode LitString -- misc rts code
257 | RtsInfoFS FastString -- misc rts info tables
258 | RtsEntryFS FastString -- misc rts entry points
259 | RtsRetInfoFS FastString -- misc rts ret info tables
260 | RtsRetFS FastString -- misc rts return points
261 | RtsDataFS FastString -- misc rts data bits, eg CHARLIKE_closure
262 | RtsCodeFS FastString -- misc rts code
264 | RtsApFast LitString -- _fast versions of generic apply
266 | RtsSlowTickyCtr String
269 -- NOTE: Eq on LitString compares the pointer only, so this isn't
272 data DynamicLinkerLabelInfo
273 = CodeStub -- MachO: Lfoo$stub, ELF: foo@plt
274 | SymbolPtr -- MachO: Lfoo$non_lazy_ptr, Windows: __imp_foo
275 | GotSymbolPtr -- ELF: foo@got
276 | GotSymbolOffset -- ELF: foo@gotoff
280 -- -----------------------------------------------------------------------------
281 -- Constructing CLabels
283 -- These are always local:
284 mkSRTLabel name = IdLabel name SRT
285 mkSRTDescLabel name = IdLabel name SRTDesc
286 mkSlowEntryLabel name = IdLabel name Slow
287 mkBitmapLabel name = IdLabel name Bitmap
288 mkRednCountsLabel name = IdLabel name RednCounts
290 -- These have local & (possibly) external variants:
291 mkLocalClosureLabel name = IdLabel name Closure
292 mkLocalInfoTableLabel name = IdLabel name InfoTable
293 mkLocalEntryLabel name = IdLabel name Entry
294 mkLocalClosureTableLabel name = IdLabel name ClosureTable
296 mkClosureLabel hmods name
297 | isDllName hmods name = DynIdLabel name Closure
298 | otherwise = IdLabel name Closure
300 mkInfoTableLabel hmods name
301 | isDllName hmods name = DynIdLabel name InfoTable
302 | otherwise = IdLabel name InfoTable
304 mkEntryLabel hmods name
305 | isDllName hmods name = DynIdLabel name Entry
306 | otherwise = IdLabel name Entry
308 mkClosureTableLabel hmods name
309 | isDllName hmods name = DynIdLabel name ClosureTable
310 | otherwise = IdLabel name ClosureTable
312 mkLocalConInfoTableLabel con = IdLabel con ConInfoTable
313 mkLocalConEntryLabel con = IdLabel con ConEntry
314 mkLocalStaticInfoTableLabel con = IdLabel con StaticInfoTable
315 mkLocalStaticConEntryLabel con = IdLabel con StaticConEntry
317 mkConInfoTableLabel name False = IdLabel name ConInfoTable
318 mkConInfoTableLabel name True = DynIdLabel name ConInfoTable
320 mkStaticInfoTableLabel name False = IdLabel name StaticInfoTable
321 mkStaticInfoTableLabel name True = DynIdLabel name StaticInfoTable
323 mkConEntryLabel hmods name
324 | isDllName hmods name = DynIdLabel name ConEntry
325 | otherwise = IdLabel name ConEntry
327 mkStaticConEntryLabel hmods name
328 | isDllName hmods name = DynIdLabel name StaticConEntry
329 | otherwise = IdLabel name StaticConEntry
332 mkReturnPtLabel uniq = CaseLabel uniq CaseReturnPt
333 mkReturnInfoLabel uniq = CaseLabel uniq CaseReturnInfo
334 mkAltLabel uniq tag = CaseLabel uniq (CaseAlt tag)
335 mkDefaultLabel uniq = CaseLabel uniq CaseDefault
337 mkStringLitLabel = StringLitLabel
338 mkAsmTempLabel = AsmTempLabel
340 mkModuleInitLabel :: HomeModules -> Module -> String -> CLabel
341 mkModuleInitLabel hmods mod way
342 = ModuleInitLabel mod way $! (not (isHomeModule hmods mod))
344 mkPlainModuleInitLabel :: HomeModules -> Module -> CLabel
345 mkPlainModuleInitLabel hmods mod
346 = PlainModuleInitLabel mod $! (not (isHomeModule hmods mod))
348 -- Some fixed runtime system labels
350 mkSplitMarkerLabel = RtsLabel (RtsCode SLIT("__stg_split_marker"))
351 mkDirty_MUT_VAR_Label = RtsLabel (RtsCode SLIT("dirty_MUT_VAR"))
352 mkUpdInfoLabel = RtsLabel (RtsInfo SLIT("stg_upd_frame"))
353 mkSeqInfoLabel = RtsLabel (RtsInfo SLIT("stg_seq_frame"))
354 mkIndStaticInfoLabel = RtsLabel (RtsInfo SLIT("stg_IND_STATIC"))
355 mkMainCapabilityLabel = RtsLabel (RtsData SLIT("MainCapability"))
356 mkMAP_FROZEN_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_FROZEN0"))
357 mkMAP_DIRTY_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_DIRTY"))
358 mkEMPTY_MVAR_infoLabel = RtsLabel (RtsInfo SLIT("stg_EMPTY_MVAR"))
360 mkTopTickyCtrLabel = RtsLabel (RtsData SLIT("top_ct"))
361 mkCAFBlackHoleInfoTableLabel = RtsLabel (RtsInfo SLIT("stg_CAF_BLACKHOLE"))
362 mkSECAFBlackHoleInfoTableLabel = if opt_DoTickyProfiling then
363 RtsLabel (RtsInfo SLIT("stg_SE_CAF_BLACKHOLE"))
364 else -- RTS won't have info table unless -ticky is on
365 panic "mkSECAFBlackHoleInfoTableLabel requires -ticky"
366 mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
368 moduleRegdLabel = ModuleRegdLabel
370 mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTable upd off)
371 mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
373 mkApInfoTableLabel upd off = RtsLabel (RtsApInfoTable upd off)
374 mkApEntryLabel upd off = RtsLabel (RtsApEntry upd off)
378 mkForeignLabel :: FastString -> Maybe Int -> Bool -> CLabel
379 mkForeignLabel str mb_sz is_dynamic = ForeignLabel str mb_sz is_dynamic
383 mkCCLabel cc = CC_Label cc
384 mkCCSLabel ccs = CCS_Label ccs
386 mkRtsInfoLabel str = RtsLabel (RtsInfo str)
387 mkRtsEntryLabel str = RtsLabel (RtsEntry str)
388 mkRtsRetInfoLabel str = RtsLabel (RtsRetInfo str)
389 mkRtsRetLabel str = RtsLabel (RtsRet str)
390 mkRtsCodeLabel str = RtsLabel (RtsCode str)
391 mkRtsDataLabel str = RtsLabel (RtsData str)
393 mkRtsInfoLabelFS str = RtsLabel (RtsInfoFS str)
394 mkRtsEntryLabelFS str = RtsLabel (RtsEntryFS str)
395 mkRtsRetInfoLabelFS str = RtsLabel (RtsRetInfoFS str)
396 mkRtsRetLabelFS str = RtsLabel (RtsRetFS str)
397 mkRtsCodeLabelFS str = RtsLabel (RtsCodeFS str)
398 mkRtsDataLabelFS str = RtsLabel (RtsDataFS str)
400 mkRtsApFastLabel str = RtsLabel (RtsApFast str)
402 mkRtsSlowTickyCtrLabel :: String -> CLabel
403 mkRtsSlowTickyCtrLabel pat = RtsLabel (RtsSlowTickyCtr pat)
407 mkDynamicLinkerLabel :: DynamicLinkerLabelInfo -> CLabel -> CLabel
408 mkDynamicLinkerLabel = DynamicLinkerLabel
410 dynamicLinkerLabelInfo :: CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
411 dynamicLinkerLabelInfo (DynamicLinkerLabel info lbl) = Just (info, lbl)
412 dynamicLinkerLabelInfo _ = Nothing
414 -- Position independent code
416 mkPicBaseLabel :: CLabel
417 mkPicBaseLabel = PicBaseLabel
419 mkDeadStripPreventer :: CLabel -> CLabel
420 mkDeadStripPreventer lbl = DeadStripPreventer lbl
422 -- -----------------------------------------------------------------------------
423 -- Converting info labels to entry labels.
425 infoLblToEntryLbl :: CLabel -> CLabel
426 infoLblToEntryLbl (IdLabel n InfoTable) = IdLabel n Entry
427 infoLblToEntryLbl (IdLabel n ConInfoTable) = IdLabel n ConEntry
428 infoLblToEntryLbl (IdLabel n StaticInfoTable) = IdLabel n StaticConEntry
429 infoLblToEntryLbl (DynIdLabel n InfoTable) = DynIdLabel n Entry
430 infoLblToEntryLbl (DynIdLabel n ConInfoTable) = DynIdLabel n ConEntry
431 infoLblToEntryLbl (DynIdLabel n StaticInfoTable) = DynIdLabel n StaticConEntry
432 infoLblToEntryLbl (CaseLabel n CaseReturnInfo) = CaseLabel n CaseReturnPt
433 infoLblToEntryLbl (RtsLabel (RtsInfo s)) = RtsLabel (RtsEntry s)
434 infoLblToEntryLbl (RtsLabel (RtsRetInfo s)) = RtsLabel (RtsRet s)
435 infoLblToEntryLbl (RtsLabel (RtsInfoFS s)) = RtsLabel (RtsEntryFS s)
436 infoLblToEntryLbl (RtsLabel (RtsRetInfoFS s)) = RtsLabel (RtsRetFS s)
437 infoLblToEntryLbl _ = panic "CLabel.infoLblToEntryLbl"
439 entryLblToInfoLbl :: CLabel -> CLabel
440 entryLblToInfoLbl (IdLabel n Entry) = IdLabel n InfoTable
441 entryLblToInfoLbl (IdLabel n ConEntry) = IdLabel n ConInfoTable
442 entryLblToInfoLbl (IdLabel n StaticConEntry) = IdLabel n StaticInfoTable
443 entryLblToInfoLbl (DynIdLabel n Entry) = DynIdLabel n InfoTable
444 entryLblToInfoLbl (DynIdLabel n ConEntry) = DynIdLabel n ConInfoTable
445 entryLblToInfoLbl (DynIdLabel n StaticConEntry) = DynIdLabel n StaticInfoTable
446 entryLblToInfoLbl (CaseLabel n CaseReturnPt) = CaseLabel n CaseReturnInfo
447 entryLblToInfoLbl (RtsLabel (RtsEntry s)) = RtsLabel (RtsInfo s)
448 entryLblToInfoLbl (RtsLabel (RtsRet s)) = RtsLabel (RtsRetInfo s)
449 entryLblToInfoLbl (RtsLabel (RtsEntryFS s)) = RtsLabel (RtsInfoFS s)
450 entryLblToInfoLbl (RtsLabel (RtsRetFS s)) = RtsLabel (RtsRetInfoFS s)
451 entryLblToInfoLbl l = pprPanic "CLabel.entryLblToInfoLbl" (pprCLabel l)
453 -- -----------------------------------------------------------------------------
454 -- Does a CLabel need declaring before use or not?
456 needsCDecl :: CLabel -> Bool
457 -- False <=> it's pre-declared; don't bother
458 -- don't bother declaring SRT & Bitmap labels, we always make sure
459 -- they are defined before use.
460 needsCDecl (IdLabel _ SRT) = False
461 needsCDecl (IdLabel _ SRTDesc) = False
462 needsCDecl (IdLabel _ Bitmap) = False
463 needsCDecl (IdLabel _ _) = True
464 needsCDecl (DynIdLabel _ _) = True
465 needsCDecl (CaseLabel _ _) = True
466 needsCDecl (ModuleInitLabel _ _ _) = True
467 needsCDecl (PlainModuleInitLabel _ _) = True
468 needsCDecl ModuleRegdLabel = False
470 needsCDecl (StringLitLabel _) = False
471 needsCDecl (AsmTempLabel _) = False
472 needsCDecl (RtsLabel _) = False
473 needsCDecl (ForeignLabel _ _ _) = False
474 needsCDecl (CC_Label _) = True
475 needsCDecl (CCS_Label _) = True
477 -- Whether the label is an assembler temporary:
479 isAsmTemp :: CLabel -> Bool -- is a local temporary for native code generation
480 isAsmTemp (AsmTempLabel _) = True
483 -- -----------------------------------------------------------------------------
484 -- Is a CLabel visible outside this object file or not?
486 -- From the point of view of the code generator, a name is
487 -- externally visible if it has to be declared as exported
488 -- in the .o file's symbol table; that is, made non-static.
490 externallyVisibleCLabel :: CLabel -> Bool -- not C "static"
491 externallyVisibleCLabel (CaseLabel _ _) = False
492 externallyVisibleCLabel (StringLitLabel _) = False
493 externallyVisibleCLabel (AsmTempLabel _) = False
494 externallyVisibleCLabel (ModuleInitLabel _ _ _)= True
495 externallyVisibleCLabel (PlainModuleInitLabel _ _)= True
496 externallyVisibleCLabel ModuleRegdLabel = False
497 externallyVisibleCLabel (RtsLabel _) = True
498 externallyVisibleCLabel (ForeignLabel _ _ _) = True
499 externallyVisibleCLabel (IdLabel name _) = isExternalName name
500 externallyVisibleCLabel (DynIdLabel name _) = isExternalName name
501 externallyVisibleCLabel (CC_Label _) = True
502 externallyVisibleCLabel (CCS_Label _) = True
503 externallyVisibleCLabel (DynamicLinkerLabel _ _) = False
505 -- -----------------------------------------------------------------------------
506 -- Finding the "type" of a CLabel
508 -- For generating correct types in label declarations:
514 labelType :: CLabel -> CLabelType
515 labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
516 labelType (RtsLabel (RtsApInfoTable _ _)) = DataLabel
517 labelType (RtsLabel (RtsData _)) = DataLabel
518 labelType (RtsLabel (RtsCode _)) = CodeLabel
519 labelType (RtsLabel (RtsInfo _)) = DataLabel
520 labelType (RtsLabel (RtsEntry _)) = CodeLabel
521 labelType (RtsLabel (RtsRetInfo _)) = DataLabel
522 labelType (RtsLabel (RtsRet _)) = CodeLabel
523 labelType (RtsLabel (RtsDataFS _)) = DataLabel
524 labelType (RtsLabel (RtsCodeFS _)) = CodeLabel
525 labelType (RtsLabel (RtsInfoFS _)) = DataLabel
526 labelType (RtsLabel (RtsEntryFS _)) = CodeLabel
527 labelType (RtsLabel (RtsRetInfoFS _)) = DataLabel
528 labelType (RtsLabel (RtsRetFS _)) = CodeLabel
529 labelType (RtsLabel (RtsApFast _)) = CodeLabel
530 labelType (CaseLabel _ CaseReturnInfo) = DataLabel
531 labelType (CaseLabel _ _) = CodeLabel
532 labelType (ModuleInitLabel _ _ _) = CodeLabel
533 labelType (PlainModuleInitLabel _ _) = CodeLabel
535 labelType (IdLabel _ info) = idInfoLabelType info
536 labelType (DynIdLabel _ info) = idInfoLabelType info
537 labelType _ = DataLabel
539 idInfoLabelType info =
541 InfoTable -> DataLabel
544 ConInfoTable -> DataLabel
545 StaticInfoTable -> DataLabel
546 ClosureTable -> DataLabel
550 -- -----------------------------------------------------------------------------
551 -- Does a CLabel need dynamic linkage?
553 -- When referring to data in code, we need to know whether
554 -- that data resides in a DLL or not. [Win32 only.]
555 -- @labelDynamic@ returns @True@ if the label is located
556 -- in a DLL, be it a data reference or not.
558 labelDynamic :: CLabel -> Bool
561 RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
563 DynIdLabel n k -> True
564 #if mingw32_TARGET_OS
565 ForeignLabel _ _ d -> d
567 -- On Mac OS X and on ELF platforms, false positives are OK,
568 -- so we claim that all foreign imports come from dynamic libraries
569 ForeignLabel _ _ _ -> True
571 ModuleInitLabel m _ dyn -> not opt_Static && dyn
572 PlainModuleInitLabel m dyn -> not opt_Static && dyn
574 -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
578 OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
579 right places. It is used to detect when the abstractC statement of an
580 CCodeBlock actually contains the code for a slow entry point. -- HWL
582 We need at least @Eq@ for @CLabels@, because we want to avoid
583 duplicate declarations in generating C (see @labelSeenTE@ in
587 -----------------------------------------------------------------------------
588 -- Printing out CLabels.
595 where <name> is <Module>_<name> for external names and <unique> for
596 internal names. <type> is one of the following:
599 srt Static reference table
600 srtd Static reference table descriptor
601 entry Entry code (function, closure)
602 slow Slow entry code (if any)
603 ret Direct return address
605 <n>_alt Case alternative (tag n)
606 dflt Default case alternative
607 btm Large bitmap vector
608 closure Static closure
609 con_entry Dynamic Constructor entry code
610 con_info Dynamic Constructor info table
611 static_entry Static Constructor entry code
612 static_info Static Constructor info table
613 sel_info Selector info table
614 sel_entry Selector entry code
616 ccs Cost centre stack
618 Many of these distinctions are only for documentation reasons. For
619 example, _ret is only distinguished from _entry to make it easy to
620 tell whether a code fragment is a return point or a closure/function
624 instance Outputable CLabel where
627 pprCLabel :: CLabel -> SDoc
629 #if ! OMIT_NATIVE_CODEGEN
630 pprCLabel (AsmTempLabel u)
631 = getPprStyle $ \ sty ->
633 ptext asmTempLabelPrefix <> pprUnique u
635 char '_' <> pprUnique u
637 pprCLabel (DynamicLinkerLabel info lbl)
638 = pprDynamicLinkerAsmLabel info lbl
640 pprCLabel PicBaseLabel
643 pprCLabel (DeadStripPreventer lbl)
644 = pprCLabel lbl <> ptext SLIT("_dsp")
648 #if ! OMIT_NATIVE_CODEGEN
649 getPprStyle $ \ sty ->
651 maybe_underscore (pprAsmCLbl lbl)
657 | underscorePrefix = pp_cSEP <> doc
660 #ifdef mingw32_TARGET_OS
661 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel.
662 -- (The C compiler does this itself).
663 pprAsmCLbl (ForeignLabel fs (Just sz) _)
664 = ftext fs <> char '@' <> int sz
669 pprCLbl (StringLitLabel u)
670 = pprUnique u <> ptext SLIT("_str")
672 pprCLbl (CaseLabel u CaseReturnPt)
673 = hcat [pprUnique u, ptext SLIT("_ret")]
674 pprCLbl (CaseLabel u CaseReturnInfo)
675 = hcat [pprUnique u, ptext SLIT("_info")]
676 pprCLbl (CaseLabel u (CaseAlt tag))
677 = hcat [pprUnique u, pp_cSEP, int tag, ptext SLIT("_alt")]
678 pprCLbl (CaseLabel u CaseDefault)
679 = hcat [pprUnique u, ptext SLIT("_dflt")]
681 pprCLbl (RtsLabel (RtsCode str)) = ptext str
682 pprCLbl (RtsLabel (RtsData str)) = ptext str
683 pprCLbl (RtsLabel (RtsCodeFS str)) = ftext str
684 pprCLbl (RtsLabel (RtsDataFS str)) = ftext str
686 pprCLbl (RtsLabel (RtsApFast str)) = ptext str <> ptext SLIT("_fast")
688 pprCLbl (RtsLabel (RtsSelectorInfoTable upd_reqd offset))
689 = hcat [ptext SLIT("stg_sel_"), text (show offset),
691 then SLIT("_upd_info")
692 else SLIT("_noupd_info"))
695 pprCLbl (RtsLabel (RtsSelectorEntry upd_reqd offset))
696 = hcat [ptext SLIT("stg_sel_"), text (show offset),
698 then SLIT("_upd_entry")
699 else SLIT("_noupd_entry"))
702 pprCLbl (RtsLabel (RtsApInfoTable upd_reqd arity))
703 = hcat [ptext SLIT("stg_ap_"), text (show arity),
705 then SLIT("_upd_info")
706 else SLIT("_noupd_info"))
709 pprCLbl (RtsLabel (RtsApEntry upd_reqd arity))
710 = hcat [ptext SLIT("stg_ap_"), text (show arity),
712 then SLIT("_upd_entry")
713 else SLIT("_noupd_entry"))
716 pprCLbl (RtsLabel (RtsInfo fs))
717 = ptext fs <> ptext SLIT("_info")
719 pprCLbl (RtsLabel (RtsEntry fs))
720 = ptext fs <> ptext SLIT("_entry")
722 pprCLbl (RtsLabel (RtsRetInfo fs))
723 = ptext fs <> ptext SLIT("_info")
725 pprCLbl (RtsLabel (RtsRet fs))
726 = ptext fs <> ptext SLIT("_ret")
728 pprCLbl (RtsLabel (RtsInfoFS fs))
729 = ftext fs <> ptext SLIT("_info")
731 pprCLbl (RtsLabel (RtsEntryFS fs))
732 = ftext fs <> ptext SLIT("_entry")
734 pprCLbl (RtsLabel (RtsRetInfoFS fs))
735 = ftext fs <> ptext SLIT("_info")
737 pprCLbl (RtsLabel (RtsRetFS fs))
738 = ftext fs <> ptext SLIT("_ret")
740 pprCLbl (RtsLabel (RtsPrimOp primop))
741 = ppr primop <> ptext SLIT("_fast")
743 pprCLbl (RtsLabel (RtsSlowTickyCtr pat))
744 = ptext SLIT("SLOW_CALL_") <> text pat <> ptext SLIT("_ctr")
746 pprCLbl ModuleRegdLabel
747 = ptext SLIT("_module_registered")
749 pprCLbl (ForeignLabel str _ _)
752 pprCLbl (IdLabel name flavor) = ppr name <> ppIdFlavor flavor
753 pprCLbl (DynIdLabel name flavor) = ppr name <> ppIdFlavor flavor
755 pprCLbl (CC_Label cc) = ppr cc
756 pprCLbl (CCS_Label ccs) = ppr ccs
758 pprCLbl (ModuleInitLabel mod way _)
759 = ptext SLIT("__stginit_") <> ppr mod
760 <> char '_' <> text way
761 pprCLbl (PlainModuleInitLabel mod _)
762 = ptext SLIT("__stginit_") <> ppr mod
764 ppIdFlavor :: IdLabelInfo -> SDoc
765 ppIdFlavor x = pp_cSEP <>
767 Closure -> ptext SLIT("closure")
768 SRT -> ptext SLIT("srt")
769 SRTDesc -> ptext SLIT("srtd")
770 InfoTable -> ptext SLIT("info")
771 Entry -> ptext SLIT("entry")
772 Slow -> ptext SLIT("slow")
773 RednCounts -> ptext SLIT("ct")
774 Bitmap -> ptext SLIT("btm")
775 ConEntry -> ptext SLIT("con_entry")
776 ConInfoTable -> ptext SLIT("con_info")
777 StaticConEntry -> ptext SLIT("static_entry")
778 StaticInfoTable -> ptext SLIT("static_info")
779 ClosureTable -> ptext SLIT("closure_tbl")
785 -- -----------------------------------------------------------------------------
786 -- Machine-dependent knowledge about labels.
788 underscorePrefix :: Bool -- leading underscore on assembler labels?
789 underscorePrefix = (cLeadingUnderscore == "YES")
791 asmTempLabelPrefix :: LitString -- for formatting labels
794 {- The alpha assembler likes temporary labels to look like $L123
795 instead of L123. (Don't toss the L, because then Lf28
799 #elif darwin_TARGET_OS
805 pprDynamicLinkerAsmLabel :: DynamicLinkerLabelInfo -> CLabel -> SDoc
808 pprDynamicLinkerAsmLabel SymbolPtr lbl
809 = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
810 pprDynamicLinkerAsmLabel CodeStub lbl
811 = char 'L' <> pprCLabel lbl <> text "$stub"
812 #elif powerpc_TARGET_ARCH && linux_TARGET_OS
813 pprDynamicLinkerAsmLabel CodeStub lbl
814 = pprCLabel lbl <> text "@plt"
815 pprDynamicLinkerAsmLabel SymbolPtr lbl
816 = text ".LC_" <> pprCLabel lbl
817 #elif linux_TARGET_OS
818 pprDynamicLinkerAsmLabel CodeStub lbl
819 = pprCLabel lbl <> text "@plt"
820 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
821 = pprCLabel lbl <> text "@got"
822 pprDynamicLinkerAsmLabel GotSymbolOffset lbl
823 = pprCLabel lbl <> text "@gotoff"
824 pprDynamicLinkerAsmLabel SymbolPtr lbl
825 = text ".LC_" <> pprCLabel lbl
826 #elif mingw32_TARGET_OS
827 pprDynamicLinkerAsmLabel SymbolPtr lbl
828 = text "__imp_" <> pprCLabel lbl
830 pprDynamicLinkerAsmLabel _ _
831 = panic "pprDynamicLinkerAsmLabel"