Ticket #7758: 0002-Detabify-StgCmmEnv.patch

File 0002-Detabify-StgCmmEnv.patch, 7.5 KB (added by bosu, 2 years ago)
  • compiler/codeGen/StgCmmEnv.hs

    From 8119a1d4c86ceaf40a2e973d7d5a7e67f2bd256d Mon Sep 17 00:00:00 2001
    From: Boris Sukholitko <[email protected]>
    Date: Sat, 9 Mar 2013 11:32:32 +0200
    Subject: [PATCH 2/3] Detabify StgCmmEnv
    
    ---
     compiler/codeGen/StgCmmEnv.hs |  118 +++++++++++++++++++----------------------
     1 file changed, 55 insertions(+), 63 deletions(-)
    
    diff --git a/compiler/codeGen/StgCmmEnv.hs b/compiler/codeGen/StgCmmEnv.hs
    index 5106b97..1d6f386 100644
    a b  
    55-- (c) The University of Glasgow 2004-2006 
    66-- 
    77----------------------------------------------------------------------------- 
    8  
    9 {-# OPTIONS -fno-warn-tabs #-} 
    10 -- The above warning supression flag is a temporary kludge. 
    11 -- While working on this module you are encouraged to remove it and 
    12 -- detab the module (please do the detabbing in a separate patch). See 
    13 --     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces 
    14 -- for details 
    15  
    168module StgCmmEnv ( 
    17         CgIdInfo, 
     9        CgIdInfo, 
    1810 
    19         cgIdInfoId, cgIdInfoLF, 
     11        cgIdInfoId, cgIdInfoLF, 
    2012 
    2113        litIdInfo, lneIdInfo, rhsIdInfo, mkRhsInit, 
    22         idInfoToAmode, 
     14        idInfoToAmode, 
    2315 
    2416        NonVoid(..), isVoidId, nonVoidIds, 
    2517 
    26         addBindC, addBindsC, 
     18        addBindC, addBindsC, 
    2719 
    28         bindArgsToRegs, bindToReg, rebindToReg, 
    29         bindArgToReg, idToReg, 
     20        bindArgsToRegs, bindToReg, rebindToReg, 
     21        bindArgToReg, idToReg, 
    3022        getArgAmode, getNonVoidArgAmodes, 
    31         getCgIdInfo,  
    32         maybeLetNoEscape,  
     23        getCgIdInfo,  
     24        maybeLetNoEscape,  
    3325    ) where 
    3426 
    3527#include "HsVersions.h" 
    import StgSyn 
    5547import Outputable 
    5648 
    5749------------------------------------- 
    58 --      Non-void types 
     50--        Non-void types 
    5951------------------------------------- 
    6052-- We frequently need the invariant that an Id or a an argument 
    6153-- is of a non-void type. This type is a witness to the invariant. 
    nonVoidIds :: [Id] -> [NonVoid Id] 
    7365nonVoidIds ids = [NonVoid id | id <- ids, not (isVoidRep (idPrimRep id))] 
    7466 
    7567------------------------------------- 
    76 --      Manipulating CgIdInfo 
     68--        Manipulating CgIdInfo 
    7769------------------------------------- 
    7870 
    7971mkCgIdInfo :: DynFlags -> Id -> LambdaFormInfo -> CmmExpr -> CgIdInfo 
    litIdInfo :: DynFlags -> Id -> LambdaFormInfo -> CmmLit -> CgIdInfo 
    8678litIdInfo dflags id lf lit 
    8779  = CgIdInfo { cg_id = id, cg_lf = lf 
    8880             , cg_loc = CmmLoc (addDynTag dflags (CmmLit lit) tag)  
    89              , cg_tag = tag } 
     81             , cg_tag = tag } 
    9082  where 
    9183    tag = lfDynTag dflags lf 
    9284 
    idInfoToAmode :: CgIdInfo -> CmmExpr 
    114106-- Returns a CmmExpr for the *tagged* pointer 
    115107idInfoToAmode (CgIdInfo { cg_loc = CmmLoc e }) = e 
    116108idInfoToAmode cg_info 
    117   = pprPanic "idInfoToAmode" (ppr (cg_id cg_info))      -- LneLoc 
     109  = pprPanic "idInfoToAmode" (ppr (cg_id cg_info))        -- LneLoc 
    118110 
    119111addDynTag :: DynFlags -> CmmExpr -> DynTag -> CmmExpr 
    120112-- A tag adds a byte offset to the pointer 
    cgIdInfoLF = cg_lf 
    128120 
    129121maybeLetNoEscape :: CgIdInfo -> Maybe (BlockId, [LocalReg]) 
    130122maybeLetNoEscape (CgIdInfo { cg_loc = LneLoc blk_id args}) = Just (blk_id, args) 
    131 maybeLetNoEscape _other                                    = Nothing 
     123maybeLetNoEscape _other                                      = Nothing 
    132124 
    133125 
    134126 
    135127--------------------------------------------------------- 
    136 --      The binding environment 
     128--        The binding environment 
    137129--  
    138130-- There are three basic routines, for adding (addBindC),  
    139131-- modifying(modifyBindC) and looking up (getCgIdInfo) bindings. 
    maybeLetNoEscape _other = Nothing 
    141133 
    142134addBindC :: Id -> CgIdInfo -> FCode () 
    143135addBindC name stuff_to_bind = do 
    144         binds <- getBinds 
    145         setBinds $ extendVarEnv binds name stuff_to_bind 
     136        binds <- getBinds 
     137        setBinds $ extendVarEnv binds name stuff_to_bind 
    146138 
    147139addBindsC :: [CgIdInfo] -> FCode () 
    148140addBindsC new_bindings = do 
    149         binds <- getBinds 
    150         let new_binds = foldl (\ binds info -> extendVarEnv binds (cg_id info) info) 
    151                               binds 
    152                               new_bindings 
    153         setBinds new_binds 
     141        binds <- getBinds 
     142        let new_binds = foldl (\ binds info -> extendVarEnv binds (cg_id info) info) 
     143                              binds 
     144                              new_bindings 
     145        setBinds new_binds 
    154146 
    155147getCgIdInfo :: Id -> FCode CgIdInfo 
    156148getCgIdInfo id 
    157   = do  {       -- Try local bindings first 
    158         ; local_binds  <- getBinds 
    159         ; case lookupVarEnv local_binds id of { 
    160             Just info -> return info ; 
    161             Nothing   -> do 
    162  
    163         {       -- Try top-level bindings 
    164           static_binds <- getStaticBinds 
    165         ; case lookupVarEnv static_binds id of { 
    166             Just info -> return info ; 
    167             Nothing   -> 
    168  
    169                 -- Should be imported; make up a CgIdInfo for it 
    170         let  
    171             name = idName id 
    172         in 
    173         if isExternalName name then do 
    174             let ext_lbl = CmmLabel (mkClosureLabel name $ idCafInfo id) 
     149  = do        {         -- Try local bindings first 
     150        ; local_binds  <- getBinds 
     151        ; case lookupVarEnv local_binds id of { 
     152            Just info -> return info ; 
     153            Nothing   -> do 
     154 
     155        {         -- Try top-level bindings 
     156          static_binds <- getStaticBinds 
     157        ; case lookupVarEnv static_binds id of { 
     158            Just info -> return info ; 
     159            Nothing   -> 
     160 
     161                -- Should be imported; make up a CgIdInfo for it 
     162        let  
     163            name = idName id 
     164        in 
     165        if isExternalName name then do 
     166            let ext_lbl = CmmLabel (mkClosureLabel name $ idCafInfo id) 
    175167            dflags <- getDynFlags 
    176             return (litIdInfo dflags id (mkLFImported id) ext_lbl) 
    177         else 
    178         -- Bug   
    179         cgLookupPanic id 
    180         }}}} 
     168            return (litIdInfo dflags id (mkLFImported id) ext_lbl) 
     169        else 
     170            -- Bug         
     171            cgLookupPanic id 
     172        }}}} 
    181173     
    182174cgLookupPanic :: Id -> FCode a 
    183175cgLookupPanic id 
    184   = do  static_binds <- getStaticBinds 
    185         local_binds <- getBinds 
     176  = do  static_binds <- getStaticBinds 
     177        local_binds <- getBinds 
    186178        pprPanic "StgCmmEnv: variable not found" 
    187                 (vcat [ppr id, 
    188                 ptext (sLit "static binds for:"), 
    189                 vcat [ ppr (cg_id info) | info <- varEnvElts static_binds ], 
    190                 ptext (sLit "local binds for:"), 
     179                (vcat [ppr id, 
     180                ptext (sLit "static binds for:"), 
     181                vcat [ ppr (cg_id info) | info <- varEnvElts static_binds ], 
     182                ptext (sLit "local binds for:"), 
    191183                vcat [ ppr (cg_id info) | info <- varEnvElts local_binds ] 
    192184              ]) 
    193185 
    getNonVoidArgAmodes [] = return [] 
    205197getNonVoidArgAmodes (arg:args) 
    206198  | isVoidRep (argPrimRep arg) = getNonVoidArgAmodes args 
    207199  | otherwise = do { amode  <- getArgAmode (NonVoid arg) 
    208                    ; amodes <- getNonVoidArgAmodes args 
    209                    ; return ( amode : amodes ) } 
     200                    ; amodes <- getNonVoidArgAmodes args 
     201                    ; return ( amode : amodes ) } 
    210202 
    211203------------------------------------------------------------------------ 
    212 --      Interface functions for binding and re-binding names 
     204--        Interface functions for binding and re-binding names 
    213205------------------------------------------------------------------------ 
    214206 
    215207bindToReg :: NonVoid Id -> LambdaFormInfo -> FCode LocalReg 
    rebindToReg :: NonVoid Id -> FCode LocalReg 
    224216-- Like bindToReg, but the Id is already in scope, so  
    225217-- get its LF info from the envt 
    226218rebindToReg nvid@(NonVoid id) 
    227   = do  { info <- getCgIdInfo id 
    228         ; bindToReg nvid (cgIdInfoLF info) } 
     219  = do  { info <- getCgIdInfo id 
     220        ; bindToReg nvid (cgIdInfoLF info) } 
    229221 
    230222bindArgToReg :: NonVoid Id -> FCode LocalReg 
    231223bindArgToReg nvid@(NonVoid id) = bindToReg nvid (mkLFArgument id)