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,
......
This diff is collapsed.
......@@ -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