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

Add csyntaxgen tool for exporting CompCert C (Csyntax) AST as .v file #404

Closed
wants to merge 4 commits into from

Conversation

btj
Copy link
Contributor

@btj btj commented Jul 30, 2021

Adds the csyntaxgen tool, which takes a .c file and exports the CompCert C AST (as defined in Csyntax.v) to a .v file.

Produced by copy-pasting and adapting the exportclight and tests/clightgen directories. I left these steps as separate commits to ease reviewing; of course, these should be squashed.

Motivation

The Clight AST, as exported by the clightgen tool, is most appropriate when a human user needs to directly interact with the AST, such as when using the Verified Software Toolchain. For certain other use cases, however, the CompCert C AST may be more appropriate.

Specifically, we want to prove soundness of CH2O with respect to CompCert C, and then obtain theorems about CompCert-compiled assembly code by first verifying the .c program using our VeriFast verification tool, which will eventually emit a Coq proof of correctness with respect to CH2O, and then porting this correctness statement to CompCert C using the soundness theorem, and then applying the CompCert correctness proof.

The CH2O-CompCert soundness theorem will be based on a relation linking a CH2O Core C program to a corresponding CompCert C program. This relation is easier to define between CH2O Core C and CompCert C than between CH2O Core C and Clight, and easier to prove for the CH2O Core C AST generated from a .c file and the CompCert C AST generated from that .c file, because CompCert C is closer to the source code (and closer to CH2O Core C) than Clight.

In any case, we want to prove soundness of CH2O with respect to CompCert C, not Clight, because the former is a stronger statement.

@xavierleroy
Copy link
Contributor

Thank you @btj for this code! I agree it's good to have tools to support working with the CompCert C AST. I'll review and get back to you later this month.

xavierleroy added a commit that referenced this pull request Sep 17, 2021
As proposed in #404.

The tool is called `cexport` and has two modes,
- `cexport -clight` producing Clight AST, like the old `clightgen`
- `cexport -csyntax`, producing Csyntax AST, using code from #404.
xavierleroy added a commit that referenced this pull request Sep 22, 2021
As proposed in #404.

This is presented as a new option `-clight` to the existing `clightgen` tool.

Revise clightgen testing to test the Csyntax output in addition to
the Clight output.
xavierleroy added a commit that referenced this pull request Sep 22, 2021
As proposed in #404.

This is presented as a new option `-clight` to the existing `clightgen` tool.

Revise clightgen testing to test the Csyntax output in addition to
the Clight output.
@xavierleroy
Copy link
Contributor

PR #413 takes this PR and shares more of the code with clightgen. #413 was merged, so I'm closing this PR. Thanks for the suggestion and for the code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants