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