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

Intermediate representation for sessions #1204

Closed
4 tasks
treiher opened this issue Sep 27, 2022 · 1 comment
Closed
4 tasks

Intermediate representation for sessions #1204

treiher opened this issue Sep 27, 2022 · 1 comment
Assignees

Comments

@treiher
Copy link
Collaborator

treiher commented Sep 27, 2022

Research

Concepts

Languages

Design

Approach

Specification ⇾ Model ⤵
                     Intermediate Representation ⇾ SPARK Model ⇾ SPARK Code
          Integration ⤴

Objectives

  • Represent actions of session states
  • Enable static analysis / verification of session model
    • Take into account
      • Contracts of states
      • Contracts of functions
      • Type constraints
      • Buffer sizes defined in integration file
    • Prove absence of runtime errors (e.g., integer overflows)
    • Enable mapping of issues in the intermediate representation back to the specification
  • Enable code generation for various languages (at least SPARK and C)
  • Prevent unnecessary checks in generated code

Instructions

  • Assignment (TAC, maybe also SSA?)
    • Variable
    • Literal
    • Mathematical expression (add, sub, mul, div, pow, mod)
    • Boolean expression (and, or)
    • Relation (lt, le, eq, ge, gt, ne)
    • Quantified expression (for all, for some)
    • Call expression
      • Variable
      • Constant
      • Literal
  • Assertion
    • Boolean expression

Convertion from Model to IR

  1. Transform state actions into TAC format
  2. Transform model statements into IR instructions
  3. Infer and add assertions (e.g., preconditions of calls, checks to prevent overflows)

Mapping from Model to IR

Statements

Model Statement IR
VariableAssignment Assignment
MessageFieldAssignment Call?
Reset Call?
Append Call?
Extend Call?
Read Call?
Write Call?

Expressions (in VariableAssignment)

Model (in TAC format) IR
T := X T:= X
T := not X T := not X
T := X and Y T := X and Y
(Other boolean expressions) (Direct mapping)
(Mathematical expressions) (Direct mapping)
(Relations) (Direct mapping)
(Quantified expressions) (Direct mapping)
T := X'Size T := Type_Specific_Size_Func (X)
(Other attributes) (Equivalent mapping to call)
T := M.F T := Message_Type_Specific_Field_Func (M)
T := F (X, Y) (Direct mapping)
T := (1, 2, 3) (Direct mapping)
T := "FOO" (Direct mapping)
T := [for I in S if C => I.X] (Direct mapping or call)
T := M'(F1 => X, F2 => Y) (Direct mapping or call)
(Binding) (INVALID)

Implementation

  • Create class hierarchy for IR
    • Separate session, statement, and expression classes
    • Comply with TAC
    • Generation of VCs for state actions #861
      • Enable determining preconditions for mathematical and boolean expressions (to enable detection and prevention of runtime errors)
      • Enable representation of preconditions and postconditions of function calls (e.g., for reading or setting message fields)
  • Create transformation from existing session model to IR
  • Adapt SPARK code generator to IR
  • Create simple C code generator
@treiher treiher added the architectural decision Discussion of design decision label Sep 27, 2022
@treiher treiher self-assigned this Sep 27, 2022
@treiher treiher added this to To do in RecordFlux 0.7 via automation Sep 27, 2022
@treiher treiher moved this from To do to Design in RecordFlux 0.7 Sep 27, 2022
@treiher treiher removed the architectural decision Discussion of design decision label Sep 27, 2022
@treiher treiher removed this from Design in RecordFlux 0.7 Sep 29, 2022
@treiher treiher added this to To do in RecordFlux 0.7.1 via automation Sep 29, 2022
@treiher treiher moved this from To do to Design in RecordFlux 0.7.1 Oct 10, 2022
@senier senier removed this from Design in RecordFlux 0.7.1 Nov 1, 2022
@senier senier added this to To do in RecordFlux 0.8 via automation Nov 1, 2022
@senier senier moved this from To do to Design in RecordFlux 0.8 Nov 1, 2022
treiher added a commit that referenced this issue Nov 3, 2022
@treiher treiher removed this from Design in RecordFlux 0.8 Nov 4, 2022
@treiher treiher added this to Medium in RecordFlux Future via automation Nov 4, 2022
@treiher treiher moved this from Medium to High in RecordFlux Future Nov 4, 2022
treiher added a commit that referenced this issue Nov 4, 2022
treiher added a commit that referenced this issue Nov 4, 2022
treiher added a commit that referenced this issue Nov 4, 2022
@senier senier removed this from High in RecordFlux Future Nov 29, 2022
@senier senier added this to To do in RecordFlux 2023-01-06 via automation Nov 29, 2022
@treiher treiher moved this from To do to Implementation in RecordFlux 2023-01-06 Nov 30, 2022
@senier senier removed this from Implementation in RecordFlux 2023-01-06 Jan 3, 2023
@senier senier added this to To do in RecordFlux 2023-02-24 via automation Jan 3, 2023
@senier senier moved this from To do to In progress in RecordFlux 2023-02-24 Jan 3, 2023
@jklmnn jklmnn mentioned this issue Jan 11, 2023
2 tasks
@treiher treiher removed their assignment Apr 25, 2023
@treiher treiher self-assigned this Aug 21, 2023
@treiher
Copy link
Collaborator Author

treiher commented Aug 21, 2023

Added in version 0.12.0.

@treiher treiher closed this as completed Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

1 participant