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

Generate kore from c translation semantics #378

Merged
merged 46 commits into from May 17, 2019
Merged

Generate kore from c translation semantics #378

merged 46 commits into from May 17, 2019

Conversation

dwightguth
Copy link
Member

Parses, compiles, emits kore, and validates the C translation semantics. Does not yet work with linking semantics, c++ translation semantics, or execution semantics. Does not yet successfully generate a decision tree.

@dwightguth dwightguth marked this pull request as ready for review May 16, 2019 23:22
Copy link
Contributor

@h0nzZik h0nzZik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C++ part looks good.

@@ -546,8 +546,10 @@ syntax Stmt ::= Defaulted(SpecialMemberFunction, Class) [klabel(DefaultedSMF)]
<initializers>... X |-> (T |-> I::Init) ...</initializers>
requires isDeletedDefaultConstructor(X, T, C, FuncT, VM, I)

syntax KItem ::= "dotInit"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we cannot have .Init?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, it just didn't occur to me. I'll change it.

Copy link
Member

@chathhorn chathhorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

| SimplePointerType
| SimpleStructType
| SimpleUnionType
| SimpleFunctionType
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can lines 172-176 (in the changed file) just be removed now?


// assignment expression
rule typeof(Lbl:KLabel(t(_, Mods::Set, T::SimpleType),_) => t(noQuals, Mods, T))
requires isAssignmentKLabel(#klabel(Lbl))
rule typeof(assignmentOp(t(_, Mods::Set, T::SimpleType),_) => t(noQuals, Mods, T))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a little unfortunate that macros in the LHS like this look just like any other constructor. I wonder if we shouldn't come up with some convention for macro naming that makes what's going on here a little more clear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we made a change like this separately. I'd also rather we get all of my existing code that I have in my branches merged before making such an involved refactoring. But if you want, I can add this to my list of things to do once I get the linking semantics to parse with llvm.

rule nativeDefinedBuiltins => #nativeDefinedBuiltins()

// defined as a K rule for if the hook is not defined
rule #nativeDefinedBuiltins() => .Map
rule [[ #nativeDefinedBuiltins() => .Map ]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the meaning of the [[ ]] here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says that #nativeDefinedBuiltins() rewrites to .Map if we match the pattern after it (in this case it will always match because it's just matching on <k> _ </k>. The reason for this is to make it so that the entire configuration is passed as one of the arguments to the hook.

@@ -81,8 +81,81 @@ module COMPAT-SYNTAX

endmodule

module COMPAT-KAST [kast]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the [kast] here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so this module is not imported on the llvm backend.

@dwightguth dwightguth merged commit 3c44df1 into master May 17, 2019
@dwightguth dwightguth deleted the parser branch May 17, 2019 18:43
h0nzZik pushed a commit to h0nzZik/c-semantics that referenced this pull request May 20, 2019
* minor fixes for parsing issues

* remove explicit use of klabels

* remove use of makeEmptyArray

* ensure terms have least sort

* fix return types

* remove fresh var in function

* fix imports

* fix kseq in map

* fix impure function

* put functions with klabels in [kast] module

* Expression => KItem

* update k submodule

* fix map lookup of bottom

* more fixes for functions that return K

* make a few constructs take kseq as argument

* another fix for impure function

* fix imports of kast module

* a few more fixes for badly typed ksequences

* fix a few bad outer casts

* fix isOpaque check

* fix bug where we called type() on variadic

* tmp: update k submodule

* update k submodule

* more parsing fixes

* fix some more parser errors with latest version of k

* fix nested choices

* fix unbound var on rhs

* update k submodule

* fix another parser error from merged code

* update k submodule

* fix withConfig

* fix syntax

* update k submodule

* update k submodule

* update k submodule

* add back linc function in C

* fix jan's comments

* fix chris's comment
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

3 participants