Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading Cmm chapter #98

Open
doyougnu opened this issue Jan 3, 2024 · 8 comments
Open

Reading Cmm chapter #98

doyougnu opened this issue Jan 3, 2024 · 8 comments

Comments

@doyougnu
Copy link
Collaborator

doyougnu commented Jan 3, 2024

We shall document the language once and for all!

@ulysses4ever
Copy link
Contributor

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

@doyougnu
Copy link
Collaborator Author

doyougnu commented Jan 4, 2024

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
Copy link
Contributor

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
Copy link
Collaborator Author

Some References:

@doyougnu
Copy link
Collaborator Author

doyougnu commented Feb 5, 2024

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

@doyougnu
Copy link
Collaborator Author

this paper as well: https://simonmar.github.io/bib/papers/ptr-tagging.pdf

which I used in the memory footprint chapter to track the calls to a static top level pair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To do
Development

No branches or pull requests

2 participants