Constant.xcc
Author: Benoit Dupont de Dinechin (Benoit.Dupont-de-Dinechin@st.com)
Copyright 2001 - 2007 STMicroelectronics
This program is free software; you can redistribute it and/or modify it under the terms of either (at your option): the GNU General Public License (GPL) version 2; the GNU Lesser General Public License (LGPL) version 2.1; any later version of these licences as published by the Free Software Foundation.
ConstantType— Enumerates the Constant types.
typedef enum { ConstantType_Absolute, // Absolute constant: HANDLE is NULL ConstantType_Symbol, // Symbol constant: SYMBOL is the Symbol ConstantType_Label, // Label constant: LABEL is the Label ConstantType__ } enum_ConstantType; typedef uint8_t ConstantType; #define ConstantType_isAbsolute(type) ((type) == ConstantType_Absolute) #define ConstantType_isSymbol(type) ((type) == ConstantType_Symbol) #define ConstantType_isLabel(type) ((type) == ConstantType_Label)
ConstantUnion_— Union for the variant part of Constant.
union ConstantUnion_ { void *HANDLE; // Client handle. Symbol SYMBOL; // Symbol of this Constant. Label LABEL; // Label of this Constant. }; typedef union ConstantUnion_ ConstantUnion_, *ConstantUnion;
Constant— Constant for native code.
struct Constant_ { //@args ConstantType type, void *handle, //@args ImmediateValue value, ImmediateValue offset ImmediateConstant_ __; // A Constant_ ISA ImmediateConstant_. //@access VALUE ImmediateConstant_VALUE(Constant____(this)) //@mutate VALUE ImmediateConstant__VALUE(Constant____(this)) ImmediateValue OFFSET; // Offset in case of Symbol or Label constant. ConstantUnion_ UNION_; //@access HANDLE (Constant_UNION_(this).HANDLE) //@mutate HANDLE (&Constant_UNION_(this).HANDLE) //@access isRelocatable (Constant_HANDLE(this) != NULL) //@access SYMBOL (Constant_UNION_(this).SYMBOL) //@mutate SYMBOL (&Constant_UNION_(this).SYMBOL) //@access LABEL (Constant_UNION_(this).LABEL) //@mutate LABEL (&Constant_UNION_(this).LABEL) struct Constant_ *NEXT; // Next in ConstantList. ConstantType TYPE; // This Constant type. //@access isAbsolute ConstantType_isAbsolute(Constant_type(this)) //@access isSymbol ConstantType_isSymbol(Constant_type(this)) //@access isLabel ConstantType_isLabel(Constant_type(this)) };
Constant_type— This Constant type.
static inline ConstantType Constant_type(const_Constant this) { return Constant_TYPE(this); }
Constant_value— This Constant value.
static inline ImmediateValue Constant_value(const_Constant this) { return Constant_VALUE(this); }
Constant_setValue— Set this Constant value.
static inline void Constant_setValue(Constant this, ImmediateValue value) { *Constant__VALUE(this) = value; }
Constant_offset— This Constant offset in case of Constant symbol.
static inline ImmediateValue Constant_offset(const_Constant this) { Except_REQUIRE(Constant_isSymbol(this) || Constant_isLabel(this)); return Constant_OFFSET(this); }
Constant_setOffset— Set this Constant offset in case of Constant symbol.
static inline void Constant_setOffset(Constant this, ImmediateValue offset) { Except_REQUIRE(Constant_isSymbol(this) || Constant_isLabel(this)); *Constant__OFFSET(this) = offset; }
Constant_symbol— This Constant symbol.
static inline Symbol Constant_symbol(const_Constant this) { Except_REQUIRE(Constant_isSymbol(this)); return Constant_SYMBOL(this); }
Constant_label— This Constant label.
static inline Label Constant_label(const_Constant this) { Except_REQUIRE(Constant_isLabel(this)); return Constant_LABEL(this); }
ConstantTable— Implement a table of Constant(s) indexed by HANDLE.
struct ConstantTable_ { //@args Memory memory, int32_t estimate HTable_ HTABLE[1]; // The base HTable for this ConstantTable. //@access MEMORY HTable_memory(ConstantTable_HTABLE(this)) };
ConstantTable_memory— This ConstantTable memory.
static inline Memory ConstantTable_memory(const_ConstantTable this) { return ConstantTable_MEMORY(this); }
ConstantTable_htable— For buse by ConstantTable_FOREACH_Constant.
static inline const_HTable ConstantTable_htable(const_ConstantTable this) { return ConstantTable_HTABLE(this); }
ConstantTable_FOREACH_Constant— Iterate this ConstantTable Constant(s).
#define ConstantTable_FOREACH_Constant(this, constant) { \ const_HTable ConstantTable_HTABLE = ConstantTable_htable(this); \ HTable_FOREACH(ConstantTable_HTABLE, ConstantTable__, Constant_, constant) { #define ConstantTable_ENDEACH_Constant \ } HTable_ENDEACH; \ }
ConstantTable_search— Search a Constant in this ConstantTable.
static inline Constant ConstantTable_search(const_ConstantTable this, HTableKey key) { const_HTable htable = ConstantTable_HTABLE(this); Constant constant = HTable_search(htable, key); return constant; }
ConstantTable_lookup— Lookup a Constant into this ConstantTable.
static inline Constant ConstantTable_lookup(ConstantTable this, HTableKey key, ConstantType type, void *handle, ImmediateValue value, ImmediateValue offset) { HTable htable = ConstantTable_HTABLE(this); int32_t count = HTable_count(htable); size_t size = Constant_Size(type, handle, value, offset); Constant constant = HTable_lookup_(htable, key, size); if (count != HTable_count(htable)) { Constant_Ctor(constant, type, handle, value, offset); } return constant; }
ConstantList— Implement a list of Constant(s) by using the NEXT pointers.
struct ConstantList_ { //@args Memory memory Memory MEMORY; // This ConstantList Memory allocator. Constant FIRST; // First Constant in this ConstantList. Constant LAST; // First Constant in this ConstantList. int32_t COUNT; // Count of Constant(s) in this ConstantList. };
ConstantList_memory— This ConstantList memory.
static inline Memory ConstantList_memory(const_ConstantList this) { return ConstantList_MEMORY(this); }
ConstantList_first— First Constant of this ConstantList.
static inline Constant ConstantList_first(const_ConstantList this) { return ConstantList_FIRST(this); }
ConstantList_last— Last Constant of this ConstantList.
static inline Constant ConstantList_last(const_ConstantList this) { return ConstantList_LAST(this); }
ConstantList_count— Count of Constant(s) in this ConstantList.
static inline int32_t ConstantList_count(const_ConstantList this) { return ConstantList_COUNT(this); }
ConstantList_FOREACH_Constant— Iterate first to last Constant in this ConstantList.
#define ConstantList_FOREACH_Constant(this, constant) { \ Constant ConstantList_NEXT = NULL; \ Constant constant = ConstantList_first(this); \ for (; constant != NULL; constant = ConstantList_NEXT) { \ ConstantList_NEXT = Constant_NEXT(constant); #define ConstantList_ENDEACH_Constant \ } \ }
ConstantList_itemPush— Internal call to push a Constant as last of this ConstantList.
static inline Constant ConstantList_itemPush(ConstantList this, Constant item) { Constant first = ConstantList_FIRST(this); Constant last = ConstantList_LAST(this); Except_REQUIRE(item != last && Constant_NEXT(item) == NULL); if (last != NULL) *Constant__NEXT(last) = item; if (first == NULL) *ConstantList__FIRST(this) = item; *ConstantList__LAST(this) = item; *Constant__NEXT(item) = NULL; ++*ConstantList__COUNT(this); return item; }
ConstantList_itemPut— Internal call to put a Constant as first of this ConstantList.
static inline Constant ConstantList_itemPut(ConstantList this, Constant item) { Constant first = ConstantList_FIRST(this); Constant last = ConstantList_LAST(this); Except_REQUIRE(item != last && Constant_NEXT(item) == NULL); if (last == NULL) *ConstantList__LAST(this) = item; *ConstantList__FIRST(this) = item; *Constant__NEXT(item) = first; ++*ConstantList__COUNT(this); return item; }
ConstantList_push— Construct and push a Constant as last of this ConstantList.
Constant ConstantList_push(ConstantList this, ConstantType type, void *handle, ImmediateValue value, ImmediateValue offset);
ConstantList_drop— Drop the first Constant from this ConstantList.
static inline void ConstantList_drop(ConstantList this) { Constant first = ConstantList_FIRST(this); Constant next = Constant_NEXT(first); Except_REQUIRE(first != NULL); *ConstantList__FIRST(this) = next; if (next == NULL) { *ConstantList__LAST(this) = NULL; } *Constant__NEXT(first) = NULL; --*ConstantList__COUNT(this); }