haskellfoundation / hs-opt-handbook.github.io

The Haskell Optimization Handbook
https://haskell.foundation/hs-opt-handbook.github.io/
Creative Commons Attribution 4.0 International
169 stars 12 forks source link

Reading Cmm chapter #98

Open doyougnu opened 6 months ago

doyougnu commented 6 months ago

We shall document the language once and for all!

ulysses4ever commented 6 months ago

The Wikipedia page is surprisingly informative with a bunch of further references:

doyougnu commented 6 months ago

Thank you for the reference! But I believe that the Cmm generated by GHC has diverged from the standard. Although I'll have to verify that claim to be sure.

ulysses4ever commented 6 months ago

I believe that the Cmm generated by GHC has diverged from the standard

The Wikipedia article does acknowledge this:

There are two main branches:

doyougnu commented 6 months ago

Some References:

doyougnu commented 5 months ago

This note in the Cmm.Info.Build for cafAnal and the constructing SRTs:


-- |
-- The label of a CAFfy thing.
--
-- Labels that come from 'cafAnal' can be:
--   - @_closure@ labels for static functions, static data constructor
--     applications, or static thunks
--   - @_info@ labels for dynamic functions, thunks, or continuations
--   - @_entry@ labels for functions or thunks
--
doyougnu commented 5 months ago

and this data type:

-- | What type of Cmm label we're dealing with.
--      Determines the suffix appended to the name when a CLabel.CmmLabel
--      is pretty printed.
data CmmLabelInfo
  = CmmInfo                     -- ^ misc rts info tables,      suffix _info
  | CmmEntry                    -- ^ misc rts entry points,     suffix _entry
  | CmmRetInfo                  -- ^ misc rts ret info tables,  suffix _info
  | CmmRet                      -- ^ misc rts return points,    suffix _ret
  | CmmData                     -- ^ misc rts data bits, eg CHARLIKE_closure
  | CmmCode                     -- ^ misc rts code
  | CmmClosure                  -- ^ closures eg CHARLIKE_closure
  | CmmPrimCall                 -- ^ a prim call to some hand written Cmm code
  deriving (Eq, Ord)
doyougnu commented 5 months ago

and this note:

-----------------------------------------------------------------------------
-- Printing out CLabels.

{-
Convention:

      <name>_<type>

where <name> is <Module>_<name> for external names and <unique> for
internal names. <type> is one of the following:

         info                   Info table
         srt                    Static reference table
         entry                  Entry code (function, closure)
         slow                   Slow entry code (if any)
         ret                    Direct return address
         vtbl                   Vector table
         <n>_alt                Case alternative (tag n)
         dflt                   Default case alternative
         btm                    Large bitmap vector
         closure                Static closure
         con_entry              Dynamic Constructor entry code
         con_info               Dynamic Constructor info table
         static_entry           Static Constructor entry code
         static_info            Static Constructor info table
         sel_info               Selector info table
         sel_entry              Selector entry code
         cc                     Cost centre
         ccs                    Cost centre stack