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

Improve #9399 using additions from #9408 #9427

Merged
merged 19 commits into from
Sep 25, 2022
Merged

Conversation

mahge
Copy link
Contributor

@mahge mahge commented Sep 25, 2022

This improves the fix for #8591 (done in #9399) using the additional information from the NF provided by #9408.

After these changes, the NF will generate the additional external conversion code only when it is needed. The OF will still cause generation of unnecessary code. However, it is minimal or none for MetaModelica usage. For Modelica usage it generates more but is not supposed to be used for that purpose anymore. It only affects some tests in the test suite that still use the OF for now.


  - Use a map (string, record Declaration) to keep a track of records in
    the SimCode. This allows for a simpler and quicker check. In addition
    we can update entries easily.
  - See what fails in the testsuite.
  - It was actually affecting some tests because nested records were cycling
    back and messing with the order. Not exactly sure how but is not
    relevant anymore.
  - Remove returned lists from functions:
     elaborateNestedRecordDeclarations
     elaborateRecordDeclarationsFromTypes
     elaborateRecordDeclarationsForRecord
     elaborateNestedRecordDeclarations

  - Remove input lists from functions:
    - elaborateRecordDeclarationsFromTypes
  - If an entry already exists in the map and we always update, then there
    is a chance we might overwrite a 'true' value with a 'false' value
    for external conversion marker.

    Check if the entry exists and if it is marked false while then new
    incoming entry is marked true, then update it. Otherwise do nothing.
  - Remove input lists from functions:
    - elaborateNestedRecordDeclarations
    - elaborateRecordDeclarationsForRecord
  - Removed from
    - elaborateRecordDeclarationsForMetarecords
  - Remove input and output lists from functions:
    - elaborateFunctions2
    - elaborateFunction
  - Recursive functions converted to loops:
    - elaborateNestedRecordDeclarations
    - elaborateRecordDeclarationsForMetarecords
    - elaborateRecordDeclarationsFromTypes
  - elaborateRecordDeclarationsForMetarecords -> collectRecDeclsFromMetaRecordCallExps
  - elaborateNestedRecordDeclarations -> collectRecDeclsFromTypesVars
  - elaborateRecordDeclarationsFromTypes -> collectRecDeclsFromTypes
  - elaborateRecordDeclarationsForRecord -> collectRecDeclsFromType
  - Instead of:
    - traversing all expressions, collecting all meta record calls to a list,
      and then traversing this list to collect record declarations

    - collect record declarations while traversing all expressions (without
      collecting metarecordcalls into a whole new list.)
  - elaborateRecordDeclarations -> collectRecDeclsFromElems
  - Convert recursive functions to loops:
    - collectRecDeclsFromElems (used to be `elaborateRecordDeclarations`)
  - declMap -> recDeclsMap
  - needsExternalConversion -> usedExternally
@mahge mahge added COMP/OMC/SimCode COMP/OMC/Codegen Issue and pull request related to Code generation labels Sep 25, 2022
@mahge mahge self-assigned this Sep 25, 2022
@mahge mahge enabled auto-merge (squash) September 25, 2022 12:01
@mahge mahge merged commit eb5e7e0 into OpenModelica:master Sep 25, 2022
@mahge mahge deleted the ticket_8591 branch September 25, 2022 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP/OMC/Codegen Issue and pull request related to Code generation COMP/OMC/SimCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

State record with integer variable is not handled correctly in external function
1 participant