[project @ 2005-03-16 09:04:26 by simonpj]
[ghc-hetmet.git] / ghc / compiler / codeGen / CgInfoTbls.hs
index 7692e7d..2183d89 100644 (file)
@@ -44,7 +44,8 @@ import CgCallConv     ( isBigLiveness, mkLivenessCLit, buildContLiveness,
                          CtrlReturnConvention(..) )
 import CgUtils         ( mkStringCLit, packHalfWordsCLit, mkWordCLit, 
                          cmmOffsetB, cmmOffsetExprW, cmmLabelOffW, cmmOffsetW,
-                         emitDataLits, emitRODataLits, emitSwitch, cmmNegate )
+                         emitDataLits, emitRODataLits, emitSwitch, cmmNegate,
+                         newTemp )
 import CgMonad
 
 import CmmUtils                ( mkIntCLit, zeroCLit )
@@ -56,7 +57,7 @@ import StgSyn         ( SRT(..) )
 import Name            ( Name )
 import DataCon         ( DataCon, dataConTag, fIRST_TAG )
 import Unique          ( Uniquable(..) )
-import CmdLineOpts     ( opt_SccProfilingOn )
+import CmdLineOpts     ( opt_SccProfilingOn, DynFlags(..), HscTarget(..) )
 import ListSetOps      ( assocDefault )
 import Maybes          ( isJust )
 import Constants       ( wORD_SIZE, sIZEOF_StgFunInfoExtraRev )
@@ -348,7 +349,18 @@ emitVectoredReturnInstr :: CmmExpr -- *Zero-indexed* constructor tag
                        -> Code
 emitVectoredReturnInstr zero_indexed_tag
   = do { info_amode <- getSequelAmode
-       ; let target = retVec info_amode zero_indexed_tag
+               -- HACK! assign info_amode to a temp, because retVec
+               -- uses it twice and the NCG doesn't have any CSE yet.
+               -- Only do this for the NCG, because gcc is too stupid
+               -- to optimise away the extra tmp (grrr).
+       ; dflags <- getDynFlags
+       ; x <- if hscTarget dflags == HscAsm
+                  then do z <- newTemp wordRep
+                          stmtC (CmmAssign z info_amode)
+                          return (CmmReg z)
+                  else
+                       return info_amode
+       ; let target = retVec x zero_indexed_tag
        ; stmtC (CmmJump target []) }