-
Notifications
You must be signed in to change notification settings - Fork 404
[MooreToCore] [4/4] Add support for class.property_ref #9153
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
[MooreToCore] [4/4] Add support for class.property_ref #9153
Conversation
a1530a2 to
cd6bf84
Compare
fabianschuiki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! We'll need to think about how we are going to deal with that !llvm.ptr vs !llhd.ref<T> type mismatch. The !llhd.ref<T> expects to point to a signal that can then be used with llhd.prb and llhd.drv. Since classes are just bits of memory on the heap, that doesn't really work. Not sure how to reconcile this. Maybe we need a special !moore.ref type that is a pointer and can't be used with delayed and non-blocking assigns, which we could lower to !llvm.ptr 🤔
I think the problem is mainly difficult for LValue accesses. I think we can add another operator for RValues in Moore (property_value?) to just return |
cd6bf84 to
c553181
Compare
Add a conversion pattern to translate `moore.class.property_ref` into an
LLVM `gep` over the identified class struct, bridging the resulting pointer
back to `!llhd.ref<…>` via `unrealized_conversion_cast`.
- Implement `ClassPropertyRefOpConversion`:
- Validates result lowers to `!llhd.ref<T>`.
- Ensures instance is `!llvm.ptr` (opaque ptr mode).
- Resolves the class’s identified struct and per-field GEP path via
`ClassTypeCache`.
- Emits `llvm.getelementptr` with cached indices and wraps back to ref.
- Register the pattern in `populateOpConversion`.
- Tests:
- Extend `classes.mlir` to verify that `property_ref` lowers to GEP.
c553181 to
e7fcd95
Compare
|
I think the problem is that |
Add a conversion pattern to translate
moore.class.property_refinto an LLVMgepover the identified class struct, bridging the resulting pointer back to!llhd.ref<…>viaunrealized_conversion_cast.ClassPropertyRefOpConversion:!llhd.ref<T>.!llvm.ptr.ClassTypeCache.llvm.getelementptrwith cached indices and wraps back to ref.populateOpConversion.classes.mlirto verify thatproperty_reflowers to GEP.