[Git][ghc/ghc][wip/drop-long-reg] cmm: Drop LongReg GlobalRegs

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Tue Oct 18 13:21:36 UTC 2022



Ben Gamari pushed to branch wip/drop-long-reg at Glasgow Haskell Compiler / GHC


Commits:
5c183641 by Ben Gamari at 2022-10-18T09:21:27-04:00
cmm: Drop LongReg GlobalRegs

This register is not mapped to a machine register on any platform that
we currently support. Consequently, it doesn't really make sense to
carry around the infrastructure for this register.

- - - - -


13 changed files:

- compiler/CodeGen.Platform.h
- compiler/GHC/Cmm/CallConv.hs
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/Reg.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm/Regs.hs
- compiler/GHC/StgToCmm/CgUtils.hs
- rts/HeapStackCheck.cmm
- rts/StgMiscClosures.cmm
- rts/include/stg/MachRegs.h
- rts/include/stg/Regs.h
- utils/deriveConstants/Main.hs
- utils/genapply/Main.hs


Changes:

=====================================
compiler/CodeGen.Platform.h
=====================================
@@ -449,9 +449,6 @@ callerSaves (DoubleReg 5)     = True
 #if defined(CALLER_SAVES_D6)
 callerSaves (DoubleReg 6)     = True
 #endif
-#if defined(CALLER_SAVES_L1)
-callerSaves (LongReg 1)       = True
-#endif
 #if defined(CALLER_SAVES_Sp)
 callerSaves Sp                = True
 #endif
@@ -797,12 +794,6 @@ globalRegMaybe (ZmmReg 6)               = Just (RealRegSingle REG_ZMM6)
 # if defined(REG_Sp)
 globalRegMaybe Sp                       = Just (RealRegSingle REG_Sp)
 # endif
-# if defined(REG_Lng1)
-globalRegMaybe (LongReg 1)              = Just (RealRegSingle REG_Lng1)
-# endif
-# if defined(REG_Lng2)
-globalRegMaybe (LongReg 2)              = Just (RealRegSingle REG_Lng2)
-# endif
 # if defined(REG_SpLim)
 globalRegMaybe SpLim                    = Just (RealRegSingle REG_SpLim)
 # endif


=====================================
compiler/GHC/Cmm/CallConv.hs
=====================================
@@ -149,7 +149,6 @@ getRegsWithoutNode platform =
   ( filter (\r -> r VGcPtr /= node) (realVanillaRegs platform)
   , realFloatRegs platform
   , realDoubleRegs platform
-  , realLongRegs platform
   , realXmmRegNos platform)
 
 -- getRegsWithNode uses R1/node even if it isn't a register
@@ -159,26 +158,23 @@ getRegsWithNode platform =
     else realVanillaRegs platform
   , realFloatRegs platform
   , realDoubleRegs platform
-  , realLongRegs platform
   , realXmmRegNos platform)
 
-allFloatRegs, allDoubleRegs, allLongRegs :: Platform -> [GlobalReg]
+allFloatRegs, allDoubleRegs :: Platform -> [GlobalReg]
 allVanillaRegs :: Platform -> [VGcPtr -> GlobalReg]
 allXmmRegs :: Platform -> [Int]
 
 allVanillaRegs platform = map VanillaReg $ regList (pc_MAX_Vanilla_REG (platformConstants platform))
 allFloatRegs   platform = map FloatReg   $ regList (pc_MAX_Float_REG   (platformConstants platform))
 allDoubleRegs  platform = map DoubleReg  $ regList (pc_MAX_Double_REG  (platformConstants platform))
-allLongRegs    platform = map LongReg    $ regList (pc_MAX_Long_REG    (platformConstants platform))
 allXmmRegs     platform =                  regList (pc_MAX_XMM_REG     (platformConstants platform))
 
-realFloatRegs, realDoubleRegs, realLongRegs :: Platform -> [GlobalReg]
+realFloatRegs, realDoubleRegs :: Platform -> [GlobalReg]
 realVanillaRegs :: Platform -> [VGcPtr -> GlobalReg]
 
 realVanillaRegs platform = map VanillaReg $ regList (pc_MAX_Real_Vanilla_REG (platformConstants platform))
 realFloatRegs   platform = map FloatReg   $ regList (pc_MAX_Real_Float_REG   (platformConstants platform))
 realDoubleRegs  platform = map DoubleReg  $ regList (pc_MAX_Real_Double_REG  (platformConstants platform))
