-
Notifications
You must be signed in to change notification settings - Fork 70
copilot-c99
: Allow multiple triggers with the same name. Refs #296.
#572
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
Merged
ivanperez-keera
merged 6 commits into
Copilot-Language:master
from
fdedden:develop-multiple-triggers
Jan 3, 2025
Merged
copilot-c99
: Allow multiple triggers with the same name. Refs #296.
#572
ivanperez-keera
merged 6 commits into
Copilot-Language:master
from
fdedden:develop-multiple-triggers
Jan 3, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copilot-c99
: Allow multiple triggers with the same name. Refs #296.
Change Manager: Can you please:
streams = specStreams spec
triggers = specTriggers spec
+ uniqueTriggers = mkUniqueTriggers triggers
exts = gatherExts streams triggers
|
304313c
to
442d842
Compare
Change Manager: Can you please modify the |
…uage#296. The current implementation of Copilot does not allow using the same trigger handler name multiple times, since the C99 backend produces multiple repeated declarations, which is invalid. Consequently, the code generator assumes that trigger names are unique. To allow for multiple triggers that trigger the same handler, we need to introduce a separate construct in triggers that acts as a unique identifier. This commit introduces an internal datatype to represent a `Trigger` with a unique name that is different from that of the function called when triggered.
…uage#296. The current implementation of Copilot does not allow using the same trigger handler name multiple times, since the C99 backend produces multiple repeated declarations, which is invalid. A prior commit has introduced a representation of triggers with unique IDs, allowing us to distinguish between a monitor for one condition within a Copilot spec vs the external C function being called when the condition becomes true. This commit updates the generation of the `step` function to use unique names for the triggers.
…gers. Refs Copilot-Language#296. The current implementation of Copilot does not allow using the same trigger handler name multiple times, since the C99 backend produces multiple repeated declarations, which is invalid. Prior commits have introduced a representation of triggers with unique IDs (allowing us to distinguish between a monitor for one condition within a Copilot spec vs the external C function being called when the condition becomes true), and have adapted low-level functions accordingly. This commit adapts the top-level compilation functions in the same way, by generating trigger guards and argument functions using the unique names.
…opilot-Language#296. The current implementation of Copilot's C99 backend produces multiple repeated declarations when the same trigger is used multiple times, which is invalid C code. This commit modifies the code that generates the header file to prevent the same trigger from being declared multiple times.
…anguage#296. The current implementation of Copilot does not allow using the same trigger handler name multiple times, since the C99 backend produces multiple repeated declarations, which is invalid. Prior commits have modified the C99 backend to now allow for multiple triggers with the same handler. However, the resulting code is only valid in C if the triggers always have the same type signatures, since C does not support polymorphism. This commit adds a check to the compilation step to ensure that triggers used multiple times are always used with the same types (and, consequently, the same arity).
442d842
to
1d38949
Compare
Implementor: Fix implemented, review requested. |
Change Manager: Verified that:
|
RyanGlScott
added a commit
to Copilot-Language/copilot-bluespec
that referenced
this pull request
Jan 20, 2025
`copilot-c99-4.2` (part of the overall Copilot 4.2 release) now allows multiple triggers with the same handler, provided that the triggers always have the same type signatures. See Copilot-Language/copilot#296 (as well as the fix in Copilot-Language/copilot#572). Since `copilot-bluespec` wishes to achieve feature parity with `copilot-c99`, we would like to add this ability to `copilot-bluespec` as well. This commit adds multiple triggers support for `copilot-bluespec`, piggybacking off of the implementation in Copilot-Language/copilot#572.
RyanGlScott
added a commit
to Copilot-Language/copilot-verifier
that referenced
this pull request
Jan 20, 2025
Although `copilot-c99` added the ability to invoke multiple triggers with the same name in Copilot-Language/copilot#572, it is not yet clear how best to support this in `copilot-verifier`. In the meantime, this adds an explicit check that rules out specifications that use multiple triggers with the same name to prevent the verifier from becoming confused by them. The remaining task of fully supporting such specifications is tracked in #74.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extends the C99 backend to allow multiple references to the same trigger:
Note that the guards may overlap, which will mean the trigger is called twice in that iteration.
As C99 does not allow multiple function definitions sharing the same name, we can only allow a single type per trigger function. The following is explicitly disallowed by the backend:
Upon compilation, the user gets an error message:
Feel free to make any modification necessary to my commits.