COMMINSTs for getting the values of top-level definitions by ID
This issue is motivated by mu-client-pypy#8 (closed)
Currently, the set of common instructions is insufficient. After a bundle is built and loaded at run time, there is no way to get the value of any top-level definition by their ID using the COMMINST-based client API. The C-based client API has the
handle_from_xxx functions that create handles for top-level definitions, but their counterparts are absent in COMMINSTs.
The straight forward solution is to add the following COMMINSTs so that top-level definitions can be dynamically looked up by ID.
[0x268]@uvm.meta.constant_by_id <T> (%id: int<32>) -> T [0x269]@uvm.meta.global_by_id <T> (%id: int<32>) -> T [0x26a]@uvm.meta.func_by_id <T> (%id: int<32>) -> T [0x26b]@uvm.meta.expfunc_by_id <T> (%id: int<32>) -> T
Adding one single COMMINST
The following COMMINST is sufficient to get any top-level definition by ID.
[0x268]@uvm.meta.top_level_by_id <T> (%id: int<32>) -> T
But it has less static information for the Mu backend compiler to translate that instruction.
Having a per-bundle initialiser function
It will behave like Java's
<init> method. But it is no different from allowing the client to look up a particular Mu function by ID and then execute it.