HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.CmmToAsm.Reg.Graph.Base

Utils for calculating general worst, bound, squeese and free, functions.

as per: "A Generalized Algorithm for Graph-Coloring Register Allocation" Michael Smith, Normal Ramsey, Glenn Holloway. PLDI 2004

These general versions are not used in GHC proper because they are too slow. Instead, hand written optimised versions are provided for each architecture in MachRegs*.hs

This code is here because we can test the architecture specific code against it.

  • 3 types
  • 3 values
  • Packageghc-9.10.3
  • Exports6
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceBase.hs
datadata Reg
#

A register of some class

Instances3Eq, Show, Uniquable
  • Eq RegDefined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Graph.Base
  • Show RegDefined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Graph.Base
  • Uniquable RegDefined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Graph.Base

    so we can put regs in UniqSets

datadata RegSub
#

A subcomponent of another register

Instances4Enum, Eq, Ord, Show
  • Enum RegSubDefined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Graph.Base
  • Eq RegSubDefined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Graph.Base
  • Ord RegSubDefined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Graph.Base
  • Show RegSubDefined in ghc-9.10.3 · GHC.CmmToAsm.Reg.Graph.Base

Worst case displacement

a node N of classN has some number of neighbors, all of which are from classC.

(worst neighbors classN classC) is the maximum number of potential colors for N that can be lost by coloring its neighbors.

This should be hand coded/cached for each particular architecture, because the compute time is very long..

valuesqueese
  1. :: RegClass -> UniqSet Reg
  2. -> Reg -> UniqSet Reg
  3. -> RegClass
  4. -> [(Int, RegClass)]
  5. -> Int
#

The total squeese on a particular node with a list of neighbors.

A version of this should be constructed for each particular architecture, possibly including uses of bound, so that aliased registers don't get counted twice, as per the paper.