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 mkEMPTY_MVAR_infoLabel,
57 mkCAFBlackHoleInfoTableLabel,
58 mkSECAFBlackHoleInfoTableLabel,
60 mkRtsSlowTickyCtrLabel,
83 mkCCLabel, mkCCSLabel,
85 DynamicLinkerLabelInfo(..),
87 dynamicLinkerLabelInfo,
91 infoLblToEntryLbl, entryLblToInfoLbl,
92 needsCDecl, isAsmTemp, externallyVisibleCLabel,
93 CLabelType(..), labelType, labelDynamic,
99 #include "HsVersions.h"
100 #include "../includes/ghcconfig.h"
102 import CmdLineOpts ( DynFlags, opt_Static, opt_DoTickyProfiling )
103 import Packages ( isHomeModule )
104 import DataCon ( ConTag )
105 import Module ( moduleFS, Module )
106 import Name ( Name, isExternalName, nameModule )
107 import Unique ( pprUnique, Unique )
108 import PrimOp ( PrimOp )
109 import Config ( cLeadingUnderscore )
110 import CostCentre ( CostCentre, CostCentreStack )
114 -- -----------------------------------------------------------------------------
118 CLabel is an abstract type that supports the following operations:
122 - In a C file, does it need to be declared before use? (i.e. is it
123 guaranteed to be already in scope in the places we need to refer to it?)
125 - If it needs to be declared, what type (code or data) should it be
128 - Is it visible outside this object file or not?
130 - Is it "dynamic" (see details below)
132 - Eq and Ord, so that we can make sets of CLabels (currently only
133 used in outputting C as far as I can tell, to avoid generating
134 more than one declaration for any given label).
136 - Converting an info table label into an entry label.
140 = IdLabel -- A family of labels related to the
141 Name -- definition of a particular Id or Con
144 | DynIdLabel -- like IdLabel, but in a separate package,
145 Name -- and might therefore need a dynamic
146 IdLabelInfo -- reference.
148 | CaseLabel -- A family of labels related to a particular
150 {-# UNPACK #-} !Unique -- Unique says which case expression
154 {-# UNPACK #-} !Unique
157 {-# UNPACK #-} !Unique
160 Module -- the module name
162 Bool -- True <=> is in a different package
163 -- at some point we might want some kind of version number in
164 -- the module init label, to guard against compiling modules in
165 -- the wrong order. We can't use the interface file version however,
166 -- because we don't always recompile modules which depend on a module
167 -- whose version has changed.
169 | PlainModuleInitLabel -- without the vesrion & way info
171 Bool -- True <=> is in a different package
175 | RtsLabel RtsLabelInfo
177 | ForeignLabel FastString -- a 'C' (or otherwise foreign) label
178 (Maybe Int) -- possible '@n' suffix for stdcall functions
179 -- When generating C, the '@n' suffix is omitted, but when
180 -- generating assembler we must add it to the label.
181 Bool -- True <=> is dynamic
183 | CC_Label CostCentre
184 | CCS_Label CostCentreStack
186 -- Dynamic Linking in the NCG:
187 -- generated and used inside the NCG only,
188 -- see module PositionIndependentCode for details.
190 | DynamicLinkerLabel DynamicLinkerLabelInfo CLabel
191 -- special variants of a label used for dynamic linking
193 | PicBaseLabel -- a label used as a base for PIC calculations
194 -- on some platforms.
195 -- It takes the form of a local numeric
196 -- assembler label '1'; it is pretty-printed
197 -- as 1b, referring to the previous definition
198 -- of 1: in the assembler source file.
202 = Closure -- Label for closure
203 | SRT -- Static reference table
204 | SRTDesc -- Static reference table descriptor
205 | InfoTable -- Info tables for closures; always read-only
206 | Entry -- entry point
207 | Slow -- slow entry point
209 | RednCounts -- Label of place to keep Ticky-ticky info for
212 | Bitmap -- A bitmap (function or case return)
214 | ConEntry -- constructor entry point
215 | ConInfoTable -- corresponding info table
216 | StaticConEntry -- static constructor entry point
217 | StaticInfoTable -- corresponding info table
219 | ClosureTable -- table of closures for Enum tycons
233 = RtsSelectorInfoTable Bool{-updatable-} Int{-offset-} -- Selector thunks
234 | RtsSelectorEntry Bool{-updatable-} Int{-offset-}
236 | RtsApInfoTable Bool{-updatable-} Int{-arity-} -- AP thunks
237 | RtsApEntry Bool{-updatable-} Int{-arity-}
241 | RtsInfo LitString -- misc rts info tables
242 | RtsEntry LitString -- misc rts entry points
243 | RtsRetInfo LitString -- misc rts ret info tables
244 | RtsRet LitString -- misc rts return points
245 | RtsData LitString -- misc rts data bits, eg CHARLIKE_closure
246 | RtsCode LitString -- misc rts code
248 | RtsInfoFS FastString -- misc rts info tables
249 | RtsEntryFS FastString -- misc rts entry points
250 | RtsRetInfoFS FastString -- misc rts ret info tables
251 | RtsRetFS FastString -- misc rts return points
252 | RtsDataFS FastString -- misc rts data bits, eg CHARLIKE_closure
253 | RtsCodeFS FastString -- misc rts code
255 | RtsSlowTickyCtr String
258 -- NOTE: Eq on LitString compares the pointer only, so this isn't
261 data DynamicLinkerLabelInfo
262 = CodeStub -- MachO: Lfoo$stub, ELF: foo@plt
263 | SymbolPtr -- MachO: Lfoo$non_lazy_ptr, Windows: __imp_foo
264 | GotSymbolPtr -- ELF: foo@got
265 | GotSymbolOffset -- ELF: foo@gotoff
269 -- -----------------------------------------------------------------------------
270 -- Constructing CLabels
272 -- These are always local:
273 mkSRTLabel name = IdLabel name SRT
274 mkSRTDescLabel name = IdLabel name SRTDesc
275 mkSlowEntryLabel name = IdLabel name Slow
276 mkBitmapLabel name = IdLabel name Bitmap
277 mkRednCountsLabel name = IdLabel name RednCounts
279 -- These have local & (possibly) external variants:
280 mkLocalClosureLabel name = IdLabel name Closure
281 mkLocalInfoTableLabel name = IdLabel name InfoTable
282 mkLocalEntryLabel name = IdLabel name Entry
283 mkLocalClosureTableLabel name = IdLabel name ClosureTable
285 mkClosureLabel dflags name
286 | opt_Static || isHomeModule dflags mod = IdLabel name Closure
287 | otherwise = DynIdLabel name Closure
288 where mod = nameModule name
290 mkInfoTableLabel dflags name
291 | opt_Static || isHomeModule dflags mod = IdLabel name InfoTable
292 | otherwise = DynIdLabel name InfoTable
293 where mod = nameModule name
295 mkEntryLabel dflags name
296 | opt_Static || isHomeModule dflags mod = IdLabel name Entry
297 | otherwise = DynIdLabel name Entry
298 where mod = nameModule name
300 mkClosureTableLabel dflags name
301 | opt_Static || isHomeModule dflags mod = IdLabel name ClosureTable
302 | otherwise = DynIdLabel name ClosureTable
303 where mod = nameModule name
305 mkLocalConInfoTableLabel con = IdLabel con ConInfoTable
306 mkLocalConEntryLabel con = IdLabel con ConEntry
307 mkLocalStaticInfoTableLabel con = IdLabel con StaticInfoTable
308 mkLocalStaticConEntryLabel con = IdLabel con StaticConEntry
310 mkConInfoTableLabel name False = IdLabel name ConInfoTable
311 mkConInfoTableLabel name True = DynIdLabel name ConInfoTable
313 mkStaticInfoTableLabel name False = IdLabel name StaticInfoTable
314 mkStaticInfoTableLabel name True = DynIdLabel name StaticInfoTable
316 mkConEntryLabel dflags name
317 | opt_Static || isHomeModule dflags mod = IdLabel name ConEntry
318 | otherwise = DynIdLabel name ConEntry
319 where mod = nameModule name
321 mkStaticConEntryLabel dflags name
322 | opt_Static || isHomeModule dflags mod = IdLabel name StaticConEntry
323 | otherwise = DynIdLabel name StaticConEntry
324 where mod = nameModule name
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 :: DynFlags -> Module -> String -> CLabel
336 mkModuleInitLabel dflags mod way
337 = ModuleInitLabel mod way $! (not (isHomeModule dflags mod))
339 mkPlainModuleInitLabel :: DynFlags -> Module -> CLabel
340 mkPlainModuleInitLabel dflags mod
341 = PlainModuleInitLabel mod $! (not (isHomeModule dflags 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_FROZEN"))
351 mkEMPTY_MVAR_infoLabel = RtsLabel (RtsInfo SLIT("stg_EMPTY_MVAR"))
353 mkTopTickyCtrLabel = RtsLabel (RtsData SLIT("top_ct"))
354 mkCAFBlackHoleInfoTableLabel = RtsLabel (RtsInfo SLIT("stg_CAF_BLACKHOLE"))
355 mkSECAFBlackHoleInfoTableLabel = if opt_DoTickyProfiling then
356 RtsLabel (RtsInfo SLIT("stg_SE_CAF_BLACKHOLE"))
357 else -- RTS won't have info table unless -ticky is on
358 panic "mkSECAFBlackHoleInfoTableLabel requires -ticky"
359 mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
361 moduleRegdLabel = ModuleRegdLabel
363 mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTable upd off)
364 mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
366 mkApInfoTableLabel upd off = RtsLabel (RtsApInfoTable upd off)
367 mkApEntryLabel upd off = RtsLabel (RtsApEntry upd off)
371 mkForeignLabel :: FastString -> Maybe Int -> Bool -> CLabel
372 mkForeignLabel str mb_sz is_dynamic = ForeignLabel str mb_sz is_dynamic
376 mkCCLabel cc = CC_Label cc
377 mkCCSLabel ccs = CCS_Label ccs
379 mkRtsInfoLabel str = RtsLabel (RtsInfo str)
380 mkRtsEntryLabel str = RtsLabel (RtsEntry str)
381 mkRtsRetInfoLabel str = RtsLabel (RtsRetInfo str)
382 mkRtsRetLabel str = RtsLabel (RtsRet str)
383 mkRtsCodeLabel str = RtsLabel (RtsCode str)
384 mkRtsDataLabel str = RtsLabel (RtsData str)
386 mkRtsInfoLabelFS str = RtsLabel (RtsInfoFS str)
387 mkRtsEntryLabelFS str = RtsLabel (RtsEntryFS str)
388 mkRtsRetInfoLabelFS str = RtsLabel (RtsRetInfoFS str)
389 mkRtsRetLabelFS str = RtsLabel (RtsRetFS str)
390 mkRtsCodeLabelFS str = RtsLabel (RtsCodeFS str)
391 mkRtsDataLabelFS str = RtsLabel (RtsDataFS str)
393 mkRtsSlowTickyCtrLabel :: String -> CLabel
394 mkRtsSlowTickyCtrLabel pat = RtsLabel (RtsSlowTickyCtr pat)
398 mkDynamicLinkerLabel :: DynamicLinkerLabelInfo -> CLabel -> CLabel
399 mkDynamicLinkerLabel = DynamicLinkerLabel
401 dynamicLinkerLabelInfo :: CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
402 dynamicLinkerLabelInfo (DynamicLinkerLabel info lbl) = Just (info, lbl)
403 dynamicLinkerLabelInfo _ = Nothing
405 -- Position independent code
407 mkPicBaseLabel :: CLabel
408 mkPicBaseLabel = PicBaseLabel
410 -- -----------------------------------------------------------------------------
411 -- Converting info labels to entry labels.
413 infoLblToEntryLbl :: CLabel -> CLabel
414 infoLblToEntryLbl (IdLabel n InfoTable) = IdLabel n Entry
415 infoLblToEntryLbl (IdLabel n ConInfoTable) = IdLabel n ConEntry
416 infoLblToEntryLbl (IdLabel n StaticInfoTable) = IdLabel n StaticConEntry
417 infoLblToEntryLbl (DynIdLabel n InfoTable) = DynIdLabel n Entry
418 infoLblToEntryLbl (DynIdLabel n ConInfoTable) = DynIdLabel n ConEntry
419 infoLblToEntryLbl (DynIdLabel n StaticInfoTable) = DynIdLabel n StaticConEntry
420 infoLblToEntryLbl (CaseLabel n CaseReturnInfo) = CaseLabel n CaseReturnPt
421 infoLblToEntryLbl (RtsLabel (RtsInfo s)) = RtsLabel (RtsEntry s)
422 infoLblToEntryLbl (RtsLabel (RtsRetInfo s)) = RtsLabel (RtsRet s)
423 infoLblToEntryLbl (RtsLabel (RtsInfoFS s)) = RtsLabel (RtsEntryFS s)
424 infoLblToEntryLbl (RtsLabel (RtsRetInfoFS s)) = RtsLabel (RtsRetFS s)
425 infoLblToEntryLbl _ = panic "CLabel.infoLblToEntryLbl"
427 entryLblToInfoLbl :: CLabel -> CLabel
428 entryLblToInfoLbl (IdLabel n Entry) = IdLabel n InfoTable
429 entryLblToInfoLbl (IdLabel n ConEntry) = IdLabel n ConInfoTable
430 entryLblToInfoLbl (IdLabel n StaticConEntry) = IdLabel n StaticInfoTable
431 entryLblToInfoLbl (DynIdLabel n Entry) = DynIdLabel n InfoTable
432 entryLblToInfoLbl (DynIdLabel n ConEntry) = DynIdLabel n ConInfoTable
433 entryLblToInfoLbl (DynIdLabel n StaticConEntry) = DynIdLabel n StaticInfoTable
434 entryLblToInfoLbl (CaseLabel n CaseReturnPt) = CaseLabel n CaseReturnInfo
435 entryLblToInfoLbl (RtsLabel (RtsEntry s)) = RtsLabel (RtsInfo s)
436 entryLblToInfoLbl (RtsLabel (RtsRet s)) = RtsLabel (RtsRetInfo s)
437 entryLblToInfoLbl (RtsLabel (RtsEntryFS s)) = RtsLabel (RtsInfoFS s)
438 entryLblToInfoLbl (RtsLabel (RtsRetFS s)) = RtsLabel (RtsRetInfoFS s)
439 entryLblToInfoLbl l = pprPanic "CLabel.entryLblToInfoLbl" (pprCLabel l)
441 -- -----------------------------------------------------------------------------
442 -- Does a CLabel need declaring before use or not?
444 needsCDecl :: CLabel -> Bool
445 -- False <=> it's pre-declared; don't bother
446 -- don't bother declaring SRT & Bitmap labels, we always make sure
447 -- they are defined before use.
448 needsCDecl (IdLabel _ SRT) = False
449 needsCDecl (IdLabel _ SRTDesc) = False
450 needsCDecl (IdLabel _ Bitmap) = False
451 needsCDecl (IdLabel _ _) = True
452 needsCDecl (DynIdLabel _ _) = True
453 needsCDecl (CaseLabel _ _) = True
454 needsCDecl (ModuleInitLabel _ _ _) = True
455 needsCDecl (PlainModuleInitLabel _ _) = True
456 needsCDecl ModuleRegdLabel = False
458 needsCDecl (CaseLabel _ _) = False
459 needsCDecl (StringLitLabel _) = False
460 needsCDecl (AsmTempLabel _) = False
461 needsCDecl (RtsLabel _) = False
462 needsCDecl (ForeignLabel _ _ _) = False
463 needsCDecl (CC_Label _) = True
464 needsCDecl (CCS_Label _) = True
466 -- Whether the label is an assembler temporary:
468 isAsmTemp :: CLabel -> Bool -- is a local temporary for native code generation
469 isAsmTemp (AsmTempLabel _) = True
472 -- -----------------------------------------------------------------------------
473 -- Is a CLabel visible outside this object file or not?
475 -- From the point of view of the code generator, a name is
476 -- externally visible if it has to be declared as exported
477 -- in the .o file's symbol table; that is, made non-static.
479 externallyVisibleCLabel :: CLabel -> Bool -- not C "static"
480 externallyVisibleCLabel (CaseLabel _ _) = False
481 externallyVisibleCLabel (StringLitLabel _) = False
482 externallyVisibleCLabel (AsmTempLabel _) = False
483 externallyVisibleCLabel (ModuleInitLabel _ _ _)= True
484 externallyVisibleCLabel (PlainModuleInitLabel _ _)= True
485 externallyVisibleCLabel ModuleRegdLabel = False
486 externallyVisibleCLabel (RtsLabel _) = True
487 externallyVisibleCLabel (ForeignLabel _ _ _) = True
488 externallyVisibleCLabel (IdLabel name _) = isExternalName name
489 externallyVisibleCLabel (DynIdLabel name _) = isExternalName name
490 externallyVisibleCLabel (CC_Label _) = True
491 externallyVisibleCLabel (CCS_Label _) = True
492 externallyVisibleCLabel (DynamicLinkerLabel _ _) = False
494 -- -----------------------------------------------------------------------------
495 -- Finding the "type" of a CLabel
497 -- For generating correct types in label declarations:
503 labelType :: CLabel -> CLabelType
504 labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
505 labelType (RtsLabel (RtsApInfoTable _ _)) = DataLabel
506 labelType (RtsLabel (RtsData _)) = DataLabel
507 labelType (RtsLabel (RtsCode _)) = CodeLabel
508 labelType (RtsLabel (RtsInfo _)) = DataLabel
509 labelType (RtsLabel (RtsEntry _)) = CodeLabel
510 labelType (RtsLabel (RtsRetInfo _)) = DataLabel
511 labelType (RtsLabel (RtsRet _)) = CodeLabel
512 labelType (RtsLabel (RtsDataFS _)) = DataLabel
513 labelType (RtsLabel (RtsCodeFS _)) = CodeLabel
514 labelType (RtsLabel (RtsInfoFS _)) = DataLabel
515 labelType (RtsLabel (RtsEntryFS _)) = CodeLabel
516 labelType (RtsLabel (RtsRetInfoFS _)) = DataLabel
517 labelType (RtsLabel (RtsRetFS _)) = CodeLabel
518 labelType (CaseLabel _ CaseReturnInfo) = DataLabel
519 labelType (CaseLabel _ _) = CodeLabel
520 labelType (ModuleInitLabel _ _ _) = CodeLabel
521 labelType (PlainModuleInitLabel _ _) = CodeLabel
523 labelType (IdLabel _ info) = idInfoLabelType info
524 labelType (DynIdLabel _ info) = idInfoLabelType info
525 labelType _ = DataLabel
527 idInfoLabelType info =
529 InfoTable -> DataLabel
532 ConInfoTable -> DataLabel
533 StaticInfoTable -> DataLabel
534 ClosureTable -> DataLabel
538 -- -----------------------------------------------------------------------------
539 -- Does a CLabel need dynamic linkage?
541 -- When referring to data in code, we need to know whether
542 -- that data resides in a DLL or not. [Win32 only.]
543 -- @labelDynamic@ returns @True@ if the label is located
544 -- in a DLL, be it a data reference or not.
546 labelDynamic :: CLabel -> Bool
549 RtsLabel _ -> not opt_Static -- i.e., is the RTS in a DLL or not?
551 DynIdLabel n k -> True
552 #if mingw32_TARGET_OS
553 ForeignLabel _ _ d -> d
555 -- On Mac OS X and on ELF platforms, false positives are OK,
556 -- so we claim that all foreign imports come from dynamic libraries
557 ForeignLabel _ _ _ -> True
559 ModuleInitLabel m _ dyn -> not opt_Static && dyn
560 PlainModuleInitLabel m dyn -> not opt_Static && dyn
562 -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
566 OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
567 right places. It is used to detect when the abstractC statement of an
568 CCodeBlock actually contains the code for a slow entry point. -- HWL
570 We need at least @Eq@ for @CLabels@, because we want to avoid
571 duplicate declarations in generating C (see @labelSeenTE@ in
575 -----------------------------------------------------------------------------
576 -- Printing out CLabels.
583 where <name> is <Module>_<name> for external names and <unique> for
584 internal names. <type> is one of the following:
587 srt Static reference table
588 srtd Static reference table descriptor
589 entry Entry code (function, closure)
590 slow Slow entry code (if any)
591 ret Direct return address
593 <n>_alt Case alternative (tag n)
594 dflt Default case alternative
595 btm Large bitmap vector
596 closure Static closure
597 con_entry Dynamic Constructor entry code
598 con_info Dynamic Constructor info table
599 static_entry Static Constructor entry code
600 static_info Static Constructor info table
601 sel_info Selector info table
602 sel_entry Selector entry code
604 ccs Cost centre stack
606 Many of these distinctions are only for documentation reasons. For
607 example, _ret is only distinguished from _entry to make it easy to
608 tell whether a code fragment is a return point or a closure/function
612 pprCLabel :: CLabel -> SDoc
614 #if ! OMIT_NATIVE_CODEGEN
615 pprCLabel (AsmTempLabel u)
616 = getPprStyle $ \ sty ->
618 ptext asmTempLabelPrefix <> pprUnique u
620 char '_' <> pprUnique u
622 pprCLabel (DynamicLinkerLabel info lbl)
623 = pprDynamicLinkerAsmLabel info lbl
625 pprCLabel PicBaseLabel
630 #if ! OMIT_NATIVE_CODEGEN
631 getPprStyle $ \ sty ->
633 maybe_underscore (pprAsmCLbl lbl)
639 | underscorePrefix = pp_cSEP <> doc
642 #ifdef mingw32_TARGET_OS
643 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel.
644 -- (The C compiler does this itself).
645 pprAsmCLbl (ForeignLabel fs (Just sz) _)
646 = ftext fs <> char '@' <> int sz
651 pprCLbl (StringLitLabel u)
652 = pprUnique u <> ptext SLIT("_str")
654 pprCLbl (CaseLabel u CaseReturnPt)
655 = hcat [pprUnique u, ptext SLIT("_ret")]
656 pprCLbl (CaseLabel u CaseReturnInfo)
657 = hcat [pprUnique u, ptext SLIT("_info")]
658 pprCLbl (CaseLabel u (CaseAlt tag))
659 = hcat [pprUnique u, pp_cSEP, int tag, ptext SLIT("_alt")]
660 pprCLbl (CaseLabel u CaseDefault)
661 = hcat [pprUnique u, ptext SLIT("_dflt")]
663 pprCLbl (RtsLabel (RtsCode str)) = ptext str
664 pprCLbl (RtsLabel (RtsData str)) = ptext str
665 pprCLbl (RtsLabel (RtsCodeFS str)) = ftext str
666 pprCLbl (RtsLabel (RtsDataFS str)) = ftext str
668 pprCLbl (RtsLabel (RtsSelectorInfoTable upd_reqd offset))
669 = hcat [ptext SLIT("stg_sel_"), text (show offset),
671 then SLIT("_upd_info")
672 else SLIT("_noupd_info"))
675 pprCLbl (RtsLabel (RtsSelectorEntry upd_reqd offset))
676 = hcat [ptext SLIT("stg_sel_"), text (show offset),
678 then SLIT("_upd_entry")
679 else SLIT("_noupd_entry"))
682 pprCLbl (RtsLabel (RtsApInfoTable upd_reqd arity))
683 = hcat [ptext SLIT("stg_ap_"), text (show arity),
685 then SLIT("_upd_info")
686 else SLIT("_noupd_info"))
689 pprCLbl (RtsLabel (RtsApEntry upd_reqd arity))
690 = hcat [ptext SLIT("stg_ap_"), text (show arity),
692 then SLIT("_upd_entry")
693 else SLIT("_noupd_entry"))
696 pprCLbl (RtsLabel (RtsInfo fs))
697 = ptext fs <> ptext SLIT("_info")
699 pprCLbl (RtsLabel (RtsEntry fs))
700 = ptext fs <> ptext SLIT("_entry")
702 pprCLbl (RtsLabel (RtsRetInfo fs))
703 = ptext fs <> ptext SLIT("_info")
705 pprCLbl (RtsLabel (RtsRet fs))
706 = ptext fs <> ptext SLIT("_ret")
708 pprCLbl (RtsLabel (RtsInfoFS fs))
709 = ftext fs <> ptext SLIT("_info")
711 pprCLbl (RtsLabel (RtsEntryFS fs))
712 = ftext fs <> ptext SLIT("_entry")
714 pprCLbl (RtsLabel (RtsRetInfoFS fs))
715 = ftext fs <> ptext SLIT("_info")
717 pprCLbl (RtsLabel (RtsRetFS fs))
718 = ftext fs <> ptext SLIT("_ret")
720 pprCLbl (RtsLabel (RtsPrimOp primop))
721 = ppr primop <> ptext SLIT("_fast")
723 pprCLbl (RtsLabel (RtsSlowTickyCtr pat))
724 = ptext SLIT("SLOW_CALL_") <> text pat <> ptext SLIT("_ctr")
726 pprCLbl ModuleRegdLabel
727 = ptext SLIT("_module_registered")
729 pprCLbl (ForeignLabel str _ _)
732 pprCLbl (IdLabel name flavor) = ppr name <> ppIdFlavor flavor
733 pprCLbl (DynIdLabel name flavor) = ppr name <> ppIdFlavor flavor
735 pprCLbl (CC_Label cc) = ppr cc
736 pprCLbl (CCS_Label ccs) = ppr ccs
738 pprCLbl (ModuleInitLabel mod way _)
739 = ptext SLIT("__stginit_") <> ftext (moduleFS mod)
740 <> char '_' <> text way
741 pprCLbl (PlainModuleInitLabel mod _)
742 = ptext SLIT("__stginit_") <> ftext (moduleFS mod)
744 ppIdFlavor :: IdLabelInfo -> SDoc
745 ppIdFlavor x = pp_cSEP <>
747 Closure -> ptext SLIT("closure")
748 SRT -> ptext SLIT("srt")
749 SRTDesc -> ptext SLIT("srtd")
750 InfoTable -> ptext SLIT("info")
751 Entry -> ptext SLIT("entry")
752 Slow -> ptext SLIT("slow")
753 RednCounts -> ptext SLIT("ct")
754 Bitmap -> ptext SLIT("btm")
755 ConEntry -> ptext SLIT("con_entry")
756 ConInfoTable -> ptext SLIT("con_info")
757 StaticConEntry -> ptext SLIT("static_entry")
758 StaticInfoTable -> ptext SLIT("static_info")
759 ClosureTable -> ptext SLIT("closure_tbl")
765 -- -----------------------------------------------------------------------------
766 -- Machine-dependent knowledge about labels.
768 underscorePrefix :: Bool -- leading underscore on assembler labels?
769 underscorePrefix = (cLeadingUnderscore == "YES")
771 asmTempLabelPrefix :: LitString -- for formatting labels
774 {- The alpha assembler likes temporary labels to look like $L123
775 instead of L123. (Don't toss the L, because then Lf28
779 #elif darwin_TARGET_OS
785 pprDynamicLinkerAsmLabel :: DynamicLinkerLabelInfo -> CLabel -> SDoc
788 pprDynamicLinkerAsmLabel SymbolPtr lbl
789 = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
790 pprDynamicLinkerAsmLabel CodeStub lbl
791 = char 'L' <> pprCLabel lbl <> text "$stub"
792 #elif powerpc_TARGET_ARCH && linux_TARGET_OS
793 pprDynamicLinkerAsmLabel CodeStub lbl
794 = pprCLabel lbl <> text "@plt"
795 pprDynamicLinkerAsmLabel SymbolPtr lbl
796 = text ".LC_" <> pprCLabel lbl
797 #elif linux_TARGET_OS
798 pprDynamicLinkerAsmLabel CodeStub lbl
799 = pprCLabel lbl <> text "@plt"
800 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
801 = pprCLabel lbl <> text "@got"
802 pprDynamicLinkerAsmLabel GotSymbolOffset lbl
803 = pprCLabel lbl <> text "@gotoff"
804 #elif mingw32_TARGET_OS
805 pprDynamicLinkerAsmLabel SymbolPtr lbl
806 = text "__imp_" <> pprCLabel lbl
808 pprDynamicLinkerAsmLabel _ _
809 = panic "pprDynamicLinkerAsmLabel"