add codegen plugin support for special functions #24
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#24
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is to enable the implementation of
now_mu()
,at_mu()
anddelay_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.
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?
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.
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, withnac3core
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?
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.
Ok, fine by me.