-
Notifications
You must be signed in to change notification settings - Fork 88
Add asm goto support
#2067
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
base: master
Are you sure you want to change the base?
Add asm goto support
#2067
Changes from all commits
d73ecf4
01710da
ef4680c
ad5bcec
a5d230d
0c878ce
dfd3783
3683736
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -380,11 +380,25 @@ class patchLabelsGotosVisitor(newtarget) = object | |
| inherit nopCilVisitor | ||
|
|
||
| method! vstmt s = | ||
| (* TODO: why sometimes SkipChildren? *) | ||
| match s.skind with | ||
| | Goto (target,loc) -> | ||
| (match newtarget !target with | ||
| | None -> SkipChildren | ||
| | Some nt -> s.skind <- Goto (ref nt, loc); DoChildren) | ||
| | Asm a -> | ||
| let (changed, gotos') = List.fold_left_map (fun acc target -> | ||
| match newtarget !target with | ||
| | None -> (acc, target) (* TODO: need to copy target ref as well? *) | ||
| | Some nt -> (true, ref nt) | ||
| ) false a.gotos | ||
| in | ||
| if changed then ( | ||
| s.skind <- Asm {a with gotos = gotos'}; | ||
| DoChildren | ||
| ) | ||
| else | ||
| SkipChildren | ||
|
Comment on lines
+389
to
+401
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wondered about this too and that's why I left the TODO. It wasn't clear to me whether the sharing of I then tried to just remove the If that's the case, it'd be useful to have private mutability (which sadly doesn't exist): https://discuss.ocaml.org/t/mutable-fields-of-private-records/18213.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth turning into an issue and solving separately.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure there's really any issue to fix here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about your comments to limit mutability. |
||
| | _ -> DoChildren | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // CRAM | ||
|
|
||
| int main() | ||
| { | ||
| int x; | ||
| while (1) { | ||
| asm goto ( | ||
| "nop" | ||
| : | ||
| : | ||
| : | ||
| : label1, label2 | ||
| ); | ||
| x = 0; | ||
| continue; | ||
| label1: | ||
| x = 1; | ||
| } | ||
| return 0; | ||
| label2: | ||
| return 1; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.