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

Refactor class/type lowering, add static calls #312

Merged
merged 5 commits into from Oct 12, 2020

Conversation

rengolin
Copy link
Contributor

@rengolin rengolin commented Oct 9, 2020

This is a massive change, but it's one that moves towards simpler code
and IR. The main changes are:

  1. There are no special types any more

Integer, float, bool are all "classes" and they get casted to whatever
needed for arguments and return values. All numeric types will be coded
like classes with dynamic calls in the future, so that fits better with
the model.

Lowering of native arithmetic will be done when lowering to LLVM, with
special lowering for known patterns.

  1. The DescriptorType was created

That's a handler to a class for static calls. Unlike dynamic calls, we
don't have an object to infer what the type is, so we create this type
that will hold a (global, unique) handler to lower a call in the same
way as dynamic calls, but with that handler instead of an object.

  1. Two new operations were created: Call and Static

Call implements both dynamic and static calls, by taking the handlers
(descriptor or object) and call a method by name and arguments.

Static gets the descriptor of a type, to be able to call its static
methods.

  1. Add qualifiers to functions as attributes

We should start annotating our nodes with the extra information that
comes from the AST and the difference between static and dynamic
calls is an important one.

The implementation is not limited to it, but so far, we only have examples
to that one.

  1. Added comments to the remaining types (VeronaTypes.h)

Please check to make sure my comments are accurate.

Fixes #280

Adding qualifiers as an MLIR attribute to function declarations.
This is a massive change, but it's one that moves towards simpler code
and IR. The main changes are:

1. There are no special types any more

Integer, float, bool are all "classes" and they get casted to whatever
needed for arguments and return values. All numeric types will be coded
like classes with dynamic calls in the future, so that fits better with
the model.

Lowering of native arithmetic will be done when lowering to LLVM, with
special lowering for known patterns.

2. The DescriptorType was created

That's a handler to a class for static calls. Unlike dynamic calls, we
don't have an object to infer what the type is, so we create this type
that will hold a (global, unique) handler to lower a call in the same
way as dynamic calls, but with that handler instead of an object.

3. Two new operations were created: Call and Static

Call implements both dynamic and static calls, by taking the handlers
(descriptor or object) and call a method by name and arguments.

Static gets the descriptor of a type, to be able to call its static
methods.
Copy link
Contributor

@davidchisnall davidchisnall left a comment

Choose a reason for hiding this comment

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

Some minor nits, nothing that should block a merge. This looks like a big improvement and will make it fairly trivial to support things like U27 as storage-only types and U32 as types with operations defined on them.

There are a few bits where the terminology in the compiler appears to be diverging from the terminology in the language, we should try to unify those.

src/mlir/dialect/VeronaTypes.cc Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Outdated Show resolved Hide resolved
src/mlir/generator.cc Show resolved Hide resolved
src/mlir/generator.cc Outdated Show resolved Hide resolved
src/mlir/generator.cc Outdated Show resolved Hide resolved
 - Clean up some misleading comments
 - Only add function attributes if non-empy
src/mlir/dialect/VeronaTypes.cc Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.cc Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.cc Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.cc Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Show resolved Hide resolved
src/mlir/dialect/VeronaOps.td Outdated Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Outdated Show resolved Hide resolved
}

UnknownType UnknownType::get(MLIRContext* ctx)
Type StaticClassType::getTypes() const
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be in the plural form.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, I'll fix it.

src/mlir/dialect/VeronaTypes.cc Show resolved Hide resolved
src/mlir/dialect/VeronaTypes.h Show resolved Hide resolved
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.

Lower class to class types
3 participants