-realLongRegs    platform = map LongReg    $ regList (pc_MAX_Real_Long_REG    (platformConstants platform))
 
 realXmmRegNos :: Platform -> [Int]
 realXmmRegNos platform
@@ -192,7 +188,6 @@ allRegs :: Platform -> AvailRegs
 allRegs platform = ( allVanillaRegs platform
                    , allFloatRegs   platform
                    , allDoubleRegs  platform
-                   , allLongRegs    platform
                    , allXmmRegs     platform
                    )
 
@@ -208,7 +203,6 @@ realArgRegsCover :: Platform -> [GlobalReg]
 realArgRegsCover platform
     | passFloatArgsInXmm platform
     = map ($ VGcPtr) (realVanillaRegs platform) ++
-      realLongRegs platform ++
       realDoubleRegs platform -- we only need to save the low Double part of XMM registers.
                               -- Moreover, the NCG can't load/store full XMM
                               -- registers for now...
@@ -216,8 +210,7 @@ realArgRegsCover platform
     | otherwise
     = map ($ VGcPtr) (realVanillaRegs platform) ++
       realFloatRegs  platform ++
-      realDoubleRegs platform ++
-      realLongRegs   platform
+      realDoubleRegs platform
       -- we don't save XMM registers if they are not used for parameter passing
 
 -- Like realArgRegsCover but always includes the node. This covers the real


=====================================
compiler/GHC/Cmm/Lexer.x
=====================================
@@ -103,7 +103,6 @@ $white_no_nl+           ;
   R at decimal             { global_regN (\n -> VanillaReg n VNonGcPtr) }
   F at decimal             { global_regN FloatReg }
   D at decimal             { global_regN DoubleReg }
-  L at decimal             { global_regN LongReg }
   Sp                    { global_reg Sp }
   SpLim                 { global_reg SpLim }
   Hp                    { global_reg Hp }


