1 -----------------------------------------------------------------------------
3 -- Object-file symbols (called CLabel for histerical raisins).
5 -- (c) The University of Glasgow 2004-2006
7 -----------------------------------------------------------------------------
10 -- The above warning supression flag is a temporary kludge.
11 -- While working on this module you are encouraged to remove it and fix
12 -- any warnings in the module. See
13 -- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
17 CLabel, -- abstract type
25 mkStaticConEntryLabel,
28 mkStaticInfoTableLabel,
35 mkLocalInfoTableLabel,
38 mkLocalStaticConEntryLabel,
39 mkLocalConInfoTableLabel,
40 mkLocalStaticInfoTableLabel,
41 mkLocalClosureTableLabel,
53 mkPlainModuleInitLabel,
56 mkDirty_MUT_VAR_Label,
59 mkMainCapabilityLabel,
60 mkMAP_FROZEN_infoLabel,
61 mkMAP_DIRTY_infoLabel,
62 mkEMPTY_MVAR_infoLabel,
65 mkCAFBlackHoleInfoTableLabel,
66 mkSECAFBlackHoleInfoTableLabel,
68 mkRtsSlowTickyCtrLabel,
93 mkCCLabel, mkCCSLabel,
95 DynamicLinkerLabelInfo(..),
97 dynamicLinkerLabelInfo,
100 mkDeadStripPreventer,
103 mkHpcModuleNameLabel,
105 infoLblToEntryLbl, entryLblToInfoLbl,
106 needsCDecl, isAsmTemp, maybeAsmTemp, externallyVisibleCLabel,
107 CLabelType(..), labelType, labelDynamic,
113 #include "HsVersions.h"
129 -- -----------------------------------------------------------------------------
133 CLabel is an abstract type that supports the following operations:
137 - In a C file, does it need to be declared before use? (i.e. is it
138 guaranteed to be already in scope in the places we need to refer to it?)
140 - If it needs to be declared, what type (code or data) should it be
143 - Is it visible outside this object file or not?
145 - Is it "dynamic" (see details below)
147 - Eq and Ord, so that we can make sets of CLabels (currently only
148 used in outputting C as far as I can tell, to avoid generating
149 more than one declaration for any given label).
151 - Converting an info table label into an entry label.
155 = IdLabel -- A family of labels related to the
156 Name -- definition of a particular Id or Con
159 | CaseLabel -- A family of labels related to a particular
161 {-# UNPACK #-} !Unique -- Unique says which case expression
165 {-# UNPACK #-} !Unique
168 {-# UNPACK #-} !Unique
171 Module -- the module name
173 -- at some point we might want some kind of version number in
174 -- the module init label, to guard against compiling modules in
175 -- the wrong order. We can't use the interface file version however,
176 -- because we don't always recompile modules which depend on a module
177 -- whose version has changed.
179 | PlainModuleInitLabel -- without the vesrion & way info
184 | RtsLabel RtsLabelInfo
186 | ForeignLabel FastString -- a 'C' (or otherwise foreign) label
187 (Maybe Int) -- possible '@n' suffix for stdcall functions
188 -- When generating C, the '@n' suffix is omitted, but when
189 -- generating assembler we must add it to the label.
190 Bool -- True <=> is dynamic
192 | CC_Label CostCentre
193 | CCS_Label CostCentreStack
195 -- Dynamic Linking in the NCG:
196 -- generated and used inside the NCG only,
197 -- see module PositionIndependentCode for details.
199 | DynamicLinkerLabel DynamicLinkerLabelInfo CLabel
200 -- special variants of a label used for dynamic linking
202 | PicBaseLabel -- a label used as a base for PIC calculations
203 -- on some platforms.
204 -- It takes the form of a local numeric
205 -- assembler label '1'; it is pretty-printed
206 -- as 1b, referring to the previous definition
207 -- of 1: in the assembler source file.
209 | DeadStripPreventer CLabel
210 -- label before an info table to prevent excessive dead-stripping on darwin
212 | HpcTicksLabel Module -- Per-module table of tick locations
213 | HpcModuleNameLabel -- Per-module name of the module for Hpc
215 | LargeSRTLabel -- Label of an StgLargeSRT
216 {-# UNPACK #-} !Unique
218 | LargeBitmapLabel -- A bitmap (function or case return)
219 {-# UNPACK #-} !Unique
224 = Closure -- Label for closure
225 | SRT -- Static reference table
226 | InfoTable -- Info tables for closures; always read-only
227 | Entry -- entry point
228 | Slow -- slow entry point
230 | RednCounts -- Label of place to keep Ticky-ticky info for
233 | ConEntry -- constructor entry point
234 | ConInfoTable -- corresponding info table
235 | StaticConEntry -- static constructor entry point
236 | StaticInfoTable -- corresponding info table
238 | ClosureTable -- table of closures for Enum tycons
252 = RtsSelectorInfoTable Bool{-updatable-} Int{-offset-} -- Selector thunks
253 | RtsSelectorEntry Bool{-updatable-} Int{-offset-}
255 | RtsApInfoTable Bool{-updatable-} Int{-arity-} -- AP thunks
256 | RtsApEntry Bool{-updatable-} Int{-arity-}
260 | RtsInfo LitString -- misc rts info tables
261 | RtsEntry LitString -- misc rts entry points
262 | RtsRetInfo LitString -- misc rts ret info tables
263 | RtsRet LitString -- misc rts return points
264 | RtsData LitString -- misc rts data bits, eg CHARLIKE_closure
265 | RtsCode LitString -- misc rts code
267 | RtsInfoFS FastString -- misc rts info tables
268 | RtsEntryFS FastString -- misc rts entry points
269 | RtsRetInfoFS FastString -- misc rts ret info tables
270 | RtsRetFS FastString -- misc rts return points
271 | RtsDataFS FastString -- misc rts data bits, eg CHARLIKE_closure
272 | RtsCodeFS FastString -- misc rts code
274 | RtsApFast LitString -- _fast versions of generic apply
276 | RtsSlowTickyCtr String
279 -- NOTE: Eq on LitString compares the pointer only, so this isn't
282 data DynamicLinkerLabelInfo
283 = CodeStub -- MachO: Lfoo$stub, ELF: foo@plt
284 | SymbolPtr -- MachO: Lfoo$non_lazy_ptr, Windows: __imp_foo
285 | GotSymbolPtr -- ELF: foo@got
286 | GotSymbolOffset -- ELF: foo@gotoff
290 -- -----------------------------------------------------------------------------
291 -- Constructing CLabels
293 -- These are always local:
294 mkSRTLabel name = IdLabel name SRT
295 mkSlowEntryLabel name = IdLabel name Slow
296 mkRednCountsLabel name = IdLabel name RednCounts
298 -- These have local & (possibly) external variants:
299 mkLocalClosureLabel name = IdLabel name Closure
300 mkLocalInfoTableLabel name = IdLabel name InfoTable
301 mkLocalEntryLabel name = IdLabel name Entry
302 mkLocalClosureTableLabel name = IdLabel name ClosureTable
304 mkClosureLabel name = IdLabel name Closure
305 mkInfoTableLabel name = IdLabel name InfoTable
306 mkEntryLabel name = IdLabel name Entry
307 mkClosureTableLabel name = 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
312 mkConInfoTableLabel name = IdLabel name ConInfoTable
313 mkStaticInfoTableLabel name = IdLabel name StaticInfoTable
315 mkConEntryLabel name = IdLabel name ConEntry
316 mkStaticConEntryLabel name = IdLabel name StaticConEntry
318 mkLargeSRTLabel uniq = LargeSRTLabel uniq
319 mkBitmapLabel uniq = LargeBitmapLabel uniq
321 mkReturnPtLabel uniq = CaseLabel uniq CaseReturnPt
322 mkReturnInfoLabel uniq = CaseLabel uniq CaseReturnInfo
323 mkAltLabel uniq tag = CaseLabel uniq (CaseAlt tag)
324 mkDefaultLabel uniq = CaseLabel uniq CaseDefault
326 mkStringLitLabel = StringLitLabel
327 mkAsmTempLabel = AsmTempLabel
329 mkModuleInitLabel :: Module -> String -> CLabel
330 mkModuleInitLabel mod way = ModuleInitLabel mod way
332 mkPlainModuleInitLabel :: Module -> CLabel
333 mkPlainModuleInitLabel mod = PlainModuleInitLabel mod
335 -- Some fixed runtime system labels
337 mkSplitMarkerLabel = RtsLabel (RtsCode SLIT("__stg_split_marker"))
338 mkDirty_MUT_VAR_Label = RtsLabel (RtsCode SLIT("dirty_MUT_VAR"))
339 mkUpdInfoLabel = RtsLabel (RtsInfo SLIT("stg_upd_frame"))
340 mkIndStaticInfoLabel = RtsLabel (RtsInfo SLIT("stg_IND_STATIC"))
341 mkMainCapabilityLabel = RtsLabel (RtsData SLIT("MainCapability"))
342 mkMAP_FROZEN_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_FROZEN0"))
343 mkMAP_DIRTY_infoLabel = RtsLabel (RtsInfo SLIT("stg_MUT_ARR_PTRS_DIRTY"))
344 mkEMPTY_MVAR_infoLabel = RtsLabel (RtsInfo SLIT("stg_EMPTY_MVAR"))
346 mkTopTickyCtrLabel = RtsLabel (RtsData SLIT("top_ct"))
347 mkCAFBlackHoleInfoTableLabel = RtsLabel (RtsInfo SLIT("stg_CAF_BLACKHOLE"))
348 mkSECAFBlackHoleInfoTableLabel = if opt_DoTickyProfiling then
349 RtsLabel (RtsInfo SLIT("stg_SE_CAF_BLACKHOLE"))
350 else -- RTS won't have info table unless -ticky is on
351 panic "mkSECAFBlackHoleInfoTableLabel requires -ticky"
352 mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
354 moduleRegdLabel = ModuleRegdLabel
356 mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTable upd off)
357 mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
359 mkApInfoTableLabel upd off = RtsLabel (RtsApInfoTable upd off)
360 mkApEntryLabel upd off = RtsLabel (RtsApEntry upd off)
364 mkForeignLabel :: FastString -> Maybe Int -> Bool -> CLabel
365 mkForeignLabel str mb_sz is_dynamic = ForeignLabel str mb_sz is_dynamic
369 mkCCLabel cc = CC_Label cc
370 mkCCSLabel ccs = CCS_Label ccs
372 mkRtsInfoLabel str = RtsLabel (RtsInfo str)
373 mkRtsEntryLabel str = RtsLabel (RtsEntry str)
374 mkRtsRetInfoLabel str = RtsLabel (RtsRetInfo str)
375 mkRtsRetLabel str = RtsLabel (RtsRet str)
376 mkRtsCodeLabel str = RtsLabel (RtsCode str)
377 mkRtsDataLabel str = RtsLabel (RtsData str)
379 mkRtsInfoLabelFS str = RtsLabel (RtsInfoFS str)
380 mkRtsEntryLabelFS str = RtsLabel (RtsEntryFS str)
381 mkRtsRetInfoLabelFS str = RtsLabel (RtsRetInfoFS str)
382 mkRtsRetLabelFS str = RtsLabel (RtsRetFS str)
383 mkRtsCodeLabelFS str = RtsLabel (RtsCodeFS str)
384 mkRtsDataLabelFS str = RtsLabel (RtsDataFS str)
386 mkRtsApFastLabel str = RtsLabel (RtsApFast str)
388 mkRtsSlowTickyCtrLabel :: String -> CLabel
389 mkRtsSlowTickyCtrLabel pat = RtsLabel (RtsSlowTickyCtr pat)
393 mkHpcTicksLabel = HpcTicksLabel
394 mkHpcModuleNameLabel = HpcModuleNameLabel
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 mkDeadStripPreventer :: CLabel -> CLabel
411 mkDeadStripPreventer lbl = DeadStripPreventer lbl
413 -- -----------------------------------------------------------------------------
414 -- Converting between info labels and entry/ret labels.
416 infoLblToEntryLbl :: CLabel -> CLabel
417 infoLblToEntryLbl (IdLabel n InfoTable) = IdLabel n Entry
418 infoLblToEntryLbl (IdLabel n ConInfoTable) = IdLabel n ConEntry
419 infoLblToEntryLbl (IdLabel n StaticInfoTable) = IdLabel 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 (CaseLabel n CaseReturnPt) = CaseLabel n CaseReturnInfo
432 entryLblToInfoLbl (RtsLabel (RtsEntry s)) = RtsLabel (RtsInfo s)
433 entryLblToInfoLbl (RtsLabel (RtsRet s)) = RtsLabel (RtsRetInfo s)
434 entryLblToInfoLbl (RtsLabel (RtsEntryFS s)) = RtsLabel (RtsInfoFS s)
435 entryLblToInfoLbl (RtsLabel (RtsRetFS s)) = RtsLabel (RtsRetInfoFS s)
436 entryLblToInfoLbl l = pprPanic "CLabel.entryLblToInfoLbl" (pprCLabel l)
438 -- -----------------------------------------------------------------------------
439 -- Does a CLabel need declaring before use or not?
441 needsCDecl :: CLabel -> Bool
442 -- False <=> it's pre-declared; don't bother
443 -- don't bother declaring SRT & Bitmap labels, we always make sure
444 -- they are defined before use.
445 needsCDecl (IdLabel _ SRT) = False
446 needsCDecl (LargeSRTLabel _) = False
447 needsCDecl (LargeBitmapLabel _) = False
448 needsCDecl (IdLabel _ _) = True
449 needsCDecl (CaseLabel _ _) = True
450 needsCDecl (ModuleInitLabel _ _) = True
451 needsCDecl (PlainModuleInitLabel _) = True
452 needsCDecl ModuleRegdLabel = False
454 needsCDecl (StringLitLabel _) = False
455 needsCDecl (AsmTempLabel _) = False
456 needsCDecl (RtsLabel _) = False
457 needsCDecl (ForeignLabel _ _ _) = False
458 needsCDecl (CC_Label _) = True
459 needsCDecl (CCS_Label _) = True
460 needsCDecl (HpcTicksLabel _) = True
461 needsCDecl HpcModuleNameLabel = False
463 -- Whether the label is an assembler temporary:
465 isAsmTemp :: CLabel -> Bool -- is a local temporary for native code generation
466 isAsmTemp (AsmTempLabel _) = True
469 maybeAsmTemp :: CLabel -> Maybe Unique
470 maybeAsmTemp (AsmTempLabel uq) = Just uq
471 maybeAsmTemp _ = Nothing
473 -- -----------------------------------------------------------------------------
474 -- Is a CLabel visible outside this object file or not?
476 -- From the point of view of the code generator, a name is
477 -- externally visible if it has to be declared as exported
478 -- in the .o file's symbol table; that is, made non-static.
480 externallyVisibleCLabel :: CLabel -> Bool -- not C "static"
481 externallyVisibleCLabel (CaseLabel _ _) = False
482 externallyVisibleCLabel (StringLitLabel _) = False
483 externallyVisibleCLabel (AsmTempLabel _) = False
484 externallyVisibleCLabel (ModuleInitLabel _ _) = True
485 externallyVisibleCLabel (PlainModuleInitLabel _)= True
486 externallyVisibleCLabel ModuleRegdLabel = False
487 externallyVisibleCLabel (RtsLabel _) = True
488 externallyVisibleCLabel (ForeignLabel _ _ _) = True
489 externallyVisibleCLabel (IdLabel name _) = isExternalName name
490 externallyVisibleCLabel (CC_Label _) = True
491 externallyVisibleCLabel (CCS_Label _) = True
492 externallyVisibleCLabel (DynamicLinkerLabel _ _) = False
493 externallyVisibleCLabel (HpcTicksLabel _) = True
494 externallyVisibleCLabel HpcModuleNameLabel = False
495 externallyVisibleCLabel (LargeBitmapLabel _) = False
496 externallyVisibleCLabel (LargeSRTLabel _) = False
498 -- -----------------------------------------------------------------------------
499 -- Finding the "type" of a CLabel
501 -- For generating correct types in label declarations:
507 labelType :: CLabel -> CLabelType
508 labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
509 labelType (RtsLabel (RtsApInfoTable _ _)) = DataLabel
510 labelType (RtsLabel (RtsData _)) = DataLabel
511 labelType (RtsLabel (RtsCode _)) = CodeLabel
512 labelType (RtsLabel (RtsInfo _)) = DataLabel
513 labelType (RtsLabel (RtsEntry _)) = CodeLabel
514 labelType (RtsLabel (RtsRetInfo _)) = DataLabel
515 labelType (RtsLabel (RtsRet _)) = CodeLabel
516 labelType (RtsLabel (RtsDataFS _)) = DataLabel
517 labelType (RtsLabel (RtsCodeFS _)) = CodeLabel
518 labelType (RtsLabel (RtsInfoFS _)) = DataLabel
519 labelType (RtsLabel (RtsEntryFS _)) = CodeLabel
520 labelType (RtsLabel (RtsRetInfoFS _)) = DataLabel
521 labelType (RtsLabel (RtsRetFS _)) = CodeLabel
522 labelType (RtsLabel (RtsApFast _)) = CodeLabel
523 labelType (CaseLabel _ CaseReturnInfo) = DataLabel
524 labelType (CaseLabel _ _) = CodeLabel
525 labelType (ModuleInitLabel _ _) = CodeLabel
526 labelType (PlainModuleInitLabel _) = CodeLabel
527 labelType (LargeSRTLabel _) = DataLabel
528 labelType (LargeBitmapLabel _) = DataLabel
530 labelType (IdLabel _ info) = idInfoLabelType info
531 labelType _ = DataLabel
533 idInfoLabelType info =
535 InfoTable -> DataLabel
537 ConInfoTable -> DataLabel
538 StaticInfoTable -> DataLabel
539 ClosureTable -> DataLabel
540 -- krc: aie! a ticky counter label is data
541 RednCounts -> DataLabel
545 -- -----------------------------------------------------------------------------
546 -- Does a CLabel need dynamic linkage?
548 -- When referring to data in code, we need to know whether
549 -- that data resides in a DLL or not. [Win32 only.]
550 -- @labelDynamic@ returns @True@ if the label is located
551 -- in a DLL, be it a data reference or not.
553 labelDynamic :: PackageId -> CLabel -> Bool
554 labelDynamic this_pkg lbl =
556 RtsLabel _ -> not opt_Static && (this_pkg /= rtsPackageId) -- i.e., is the RTS in a DLL or not?
557 IdLabel n k -> isDllName this_pkg n
558 #if mingw32_TARGET_OS
559 ForeignLabel _ _ d -> d
561 -- On Mac OS X and on ELF platforms, false positives are OK,
562 -- so we claim that all foreign imports come from dynamic libraries
563 ForeignLabel _ _ _ -> True
565 ModuleInitLabel m _ -> not opt_Static && this_pkg /= (modulePackageId m)
566 PlainModuleInitLabel m -> not opt_Static && this_pkg /= (modulePackageId m)
568 -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
572 OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
573 right places. It is used to detect when the abstractC statement of an
574 CCodeBlock actually contains the code for a slow entry point. -- HWL
576 We need at least @Eq@ for @CLabels@, because we want to avoid
577 duplicate declarations in generating C (see @labelSeenTE@ in
581 -----------------------------------------------------------------------------
582 -- Printing out CLabels.
589 where <name> is <Module>_<name> for external names and <unique> for
590 internal names. <type> is one of the following:
593 srt Static reference table
594 srtd Static reference table descriptor
595 entry Entry code (function, closure)
596 slow Slow entry code (if any)
597 ret Direct return address
599 <n>_alt Case alternative (tag n)
600 dflt Default case alternative
601 btm Large bitmap vector
602 closure Static closure
603 con_entry Dynamic Constructor entry code
604 con_info Dynamic Constructor info table
605 static_entry Static Constructor entry code
606 static_info Static Constructor info table
607 sel_info Selector info table
608 sel_entry Selector entry code
610 ccs Cost centre stack
612 Many of these distinctions are only for documentation reasons. For
613 example, _ret is only distinguished from _entry to make it easy to
614 tell whether a code fragment is a return point or a closure/function
618 instance Outputable CLabel where
621 pprCLabel :: CLabel -> SDoc
623 #if ! OMIT_NATIVE_CODEGEN
624 pprCLabel (AsmTempLabel u)
625 = getPprStyle $ \ sty ->
627 ptext asmTempLabelPrefix <> pprUnique u
629 char '_' <> pprUnique u
631 pprCLabel (DynamicLinkerLabel info lbl)
632 = pprDynamicLinkerAsmLabel info lbl
634 pprCLabel PicBaseLabel
637 pprCLabel (DeadStripPreventer lbl)
638 = pprCLabel lbl <> ptext SLIT("_dsp")
642 #if ! OMIT_NATIVE_CODEGEN
643 getPprStyle $ \ sty ->
645 maybe_underscore (pprAsmCLbl lbl)
651 | underscorePrefix = pp_cSEP <> doc
654 #ifdef mingw32_TARGET_OS
655 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel.
656 -- (The C compiler does this itself).
657 pprAsmCLbl (ForeignLabel fs (Just sz) _)
658 = ftext fs <> char '@' <> int sz
663 pprCLbl (StringLitLabel u)
664 = pprUnique u <> ptext SLIT("_str")
666 pprCLbl (CaseLabel u CaseReturnPt)
667 = hcat [pprUnique u, ptext SLIT("_ret")]
668 pprCLbl (CaseLabel u CaseReturnInfo)
669 = hcat [pprUnique u, ptext SLIT("_info")]
670 pprCLbl (CaseLabel u (CaseAlt tag))
671 = hcat [pprUnique u, pp_cSEP, int tag, ptext SLIT("_alt")]
672 pprCLbl (CaseLabel u CaseDefault)
673 = hcat [pprUnique u, ptext SLIT("_dflt")]
675 pprCLbl (LargeSRTLabel u) = pprUnique u <> pp_cSEP <> ptext SLIT("srtd")
676 pprCLbl (LargeBitmapLabel u) = text "b" <> pprUnique u <> pp_cSEP <> ptext SLIT("btm")
677 -- Some bitsmaps for tuple constructors have a numeric tag (e.g. '7')
678 -- until that gets resolved we'll just force them to start
679 -- with a letter so the label will be legal assmbly code.
682 pprCLbl (RtsLabel (RtsCode str)) = ptext str
683 pprCLbl (RtsLabel (RtsData str)) = ptext str
684 pprCLbl (RtsLabel (RtsCodeFS str)) = ftext str
685 pprCLbl (RtsLabel (RtsDataFS str)) = ftext str
687 pprCLbl (RtsLabel (RtsApFast str)) = ptext str <> ptext SLIT("_fast")
689 pprCLbl (RtsLabel (RtsSelectorInfoTable upd_reqd offset))
690 = hcat [ptext SLIT("stg_sel_"), text (show offset),
692 then SLIT("_upd_info")
693 else SLIT("_noupd_info"))
696 pprCLbl (RtsLabel (RtsSelectorEntry upd_reqd offset))
697 = hcat [ptext SLIT("stg_sel_"), text (show offset),
699 then SLIT("_upd_entry")
700 else SLIT("_noupd_entry"))
703 pprCLbl (RtsLabel (RtsApInfoTable upd_reqd arity))
704 = hcat [ptext SLIT("stg_ap_"), text (show arity),
706 then SLIT("_upd_info")
707 else SLIT("_noupd_info"))
710 pprCLbl (RtsLabel (RtsApEntry upd_reqd arity))
711 = hcat [ptext SLIT("stg_ap_"), text (show arity),
713 then SLIT("_upd_entry")
714 else SLIT("_noupd_entry"))
717 pprCLbl (RtsLabel (RtsInfo fs))
718 = ptext fs <> ptext SLIT("_info")
720 pprCLbl (RtsLabel (RtsEntry fs))
721 = ptext fs <> ptext SLIT("_entry")
723 pprCLbl (RtsLabel (RtsRetInfo fs))
724 = ptext fs <> ptext SLIT("_info")
726 pprCLbl (RtsLabel (RtsRet fs))
727 = ptext fs <> ptext SLIT("_ret")
729 pprCLbl (RtsLabel (RtsInfoFS fs))
730 = ftext fs <> ptext SLIT("_info")
732 pprCLbl (RtsLabel (RtsEntryFS fs))
733 = ftext fs <> ptext SLIT("_entry")
735 pprCLbl (RtsLabel (RtsRetInfoFS fs))
736 = ftext fs <> ptext SLIT("_info")
738 pprCLbl (RtsLabel (RtsRetFS fs))
739 = ftext fs <> ptext SLIT("_ret")
741 pprCLbl (RtsLabel (RtsPrimOp primop))
742 = ppr primop <> ptext SLIT("_fast")
744 pprCLbl (RtsLabel (RtsSlowTickyCtr pat))
745 = ptext SLIT("SLOW_CALL_") <> text pat <> ptext SLIT("_ctr")
747 pprCLbl ModuleRegdLabel
748 = ptext SLIT("_module_registered")
750 pprCLbl (ForeignLabel str _ _)
753 pprCLbl (IdLabel 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 pprCLbl (HpcTicksLabel mod)
765 = ptext SLIT("_hpc_tickboxes_") <> ppr mod <> ptext SLIT("_hpc")
767 pprCLbl HpcModuleNameLabel
768 = ptext SLIT("_hpc_module_name_str")
770 ppIdFlavor :: IdLabelInfo -> SDoc
771 ppIdFlavor x = pp_cSEP <>
773 Closure -> ptext SLIT("closure")
774 SRT -> ptext SLIT("srt")
775 InfoTable -> ptext SLIT("info")
776 Entry -> ptext SLIT("entry")
777 Slow -> ptext SLIT("slow")
778 RednCounts -> ptext SLIT("ct")
779 ConEntry -> ptext SLIT("con_entry")
780 ConInfoTable -> ptext SLIT("con_info")
781 StaticConEntry -> ptext SLIT("static_entry")
782 StaticInfoTable -> ptext SLIT("static_info")
783 ClosureTable -> ptext SLIT("closure_tbl")
789 -- -----------------------------------------------------------------------------
790 -- Machine-dependent knowledge about labels.
792 underscorePrefix :: Bool -- leading underscore on assembler labels?
793 underscorePrefix = (cLeadingUnderscore == "YES")
795 asmTempLabelPrefix :: LitString -- for formatting labels
798 {- The alpha assembler likes temporary labels to look like $L123
799 instead of L123. (Don't toss the L, because then Lf28
803 #elif darwin_TARGET_OS
809 pprDynamicLinkerAsmLabel :: DynamicLinkerLabelInfo -> CLabel -> SDoc
811 #if x86_64_TARGET_ARCH && darwin_TARGET_OS
812 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
813 = pprCLabel lbl <> text "@GOTPCREL"
814 pprDynamicLinkerAsmLabel GotSymbolOffset lbl
816 pprDynamicLinkerAsmLabel _ _
817 = panic "pprDynamicLinkerAsmLabel"
818 #elif darwin_TARGET_OS
819 pprDynamicLinkerAsmLabel CodeStub lbl
820 = char 'L' <> pprCLabel lbl <> text "$stub"
821 pprDynamicLinkerAsmLabel SymbolPtr lbl
822 = char 'L' <> pprCLabel lbl <> text "$non_lazy_ptr"
823 pprDynamicLinkerAsmLabel _ _
824 = panic "pprDynamicLinkerAsmLabel"
825 #elif powerpc_TARGET_ARCH && linux_TARGET_OS
826 pprDynamicLinkerAsmLabel CodeStub lbl
827 = pprCLabel lbl <> text "@plt"
828 pprDynamicLinkerAsmLabel SymbolPtr lbl
829 = text ".LC_" <> pprCLabel lbl
830 pprDynamicLinkerAsmLabel _ _
831 = panic "pprDynamicLinkerAsmLabel"
832 #elif x86_64_TARGET_ARCH && linux_TARGET_OS
833 pprDynamicLinkerAsmLabel CodeStub lbl
834 = pprCLabel lbl <> text "@plt"
835 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
836 = pprCLabel lbl <> text "@gotpcrel"
837 pprDynamicLinkerAsmLabel GotSymbolOffset lbl
839 pprDynamicLinkerAsmLabel SymbolPtr lbl
840 = text ".LC_" <> pprCLabel lbl
841 #elif linux_TARGET_OS
842 pprDynamicLinkerAsmLabel CodeStub lbl
843 = pprCLabel lbl <> text "@plt"
844 pprDynamicLinkerAsmLabel SymbolPtr lbl
845 = text ".LC_" <> pprCLabel lbl
846 pprDynamicLinkerAsmLabel GotSymbolPtr lbl
847 = pprCLabel lbl <> text "@got"
848 pprDynamicLinkerAsmLabel GotSymbolOffset lbl
849 = pprCLabel lbl <> text "@gotoff"
850 #elif mingw32_TARGET_OS
851 pprDynamicLinkerAsmLabel SymbolPtr lbl
852 = text "__imp_" <> pprCLabel lbl
853 pprDynamicLinkerAsmLabel _ _
854 = panic "pprDynamicLinkerAsmLabel"
856 pprDynamicLinkerAsmLabel _ _
857 = panic "pprDynamicLinkerAsmLabel"