Whitespace only in cmm/CLabel.hs
[ghc.git] / compiler / cmm / CLabel.hs
1 {-# OPTIONS -w #-}
2 -- The above warning supression flag is a temporary kludge.
3 -- While working on this module you are encouraged to remove it and fix
4 -- any warnings in the module. See
5 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
6 -- for details
7
8 -----------------------------------------------------------------------------
9 --
10 -- Object-file symbols (called CLabel for histerical raisins).
11 --
12 -- (c) The University of Glasgow 2004-2006
13 --
14 -----------------------------------------------------------------------------
15
16 module CLabel (
17 CLabel, -- abstract type
18 ForeignLabelSource(..),
19 pprDebugCLabel,
20
21 mkClosureLabel,
22 mkSRTLabel,
23 mkInfoTableLabel,
24 mkEntryLabel,
25 mkSlowEntryLabel,
26 mkConEntryLabel,
27 mkStaticConEntryLabel,
28 mkRednCountsLabel,
29 mkConInfoTableLabel,
30 mkStaticInfoTableLabel,
31 mkLargeSRTLabel,
32 mkApEntryLabel,
33 mkApInfoTableLabel,
34 mkClosureTableLabel,
35
36 mkLocalClosureLabel,
37 mkLocalInfoTableLabel,
38 mkLocalEntryLabel,
39 mkLocalConEntryLabel,
40 mkLocalStaticConEntryLabel,
41 mkLocalConInfoTableLabel,
42 mkLocalStaticInfoTableLabel,
43 mkLocalClosureTableLabel,
44
45 mkReturnPtLabel,
46 mkReturnInfoLabel,
47 mkAltLabel,
48 mkDefaultLabel,
49 mkBitmapLabel,
50 mkStringLitLabel,
51
52 mkAsmTempLabel,
53
54 mkPlainModuleInitLabel,
55
56 mkSplitMarkerLabel,
57 mkDirty_MUT_VAR_Label,
58 mkUpdInfoLabel,
59 mkBHUpdInfoLabel,
60 mkIndStaticInfoLabel,
61 mkMainCapabilityLabel,
62 mkMAP_FROZEN_infoLabel,
63 mkMAP_DIRTY_infoLabel,
64 mkEMPTY_MVAR_infoLabel,
65
66 mkTopTickyCtrLabel,
67 mkCAFBlackHoleInfoTableLabel,
68 mkCAFBlackHoleEntryLabel,
69 mkRtsPrimOpLabel,
70 mkRtsSlowTickyCtrLabel,
71
72 mkSelectorInfoLabel,
73 mkSelectorEntryLabel,
74
75 mkCmmInfoLabel,
76 mkCmmEntryLabel,
77 mkCmmRetInfoLabel,
78 mkCmmRetLabel,
79 mkCmmCodeLabel,
80 mkCmmDataLabel,
81 mkCmmGcPtrLabel,
82
83 mkRtsApFastLabel,
84
85 mkPrimCallLabel,
86
87 mkForeignLabel,
88 addLabelSize,
89 foreignLabelStdcallInfo,
90
91 mkCCLabel, mkCCSLabel,
92
93 DynamicLinkerLabelInfo(..),
94 mkDynamicLinkerLabel,
95 dynamicLinkerLabelInfo,
96
97 mkPicBaseLabel,
98 mkDeadStripPreventer,
99
100 mkHpcTicksLabel,
101
102 hasCAF,
103 needsCDecl, isAsmTemp, maybeAsmTemp, externallyVisibleCLabel,
104 isMathFun,
105 isCFunctionLabel, isGcPtrLabel, labelDynamic,
106
107 -- * Conversions
108 toClosureLbl, toSlowEntryLbl, toEntryLbl, toInfoLbl, toRednCountsLbl,
109
110 pprCLabel
111 ) where
112
113 import IdInfo
114 import StaticFlags
115 import BasicTypes
116 import Literal
117 import Packages
118 import DataCon
119 import PackageConfig
120 import Module
121 import Name
122 import Unique
123 import PrimOp
124 import Config
125 import CostCentre
126 import Outputable
127 import FastString
128 import DynFlags
129 import Platform
130 import UniqSet
131
132 -- -----------------------------------------------------------------------------
133 -- The CLabel type
134
135 {-
136 | CLabel is an abstract type that supports the following operations:
137
138 - Pretty printing
139
140 - In a C file, does it need to be declared before use? (i.e. is it
141 guaranteed to be already in scope in the places we need to refer to it?)
142
143 - If it needs to be declared, what type (code or data) should it be
144 declared to have?
145
146 - Is it visible outside this object file or not?
147
148 - Is it "dynamic" (see details below)
149
150 - Eq and Ord, so that we can make sets of CLabels (currently only
151 used in outputting C as far as I can tell, to avoid generating
152 more than one declaration for any given label).
153
154 - Converting an info table label into an entry label.
155 -}
156
157 data CLabel
158 = -- | A label related to the definition of a particular Id or Con in a .hs file.
159 IdLabel
160 Name
161 CafInfo
162 IdLabelInfo -- encodes the suffix of the label
163
164 -- | A label from a .cmm file that is not associated with a .hs level Id.
165 | CmmLabel
166 PackageId -- what package the label belongs to.
167 FastString -- identifier giving the prefix of the label
168 CmmLabelInfo -- encodes the suffix of the label
169
170 -- | A label with a baked-in \/ algorithmically generated name that definitely
171 -- comes from the RTS. The code for it must compile into libHSrts.a \/ libHSrts.so
172 -- If it doesn't have an algorithmically generated name then use a CmmLabel
173 -- instead and give it an appropriate PackageId argument.
174 | RtsLabel
175 RtsLabelInfo
176
177 -- | A 'C' (or otherwise foreign) label.
178 --
179 | ForeignLabel
180 FastString -- name of the imported label.
181
182 (Maybe Int) -- possible '@n' suffix for stdcall functions
183 -- When generating C, the '@n' suffix is omitted, but when
184 -- generating assembler we must add it to the label.
185
186 ForeignLabelSource -- what package the foreign label is in.
187
188 FunctionOrData
189
190 -- | A family of labels related to a particular case expression.
191 | CaseLabel
192 {-# UNPACK #-} !Unique -- Unique says which case expression
193 CaseLabelInfo
194
195 | AsmTempLabel
196 {-# UNPACK #-} !Unique
197
198 | StringLitLabel
199 {-# UNPACK #-} !Unique
200
201 | PlainModuleInitLabel -- without the version & way info
202 Module
203
204 | CC_Label CostCentre
205 | CCS_Label CostCentreStack
206
207
208 -- | These labels are generated and used inside the NCG only.
209 -- They are special variants of a label used for dynamic linking
210 -- see module PositionIndependentCode for details.
211 | DynamicLinkerLabel DynamicLinkerLabelInfo CLabel
212
213 -- | This label is generated and used inside the NCG only.
214 -- It is used as a base for PIC calculations on some platforms.
215 -- It takes the form of a local numeric assembler label '1'; and
216 -- is pretty-printed as 1b, referring to the previous definition
217 -- of 1: in the assembler source file.
218 | PicBaseLabel
219
220 -- | A label before an info table to prevent excessive dead-stripping on darwin
221 | DeadStripPreventer CLabel
222
223
224 -- | Per-module table of tick locations
225 | HpcTicksLabel Module
226
227 -- | Label of an StgLargeSRT
228 | LargeSRTLabel
229 {-# UNPACK #-} !Unique
230
231 -- | A bitmap (function or case return)
232 | LargeBitmapLabel
233 {-# UNPACK #-} !Unique
234
235 deriving (Eq, Ord)
236
237
238 -- | Record where a foreign label is stored.
239 data ForeignLabelSource
240
241 -- | Label is in a named package
242 = ForeignLabelInPackage PackageId
243
244 -- | Label is in some external, system package that doesn't also
245 -- contain compiled Haskell code, and is not associated with any .hi files.
246 -- We don't have to worry about Haskell code being inlined from
247 -- external packages. It is safe to treat the RTS package as "external".
248 | ForeignLabelInExternalPackage
249
250 -- | Label is in the package currenly being compiled.
251 -- This is only used for creating hacky tmp labels during code generation.
252 -- Don't use it in any code that might be inlined across a package boundary
253 -- (ie, core code) else the information will be wrong relative to the
254 -- destination module.
255 | ForeignLabelInThisPackage
256
257 deriving (Eq, Ord)
258
259
260 -- | For debugging problems with the CLabel representation.
261 -- We can't make a Show instance for CLabel because lots of its components don't have instances.
262 -- The regular Outputable instance only shows the label name, and not its other info.
263 --
264 pprDebugCLabel :: Platform -> CLabel -> SDoc
265 pprDebugCLabel platform lbl
266 = case lbl of
267 IdLabel{} -> pprPlatform platform lbl <> (parens $ text "IdLabel")
268 CmmLabel pkg name _info
269 -> pprPlatform platform lbl <> (parens $ text "CmmLabel" <+> ppr pkg)
270
271 RtsLabel{} -> pprPlatform platform lbl <> (parens $ text "RtsLabel")
272
273 ForeignLabel name mSuffix src funOrData
274 -> pprPlatform platform lbl <> (parens
275 $ text "ForeignLabel"
276 <+> ppr mSuffix
277 <+> ppr src
278 <+> ppr funOrData)
279
280 _ -> pprPlatform platform lbl <> (parens $ text "other CLabel)")
281
282
283 -- True if a local IdLabel that we won't mark as exported
284 type IsLocal = Bool
285
286 data IdLabelInfo
287 = Closure -- ^ Label for closure
288 | SRT -- ^ Static reference table
289 | InfoTable -- ^ Info tables for closures; always read-only
290 | Entry -- ^ Entry point
291 | Slow -- ^ Slow entry point
292
293 | LocalInfoTable -- ^ Like InfoTable but not externally visible
294 | LocalEntry -- ^ Like Entry but not externally visible
295
296 | RednCounts -- ^ Label of place to keep Ticky-ticky info for this Id
297
298 | ConEntry -- ^ Constructor entry point
299 | ConInfoTable -- ^ Corresponding info table
300 | StaticConEntry -- ^ Static constructor entry point
301 | StaticInfoTable -- ^ Corresponding info table
302
303 | ClosureTable -- ^ Table of closures for Enum tycons
304
305 deriving (Eq, Ord)
306
307
308 data CaseLabelInfo
309 = CaseReturnPt
310 | CaseReturnInfo
311 | CaseAlt ConTag
312 | CaseDefault
313 deriving (Eq, Ord)
314
315
316 data RtsLabelInfo
317 = RtsSelectorInfoTable Bool{-updatable-} Int{-offset-} -- ^ Selector thunks
318 | RtsSelectorEntry Bool{-updatable-} Int{-offset-}
319
320 | RtsApInfoTable Bool{-updatable-} Int{-arity-} -- ^ AP thunks
321 | RtsApEntry Bool{-updatable-} Int{-arity-}
322
323 | RtsPrimOp PrimOp
324 | RtsApFast FastString -- ^ _fast versions of generic apply
325 | RtsSlowTickyCtr String
326
327 deriving (Eq, Ord)
328 -- NOTE: Eq on LitString compares the pointer only, so this isn't
329 -- a real equality.
330
331
332 -- | What type of Cmm label we're dealing with.
333 -- Determines the suffix appended to the name when a CLabel.CmmLabel
334 -- is pretty printed.
335 data CmmLabelInfo
336 = CmmInfo -- ^ misc rts info tabless, suffix _info
337 | CmmEntry -- ^ misc rts entry points, suffix _entry
338 | CmmRetInfo -- ^ misc rts ret info tables, suffix _info
339 | CmmRet -- ^ misc rts return points, suffix _ret
340 | CmmData -- ^ misc rts data bits, eg CHARLIKE_closure
341 | CmmCode -- ^ misc rts code
342 | CmmGcPtr -- ^ GcPtrs eg CHARLIKE_closure
343 | CmmPrimCall -- ^ a prim call to some hand written Cmm code
344 deriving (Eq, Ord)
345
346 data DynamicLinkerLabelInfo
347 = CodeStub -- MachO: Lfoo$stub, ELF: foo@plt
348 | SymbolPtr -- MachO: Lfoo$non_lazy_ptr, Windows: __imp_foo
349 | GotSymbolPtr -- ELF: foo@got
350 | GotSymbolOffset -- ELF: foo@gotoff
351
352 deriving (Eq, Ord)
353
354
355 -- -----------------------------------------------------------------------------
356 -- Constructing CLabels
357 -- -----------------------------------------------------------------------------
358
359 -- Constructing IdLabels
360 -- These are always local:
361 mkSlowEntryLabel name c = IdLabel name c Slow
362
363 mkSRTLabel name c = IdLabel name c SRT
364 mkRednCountsLabel name c = IdLabel name c RednCounts
365
366 -- These have local & (possibly) external variants:
367 mkLocalClosureLabel name c = IdLabel name c Closure
368 mkLocalInfoTableLabel name c = IdLabel name c LocalInfoTable
369 mkLocalEntryLabel name c = IdLabel name c LocalEntry
370 mkLocalClosureTableLabel name c = IdLabel name c ClosureTable
371
372 mkClosureLabel name c = IdLabel name c Closure
373 mkInfoTableLabel name c = IdLabel name c InfoTable
374 mkEntryLabel name c = IdLabel name c Entry
375 mkClosureTableLabel name c = IdLabel name c ClosureTable
376 mkLocalConInfoTableLabel c con = IdLabel con c ConInfoTable
377 mkLocalConEntryLabel c con = IdLabel con c ConEntry
378 mkLocalStaticInfoTableLabel c con = IdLabel con c StaticInfoTable
379 mkLocalStaticConEntryLabel c con = IdLabel con c StaticConEntry
380 mkConInfoTableLabel name c = IdLabel name c ConInfoTable
381 mkStaticInfoTableLabel name c = IdLabel name c StaticInfoTable
382
383 mkConEntryLabel name c = IdLabel name c ConEntry
384 mkStaticConEntryLabel name c = IdLabel name c StaticConEntry
385
386 -- Constructing Cmm Labels
387 mkSplitMarkerLabel = CmmLabel rtsPackageId (fsLit "__stg_split_marker") CmmCode
388 mkDirty_MUT_VAR_Label = CmmLabel rtsPackageId (fsLit "dirty_MUT_VAR") CmmCode
389 mkUpdInfoLabel = CmmLabel rtsPackageId (fsLit "stg_upd_frame") CmmInfo
390 mkBHUpdInfoLabel = CmmLabel rtsPackageId (fsLit "stg_bh_upd_frame" ) CmmInfo
391 mkIndStaticInfoLabel = CmmLabel rtsPackageId (fsLit "stg_IND_STATIC") CmmInfo
392 mkMainCapabilityLabel = CmmLabel rtsPackageId (fsLit "MainCapability") CmmData
393 mkMAP_FROZEN_infoLabel = CmmLabel rtsPackageId (fsLit "stg_MUT_ARR_PTRS_FROZEN0") CmmInfo
394 mkMAP_DIRTY_infoLabel = CmmLabel rtsPackageId (fsLit "stg_MUT_ARR_PTRS_DIRTY") CmmInfo
395 mkEMPTY_MVAR_infoLabel = CmmLabel rtsPackageId (fsLit "stg_EMPTY_MVAR") CmmInfo
396 mkTopTickyCtrLabel = CmmLabel rtsPackageId (fsLit "top_ct") CmmData
397 mkCAFBlackHoleInfoTableLabel = CmmLabel rtsPackageId (fsLit "stg_CAF_BLACKHOLE") CmmInfo
398 mkCAFBlackHoleEntryLabel = CmmLabel rtsPackageId (fsLit "stg_CAF_BLACKHOLE") CmmEntry
399
400 -----
401 mkCmmInfoLabel, mkCmmEntryLabel, mkCmmRetInfoLabel, mkCmmRetLabel,
402 mkCmmCodeLabel, mkCmmDataLabel, mkCmmGcPtrLabel
403 :: PackageId -> FastString -> CLabel
404
405 mkCmmInfoLabel pkg str = CmmLabel pkg str CmmInfo
406 mkCmmEntryLabel pkg str = CmmLabel pkg str CmmEntry
407 mkCmmRetInfoLabel pkg str = CmmLabel pkg str CmmRetInfo
408 mkCmmRetLabel pkg str = CmmLabel pkg str CmmRet
409 mkCmmCodeLabel pkg str = CmmLabel pkg str CmmCode
410 mkCmmDataLabel pkg str = CmmLabel pkg str CmmData
411 mkCmmGcPtrLabel pkg str = CmmLabel pkg str CmmGcPtr
412
413
414 -- Constructing RtsLabels
415 mkRtsPrimOpLabel primop = RtsLabel (RtsPrimOp primop)
416
417 mkSelectorInfoLabel upd off = RtsLabel (RtsSelectorInfoTable upd off)
418 mkSelectorEntryLabel upd off = RtsLabel (RtsSelectorEntry upd off)
419
420 mkApInfoTableLabel upd off = RtsLabel (RtsApInfoTable upd off)
421 mkApEntryLabel upd off = RtsLabel (RtsApEntry upd off)
422
423
424 -- A call to some primitive hand written Cmm code
425 mkPrimCallLabel :: PrimCall -> CLabel
426 mkPrimCallLabel (PrimCall str pkg)
427 = CmmLabel pkg str CmmPrimCall
428
429
430 -- Constructing ForeignLabels
431
432 -- | Make a foreign label
433 mkForeignLabel
434 :: FastString -- name
435 -> Maybe Int -- size prefix
436 -> ForeignLabelSource -- what package it's in
437 -> FunctionOrData
438 -> CLabel
439
440 mkForeignLabel str mb_sz src fod
441 = ForeignLabel str mb_sz src fod
442
443
444 -- | Update the label size field in a ForeignLabel
445 addLabelSize :: CLabel -> Int -> CLabel
446 addLabelSize (ForeignLabel str _ src fod) sz
447 = ForeignLabel str (Just sz) src fod
448 addLabelSize label _
449 = label
450
451 -- | Get the label size field from a ForeignLabel
452 foreignLabelStdcallInfo :: CLabel -> Maybe Int
453 foreignLabelStdcallInfo (ForeignLabel _ info _ _) = info
454 foreignLabelStdcallInfo _lbl = Nothing
455
456
457 -- Constructing Large*Labels
458 mkLargeSRTLabel uniq = LargeSRTLabel uniq
459 mkBitmapLabel uniq = LargeBitmapLabel uniq
460
461
462 -- Constructin CaseLabels
463 mkReturnPtLabel uniq = CaseLabel uniq CaseReturnPt
464 mkReturnInfoLabel uniq = CaseLabel uniq CaseReturnInfo
465 mkAltLabel uniq tag = CaseLabel uniq (CaseAlt tag)
466 mkDefaultLabel uniq = CaseLabel uniq CaseDefault
467
468 -- Constructing Cost Center Labels
469 mkCCLabel cc = CC_Label cc
470 mkCCSLabel ccs = CCS_Label ccs
471
472 mkRtsApFastLabel str = RtsLabel (RtsApFast str)
473
474 mkRtsSlowTickyCtrLabel :: String -> CLabel
475 mkRtsSlowTickyCtrLabel pat = RtsLabel (RtsSlowTickyCtr pat)
476
477
478 -- Constructing Code Coverage Labels
479 mkHpcTicksLabel = HpcTicksLabel
480
481
482 -- Constructing labels used for dynamic linking
483 mkDynamicLinkerLabel :: DynamicLinkerLabelInfo -> CLabel -> CLabel
484 mkDynamicLinkerLabel = DynamicLinkerLabel
485
486 dynamicLinkerLabelInfo :: CLabel -> Maybe (DynamicLinkerLabelInfo, CLabel)
487 dynamicLinkerLabelInfo (DynamicLinkerLabel info lbl) = Just (info, lbl)
488 dynamicLinkerLabelInfo _ = Nothing
489
490 mkPicBaseLabel :: CLabel
491 mkPicBaseLabel = PicBaseLabel
492
493
494 -- Constructing miscellaneous other labels
495 mkDeadStripPreventer :: CLabel -> CLabel
496 mkDeadStripPreventer lbl = DeadStripPreventer lbl
497
498 mkStringLitLabel :: Unique -> CLabel
499 mkStringLitLabel = StringLitLabel
500
501 mkAsmTempLabel :: Uniquable a => a -> CLabel
502 mkAsmTempLabel a = AsmTempLabel (getUnique a)
503
504 mkPlainModuleInitLabel :: Module -> CLabel
505 mkPlainModuleInitLabel mod = PlainModuleInitLabel mod
506
507 -- -----------------------------------------------------------------------------
508 -- Convert between different kinds of label
509
510 toClosureLbl :: Platform -> CLabel -> CLabel
511 toClosureLbl _ (IdLabel n c _) = IdLabel n c Closure
512 toClosureLbl platform l = pprPanic "toClosureLbl" (pprCLabel platform l)
513
514 toSlowEntryLbl :: Platform -> CLabel -> CLabel
515 toSlowEntryLbl _ (IdLabel n c _) = IdLabel n c Slow
516 toSlowEntryLbl platform l = pprPanic "toSlowEntryLbl" (pprCLabel platform l)
517
518 toRednCountsLbl :: Platform -> CLabel -> CLabel
519 toRednCountsLbl _ (IdLabel n c _) = IdLabel n c RednCounts
520 toRednCountsLbl platform l = pprPanic "toRednCountsLbl" (pprCLabel platform l)
521
522 toEntryLbl :: Platform -> CLabel -> CLabel
523 toEntryLbl _ (IdLabel n c LocalInfoTable) = IdLabel n c LocalEntry
524 toEntryLbl _ (IdLabel n c ConInfoTable) = IdLabel n c ConEntry
525 toEntryLbl _ (IdLabel n c StaticInfoTable) = IdLabel n c StaticConEntry
526 toEntryLbl _ (IdLabel n c _) = IdLabel n c Entry
527 toEntryLbl _ (CaseLabel n CaseReturnInfo) = CaseLabel n CaseReturnPt
528 toEntryLbl _ (CmmLabel m str CmmInfo) = CmmLabel m str CmmEntry
529 toEntryLbl _ (CmmLabel m str CmmRetInfo) = CmmLabel m str CmmRet
530 toEntryLbl platform l = pprPanic "toEntryLbl" (pprCLabel platform l)
531
532 toInfoLbl :: Platform -> CLabel -> CLabel
533 toInfoLbl _ (IdLabel n c Entry) = IdLabel n c InfoTable
534 toInfoLbl _ (IdLabel n c LocalEntry) = IdLabel n c LocalInfoTable
535 toInfoLbl _ (IdLabel n c ConEntry) = IdLabel n c ConInfoTable
536 toInfoLbl _ (IdLabel n c StaticConEntry) = IdLabel n c StaticInfoTable
537 toInfoLbl _ (IdLabel n c _) = IdLabel n c InfoTable
538 toInfoLbl _ (CaseLabel n CaseReturnPt) = CaseLabel n CaseReturnInfo
539 toInfoLbl _ (CmmLabel m str CmmEntry) = CmmLabel m str CmmInfo
540 toInfoLbl _ (CmmLabel m str CmmRet) = CmmLabel m str CmmRetInfo
541 toInfoLbl platform l = pprPanic "CLabel.toInfoLbl" (pprCLabel platform l)
542
543 -- -----------------------------------------------------------------------------
544 -- Does a CLabel refer to a CAF?
545 hasCAF :: CLabel -> Bool
546 hasCAF (IdLabel _ MayHaveCafRefs _) = True
547 hasCAF _ = False
548
549
550 -- -----------------------------------------------------------------------------
551 -- Does a CLabel need declaring before use or not?
552 --
553 -- See wiki:Commentary/Compiler/Backends/PprC#Prototypes
554
555 needsCDecl :: CLabel -> Bool
556 -- False <=> it's pre-declared; don't bother
557 -- don't bother declaring SRT & Bitmap labels, we always make sure
558 -- they are defined before use.
559 needsCDecl (IdLabel _ _ SRT) = False
560 needsCDecl (LargeSRTLabel _) = False
561 needsCDecl (LargeBitmapLabel _) = False
562 needsCDecl (IdLabel _ _ _) = True
563 needsCDecl (CaseLabel _ _) = True
564 needsCDecl (PlainModuleInitLabel _) = True
565
566 needsCDecl (StringLitLabel _) = False
567 needsCDecl (AsmTempLabel _) = False
568 needsCDecl (RtsLabel _) = False
569
570 needsCDecl (CmmLabel pkgId _ _)
571 -- Prototypes for labels defined in the runtime system are imported
572 -- into HC files via includes/Stg.h.
573 | pkgId == rtsPackageId = False
574
575 -- For other labels we inline one into the HC file directly.
576 | otherwise = True
577
578 needsCDecl l@(ForeignLabel{}) = not (isMathFun l)
579 needsCDecl (CC_Label _) = True
580 needsCDecl (CCS_Label _) = True
581 needsCDecl (HpcTicksLabel _) = True
582
583
584 -- | Check whether a label is a local temporary for native code generation
585 isAsmTemp :: CLabel -> Bool
586 isAsmTemp (AsmTempLabel _) = True
587 isAsmTemp _ = False
588
589
590 -- | If a label is a local temporary used for native code generation
591 -- then return just its unique, otherwise nothing.
592 maybeAsmTemp :: CLabel -> Maybe Unique
593 maybeAsmTemp (AsmTempLabel uq) = Just uq
594 maybeAsmTemp _ = Nothing
595
596
597 -- | Check whether a label corresponds to a C function that has
598 -- a prototype in a system header somehere, or is built-in
599 -- to the C compiler. For these labels we avoid generating our
600 -- own C prototypes.
601 isMathFun :: CLabel -> Bool
602 isMathFun (ForeignLabel fs _ _ _) = fs `elementOfUniqSet` math_funs
603 isMathFun _ = False
604
605 math_funs = mkUniqSet [
606 -- _ISOC99_SOURCE
607 (fsLit "acos"), (fsLit "acosf"), (fsLit "acosh"),
608 (fsLit "acoshf"), (fsLit "acoshl"), (fsLit "acosl"),
609 (fsLit "asin"), (fsLit "asinf"), (fsLit "asinl"),
610 (fsLit "asinh"), (fsLit "asinhf"), (fsLit "asinhl"),
611 (fsLit "atan"), (fsLit "atanf"), (fsLit "atanl"),
612 (fsLit "atan2"), (fsLit "atan2f"), (fsLit "atan2l"),
613 (fsLit "atanh"), (fsLit "atanhf"), (fsLit "atanhl"),
614 (fsLit "cbrt"), (fsLit "cbrtf"), (fsLit "cbrtl"),
615 (fsLit "ceil"), (fsLit "ceilf"), (fsLit "ceill"),
616 (fsLit "copysign"), (fsLit "copysignf"), (fsLit "copysignl"),
617 (fsLit "cos"), (fsLit "cosf"), (fsLit "cosl"),
618 (fsLit "cosh"), (fsLit "coshf"), (fsLit "coshl"),
619 (fsLit "erf"), (fsLit "erff"), (fsLit "erfl"),
620 (fsLit "erfc"), (fsLit "erfcf"), (fsLit "erfcl"),
621 (fsLit "exp"), (fsLit "expf"), (fsLit "expl"),
622 (fsLit "exp2"), (fsLit "exp2f"), (fsLit "exp2l"),
623 (fsLit "expm1"), (fsLit "expm1f"), (fsLit "expm1l"),
624 (fsLit "fabs"), (fsLit "fabsf"), (fsLit "fabsl"),
625 (fsLit "fdim"), (fsLit "fdimf"), (fsLit "fdiml"),
626 (fsLit "floor"), (fsLit "floorf"), (fsLit "floorl"),
627 (fsLit "fma"), (fsLit "fmaf"), (fsLit "fmal"),
628 (fsLit "fmax"), (fsLit "fmaxf"), (fsLit "fmaxl"),
629 (fsLit "fmin"), (fsLit "fminf"), (fsLit "fminl"),
630 (fsLit "fmod"), (fsLit "fmodf"), (fsLit "fmodl"),
631 (fsLit "frexp"), (fsLit "frexpf"), (fsLit "frexpl"),
632 (fsLit "hypot"), (fsLit "hypotf"), (fsLit "hypotl"),
633 (fsLit "ilogb"), (fsLit "ilogbf"), (fsLit "ilogbl"),
634 (fsLit "ldexp"), (fsLit "ldexpf"), (fsLit "ldexpl"),
635 (fsLit "lgamma"), (fsLit "lgammaf"), (fsLit "lgammal"),
636 (fsLit "llrint"), (fsLit "llrintf"), (fsLit "llrintl"),
637 (fsLit "llround"), (fsLit "llroundf"), (fsLit "llroundl"),
638 (fsLit "log"), (fsLit "logf"), (fsLit "logl"),
639 (fsLit "log10l"), (fsLit "log10"), (fsLit "log10f"),
640 (fsLit "log1pl"), (fsLit "log1p"), (fsLit "log1pf"),
641 (fsLit "log2"), (fsLit "log2f"), (fsLit "log2l"),
642 (fsLit "logb"), (fsLit "logbf"), (fsLit "logbl"),
643 (fsLit "lrint"), (fsLit "lrintf"), (fsLit "lrintl"),
644 (fsLit "lround"), (fsLit "lroundf"), (fsLit "lroundl"),
645 (fsLit "modf"), (fsLit "modff"), (fsLit "modfl"),
646 (fsLit "nan"), (fsLit "nanf"), (fsLit "nanl"),
647 (fsLit "nearbyint"), (fsLit "nearbyintf"), (fsLit "nearbyintl"),
648 (fsLit "nextafter"), (fsLit "nextafterf"), (fsLit "nextafterl"),
649 (fsLit "nexttoward"), (fsLit "nexttowardf"), (fsLit "nexttowardl"),
650 (fsLit "pow"), (fsLit "powf"), (fsLit "powl"),
651 (fsLit "remainder"), (fsLit "remainderf"), (fsLit "remainderl"),
652 (fsLit "remquo"), (fsLit "remquof"), (fsLit "remquol"),
653 (fsLit "rint"), (fsLit "rintf"), (fsLit "rintl"),
654 (fsLit "round"), (fsLit "roundf"), (fsLit "roundl"),
655 (fsLit "scalbln"), (fsLit "scalblnf"), (fsLit "scalblnl"),
656 (fsLit "scalbn"), (fsLit "scalbnf"), (fsLit "scalbnl"),
657 (fsLit "sin"), (fsLit "sinf"), (fsLit "sinl"),
658 (fsLit "sinh"), (fsLit "sinhf"), (fsLit "sinhl"),
659 (fsLit "sqrt"), (fsLit "sqrtf"), (fsLit "sqrtl"),
660 (fsLit "tan"), (fsLit "tanf"), (fsLit "tanl"),
661 (fsLit "tanh"), (fsLit "tanhf"), (fsLit "tanhl"),
662 (fsLit "tgamma"), (fsLit "tgammaf"), (fsLit "tgammal"),
663 (fsLit "trunc"), (fsLit "truncf"), (fsLit "truncl"),
664 -- ISO C 99 also defines these function-like macros in math.h:
665 -- fpclassify, isfinite, isinf, isnormal, signbit, isgreater,
666 -- isgreaterequal, isless, islessequal, islessgreater, isunordered
667
668 -- additional symbols from _BSD_SOURCE
669 (fsLit "drem"), (fsLit "dremf"), (fsLit "dreml"),
670 (fsLit "finite"), (fsLit "finitef"), (fsLit "finitel"),
671 (fsLit "gamma"), (fsLit "gammaf"), (fsLit "gammal"),
672 (fsLit "isinf"), (fsLit "isinff"), (fsLit "isinfl"),
673 (fsLit "isnan"), (fsLit "isnanf"), (fsLit "isnanl"),
674 (fsLit "j0"), (fsLit "j0f"), (fsLit "j0l"),
675 (fsLit "j1"), (fsLit "j1f"), (fsLit "j1l"),
676 (fsLit "jn"), (fsLit "jnf"), (fsLit "jnl"),
677 (fsLit "lgamma_r"), (fsLit "lgammaf_r"), (fsLit "lgammal_r"),
678 (fsLit "scalb"), (fsLit "scalbf"), (fsLit "scalbl"),
679 (fsLit "significand"), (fsLit "significandf"), (fsLit "significandl"),
680 (fsLit "y0"), (fsLit "y0f"), (fsLit "y0l"),
681 (fsLit "y1"), (fsLit "y1f"), (fsLit "y1l"),
682 (fsLit "yn"), (fsLit "ynf"), (fsLit "ynl")
683 ]
684
685 -- -----------------------------------------------------------------------------
686 -- | Is a CLabel visible outside this object file or not?
687 -- From the point of view of the code generator, a name is
688 -- externally visible if it has to be declared as exported
689 -- in the .o file's symbol table; that is, made non-static.
690 externallyVisibleCLabel :: CLabel -> Bool -- not C "static"
691 externallyVisibleCLabel (CaseLabel _ _) = False
692 externallyVisibleCLabel (StringLitLabel _) = False
693 externallyVisibleCLabel (AsmTempLabel _) = False
694 externallyVisibleCLabel (PlainModuleInitLabel _)= True
695 externallyVisibleCLabel (RtsLabel _) = True
696 externallyVisibleCLabel (CmmLabel _ _ _) = True
697 externallyVisibleCLabel (ForeignLabel{}) = True
698 externallyVisibleCLabel (IdLabel name _ info) = isExternalName name && externallyVisibleIdLabel info
699 externallyVisibleCLabel (CC_Label _) = True
700 externallyVisibleCLabel (CCS_Label _) = True
701 externallyVisibleCLabel (DynamicLinkerLabel _ _) = False
702 externallyVisibleCLabel (HpcTicksLabel _) = True
703 externallyVisibleCLabel (LargeBitmapLabel _) = False
704 externallyVisibleCLabel (LargeSRTLabel _) = False
705
706 externallyVisibleIdLabel :: IdLabelInfo -> Bool
707 externallyVisibleIdLabel SRT = False
708 externallyVisibleIdLabel LocalInfoTable = False
709 externallyVisibleIdLabel LocalEntry = False
710 externallyVisibleIdLabel _ = True
711
712 -- -----------------------------------------------------------------------------
713 -- Finding the "type" of a CLabel
714
715 -- For generating correct types in label declarations:
716
717 data CLabelType
718 = CodeLabel -- Address of some executable instructions
719 | DataLabel -- Address of data, not a GC ptr
720 | GcPtrLabel -- Address of a (presumably static) GC object
721
722 isCFunctionLabel :: CLabel -> Bool
723 isCFunctionLabel lbl = case labelType lbl of
724 CodeLabel -> True
725 _other -> False
726
727 isGcPtrLabel :: CLabel -> Bool
728 isGcPtrLabel lbl = case labelType lbl of
729 GcPtrLabel -> True
730 _other -> False
731
732
733 -- | Work out the general type of data at the address of this label
734 -- whether it be code, data, or static GC object.
735 labelType :: CLabel -> CLabelType
736 labelType (CmmLabel _ _ CmmData) = DataLabel
737 labelType (CmmLabel _ _ CmmGcPtr) = GcPtrLabel
738 labelType (CmmLabel _ _ CmmCode) = CodeLabel
739 labelType (CmmLabel _ _ CmmInfo) = DataLabel
740 labelType (CmmLabel _ _ CmmEntry) = CodeLabel
741 labelType (CmmLabel _ _ CmmRetInfo) = DataLabel
742 labelType (CmmLabel _ _ CmmRet) = CodeLabel
743 labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
744 labelType (RtsLabel (RtsApInfoTable _ _)) = DataLabel
745 labelType (RtsLabel (RtsApFast _)) = CodeLabel
746 labelType (CaseLabel _ CaseReturnInfo) = DataLabel
747 labelType (CaseLabel _ _) = CodeLabel
748 labelType (PlainModuleInitLabel _) = CodeLabel
749 labelType (LargeSRTLabel _) = DataLabel
750 labelType (LargeBitmapLabel _) = DataLabel
751 labelType (ForeignLabel _ _ _ IsFunction) = CodeLabel
752 labelType (IdLabel _ _ info) = idInfoLabelType info
753 labelType _ = DataLabel
754
755 idInfoLabelType info =
756 case info of
757 InfoTable -> DataLabel
758 LocalInfoTable -> DataLabel
759 Closure -> GcPtrLabel
760 ConInfoTable -> DataLabel
761 StaticInfoTable -> DataLabel
762 ClosureTable -> DataLabel
763 RednCounts -> DataLabel
764 _ -> CodeLabel
765
766
767 -- -----------------------------------------------------------------------------
768 -- Does a CLabel need dynamic linkage?
769
770 -- When referring to data in code, we need to know whether
771 -- that data resides in a DLL or not. [Win32 only.]
772 -- @labelDynamic@ returns @True@ if the label is located
773 -- in a DLL, be it a data reference or not.
774
775 labelDynamic :: DynFlags -> PackageId -> CLabel -> Bool
776 labelDynamic dflags this_pkg lbl =
777 case lbl of
778 -- is the RTS in a DLL or not?
779 RtsLabel _ -> not opt_Static && (this_pkg /= rtsPackageId)
780
781 IdLabel n _ k -> isDllName this_pkg n
782
783 -- When compiling in the "dyn" way, eack package is to be linked into
784 -- its own shared library.
785 CmmLabel pkg _ _
786 | os == OSMinGW32 ->
787 not opt_Static && (this_pkg /= pkg)
788 | otherwise ->
789 True
790
791 ForeignLabel _ _ source _ ->
792 if os == OSMinGW32
793 then case source of
794 -- Foreign label is in some un-named foreign package (or DLL).
795 ForeignLabelInExternalPackage -> True
796
797 -- Foreign label is linked into the same package as the
798 -- source file currently being compiled.
799 ForeignLabelInThisPackage -> False
800
801 -- Foreign label is in some named package.
802 -- When compiling in the "dyn" way, each package is to be
803 -- linked into its own DLL.
804 ForeignLabelInPackage pkgId ->
805 (not opt_Static) && (this_pkg /= pkgId)
806
807 else -- On Mac OS X and on ELF platforms, false positives are OK,
808 -- so we claim that all foreign imports come from dynamic
809 -- libraries
810 True
811
812 PlainModuleInitLabel m -> not opt_Static && this_pkg /= (modulePackageId m)
813
814 -- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
815 _ -> False
816 where os = platformOS (targetPlatform dflags)
817
818 {-
819 OLD?: These GRAN functions are needed for spitting out GRAN_FETCH() at the
820 right places. It is used to detect when the abstractC statement of an
821 CCodeBlock actually contains the code for a slow entry point. -- HWL
822
823 We need at least @Eq@ for @CLabels@, because we want to avoid
824 duplicate declarations in generating C (see @labelSeenTE@ in
825 @PprAbsC@).
826 -}
827
828 -----------------------------------------------------------------------------
829 -- Printing out CLabels.
830
831 {-
832 Convention:
833
834 <name>_<type>
835
836 where <name> is <Module>_<name> for external names and <unique> for
837 internal names. <type> is one of the following:
838
839 info Info table
840 srt Static reference table
841 srtd Static reference table descriptor
842 entry Entry code (function, closure)
843 slow Slow entry code (if any)
844 ret Direct return address
845 vtbl Vector table
846 <n>_alt Case alternative (tag n)
847 dflt Default case alternative
848 btm Large bitmap vector
849 closure Static closure
850 con_entry Dynamic Constructor entry code
851 con_info Dynamic Constructor info table
852 static_entry Static Constructor entry code
853 static_info Static Constructor info table
854 sel_info Selector info table
855 sel_entry Selector entry code
856 cc Cost centre
857 ccs Cost centre stack
858
859 Many of these distinctions are only for documentation reasons. For
860 example, _ret is only distinguished from _entry to make it easy to
861 tell whether a code fragment is a return point or a closure/function
862 entry.
863
864 Note [Closure and info labels]
865 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
866 For a function 'foo, we have:
867 foo_info : Points to the info table describing foo's closure
868 (and entry code for foo with tables next to code)
869 foo_closure : Static (no-free-var) closure only:
870 points to the statically-allocated closure
871
872 For a data constructor (such as Just or Nothing), we have:
873 Just_con_info: Info table for the data constructor itself
874 the first word of a heap-allocated Just
875 Just_info: Info table for the *worker function*, an
876 ordinary Haskell function of arity 1 that
877 allocates a (Just x) box:
878 Just = \x -> Just x
879 Just_closure: The closure for this worker
880
881 Nothing_closure: a statically allocated closure for Nothing
882 Nothing_static_info: info table for Nothing_closure
883
884 All these must be exported symbol, EXCEPT Just_info. We don't need to
885 export this because in other modules we either have
886 * A reference to 'Just'; use Just_closure
887 * A saturated call 'Just x'; allocate using Just_con_info
888 Not exporting these Just_info labels reduces the number of symbols
889 somewhat.
890 -}
891
892 instance PlatformOutputable CLabel where
893 pprPlatform = pprCLabel
894
895 pprCLabel :: Platform -> CLabel -> SDoc
896
897 pprCLabel platform (AsmTempLabel u)
898 | cGhcWithNativeCodeGen == "YES"
899 = getPprStyle $ \ sty ->
900 if asmStyle sty then
901 ptext (asmTempLabelPrefix platform) <> pprUnique u
902 else
903 char '_' <> pprUnique u
904
905 pprCLabel platform (DynamicLinkerLabel info lbl)
906 | cGhcWithNativeCodeGen == "YES"
907 = pprDynamicLinkerAsmLabel platform info lbl
908
909 pprCLabel _ PicBaseLabel
910 | cGhcWithNativeCodeGen == "YES"
911 = ptext (sLit "1b")
912
913 pprCLabel platform (DeadStripPreventer lbl)
914 | cGhcWithNativeCodeGen == "YES"
915 = pprCLabel platform lbl <> ptext (sLit "_dsp")
916
917 pprCLabel platform lbl
918 = getPprStyle $ \ sty ->
919 if cGhcWithNativeCodeGen == "YES" && asmStyle sty
920 then maybe_underscore (pprAsmCLbl platform lbl)
921 else pprCLbl lbl
922
923 maybe_underscore doc
924 | underscorePrefix = pp_cSEP <> doc
925 | otherwise = doc
926
927 pprAsmCLbl platform (ForeignLabel fs (Just sz) _ _)
928 | platformOS platform == OSMinGW32
929 -- In asm mode, we need to put the suffix on a stdcall ForeignLabel.
930 -- (The C compiler does this itself).
931 = ftext fs <> char '@' <> int sz
932 pprAsmCLbl _ lbl
933 = pprCLbl lbl
934
935 pprCLbl (StringLitLabel u)
936 = pprUnique u <> ptext (sLit "_str")
937
938 pprCLbl (CaseLabel u CaseReturnPt)
939 = hcat [pprUnique u, ptext (sLit "_ret")]
940 pprCLbl (CaseLabel u CaseReturnInfo)
941 = hcat [pprUnique u, ptext (sLit "_info")]
942 pprCLbl (CaseLabel u (CaseAlt tag))
943 = hcat [pprUnique u, pp_cSEP, int tag, ptext (sLit "_alt")]
944 pprCLbl (CaseLabel u CaseDefault)
945 = hcat [pprUnique u, ptext (sLit "_dflt")]
946
947 pprCLbl (LargeSRTLabel u) = pprUnique u <> pp_cSEP <> ptext (sLit "srtd")
948 pprCLbl (LargeBitmapLabel u) = text "b" <> pprUnique u <> pp_cSEP <> ptext (sLit "btm")
949 -- Some bitsmaps for tuple constructors have a numeric tag (e.g. '7')
950 -- until that gets resolved we'll just force them to start
951 -- with a letter so the label will be legal assmbly code.
952
953
954 pprCLbl (CmmLabel _ str CmmCode) = ftext str
955 pprCLbl (CmmLabel _ str CmmData) = ftext str
956 pprCLbl (CmmLabel _ str CmmGcPtr) = ftext str
957 pprCLbl (CmmLabel _ str CmmPrimCall) = ftext str
958
959 pprCLbl (RtsLabel (RtsApFast str)) = ftext str <> ptext (sLit "_fast")
960
961 pprCLbl (RtsLabel (RtsSelectorInfoTable upd_reqd offset))
962 = hcat [ptext (sLit "stg_sel_"), text (show offset),
963 ptext (if upd_reqd
964 then (sLit "_upd_info")
965 else (sLit "_noupd_info"))
966 ]
967
968 pprCLbl (RtsLabel (RtsSelectorEntry upd_reqd offset))
969 = hcat [ptext (sLit "stg_sel_"), text (show offset),
970 ptext (if upd_reqd
971 then (sLit "_upd_entry")
972 else (sLit "_noupd_entry"))
973 ]
974
975 pprCLbl (RtsLabel (RtsApInfoTable upd_reqd arity))
976 = hcat [ptext (sLit "stg_ap_"), text (show arity),
977 ptext (if upd_reqd
978 then (sLit "_upd_info")
979 else (sLit "_noupd_info"))
980 ]
981
982 pprCLbl (RtsLabel (RtsApEntry upd_reqd arity))
983 = hcat [ptext (sLit "stg_ap_"), text (show arity),
984 ptext (if upd_reqd
985 then (sLit "_upd_entry")
986 else (sLit "_noupd_entry"))
987 ]
988
989 pprCLbl (CmmLabel _ fs CmmInfo)
990 = ftext fs <> ptext (sLit "_info")
991
992 pprCLbl (CmmLabel _ fs CmmEntry)
993 = ftext fs <> ptext (sLit "_entry")
994
995 pprCLbl (CmmLabel _ fs CmmRetInfo)
996 = ftext fs <> ptext (sLit "_info")
997
998 pprCLbl (CmmLabel _ fs CmmRet)
999 = ftext fs <> ptext (sLit "_ret")
1000
1001 pprCLbl (RtsLabel (RtsPrimOp primop))
1002 = ptext (sLit "stg_") <> ppr primop
1003
1004 pprCLbl (RtsLabel (RtsSlowTickyCtr pat))
1005 = ptext (sLit "SLOW_CALL_") <> text pat <> ptext (sLit "_ctr")
1006
1007 pprCLbl (ForeignLabel str _ _ _)
1008 = ftext str
1009
1010 pprCLbl (IdLabel name cafs flavor) = ppr name <> ppIdFlavor flavor
1011
1012 pprCLbl (CC_Label cc) = ppr cc
1013 pprCLbl (CCS_Label ccs) = ppr ccs
1014
1015 pprCLbl (PlainModuleInitLabel mod)
1016 = ptext (sLit "__stginit_") <> ppr mod
1017
1018 pprCLbl (HpcTicksLabel mod)
1019 = ptext (sLit "_hpc_tickboxes_") <> ppr mod <> ptext (sLit "_hpc")
1020
1021 ppIdFlavor :: IdLabelInfo -> SDoc
1022 ppIdFlavor x = pp_cSEP <>
1023 (case x of
1024 Closure -> ptext (sLit "closure")
1025 SRT -> ptext (sLit "srt")
1026 InfoTable -> ptext (sLit "info")
1027 LocalInfoTable -> ptext (sLit "info")
1028 Entry -> ptext (sLit "entry")
1029 LocalEntry -> ptext (sLit "entry")
1030 Slow -> ptext (sLit "slow")
1031 RednCounts -> ptext (sLit "ct")
1032 ConEntry -> ptext (sLit "con_entry")
1033 ConInfoTable -> ptext (sLit "con_info")
1034 StaticConEntry -> ptext (sLit "static_entry")
1035 StaticInfoTable -> ptext (sLit "static_info")
1036 ClosureTable -> ptext (sLit "closure_tbl")
1037 )
1038
1039
1040 pp_cSEP = char '_'
1041
1042
1043 instance Outputable ForeignLabelSource where
1044 ppr fs
1045 = case fs of
1046 ForeignLabelInPackage pkgId -> parens $ text "package: " <> ppr pkgId
1047 ForeignLabelInThisPackage -> parens $ text "this package"
1048 ForeignLabelInExternalPackage -> parens $ text "external package"
1049
1050 -- -----------------------------------------------------------------------------
1051 -- Machine-dependent knowledge about labels.
1052
1053 underscorePrefix :: Bool -- leading underscore on assembler labels?
1054 underscorePrefix = (cLeadingUnderscore == "YES")
1055
1056 asmTempLabelPrefix :: Platform -> LitString -- for formatting labels
1057 asmTempLabelPrefix platform =
1058 if platformOS platform == OSDarwin
1059 then sLit "L"
1060 else sLit ".L"
1061
1062 pprDynamicLinkerAsmLabel :: Platform -> DynamicLinkerLabelInfo -> CLabel -> SDoc
1063 pprDynamicLinkerAsmLabel platform dllInfo lbl
1064 = if platform == Platform ArchX86_64 OSDarwin
1065 then case dllInfo of
1066 CodeStub -> char 'L' <> pprCLabel platform lbl <> text "$stub"
1067 SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
1068 GotSymbolPtr -> pprCLabel platform lbl <> text "@GOTPCREL"
1069 GotSymbolOffset -> pprCLabel platform lbl
1070 _ -> panic "pprDynamicLinkerAsmLabel"
1071 else if platformOS platform == OSDarwin
1072 then case dllInfo of
1073 CodeStub -> char 'L' <> pprCLabel platform lbl <> text "$stub"
1074 SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
1075 _ -> panic "pprDynamicLinkerAsmLabel"
1076 else if platformArch platform == ArchPPC && osElfTarget (platformOS platform)
1077 then case dllInfo of
1078 CodeStub -> pprCLabel platform lbl <> text "@plt"
1079 SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
1080 _ -> panic "pprDynamicLinkerAsmLabel"
1081 else if platformArch platform == ArchX86_64 && osElfTarget (platformOS platform)
1082 then case dllInfo of
1083 CodeStub -> pprCLabel platform lbl <> text "@plt"
1084 GotSymbolPtr -> pprCLabel platform lbl <> text "@gotpcrel"
1085 GotSymbolOffset -> pprCLabel platform lbl
1086 SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
1087 else if osElfTarget (platformOS platform)
1088 then case dllInfo of
1089 CodeStub -> pprCLabel platform lbl <> text "@plt"
1090 SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
1091 GotSymbolPtr -> pprCLabel platform lbl <> text "@got"
1092 GotSymbolOffset -> pprCLabel platform lbl <> text "@gotoff"
1093 else if platformOS platform == OSMinGW32
1094 then case dllInfo of
1095 SymbolPtr -> text "__imp_" <> pprCLabel platform lbl
1096 _ -> panic "pprDynamicLinkerAsmLabel"
1097 else panic "pprDynamicLinkerAsmLabel"
1098