initializePicBase
) where
+#include "HsVersions.h"
+
{-
This module handles generation of position independent code and
dynamic-linking related issues for the native code generator.
#include "nativeGen/NCG.h"
import Cmm
-import MachOp ( MachOp(MO_Add), wordRep, MachRep(..) )
import CLabel ( CLabel, pprCLabel,
mkDynamicLinkerLabel, DynamicLinkerLabelInfo(..),
dynamicLinkerLabelInfo, mkPicBaseLabel,
import CLabel ( mkForeignLabel )
#endif
-import MachRegs
-import MachInstrs
+import Regs
+import Instrs
import NCGMonad ( NatM, getNewRegNat, getNewLabelNat )
import StaticFlags ( opt_PIC, opt_Static )
+import BasicTypes
import Pretty
import qualified Outputable
AccessViaSymbolPtr -> do
let symbolPtr = mkDynamicLinkerLabel SymbolPtr lbl
addImport symbolPtr
- return $ CmmLoad (cmmMakePicReference symbolPtr) wordRep
+ return $ CmmLoad (cmmMakePicReference symbolPtr) bWord
AccessDirectly -> case referenceKind of
-- for data, we might have to make some calculations:
DataReference -> return $ cmmMakePicReference lbl
-- everything gets relocated at runtime
cmmMakePicReference lbl
- | (opt_PIC || not opt_Static) && absoluteLabel lbl = CmmMachOp (MO_Add wordRep) [
+ | (opt_PIC || not opt_Static) && absoluteLabel lbl = CmmMachOp (MO_Add wordWidth) [
CmmReg (CmmGlobal PicBaseReg),
CmmLit $ picRelative lbl
]
-- The label used to refer to our "fake GOT" from
-- position-independent code.
gotLabel = mkForeignLabel -- HACK: it's not really foreign
- (fsLit ".LCTOC1") Nothing False
+ (fsLit ".LCTOC1") Nothing False IsData
-- pprGotDeclaration
-- Output whatever needs to be output once per .s file.
ptext symbolSize <+> pprCLabel_asm lbl
]
--- PLT code stubs are generated automatically be the dynamic linker.
+-- PLT code stubs are generated automatically by the dynamic linker.
| otherwise = empty
where
- symbolSize = case wordRep of
- I32 -> sLit "\t.long"
- I64 -> sLit "\t.quad"
+ symbolSize = case wordWidth of
+ W32 -> sLit "\t.long"
+ W64 -> sLit "\t.quad"
_ -> panic "Unknown wordRep in pprImportedSymbol"
#else
(CmmProc info lab params (ListGraph blocks) : statics)
= do
gotOffLabel <- getNewLabelNat
- tmp <- getNewRegNat wordRep
+ tmp <- getNewRegNat $ intSize wordWidth
let
gotOffset = CmmData Text [
CmmDataLabel gotOffLabel,
(ImmCLbl mkPicBaseLabel)
BasicBlock bID insns = head blocks
b' = BasicBlock bID (FETCHPC picReg
- : LD wordRep tmp
+ : LD wordSize tmp
(AddrRegImm picReg offsetToOffset)
: ADD picReg picReg (RIReg tmp)
: insns)