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