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