Commit 6a4a9e36 authored by qinsoon's avatar qinsoon

draft to add lowtagref

parent 8e74b6d0
......@@ -180,6 +180,24 @@ Return the created ``tagref64`` value.
They have undefined behaviours if ``%tr`` does not hold the value of the
expected type.
Low Bits Tagged Reference
=========================
::
[0x21b]@uvm.ltr.from_ref (%ref: ref<void>, %tag: int<3>) -> lowtagref
Return a low bits tagged reference from a reference and a tag
::
[0x21c]@uvm.ltr.to_ref (%ltr: lowtagref) -> ref<void>
[0x21d]@uvm.ltr.to_tag (%ltr: lowtagref) -> int<3>
- ``to_ref`` returns the reference held by ``%ltr``.
- ``to_tag`` returns the integer tag held by ``%ltr`` that accompanies the
reference.
Math Instructions
=================
......
......@@ -382,11 +382,12 @@ Creating Type Nodes
void (*new_type_vector )(MuIRBuilder *b, MuID id, MuTypeNode elemty, uint64_t len);
void (*new_type_void )(MuIRBuilder *b, MuID id);
void (*new_type_ref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_iref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_weakref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_funcref )(MuIRBuilder *b, MuID id, MuFuncSigNode sig);
void (*new_type_tagref64)(MuIRBuilder *b, MuID id);
void (*new_type_ref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_iref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_weakref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_funcref )(MuIRBuilder *b, MuID id, MuFuncSigNode sig);
void (*new_type_tagref64 )(MuIRBuilder *b, MuID id);
void (*new_type_lowtagref)(MuIRBuilder *b, MuID id);
void (*new_type_threadref )(MuIRBuilder *b, MuID id);
void (*new_type_stackref )(MuIRBuilder *b, MuID id);
......
......@@ -74,6 +74,7 @@ typedef MuSeqValue MuVectorValue; // vector<T l>
typedef MuGenRefValue MuRefValue; // ref<T>
typedef MuGenRefValue MuIRefValue; // iref<T>
typedef MuGenRefValue MuTagRef64Value; // tagref64
typedef MuGenRefValue MuLowTagRefValue; // lowtagref
typedef MuGenRefValue MuFuncRefValue; // funcref<sig>
typedef MuGenRefValue MuThreadRefValue; // threadref
typedef MuGenRefValue MuStackRefValue; // stackref
......@@ -411,6 +412,11 @@ struct MuCtx {
MuTagRef64Value (*tr64_from_fp )(MuCtx *ctx, MuDoubleValue value);
MuTagRef64Value (*tr64_from_int)(MuCtx *ctx, MuIntValue value);
MuTagRef64Value (*tr64_from_ref)(MuCtx *ctx, MuRefValue ref, MuIntValue tag);
// low bits tagged reference operations
MuLowTagRefValue (*ltr_from_ref)(MuCtx *ctx, MuRefValue ref, MuIntValue tag);
MuRefValue (*ltr_to_ref )(MuCtx *ctx, MuLowTagRefValue value);
MuIntValue (*ltr_to_tag )(MuCtx *ctx, MuLowTagRefValue value);
// Watchpoint operations
void (*enable_watchpoint )(MuCtx *ctx, MuWPID wpid);
......@@ -508,11 +514,12 @@ struct MuIRBuilder {
void (*new_type_vector )(MuIRBuilder *b, MuID id, MuTypeNode elemty, uint64_t len);
void (*new_type_void )(MuIRBuilder *b, MuID id);
void (*new_type_ref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_iref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_weakref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_funcref )(MuIRBuilder *b, MuID id, MuFuncSigNode sig);
void (*new_type_tagref64)(MuIRBuilder *b, MuID id);
void (*new_type_ref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_iref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_weakref )(MuIRBuilder *b, MuID id, MuTypeNode ty);
void (*new_type_funcref )(MuIRBuilder *b, MuID id, MuFuncSigNode sig);
void (*new_type_tagref64 )(MuIRBuilder *b, MuID id);
void (*new_type_lowtagref)(MuIRBuilder *b, MuID id);
void (*new_type_threadref )(MuIRBuilder *b, MuID id);
void (*new_type_stackref )(MuIRBuilder *b, MuID id);
......@@ -811,6 +818,7 @@ struct MuIRBuilder {
#define MU_CI_UVM_IRBUILDER_NEW_TYPE_WEAKREF ((MuCommInst)0x30f) /// MUAPIPARSER muname:@uvm.irbuilder.new_type_weakref
#define MU_CI_UVM_IRBUILDER_NEW_TYPE_FUNCREF ((MuCommInst)0x310) /// MUAPIPARSER muname:@uvm.irbuilder.new_type_funcref
#define MU_CI_UVM_IRBUILDER_NEW_TYPE_TAGREF64 ((MuCommInst)0x311) /// MUAPIPARSER muname:@uvm.irbuilder.new_type_tagref64
#define MU_CI_UVM_IRBUILDER_NEW_TYPE_LOWTAGREF ((MuCommInst)0x350) /// MUAPIPARSER muname:@uvm.irbuilder.new_type_lowtagref
#define MU_CI_UVM_IRBUILDER_NEW_TYPE_THREADREF ((MuCommInst)0x312) /// MUAPIPARSER muname:@uvm.irbuilder.new_type_threadref
#define MU_CI_UVM_IRBUILDER_NEW_TYPE_STACKREF ((MuCommInst)0x313) /// MUAPIPARSER muname:@uvm.irbuilder.new_type_stackref
#define MU_CI_UVM_IRBUILDER_NEW_TYPE_FRAMECURSORREF ((MuCommInst)0x314) /// MUAPIPARSER muname:@uvm.irbuilder.new_type_framecursorref
......
......@@ -37,6 +37,7 @@ All non-native-safe types have unspecified sizes and alignments.
``iref<T>`` N/A unspecified unspecified
``weakref<T>`` N/A unspecified unspecified
``tagref64`` N/A unspecified unspecified
``lowtagref`` N/A unspecified unspecified
``funcref<sig>`` N/A unspecified unspecified
``threadref`` N/A unspecified unspecified
``stackref`` N/A unspecified unspecified
......@@ -51,11 +52,12 @@ All non-native-safe types have unspecified sizes and alignments.
..
NOTE: Although ``int<1>`` is required and ``int<6>`` and ``int<52>`` are
NOTE: Although ``int<1>`` is required, ``int<3>`` is required
for ``lowtagref``, and ``int<6>`` and ``int<52>`` are
required when ``tagref64`` is implemented, their memory layout is
unspecified because memory access instructions ``LOAD``, ``STORE``, etc. are
not required to support those types. It it not recommended to include those
types in the memory because they may never be loaded or stored.
types in the memory because they may never be loaded or stored.
Although vectors of other lengths are not required by a Mu implementation,
implementations are encouraged to support them in a way compatible with the
......
......@@ -44,6 +44,7 @@ The following type constructors are available in Mu:
- **iref** < *T* >
- **weakref** < *T* >
- **tagref64**
- **lowtagref**
- **funcref** < *sig* >
- **threadref**
- **stackref**
......@@ -78,8 +79,8 @@ There are several kinds of 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**.
* ``int``, ``float``, ``double``, *pointer types*, *general reference types*,
``tagref64`` and ``lowtagref`` are **scalar types**.
* ``struct``, ``hybrid``, ``array`` and ``vector`` are **composite types**.
* ``void`` is neither a *scalar type* nor a *composite type*.
......@@ -637,6 +638,16 @@ bit-wise representation of the NaN.
NOTE: This type is only available on some architectures including x86-64
with 48-bit addresses.
``lowtagref``
``lowtagref`` is a reference type with its lower 3 bits as a user defined
``int<3>`` tag. ``lowtagref`` is semantically a subset of ``tagref64``, but is
more efficient and lightweight when the client only desires reference tagging.
NOTE: As implementations usually apply a minimal alignment for objects,
references have their low bits as zero for the alignment requirement.
This type uses the lower bits to store a user-supplied ``int<3>`` tag.
Function Reference Type
-----------------------
......
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