GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit 6c6aac50 authored by Kunshan Wang's avatar Kunshan Wang

Add irbuilderref for metacircular building, and comminsts

parent f331eab2
......@@ -127,7 +127,7 @@ opaque **handles**. Those handles are defined as::
// Abstract value type.
typedef MuValue MuSeqValue; // array or vector
typedef MuValue MuGenRefValue; // ref, iref, funcref, threadref, stackref, framecursorref, irnoderef
typedef MuValue MuGenRefValue; // ref, iref, funcref, threadref, stackref, framecursorref, irbuilderref
// concrete value types
typedef MuValue MuIntValue; // int<n>
......@@ -147,7 +147,7 @@ opaque **handles**. Those handles are defined as::
typedef MuGenRefValue MuThreadRefValue; // threadref
typedef MuGenRefValue MuStackRefValue; // stackref
typedef MuGenRefValue MuFCRefValue; // framecursorref
typedef MuGenRefValue MuIRNodeRefValue; // irnoderef
typedef MuGenRefValue MuIBRefValue; // irbuilderref
Each handle can only hold a Mu value of the type shown in the comments above.
Since the C programming language does not support user-defined type hierarchies,
......
......@@ -517,10 +517,16 @@ IR Building Interface
---------------------
These common instructions are the counterpart of the `IR Builder API
<irbuilder.rst>`__. The main difference is that the ``MuCtx`` is not needed.
<irbuilder.rst>`__.
This interface is not strongly type-checked, but all comminsts must
receive the appropriate node types.
The common instruction ``new_ir_builder`` will create an IR builder object, the
counterpart of the ``MuIRBuilder`` struct in the C API. Different from the C
API, common instructions refer to the IR builder object by the ``irbuilderref``
opaque reference type.
::
[0x270]@uvm.irbuilder.new_ir_builder () -> irbuilderref
The canonical definition of each function is in the `IR Builder API
<irbuilder.rst>`__ chapter. The rules of mapping to comminsts are:
......@@ -529,18 +535,16 @@ The canonical definition of each function is in the `IR Builder API
in the C API. Their IDs are allocated from 0x300 in the order they appear in
the ``MuCtx`` struct, with ``new_bundle`` = 0x300.
- The first parameter ``MuCtx`` is removed.
NOTE: The purpose of ``MuCtx`` is to let C programs hold handles to Mu
values in the micro VM. This common-instruction-based API is used directly
by Mu programs and can directly hold ``irnoderef`` values.
- The first parameter ``MuIRBuilder`` is mapped to ``irbuilderref``.
- Other parameters are mapped to the comminst parameters.
- Other parameters are mapped to the rest of comminst parameters.
- All IR node handles ``MuXxxxNode`` become ``irnoderef``.
- ``MuID`` arguments are represented as the Mu type ``int<32>``, and
``MuCString`` (including ``MuName``) is mapped to ``iref<int<8>>``, which
points to a ``'\0'``-terminated ASCII character array.
- Like the C API, all ``irnoderef`` values in a bundle become invalid after
``load_bundle_from_node`` or ``abort_bundle_node``.
- Like the C API, the IR builder object referred by ``irbuilderref`` is
invalidated after calling ``load`` or ``abort``.
- Array pointers become ``iref<T>``, where ``T`` is the element type.
......@@ -553,84 +557,84 @@ The canonical definition of each function is in the `IR Builder API
::
[0x300]@uvm.irbuilder.load () -> ()
[0x301]@uvm.irbuilder.abort () -> ()
[0x302]@uvm.irbuilder.gen_sym (%name: iref<int<8>>) -> (int<32>)
[0x303]@uvm.irbuilder.new_type_int (%id: int<32>, %len: int<32>) -> ()
[0x304]@uvm.irbuilder.new_type_float (%id: int<32>) -> ()
[0x305]@uvm.irbuilder.new_type_double (%id: int<32>) -> ()
[0x306]@uvm.irbuilder.new_type_uptr (%id: int<32>, %ty: int<32>) -> ()
[0x307]@uvm.irbuilder.new_type_ufuncptr (%id: int<32>, %sig: int<32>) -> ()
[0x308]@uvm.irbuilder.new_type_struct (%id: int<32>, %fieldtys: iref<int<32>>, %nfieldtys: int<64>) -> ()
[0x309]@uvm.irbuilder.new_type_hybrid (%id: int<32>, %fixedtys: iref<int<32>>, %nfixedtys: int<64>, %varty: int<32>) -> ()
[0x30a]@uvm.irbuilder.new_type_array (%id: int<32>, %elemty: int<32>, %len: int<64>) -> ()
[0x30b]@uvm.irbuilder.new_type_vector (%id: int<32>, %elemty: int<32>, %len: int<64>) -> ()
[0x30c]@uvm.irbuilder.new_type_void (%id: int<32>) -> ()
[0x30d]@uvm.irbuilder.new_type_ref (%id: int<32>, %ty: int<32>) -> ()
[0x30e]@uvm.irbuilder.new_type_iref (%id: int<32>, %ty: int<32>) -> ()
[0x30f]@uvm.irbuilder.new_type_weakref (%id: int<32>, %ty: int<32>) -> ()
[0x310]@uvm.irbuilder.new_type_funcref (%id: int<32>, %sig: int<32>) -> ()
[0x311]@uvm.irbuilder.new_type_tagref64 (%id: int<32>) -> ()
[0x312]@uvm.irbuilder.new_type_threadref (%id: int<32>) -> ()
[0x313]@uvm.irbuilder.new_type_stackref (%id: int<32>) -> ()
[0x314]@uvm.irbuilder.new_type_framecursorref (%id: int<32>) -> ()
[0x315]@uvm.irbuilder.new_funcsig (%id: int<32>, %paramtys: iref<int<32>>, %nparamtys: int<64>, %rettys: iref<int<32>>, %nrettys: int<64>) -> ()
[0x316]@uvm.irbuilder.new_const_int (%id: int<32>, %ty: int<32>, %value: int<64>) -> ()
[0x317]@uvm.irbuilder.new_const_int_ex (%id: int<32>, %ty: int<32>, %values: iref<int<64>>, %nvalues: int<64>) -> ()
[0x318]@uvm.irbuilder.new_const_float (%id: int<32>, %ty: int<32>, %value: float) -> ()
[0x319]@uvm.irbuilder.new_const_double (%id: int<32>, %ty: int<32>, %value: double) -> ()
[0x31a]@uvm.irbuilder.new_const_null (%id: int<32>, %ty: int<32>) -> ()
[0x31b]@uvm.irbuilder.new_const_seq (%id: int<32>, %ty: int<32>, %elems: iref<int<32>>, %nelems: int<64>) -> ()
[0x31c]@uvm.irbuilder.new_const_extern (%id: int<32>, %ty: int<32>, %symbol: iref<int<8>>) -> ()
[0x31d]@uvm.irbuilder.new_global_cell (%id: int<32>, %ty: int<32>) -> ()
[0x31e]@uvm.irbuilder.new_func (%id: int<32>, %sig: int<32>) -> ()
[0x31f]@uvm.irbuilder.new_exp_func (%id: int<32>, %func: int<32>, %callconv: int<32>, %cookie: int<32>) -> ()
[0x320]@uvm.irbuilder.new_func_ver (%id: int<32>, %func: int<32>, %bbs: iref<int<32>>, %nbbs: int<64>) -> ()
[0x321]@uvm.irbuilder.new_bb (%id: int<32>, %nor_param_ids: iref<int<32>>, %n_nor_param_ids: int<64>, %exc_param_id: int<32>, %insts: iref<int<32>>, %ninsts: int<64>) -> ()
[0x322]@uvm.irbuilder.new_dest_clause (%id: int<32>, %dest: int<32>, %vars: iref<int<32>>, %nvars: int<64>) -> ()
[0x323]@uvm.irbuilder.new_exc_clause (%id: int<32>, %nor: int<32>, %exc: int<32>) -> ()
[0x324]@uvm.irbuilder.new_keepalive_clause (%id: int<32>, %vars: iref<int<32>>, %nvars: int<64>) -> ()
[0x325]@uvm.irbuilder.new_csc_ret_with (%id: int<32>, %rettys: iref<int<32>>, %nrettys: int<64>) -> ()
[0x326]@uvm.irbuilder.new_csc_kill_old (%id: int<32>) -> ()
[0x327]@uvm.irbuilder.new_nsc_pass_values (%id: int<32>, %tys: iref<int<32>>, %vars: iref<int<32>>, %ntysvars: int<64>) -> ()
[0x328]@uvm.irbuilder.new_nsc_throw_exc (%id: int<32>, %exc: int<32>) -> ()
[0x329]@uvm.irbuilder.new_binop (%id: int<32>, %result_id: int<32>, %optr: int<32>, %ty: int<32>, %opnd1: int<32>, %opnd2: int<32>, %exc_clause: int<32>) -> ()
[0x32a]@uvm.irbuilder.new_cmp (%id: int<32>, %result_id: int<32>, %optr: int<32>, %ty: int<32>, %opnd1: int<32>, %opnd2: int<32>) -> ()
[0x32b]@uvm.irbuilder.new_conv (%id: int<32>, %result_id: int<32>, %optr: int<32>, %from_ty: int<32>, %to_ty: int<32>, %opnd: int<32>) -> ()
[0x32c]@uvm.irbuilder.new_select (%id: int<32>, %result_id: int<32>, %cond_ty: int<32>, %opnd_ty: int<32>, %cond: int<32>, %if_true: int<32>, %if_false: int<32>) -> ()
[0x32d]@uvm.irbuilder.new_branch (%id: int<32>, %dest: int<32>) -> ()
[0x32e]@uvm.irbuilder.new_branch2 (%id: int<32>, %cond: int<32>, %if_true: int<32>, %if_false: int<32>) -> ()
[0x32f]@uvm.irbuilder.new_switch (%id: int<32>, %opnd_ty: int<32>, %opnd: int<32>, %default_dest: int<32>, %cases: iref<int<32>>, %dests: iref<int<32>>, %ncasesdests: int<64>) -> ()
[0x330]@uvm.irbuilder.new_call (%id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %sig: int<32>, %callee: int<32>, %args: iref<int<32>>, %nargs: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x331]@uvm.irbuilder.new_tailcall (%id: int<32>, %sig: int<32>, %callee: int<32>, %args: iref<int<32>>, %nargs: int<64>) -> ()
[0x332]@uvm.irbuilder.new_ret (%id: int<32>, %rvs: iref<int<32>>, %nrvs: int<64>) -> ()
[0x333]@uvm.irbuilder.new_throw (%id: int<32>, %exc: int<32>) -> ()
[0x334]@uvm.irbuilder.new_extractvalue (%id: int<32>, %result_id: int<32>, %strty: int<32>, %index: int<32>, %opnd: int<32>) -> ()
[0x335]@uvm.irbuilder.new_insertvalue (%id: int<32>, %result_id: int<32>, %strty: int<32>, %index: int<32>, %opnd: int<32>, %newval: int<32>) -> ()
[0x336]@uvm.irbuilder.new_extractelement (%id: int<32>, %result_id: int<32>, %seqty: int<32>, %indty: int<32>, %opnd: int<32>, %index: int<32>) -> ()
[0x337]@uvm.irbuilder.new_insertelement (%id: int<32>, %result_id: int<32>, %seqty: int<32>, %indty: int<32>, %opnd: int<32>, %index: int<32>, %newval: int<32>) -> ()
[0x338]@uvm.irbuilder.new_shufflevector (%id: int<32>, %result_id: int<32>, %vecty: int<32>, %maskty: int<32>, %vec1: int<32>, %vec2: int<32>, %mask: int<32>) -> ()
[0x339]@uvm.irbuilder.new_new (%id: int<32>, %result_id: int<32>, %allocty: int<32>, %exc_clause: int<32>) -> ()
[0x33a]@uvm.irbuilder.new_newhybrid (%id: int<32>, %result_id: int<32>, %allocty: int<32>, %lenty: int<32>, %length: int<32>, %exc_clause: int<32>) -> ()
[0x33b]@uvm.irbuilder.new_alloca (%id: int<32>, %result_id: int<32>, %allocty: int<32>, %exc_clause: int<32>) -> ()
[0x33c]@uvm.irbuilder.new_allocahybrid (%id: int<32>, %result_id: int<32>, %allocty: int<32>, %lenty: int<32>, %length: int<32>, %exc_clause: int<32>) -> ()
[0x33d]@uvm.irbuilder.new_getiref (%id: int<32>, %result_id: int<32>, %refty: int<32>, %opnd: int<32>) -> ()
[0x33e]@uvm.irbuilder.new_getfieldiref (%id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %index: int<32>, %opnd: int<32>) -> ()
[0x33f]@uvm.irbuilder.new_getelemiref (%id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %indty: int<32>, %opnd: int<32>, %index: int<32>) -> ()
[0x340]@uvm.irbuilder.new_shiftiref (%id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %offty: int<32>, %opnd: int<32>, %offset: int<32>) -> ()
[0x341]@uvm.irbuilder.new_getvarpartiref (%id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %opnd: int<32>) -> ()
[0x342]@uvm.irbuilder.new_load (%id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %ord: int<32>, %refty: int<32>, %loc: int<32>, %exc_clause: int<32>) -> ()
[0x343]@uvm.irbuilder.new_store (%id: int<32>, %is_ptr: int<32>, %ord: int<32>, %refty: int<32>, %loc: int<32>, %newval: int<32>, %exc_clause: int<32>) -> ()
[0x344]@uvm.irbuilder.new_cmpxchg (%id: int<32>, %value_result_id: int<32>, %succ_result_id: int<32>, %is_ptr: int<32>, %is_weak: int<32>, %ord_succ: int<32>, %ord_fail: int<32>, %refty: int<32>, %loc: int<32>, %expected: int<32>, %desired: int<32>, %exc_clause: int<32>) -> ()
[0x345]@uvm.irbuilder.new_atomicrmw (%id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %ord: int<32>, %optr: int<32>, %refTy: int<32>, %loc: int<32>, %opnd: int<32>, %exc_clause: int<32>) -> ()
[0x346]@uvm.irbuilder.new_fence (%id: int<32>, %ord: int<32>) -> ()
[0x347]@uvm.irbuilder.new_trap (%id: int<32>, %result_ids: iref<int<32>>, %rettys: iref<int<32>>, %nretvals: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x348]@uvm.irbuilder.new_watchpoint (%id: int<32>, %wpid: int<32>, %result_ids: iref<int<32>>, %rettys: iref<int<32>>, %nretvals: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x349]@uvm.irbuilder.new_wpbranch (%id: int<32>, %wpid: int<32>) -> ()
[0x34a]@uvm.irbuilder.new_ccall (%id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %callconv: int<32>, %callee_ty: int<32>, %sig: int<32>, %callee: int<32>, %args: iref<int<32>>, %nargs: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x34b]@uvm.irbuilder.new_newthread (%id: int<32>, %result_id: int<32>, %stack: int<32>, %threadlocal: int<32>, %new_stack_clause: int<32>, %exc_clause: int<32>) -> ()
[0x34c]@uvm.irbuilder.new_swapstack (%id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %swappee: int<32>, %cur_stack_clause: int<32>, %new_stack_clause: int<32>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x34d]@uvm.irbuilder.new_comminst (%id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %opcode: int<32>, %flags: iref<int<32>>, %nflags: int<64>, %tys: iref<int<32>>, %ntys: int<64>, %sigs: iref<int<32>>, %nsigs: int<64>, %args: iref<int<32>>, %nargs: int<64>) -> ()
[0x300]@uvm.irbuilder.load (%b: irbuilderref) -> ()
[0x301]@uvm.irbuilder.abort (%b: irbuilderref) -> ()
[0x302]@uvm.irbuilder.gen_sym (%b: irbuilderref, %name: iref<int<8>>) -> (int<32>)
[0x303]@uvm.irbuilder.new_type_int (%b: irbuilderref, %id: int<32>, %len: int<32>) -> ()
[0x304]@uvm.irbuilder.new_type_float (%b: irbuilderref, %id: int<32>) -> ()
[0x305]@uvm.irbuilder.new_type_double (%b: irbuilderref, %id: int<32>) -> ()
[0x306]@uvm.irbuilder.new_type_uptr (%b: irbuilderref, %id: int<32>, %ty: int<32>) -> ()
[0x307]@uvm.irbuilder.new_type_ufuncptr (%b: irbuilderref, %id: int<32>, %sig: int<32>) -> ()
[0x308]@uvm.irbuilder.new_type_struct (%b: irbuilderref, %id: int<32>, %fieldtys: iref<int<32>>, %nfieldtys: int<64>) -> ()
[0x309]@uvm.irbuilder.new_type_hybrid (%b: irbuilderref, %id: int<32>, %fixedtys: iref<int<32>>, %nfixedtys: int<64>, %varty: int<32>) -> ()
[0x30a]@uvm.irbuilder.new_type_array (%b: irbuilderref, %id: int<32>, %elemty: int<32>, %len: int<64>) -> ()
[0x30b]@uvm.irbuilder.new_type_vector (%b: irbuilderref, %id: int<32>, %elemty: int<32>, %len: int<64>) -> ()
[0x30c]@uvm.irbuilder.new_type_void (%b: irbuilderref, %id: int<32>) -> ()
[0x30d]@uvm.irbuilder.new_type_ref (%b: irbuilderref, %id: int<32>, %ty: int<32>) -> ()
[0x30e]@uvm.irbuilder.new_type_iref (%b: irbuilderref, %id: int<32>, %ty: int<32>) -> ()
[0x30f]@uvm.irbuilder.new_type_weakref (%b: irbuilderref, %id: int<32>, %ty: int<32>) -> ()
[0x310]@uvm.irbuilder.new_type_funcref (%b: irbuilderref, %id: int<32>, %sig: int<32>) -> ()
[0x311]@uvm.irbuilder.new_type_tagref64 (%b: irbuilderref, %id: int<32>) -> ()
[0x312]@uvm.irbuilder.new_type_threadref (%b: irbuilderref, %id: int<32>) -> ()
[0x313]@uvm.irbuilder.new_type_stackref (%b: irbuilderref, %id: int<32>) -> ()
[0x314]@uvm.irbuilder.new_type_framecursorref (%b: irbuilderref, %id: int<32>) -> ()
[0x315]@uvm.irbuilder.new_funcsig (%b: irbuilderref, %id: int<32>, %paramtys: iref<int<32>>, %nparamtys: int<64>, %rettys: iref<int<32>>, %nrettys: int<64>) -> ()
[0x316]@uvm.irbuilder.new_const_int (%b: irbuilderref, %id: int<32>, %ty: int<32>, %value: int<64>) -> ()
[0x317]@uvm.irbuilder.new_const_int_ex (%b: irbuilderref, %id: int<32>, %ty: int<32>, %values: iref<int<64>>, %nvalues: int<64>) -> ()
[0x318]@uvm.irbuilder.new_const_float (%b: irbuilderref, %id: int<32>, %ty: int<32>, %value: float) -> ()
[0x319]@uvm.irbuilder.new_const_double (%b: irbuilderref, %id: int<32>, %ty: int<32>, %value: double) -> ()
[0x31a]@uvm.irbuilder.new_const_null (%b: irbuilderref, %id: int<32>, %ty: int<32>) -> ()
[0x31b]@uvm.irbuilder.new_const_seq (%b: irbuilderref, %id: int<32>, %ty: int<32>, %elems: iref<int<32>>, %nelems: int<64>) -> ()
[0x31c]@uvm.irbuilder.new_const_extern (%b: irbuilderref, %id: int<32>, %ty: int<32>, %symbol: iref<int<8>>) -> ()
[0x31d]@uvm.irbuilder.new_global_cell (%b: irbuilderref, %id: int<32>, %ty: int<32>) -> ()
[0x31e]@uvm.irbuilder.new_func (%b: irbuilderref, %id: int<32>, %sig: int<32>) -> ()
[0x31f]@uvm.irbuilder.new_exp_func (%b: irbuilderref, %id: int<32>, %func: int<32>, %callconv: int<32>, %cookie: int<32>) -> ()
[0x320]@uvm.irbuilder.new_func_ver (%b: irbuilderref, %id: int<32>, %func: int<32>, %bbs: iref<int<32>>, %nbbs: int<64>) -> ()
[0x321]@uvm.irbuilder.new_bb (%b: irbuilderref, %id: int<32>, %nor_param_ids: iref<int<32>>, %n_nor_param_ids: int<64>, %exc_param_id: int<32>, %insts: iref<int<32>>, %ninsts: int<64>) -> ()
[0x322]@uvm.irbuilder.new_dest_clause (%b: irbuilderref, %id: int<32>, %dest: int<32>, %vars: iref<int<32>>, %nvars: int<64>) -> ()
[0x323]@uvm.irbuilder.new_exc_clause (%b: irbuilderref, %id: int<32>, %nor: int<32>, %exc: int<32>) -> ()
[0x324]@uvm.irbuilder.new_keepalive_clause (%b: irbuilderref, %id: int<32>, %vars: iref<int<32>>, %nvars: int<64>) -> ()
[0x325]@uvm.irbuilder.new_csc_ret_with (%b: irbuilderref, %id: int<32>, %rettys: iref<int<32>>, %nrettys: int<64>) -> ()
[0x326]@uvm.irbuilder.new_csc_kill_old (%b: irbuilderref, %id: int<32>) -> ()
[0x327]@uvm.irbuilder.new_nsc_pass_values (%b: irbuilderref, %id: int<32>, %tys: iref<int<32>>, %vars: iref<int<32>>, %ntysvars: int<64>) -> ()
[0x328]@uvm.irbuilder.new_nsc_throw_exc (%b: irbuilderref, %id: int<32>, %exc: int<32>) -> ()
[0x329]@uvm.irbuilder.new_binop (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %optr: int<32>, %ty: int<32>, %opnd1: int<32>, %opnd2: int<32>, %exc_clause: int<32>) -> ()
[0x32a]@uvm.irbuilder.new_cmp (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %optr: int<32>, %ty: int<32>, %opnd1: int<32>, %opnd2: int<32>) -> ()
[0x32b]@uvm.irbuilder.new_conv (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %optr: int<32>, %from_ty: int<32>, %to_ty: int<32>, %opnd: int<32>) -> ()
[0x32c]@uvm.irbuilder.new_select (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %cond_ty: int<32>, %opnd_ty: int<32>, %cond: int<32>, %if_true: int<32>, %if_false: int<32>) -> ()
[0x32d]@uvm.irbuilder.new_branch (%b: irbuilderref, %id: int<32>, %dest: int<32>) -> ()
[0x32e]@uvm.irbuilder.new_branch2 (%b: irbuilderref, %id: int<32>, %cond: int<32>, %if_true: int<32>, %if_false: int<32>) -> ()
[0x32f]@uvm.irbuilder.new_switch (%b: irbuilderref, %id: int<32>, %opnd_ty: int<32>, %opnd: int<32>, %default_dest: int<32>, %cases: iref<int<32>>, %dests: iref<int<32>>, %ncasesdests: int<64>) -> ()
[0x330]@uvm.irbuilder.new_call (%b: irbuilderref, %id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %sig: int<32>, %callee: int<32>, %args: iref<int<32>>, %nargs: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x331]@uvm.irbuilder.new_tailcall (%b: irbuilderref, %id: int<32>, %sig: int<32>, %callee: int<32>, %args: iref<int<32>>, %nargs: int<64>) -> ()
[0x332]@uvm.irbuilder.new_ret (%b: irbuilderref, %id: int<32>, %rvs: iref<int<32>>, %nrvs: int<64>) -> ()
[0x333]@uvm.irbuilder.new_throw (%b: irbuilderref, %id: int<32>, %exc: int<32>) -> ()
[0x334]@uvm.irbuilder.new_extractvalue (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %strty: int<32>, %index: int<32>, %opnd: int<32>) -> ()
[0x335]@uvm.irbuilder.new_insertvalue (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %strty: int<32>, %index: int<32>, %opnd: int<32>, %newval: int<32>) -> ()
[0x336]@uvm.irbuilder.new_extractelement (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %seqty: int<32>, %indty: int<32>, %opnd: int<32>, %index: int<32>) -> ()
[0x337]@uvm.irbuilder.new_insertelement (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %seqty: int<32>, %indty: int<32>, %opnd: int<32>, %index: int<32>, %newval: int<32>) -> ()
[0x338]@uvm.irbuilder.new_shufflevector (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %vecty: int<32>, %maskty: int<32>, %vec1: int<32>, %vec2: int<32>, %mask: int<32>) -> ()
[0x339]@uvm.irbuilder.new_new (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %allocty: int<32>, %exc_clause: int<32>) -> ()
[0x33a]@uvm.irbuilder.new_newhybrid (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %allocty: int<32>, %lenty: int<32>, %length: int<32>, %exc_clause: int<32>) -> ()
[0x33b]@uvm.irbuilder.new_alloca (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %allocty: int<32>, %exc_clause: int<32>) -> ()
[0x33c]@uvm.irbuilder.new_allocahybrid (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %allocty: int<32>, %lenty: int<32>, %length: int<32>, %exc_clause: int<32>) -> ()
[0x33d]@uvm.irbuilder.new_getiref (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %refty: int<32>, %opnd: int<32>) -> ()
[0x33e]@uvm.irbuilder.new_getfieldiref (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %index: int<32>, %opnd: int<32>) -> ()
[0x33f]@uvm.irbuilder.new_getelemiref (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %indty: int<32>, %opnd: int<32>, %index: int<32>) -> ()
[0x340]@uvm.irbuilder.new_shiftiref (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %offty: int<32>, %opnd: int<32>, %offset: int<32>) -> ()
[0x341]@uvm.irbuilder.new_getvarpartiref (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %refty: int<32>, %opnd: int<32>) -> ()
[0x342]@uvm.irbuilder.new_load (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %ord: int<32>, %refty: int<32>, %loc: int<32>, %exc_clause: int<32>) -> ()
[0x343]@uvm.irbuilder.new_store (%b: irbuilderref, %id: int<32>, %is_ptr: int<32>, %ord: int<32>, %refty: int<32>, %loc: int<32>, %newval: int<32>, %exc_clause: int<32>) -> ()
[0x344]@uvm.irbuilder.new_cmpxchg (%b: irbuilderref, %id: int<32>, %value_result_id: int<32>, %succ_result_id: int<32>, %is_ptr: int<32>, %is_weak: int<32>, %ord_succ: int<32>, %ord_fail: int<32>, %refty: int<32>, %loc: int<32>, %expected: int<32>, %desired: int<32>, %exc_clause: int<32>) -> ()
[0x345]@uvm.irbuilder.new_atomicrmw (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %is_ptr: int<32>, %ord: int<32>, %optr: int<32>, %refTy: int<32>, %loc: int<32>, %opnd: int<32>, %exc_clause: int<32>) -> ()
[0x346]@uvm.irbuilder.new_fence (%b: irbuilderref, %id: int<32>, %ord: int<32>) -> ()
[0x347]@uvm.irbuilder.new_trap (%b: irbuilderref, %id: int<32>, %result_ids: iref<int<32>>, %rettys: iref<int<32>>, %nretvals: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x348]@uvm.irbuilder.new_watchpoint (%b: irbuilderref, %id: int<32>, %wpid: int<32>, %result_ids: iref<int<32>>, %rettys: iref<int<32>>, %nretvals: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x349]@uvm.irbuilder.new_wpbranch (%b: irbuilderref, %id: int<32>, %wpid: int<32>) -> ()
[0x34a]@uvm.irbuilder.new_ccall (%b: irbuilderref, %id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %callconv: int<32>, %callee_ty: int<32>, %sig: int<32>, %callee: int<32>, %args: iref<int<32>>, %nargs: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x34b]@uvm.irbuilder.new_newthread (%b: irbuilderref, %id: int<32>, %result_id: int<32>, %stack: int<32>, %threadlocal: int<32>, %new_stack_clause: int<32>, %exc_clause: int<32>) -> ()
[0x34c]@uvm.irbuilder.new_swapstack (%b: irbuilderref, %id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %swappee: int<32>, %cur_stack_clause: int<32>, %new_stack_clause: int<32>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
[0x34d]@uvm.irbuilder.new_comminst (%b: irbuilderref, %id: int<32>, %result_ids: iref<int<32>>, %n_result_ids: int<64>, %opcode: int<32>, %flags: iref<int<32>>, %nflags: int<64>, %tys: iref<int<32>>, %ntys: int<64>, %sigs: iref<int<32>>, %nsigs: int<64>, %args: iref<int<32>>, %nargs: int<64>, %exc_clause: int<32>, %keepalive_clause: int<32>) -> ()
.. GEN:END:IRBUILDER_COMMINSTS
......
......@@ -613,7 +613,7 @@ Null constructor
- ``framecursorref``
- ``irnoderef``
- ``irbuilderref``
It can only have ``NULL`` value.
......
......@@ -2,6 +2,8 @@
Function Call-based Mu IR Building API
======================================
TODO: rewrite this
This chapter describes the function call-based Mu IR building API. It is part of
the `Mu Client Interface <api.rst>`__.
......
......@@ -58,7 +58,7 @@ typedef void *MuValue; // Any Mu value
// Abstract value type.
typedef MuValue MuSeqValue; // array or vector
typedef MuValue MuGenRefValue; // ref, iref, funcref, threadref, stackref, framecursorref, irnoderef
typedef MuValue MuGenRefValue; // ref, iref, funcref, threadref, stackref, framecursorref, irbuilderref
// concrete value types
typedef MuValue MuIntValue; // int<n>
......@@ -147,6 +147,7 @@ typedef void _MuTrapHandler_Func(
MuCPtr userdata);
typedef _MuTrapHandler_Func* MuTrapHandler;
// Binary operators
typedef MuFlag MuBinOptr;
#define MU_BINOP_ADD ((MuBinOptr)0x01)
......@@ -505,6 +506,7 @@ struct MuIRBuilder {
void (*new_type_threadref )(MuIRBuilder *b, MuID id);
void (*new_type_stackref )(MuIRBuilder *b, MuID id);
void (*new_type_framecursorref)(MuIRBuilder *b, MuID id);
void (*new_type_irbuilderref )(MuIRBuilder *b, MuID id);
// Create function signatures
void (*new_funcsig)(MuIRBuilder *b, MuID id,
......@@ -706,15 +708,17 @@ struct MuIRBuilder {
MuCurStackClause cur_stack_clause,
MuNewStackClause new_stack_clause,
MuExcClause exc_clause,
MuKeepaliveClause keepalive_clause); /// MUAPIPARSER result_ids:array:n_result_ids;
MuKeepaliveClause keepalive_clause); /// MUAPIPARSER result_ids:array:n_result_ids;exc_clause:optional;keepalive_clause:optional
void (*new_comminst)(MuIRBuilder *b, MuID id, MuID *result_ids, MuArraySize n_result_ids,
MuCommInst opcode,
MuFlag *flags, MuArraySize nflags,
MuTypeNode *tys, MuArraySize ntys,
MuFuncSigNode *sigs, MuArraySize nsigs,
MuVarNode *args, MuArraySize nargs);
/// MUAPIPARSER result_ids:array:n_result_ids;flags:array:nflags;tys:array:ntys;sigs:array:nsigs;args:array:nargs
MuVarNode *args, MuArraySize nargs,
MuExcClause exc_clause,
MuKeepaliveClause keepalive_clause);
/// MUAPIPARSER result_ids:array:n_result_ids;flags:array:nflags;tys:array:ntys;sigs:array:nsigs;args:array:nargs;exc_clause:optional;keepalive_clause:optional
};
// Common instruction opcodes
......@@ -762,6 +766,7 @@ struct MuIRBuilder {
#define MU_CI_UVM_META_ENABLE_WATCHPOINT ((MuCommInst)0x25e) /// MUAPIPARSER muname:@uvm.meta.enable_watchpoint
#define MU_CI_UVM_META_DISABLE_WATCHPOINT ((MuCommInst)0x25f) /// MUAPIPARSER muname:@uvm.meta.disable_watchpoint
#define MU_CI_UVM_META_SET_TRAP_HANDLER ((MuCommInst)0x260) /// MUAPIPARSER muname:@uvm.meta.set_trap_handler
#define MU_CI_UVM_IRBUILDER_NEW_IR_BUILDER ((MuCommInst)0x270) /// MUAPIPARSER muname:@uvm.irbuilder.new_ir_builder
#define MU_CI_UVM_IRBUILDER_LOAD ((MuCommInst)0x300) /// MUAPIPARSER muname:@uvm.irbuilder.load
#define MU_CI_UVM_IRBUILDER_ABORT ((MuCommInst)0x301) /// MUAPIPARSER muname:@uvm.irbuilder.abort
#define MU_CI_UVM_IRBUILDER_GEN_SYM ((MuCommInst)0x302) /// MUAPIPARSER muname:@uvm.irbuilder.gen_sym
......
......@@ -41,7 +41,7 @@ All non-native-safe types have unspecified sizes and alignments.
``threadref`` N/A unspecified unspecified
``stackref`` N/A unspecified unspecified
``framecursorref`` N/A unspecified unspecified
``irnoderef`` N/A unspecified unspecified
``irbuilderref`` N/A unspecified unspecified
``int<1>`` N/A unspecified unspecified
``int<6>`` N/A unspecified unspecified
``int<52>`` N/A unspecified unspecified
......
......@@ -48,7 +48,9 @@ _type_map = {
}
def to_mu_ty(cty):
if cty.endswith("*"):
if cty == 'MuIRBuilder*':
return 'irbuilderref'
elif cty.endswith("*"):
return "iref<{}>".format(to_mu_ty(cty[:-1]))
elif cty.startswith("Mu") and (cty.endswith("Node") or cty.endswith("Clause")):
return "int<32>"
......@@ -73,7 +75,7 @@ def get_comminst_defs(ast):
mu_params = []
for param in params[1:]: # skip MuCtx*
for param in params:
pn = param["name"]
pt = param["type"]
mpn = "%" + pn
......@@ -95,7 +97,6 @@ def get_comminst_defs(ast):
return "\n".join(lines)
_enums = [
"MuDestKind",
"MuBinOptr",
"MuCmpOptr",
"MuConvOptr",
......
......@@ -48,7 +48,7 @@ The following type constructors are available in Mu:
- **threadref**
- **stackref**
- **framecursorref**
- **irnoderef**
- **irbuilderref**
..
......@@ -75,8 +75,8 @@ There are several kinds of types.
* ``float`` and ``double`` are **floating point types**.
* ``ref`` and ``weakref`` are **object referenct types**.
* ``ref``, ``iref`` and ``weakref`` are **reference types**.
* ``funcref``, ``threadref``, ``stackref``, ``framecursorref`` and ``irnoderef``
are **opaque reference types**.
* ``funcref``, ``threadref``, ``stackref``, ``framecursorref`` and
``irbuilderref`` are **opaque reference types**.
* *Reference types* and *opaque reference types* are **general reference types**.
* ``int``, ``float``, ``double``, *pointer types*, *general reference types* and
``tagref64`` are **scalar types**.
......@@ -694,7 +694,7 @@ Other Opaque Reference Types
``framecursorref``
``irnoderef``
``irbuilderref``
These types are opaque references to things within Mu. They are not
interchangeable with reference types. Only some special instructions (e.g.
......@@ -714,7 +714,8 @@ structure used by the stack introspection API to iterate through stack frames.
Its content is mutable but opaque. See `Threads and Stacks
<threads-stacks.rst>`__ for more details.
``irnoderef`` refers to a Mu IR node being constructed by the `IR Builder API
``irbuilderref`` refers to a Mu IR Builder. It is only used when a Mu IR program
meta-circularly builds other Mu IR bundles via CommInsts. See `IR Builder API
<irbuilder.rst>`__.
.. vim: tw=80
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment