Skip to content

Conversation

@Scheremo
Copy link
Contributor

  • Add getOrCreateMalloc to declare llvm.func @malloc(i64) -> !llvm.ptr (opaque ptr).
  • Implement ClassNewOpConversion:
    • Resolve class struct body, compute size via DataLayout, call malloc.
    • Replace moore.class.new with result of malloc (no cast in opaque-ptr mode).
  • Make base-class struct resolution lazy:
    • If a base’s struct isn’t finalized, resolve it on demand.
    • Add overload resolveClassStructBody(ModuleOp, SymbolRefAttr, ...).
  • Register new conversion pattern in populateOpConversion.

@Scheremo Scheremo changed the title [MooreToCore] Add support to lower ClassNewOp to llvm.malloc [MooreToCore] [2/2]Add support to lower ClassNewOp to llvm.malloc Oct 29, 2025
@Scheremo Scheremo changed the title [MooreToCore] [2/2]Add support to lower ClassNewOp to llvm.malloc [MooreToCore] [2/2] Add support to lower ClassNewOp to llvm.malloc Oct 29, 2025
@Scheremo Scheremo force-pushed the pr-moore-classes-newop-lowering branch 2 times, most recently from ed1c6b4 to 2a6b8d1 Compare October 29, 2025 13:31
@Scheremo Scheremo changed the title [MooreToCore] [2/2] Add support to lower ClassNewOp to llvm.malloc [MooreToCore] [3/3] Add support to lower ClassNewOp to llvm.malloc Oct 29, 2025
@Scheremo Scheremo changed the title [MooreToCore] [3/3] Add support to lower ClassNewOp to llvm.malloc [MooreToCore] [2/3] Add support to lower ClassNewOp to llvm.malloc Oct 29, 2025
@Scheremo Scheremo force-pushed the pr-moore-classes-newop-lowering branch from 2a6b8d1 to d673e07 Compare October 29, 2025 14:24
@Scheremo Scheremo changed the title [MooreToCore] [2/3] Add support to lower ClassNewOp to llvm.malloc [MooreToCore] [2/4] Add support to lower ClassNewOp to llvm.malloc Oct 29, 2025
@Scheremo Scheremo force-pushed the pr-moore-classes-newop-lowering branch 2 times, most recently from f896394 to c26734d Compare October 30, 2025 07:50
@Scheremo Scheremo marked this pull request as ready for review October 30, 2025 10:47
@Scheremo Scheremo force-pushed the pr-moore-classes-newop-lowering branch 6 times, most recently from d505495 to 9da5c15 Compare October 31, 2025 08:43
Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! Just a minor nit on being too defensive with symbol resolution -- not sure if that is part of a previous PR or this one here.

@Scheremo Scheremo force-pushed the pr-moore-classes-newop-lowering branch from 9da5c15 to 3f39b9e Compare November 2, 2025 12:13
- Add `getOrCreateMalloc` to declare `llvm.func @malloc(i64) -> !llvm.ptr` (opaque ptr).
- Implement `ClassNewOpConversion`:
  - Resolve class struct body, compute size via `DataLayout`, call `malloc`.
  - Replace `moore.class.new` with result of `malloc` (no cast in opaque-ptr mode).
- Make base-class struct resolution lazy:
  - If a base’s struct isn’t finalized, resolve it on demand.
  - Add overload `resolveClassStructBody(ModuleOp, SymbolRefAttr, ...)`.
- Register new conversion pattern in `populateOpConversion`.
@Scheremo Scheremo force-pushed the pr-moore-classes-newop-lowering branch from 9ebfa95 to 527e76d Compare November 2, 2025 12:49
@Scheremo Scheremo merged commit 4096f57 into llvm:main Nov 2, 2025
7 checks passed
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.

2 participants