add codegen plugin support for special functions #24

Closed
opened 2021-09-24 13:31:26 +08:00 by sb10q · 9 comments

This is to enable the implementation of now_mu(), at_mu() and delay_mu() on RISC-V ARTIQ core devices, which use now-pinning.
Ideally nac3embedded would emit the LLVM IR for those functions.

This is low priority because we can use Zynq in the meantime, where those functions are regular syscalls.

This is to enable the implementation of ``now_mu()``, ``at_mu()`` and ``delay_mu()`` on RISC-V ARTIQ core devices, which use now-pinning. Ideally nac3embedded would emit the LLVM IR for those functions. This is low priority because we can use Zynq in the meantime, where those functions are regular syscalls.
sb10q added the
low-priority
label 2021-09-24 13:31:26 +08:00

Maybe we can mark certain definition IDs as special, and delegate the codegen of them to a special callback?

@ychenfo Is it possible to modify composer such that we can get the definition of class method definition IDs?

Maybe we can mark certain definition IDs as special, and delegate the codegen of them to a special callback? @ychenfo Is it possible to modify composer such that we can get the definition of class method definition IDs?
Poster
Owner

Those are module functions and are not inside classes.

Those are module functions and are not inside classes.

Those are module functions and are not inside classes.

I thought we may also use this for implementing RPCs, which can be methods inside classes.

> Those are module functions and are not inside classes. I thought we may also use this for implementing RPCs, which can be methods inside classes.

A callback can now be defined by the application (nac3embedded/nac3standalone) to handle call codegen. A HashSet is used to decide what functions would be passed to the callback.

A callback can now be defined by the application (nac3embedded/nac3standalone) to handle call codegen. A HashSet is used to decide what functions would be passed to the callback.
Poster
Owner

Why should the user register the functions manually, and then match the obtained DefinitionIds in the callback?

Wouldn't it make more sense to have a HashMap of callbacks instead, with nac3core calling the matching callback directly?

Why should the user register the functions manually, and then match the obtained ``DefinitionId``s in the callback? Wouldn't it make more sense to have a ``HashMap`` of callbacks instead, with ``nac3core`` calling the matching callback directly?

Why should the user register the functions manually, and then match the obtained DefinitionIds in the callback?

Wouldn't it make more sense to have a HashMap of callbacks instead, with nac3core calling the matching callback directly?

Yes we can do that. Or we can just put the callback in the function definition so we do not need a hashmap. Which approach do you prefer?

> Why should the user register the functions manually, and then match the obtained ``DefinitionId``s in the callback? > > Wouldn't it make more sense to have a ``HashMap`` of callbacks instead, with ``nac3core`` calling the matching callback directly? Yes we can do that. Or we can just put the callback in the function definition so we do not need a hashmap. Which approach do you prefer?
Poster
Owner

I just suggested HashMap as an internal implementation detail. Putting the callback in the function definition API call sounds good.

I just suggested ``HashMap`` as an internal implementation detail. Putting the callback in the function definition API call sounds good.

I just suggested HashMap as an internal implementation detail. Putting the callback in the function definition API call sounds good.

I mean we can store it as an optional field here: https://git.m-labs.hk/M-Labs/nac3/src/branch/master/nac3core/src/toplevel/mod.rs#L59

and no HashMap would be needed. Maybe I would go for this approach and add an API for setting the callback.

> I just suggested ``HashMap`` as an internal implementation detail. Putting the callback in the function definition API call sounds good. I mean we can store it as an optional field here: https://git.m-labs.hk/M-Labs/nac3/src/branch/master/nac3core/src/toplevel/mod.rs#L59 and no HashMap would be needed. Maybe I would go for this approach and add an API for setting the callback.
Poster
Owner

Ok, fine by me.

Ok, fine by me.
sb10q closed this issue 2021-10-02 23:34:20 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#24
There is no content yet.