cuoo/meta.h: Opcode and Object Type Union
[cuoo: Dynamic Objects and Operations]

Defines

#define CUEX_PRIoMETA   PRIoPTR
#define CUEX_PRIuMETA   PRIuPTR
#define CUEX_PRIxMETA   PRIxPTR
#define CUEX_PRIXMETA   PRIXPTR

Functions

cuoo_type_t cuoo_type_from_meta (cuex_meta_t meta)
cuex_meta_t cuoo_type_to_meta (cuex_t type)
cu_bool_t cuex_meta_is_opr (cuex_meta_t meta)
cu_rank_t cuex_opr_r (cuex_meta_t opr)
cu_bool_t cuex_meta_is_opr_r (cu_rank_t r, cuex_meta_t meta)
cu_bool_t cuex_meta_has_aux (cuex_meta_t meta)
cuex_opr_t cuex_meta_opr (cuex_meta_t meta)
uint32_t cuex_meta_aux (cuex_meta_t meta, cuex_t e)
cuex_meta_t cuex_meta (void *obj)

Metaword Layout

The following definitions describe the layout of metawords. Client code will normally use the higher level inline functions and the macros generated from the operator defititions. Nevertheless, certain useful numeric limits can be derived from the width of the fields.



enum  cuex_meta_kind_t { cuex_meta_kind_type = 0, cuex_meta_kind_opr = 1, cuex_meta_kind_other = 2, cuex_meta_kind_ignore = 3 }
#define CUEX_META_MASK(shift, width)   (((CUEX_META_C(1) << (width)) - CUEX_META_C(1)) << (shift))
#define CUEX_METAKIND_WIDTH   2
#define CUEX_METAKIND_MASK   3
#define CUEX_OPR_FLAGS_WIDTH   4
#define CUEX_OPR_ARITY_WIDTH   6
#define CUEX_OPR_SELECT_WIDTH   20
#define CUEX_OPR_FLAGS_SHIFT   CUEX_METAKIND_WIDTH
#define CUEX_OPR_ARITY_SHIFT   (CUEX_OPR_FLAGS_SHIFT + CUEX_OPR_FLAGS_WIDTH)
#define CUEX_OPR_SELECT_SHIFT   (CUEX_OPR_ARITY_SHIFT + CUEX_OPR_ARITY_WIDTH)
#define CUEX_META_WIDTH   (CUEX_OPR_SELECT_SHIFT + CUEX_OPR_SELECT_WIDTH)
#define CUEX_OPR_FLAGS_MASK   CUEX_META_MASK(CUEX_OPR_FLAGS_SHIFT, CUEX_OPR_FLAGS_WIDTH)
#define CUEX_OPR_ARITY_MASK   CUEX_META_MASK(CUEX_OPR_ARITY_SHIFT, CUEX_OPR_ARITY_WIDTH)
#define CUEX_OPR_SELECT_MASK   CUEX_META_MASK(CUEX_OPR_SELECT_SHIFT, CUEX_OPR_SELECT_WIDTH)
#define CUEX_OPRFLAG_CTOR   (CUEX_META_C(1) << CUEX_OPR_FLAGS_SHIFT)
#define CUEX_OPRFLAG_AUX   (CUEX_META_C(2) << CUEX_OPR_FLAGS_SHIFT)
#define cuex_meta_kind(meta)   ((cuex_meta_kind_t)((meta) & 3))
#define CUEXP_VARMETA_SELECT_WIDTH   3
#define CUEXP_VARMETA_SELECT_MASK   CUEX_META_C(7)
#define CUEXP_VARMETA_SELECT_VALUE   CUEX_META_C(6)
#define CUEXP_VARMETA_WSIZE_SHIFT   CUEXP_VARMETA_SELECT_WIDTH
#define CUEXP_VARMETA_WSIZE_WIDTH   2
#define CUEXP_VARMETA_WSIZE_MASK   CUEX_META_MASK(CUEXP_VARMETA_WSIZE_SHIFT, CUEXP_VARMETA_WSIZE_WIDTH)
#define cuexP_varmeta_wsize(meta)   ((meta & CUEXP_VARMETA_WSIZE_MASK) >> CUEXP_VARMETA_WSIZE_SHIFT)

Detailed Description

A dynamic object contains a descriptor which we here call the metaword, of type cuex_meta_t, which is a discriminated union of opcodes and object types. The following provide the detailed layout, as well as more high level functions to create and inspect the metaword.


Function Documentation

cuex_meta_t cuex_meta ( void *  obj  ) 

The meta of a dynamic object or operation obj.

uint32_t cuex_meta_aux ( cuex_meta_t  meta,
cuex_t  e 
)

If present, as indicated by cuex_meta_has_aux, returns the auxiliary bits of e. The metaword meta of e is be passed for efficiency. The actual bits are stored either in meta or within e depending on the architecture.

cu_bool_t cuex_meta_has_aux ( cuex_meta_t  meta  ) 

Provided meta describes an operator, returns true iff the expression node has auxiliary constant bits which can be fetched with cuex_meta_aux.

cu_bool_t cuex_meta_is_opr ( cuex_meta_t  meta  ) 

True iff meta is an operator, i.e. it is the meta of an operation.

cu_bool_t cuex_meta_is_opr_r ( cu_rank_t  r,
cuex_meta_t  meta 
)

True iff meta is an operator of rank r.

cuex_opr_t cuex_meta_opr ( cuex_meta_t  meta  ) 

Provided meta describes an operator, returns the operator bits only. That is, any auxiliary bits and flags are stripped off and the result is cast to a possibly smaller type.

cu_rank_t cuex_opr_r ( cuex_meta_t  opr  ) 

The arity of the operator opr.

cuoo_type_t cuoo_type_from_meta ( cuex_meta_t  meta  ) 

Cast a cuex_meta_t to a cuoo_type_t, assumig cuex_meta_is_type(meta) is true.

cuex_meta_t cuoo_type_to_meta ( cuex_t  type  ) 

Cast a cuoo_type_t to a cuex_meta_t.

Generated 2009-11-23 for culibs-0.25 using Doxygen. Maintained by Petter Urkedal.