Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
Source project has a limited visibility.
  • batterseapower's avatar
    beefc60c
    Refactoring: use a structured CmmStatics type rather than [CmmStatic] · beefc60c
    batterseapower authored
    I observed that the [CmmStatics] within CmmData uses the list in a very stylised way.
    The first item in the list is almost invariably a CmmDataLabel. Many parts of the
    compiler pattern match on this list and fail if this is not true.
    
    This patch makes the invariant explicit by introducing a structured type CmmStatics
    that holds the label and the list of remaining [CmmStatic].
    
    There is one wrinkle: the x86 backend sometimes wants to output an alignment directive just
    before the label. However, this can be easily fixed up by parameterising the native codegen
    over the type of CmmStatics (though the GenCmmTop parameterisation) and using a pair
    (Alignment, CmmStatics) there instead.
    
    As a result, I think we will be able to remove CmmAlign and CmmDataLabel from the CmmStatic
    data type, thus nuking a lot of code and failing pattern matches. This change will come as part
    of my next patch.
    beefc60c
    History
    Refactoring: use a structured CmmStatics type rather than [CmmStatic]
    batterseapower authored
    I observed that the [CmmStatics] within CmmData uses the list in a very stylised way.
    The first item in the list is almost invariably a CmmDataLabel. Many parts of the
    compiler pattern match on this list and fail if this is not true.
    
    This patch makes the invariant explicit by introducing a structured type CmmStatics
    that holds the label and the list of remaining [CmmStatic].
    
    There is one wrinkle: the x86 backend sometimes wants to output an alignment directive just
    before the label. However, this can be easily fixed up by parameterising the native codegen
    over the type of CmmStatics (though the GenCmmTop parameterisation) and using a pair
    (Alignment, CmmStatics) there instead.
    
    As a result, I think we will be able to remove CmmAlign and CmmDataLabel from the CmmStatic
    data type, thus nuking a lot of code and failing pattern matches. This change will come as part
    of my next patch.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.