summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwolfgang <unknown>2005-05-15 02:46:27 +0000
committerwolfgang <unknown>2005-05-15 02:46:27 +0000
commitbaf9d8508f3fd2d042dcbe19b68f4b49c12f4769 (patch)
treebe80f62a416992f2d31115a9fbd4d12545bfb39f
parent8728711beb71425e9618db7618ab94bb4ebfaf51 (diff)
downloadhaskell-baf9d8508f3fd2d042dcbe19b68f4b49c12f4769.tar.gz
[project @ 2005-05-15 02:46:27 by wolfgang]
Clean up things by making PicBaseReg a constructor of GlobalReg instead of CmmExpr.
-rw-r--r--ghc/compiler/cmm/Cmm.hs7
-rw-r--r--ghc/compiler/cmm/PprCmm.hs2
-rw-r--r--ghc/compiler/nativeGen/MachCodeGen.hs10
-rw-r--r--ghc/compiler/nativeGen/PositionIndependentCode.hs4
4 files changed, 13 insertions, 10 deletions
diff --git a/ghc/compiler/cmm/Cmm.hs b/ghc/compiler/cmm/Cmm.hs
index a8576ec78e..304ddb2b0f 100644
--- a/ghc/compiler/cmm/Cmm.hs
+++ b/ghc/compiler/cmm/Cmm.hs
@@ -162,7 +162,6 @@ data CmmExpr
-- ** is shorthand only, meaning **
-- CmmMachOp (MO_S_Add rep (CmmReg reg) (CmmLit (CmmInt i rep)))
-- where rep = cmmRegRep reg
- | CmmPicBaseReg -- Base Register for PIC calculations
cmmExprRep :: CmmExpr -> MachRep
cmmExprRep (CmmLit lit) = cmmLitRep lit
@@ -170,7 +169,6 @@ cmmExprRep (CmmLoad _ rep) = rep
cmmExprRep (CmmReg reg) = cmmRegRep reg
cmmExprRep (CmmMachOp op _) = resultRepOfMachOp op
cmmExprRep (CmmRegOff reg _) = cmmRegRep reg
-cmmExprRep CmmPicBaseReg = wordRep
data CmmReg
= CmmLocal LocalReg
@@ -296,6 +294,11 @@ data GlobalReg
-- (where necessary) in the native code generator.
| BaseReg
+ -- Base Register for PIC (position-independent code) calculations
+ -- Only used inside the native code generator. It's exact meaning differs
+ -- from platform to platform (see module PositionIndependentCode).
+ | PicBaseReg
+
deriving( Eq
#ifdef DEBUG
, Show
diff --git a/ghc/compiler/cmm/PprCmm.hs b/ghc/compiler/cmm/PprCmm.hs
index 0f9a3d527b..f38eb30802 100644
--- a/ghc/compiler/cmm/PprCmm.hs
+++ b/ghc/compiler/cmm/PprCmm.hs
@@ -317,7 +317,6 @@ pprExpr9 e =
CmmReg reg -> ppr reg
CmmRegOff reg off -> parens (ppr reg <+> char '+' <+> int off)
CmmMachOp mop args -> genMachOp mop args
- CmmPicBaseReg -> text "PIC_BASE_REG"
e -> parens (pprExpr e)
genMachOp :: MachOp -> [CmmExpr] -> SDoc
@@ -433,6 +432,7 @@ pprGlobalReg gr
GCEnter1 -> ptext SLIT("stg_gc_enter_1")
GCFun -> ptext SLIT("stg_gc_fun")
BaseReg -> ptext SLIT("BaseReg")
+ PicBaseReg -> ptext SLIT("PicBaseReg")
_ -> panic $ "PprCmm.pprGlobalReg: unknown global reg"
diff --git a/ghc/compiler/nativeGen/MachCodeGen.hs b/ghc/compiler/nativeGen/MachCodeGen.hs
index 20693cee5a..f700fbcb71 100644
--- a/ghc/compiler/nativeGen/MachCodeGen.hs
+++ b/ghc/compiler/nativeGen/MachCodeGen.hs
@@ -513,17 +513,17 @@ getRegisterReg (CmmGlobal mid)
getRegister :: CmmExpr -> NatM Register
+getRegister (CmmReg (CmmGlobal PicBaseReg))
+ = do
+ reg <- getPicBaseNat wordRep
+ return (Fixed wordRep reg nilOL)
+
getRegister (CmmReg reg)
= return (Fixed (cmmRegRep reg) (getRegisterReg reg) nilOL)
getRegister tree@(CmmRegOff _ _)
= getRegister (mangleIndexTree tree)
-getRegister CmmPicBaseReg
- = do
- reg <- getPicBaseNat wordRep
- return (Fixed wordRep reg nilOL)
-
-- end of machine-"independent" bit; here we go on the rest...
#if alpha_TARGET_ARCH
diff --git a/ghc/compiler/nativeGen/PositionIndependentCode.hs b/ghc/compiler/nativeGen/PositionIndependentCode.hs
index acf37856dc..0a70b2d54c 100644
--- a/ghc/compiler/nativeGen/PositionIndependentCode.hs
+++ b/ghc/compiler/nativeGen/PositionIndependentCode.hs
@@ -18,7 +18,7 @@ module PositionIndependentCode (
CodeStub, SymbolPtr, GotSymbolPtr, GotSymbolOffset
- labelDynamic predicate
+ module Cmm
- - The CmmExpr datatype has a CmmPicBaseReg constructor
+ - The GlobalReg datatype has a PicBaseReg constructor
- The CmmLit datatype has a CmmLabelDiffOff constructor
+ codeGen & RTS
- When tablesNextToCode, no absolute addresses are stored in info tables
@@ -125,7 +125,7 @@ cmmMakePicReference :: CLabel -> CmmExpr
cmmMakePicReference lbl
| opt_PIC && absoluteLabel lbl = CmmMachOp (MO_Add wordRep) [
- CmmPicBaseReg,
+ CmmReg (CmmGlobal PicBaseReg),
CmmLit $ picRelative lbl
]
where