=====================================
compiler/GHC/Cmm/Reg.hs
=====================================
@@ -142,9 +142,6 @@ data GlobalReg
   | DoubleReg           -- double-precision floating-point registers
         {-# UNPACK #-} !Int     -- its number
 
-  | LongReg             -- long int registers (64-bit, really)
-        {-# UNPACK #-} !Int     -- its number
-
   | XmmReg                      -- 128-bit SIMD vector register
         {-# UNPACK #-} !Int     -- its number
 
@@ -197,7 +194,6 @@ instance Eq GlobalReg where
    VanillaReg i _ == VanillaReg j _ = i==j -- Ignore type when seeking clashes
    FloatReg i == FloatReg j = i==j
    DoubleReg i == DoubleReg j = i==j
-   LongReg i == LongReg j = i==j
    -- NOTE: XMM, YMM, ZMM registers actually are the same registers
    -- at least with respect to store at YMM i and then read from XMM i
    -- and similarly for ZMM etc.
@@ -228,7 +224,6 @@ instance Ord GlobalReg where
      -- Ignore type when seeking clashes
    compare (FloatReg i)  (FloatReg  j) = compare i j
    compare (DoubleReg i) (DoubleReg j) = compare i j
-   compare (LongReg i)   (LongReg   j) = compare i j
    compare (XmmReg i)    (XmmReg    j) = compare i j
    compare (YmmReg i)    (YmmReg    j) = compare i j
    compare (ZmmReg i)    (ZmmReg    j) = compare i j
@@ -253,8 +248,6 @@ instance Ord GlobalReg where
    compare _ (FloatReg _)     = GT
    compare (DoubleReg _) _    = LT
    compare _ (DoubleReg _)    = GT
-   compare (LongReg _) _      = LT
-   compare _ (LongReg _)      = GT
    compare (XmmReg _) _       = LT
    compare _ (XmmReg _)       = GT
    compare (YmmReg _) _       = LT
@@ -305,7 +298,6 @@ pprGlobalReg gr
 --        VanillaReg n VGcPtr    -> char 'P' <> int n
         FloatReg   n   -> char 'F' <> int n
         DoubleReg  n   -> char 'D' <> int n
-        LongReg    n   -> char 'L' <> int n
         XmmReg     n   -> text "XMM" <> int n
         YmmReg     n   -> text "YMM" <> int n
         ZmmReg     n   -> text "ZMM" <> int n
@@ -349,7 +341,6 @@ globalRegType platform = \case
    (VanillaReg _ VNonGcPtr) -> bWord platform
    (FloatReg _)             -> cmmFloat W32
    (DoubleReg _)            -> cmmFloat W64
-   (LongReg _)              -> cmmBits W64
    -- TODO: improve the internal model of SIMD/vectorized registers
    -- the right design SHOULd improve handling of float and double code too.
    -- see remarks in Note [SIMD Design for the future] in GHC.StgToCmm.Prim
@@ -365,7 +356,6 @@ isArgReg :: GlobalReg -> Bool
 isArgReg (VanillaReg {}) = True
 isArgReg (FloatReg {})   = True
 isArgReg (DoubleReg {})  = True
-isArgReg (LongReg {})    = True
 isArgReg (XmmReg {})     = True
 isArgReg (YmmReg {})     = True
 isArgReg (ZmmReg {})     = True


=====================================
compiler/GHC/CmmToC.hs
=====================================
@@ -1126,7 +1126,6 @@ pprGlobalReg gr = case gr of
         --              JMP_(*R1.p);
     FloatReg   n   -> char 'F' <> int n
     DoubleReg  n   -> char 'D' <> int n
-    LongReg    n   -> char 'L' <> int n
     Sp             -> text "Sp"
     SpLim          -> text "SpLim"
     Hp             -> text "Hp"


=====================================
compiler/GHC/CmmToLlvm/Regs.hs
=====================================
@@ -81,7 +81,7 @@ lmGlobalReg platform suf reg
         MachSp         -> wordGlobal $ "MachSp" ++ suf
         _other         -> panic $ "GHC.CmmToLlvm.Reg: GlobalReg (" ++ (show reg)
                                 ++ ") not supported!"
-        -- LongReg, HpLim, CCSS, CurrentTSO, CurrentNusery, HpAlloc
+        -- HpLim, CCSS, CurrentTSO, CurrentNusery, HpAlloc
         -- EagerBlackholeInfo, GCEnter1, GCFun, BaseReg, PicBaseReg
     where
         wordGlobal   name = LMNLocalVar (fsLit name) (llvmWord platform)


=====================================
compiler/GHC/StgToCmm/CgUtils.hs
=====================================
@@ -81,8 +81,6 @@ baseRegOffset platform reg = case reg of
    ZmmReg n             -> panic ("Registers above ZMM6 are not supported (tried to use ZMM" ++ show n ++ ")")
    Sp                   -> pc_OFFSET_StgRegTable_rSp    constants
    SpLim                -> pc_OFFSET_StgRegTable_rSpLim constants
-   LongReg 1            -> pc_OFFSET_StgRegTable_rL1    constants
-   LongReg n            -> panic ("Registers above L1 are not supported (tried to use L" ++ show n ++ ")")
    Hp                   -> pc_OFFSET_StgRegTable_rHp             constants
    HpLim                -> pc_OFFSET_StgRegTable_rHpLim          constants
    CCCS                 -> pc_OFFSET_StgRegTable_rCCCS           constants


=====================================
rts/HeapStackCheck.cmm
=====================================
@@ -338,13 +338,6 @@ stg_gc_d1 return (D_ d)
 }
 
 
-/*-- L1 contains an int64 ------------------------------------------------- */
-
-stg_gc_l1 return (L_ l)
-{
-    jump stg_gc_noregs (stg_ret_l_info, l) ();
-}
-
 /*-- Unboxed tuples with multiple pointers -------------------------------- */
 
 stg_gc_pp return (P_ arg1, P_ arg2)


=====================================
rts/StgMiscClosures.cmm
=====================================
@@ -178,18 +178,6 @@ INFO_TABLE_RET( stg_ctoi_D1, RET_BCO )
     jump stg_yield_to_interpreter [];
 }
 
-/*
- * When the returned value is in L1
- */
-INFO_TABLE_RET( stg_ctoi_L1, RET_BCO )
-    /* explicit stack */
-{
-    Sp_adj(-1) - 8;
-    L_[Sp + WDS(1)] = L1;
-    Sp(0) = stg_ret_l_info;
-    jump stg_yield_to_interpreter [];
-}
-
 /*
  * When the returned value is a void
  */


=====================================
rts/include/stg/MachRegs.h
=====================================
@@ -123,7 +123,6 @@
 #define MAX_REAL_VANILLA_REG 1  /* always, since it defines the entry conv */
 #define MAX_REAL_FLOAT_REG   0
 #define MAX_REAL_DOUBLE_REG  0
-#define MAX_REAL_LONG_REG    0
 #define MAX_REAL_XMM_REG     4
 #define MAX_REAL_YMM_REG     4
 #define MAX_REAL_ZMM_REG     4
@@ -269,7 +268,6 @@ the stack. See Note [Overlapping global registers] for implications.
 #define MAX_REAL_VANILLA_REG 6
 #define MAX_REAL_FLOAT_REG   6
 #define MAX_REAL_DOUBLE_REG  6
-#define MAX_REAL_LONG_REG    0
 #define MAX_REAL_XMM_REG     6
 #define MAX_REAL_YMM_REG     6
 #define MAX_REAL_ZMM_REG     6
@@ -684,14 +682,6 @@ the stack. See Note [Overlapping global registers] for implications.
 #  endif
 #endif
 
-#if !defined(MAX_REAL_LONG_REG)
-#  if   defined(REG_L1)
-#  define MAX_REAL_LONG_REG 1
-#  else
-#  define MAX_REAL_LONG_REG 0
-#  endif
-#endif
-
 #if !defined(MAX_REAL_XMM_REG)
 #  if   defined(REG_XMM6)
 #  define MAX_REAL_XMM_REG 6


=====================================
rts/include/stg/Regs.h
=====================================
@@ -395,12 +395,6 @@ GLOBAL_REG_DECL(StgWord512,ZMM6,REG_ZMM6)
 #define ZMM6 (BaseReg->rZMM6)
 #endif
 
-#if defined(REG_L1) && !defined(NO_GLOBAL_REG_DECLS)
-GLOBAL_REG_DECL(StgWord64,L1,REG_L1)
-#else
-#define L1 (BaseReg->rL1)
-#endif
-
 /*
  * If BaseReg isn't mapped to a machine register, just use the global
  * address of the current register table (CurrentRegTable in


=====================================
utils/deriveConstants/Main.hs
=====================================
@@ -652,7 +652,6 @@ wanteds os = concat
           ,constantWord Haskell "MAX_Real_Float_REG"   "MAX_REAL_FLOAT_REG"
           ,constantWord Haskell "MAX_Real_Double_REG"  "MAX_REAL_DOUBLE_REG"
           ,constantWord Haskell "MAX_Real_XMM_REG"     "MAX_REAL_XMM_REG"
-          ,constantWord Haskell "MAX_Real_Long_REG"    "MAX_REAL_LONG_REG"
 
           -- This tells the native code generator the size of the spill
           -- area it has available.


=====================================
utils/genapply/Main.hs
=====================================
@@ -91,15 +91,13 @@ availableRegs Unregisterised = ([],[],[],[])
 availableRegs Registerised =
   ( vanillaRegs MAX_REAL_VANILLA_REG,
     floatRegs   MAX_REAL_FLOAT_REG,
-    doubleRegs  MAX_REAL_DOUBLE_REG,
-    longRegs    MAX_REAL_LONG_REG
+    doubleRegs  MAX_REAL_DOUBLE_REG
   )
 
-vanillaRegs, floatRegs, doubleRegs, longRegs :: Int -> [Reg]
+vanillaRegs, floatRegs, doubleRegs :: Int -> [Reg]
 vanillaRegs n = [ "R" ++ show m | m <- [2..n] ]  -- never use R1
 floatRegs   n = [ "F" ++ show m | m <- [1..n] ]
 doubleRegs  n = [ "D" ++ show m | m <- [1..n] ]
-longRegs    n = [ "L" ++ show m | m <- [1..n] ]
 
 -- -----------------------------------------------------------------------------
 -- Loading/saving register arguments to the stack



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c183641a14dce754850137ff467b95cb218d30a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c183641a14dce754850137ff467b95cb218d30a
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221018/3766ec15/attachment-0001.html>


More information about the ghc-commits mailing list