INLINE static int modes_are_equal(const ir_mode *m, const ir_mode *n)
{
if (m == n) return 1;
- if (m->sort == n->sort &&
- m->arithmetic == n->arithmetic &&
- m->size == n->size &&
- m->align == n->align &&
- m->sign == n->sign &&
- m->modulo_shift == n->modulo_shift)
+ if (m->sort == n->sort &&
+ m->arithmetic == n->arithmetic &&
+ m->size == n->size &&
+ m->align == n->align &&
+ m->sign == n->sign &&
+ m->modulo_shift == n->modulo_shift &&
+ m->vector_elem == n->vector_elem)
return 1;
return 0;
PTR_INT_TYPE adr = __PTR_TO_INT((char *)p);
int mask = obstack_alignment_mask(o);
- adr += s + o->alignment_mask;
+ adr += s + mask;
- return __INT_TO_PTR(adr & ~o->alignment_mask);
+ return __INT_TO_PTR(adr & ~mask);
}
/**
assert(new_mode);
/* copy mode struct to modes array */
- mode=(ir_mode*) obstack_copy(&modes, new_mode, sizeof(ir_mode));
+ mode = (ir_mode*)obstack_copy(&modes, new_mode, sizeof(ir_mode));
mode->kind = k_ir_mode;
if(num_modes>=irm_max) mode->code = num_modes;
mode_tmpl.align = align;
mode_tmpl.sign = sign ? 1 : 0;
mode_tmpl.modulo_shift = (mode_tmpl.sort == irms_int_number) ? modulo_shift : 0;
+ mode_tmpl.vector_elem = 1;
mode_tmpl.arithmetic = arithmetic;
mode_tmpl.link = NULL;
mode_tmpl.tv_priv = NULL;
return NULL; /* to shut up gcc */
}
+/*
+ * Creates a new vector mode.
+ */
+ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int align, int sign,
+ mode_arithmetic arithmetic, unsigned int modulo_shift )
+{
+ ir_mode mode_tmpl;
+ ir_mode *mode;
+
+ mode_tmpl.name = new_id_from_str(name);
+ mode_tmpl.sort = sort;
+ mode_tmpl.size = bit_size * num_of_elem;
+ mode_tmpl.align = align;
+ mode_tmpl.sign = sign ? 1 : 0;
+ mode_tmpl.modulo_shift = (mode_tmpl.sort == irms_int_number) ? modulo_shift : 0;
+ mode_tmpl.vector_elem = num_of_elem;
+ mode_tmpl.arithmetic = arithmetic;
+ mode_tmpl.link = NULL;
+ mode_tmpl.tv_priv = NULL;
+
+ mode = find_mode(&mode_tmpl);
+ if (mode)
+ return mode;
+
+ if (num_of_elem <= 1) {
+ assert(0 && "vector modes should have at least 2 elements");
+ return NULL;
+ }
+
+ /* sanity checks */
+ switch (sort)
+ {
+ case irms_auxiliary:
+ case irms_control_flow:
+ case irms_memory:
+ case irms_internal_boolean:
+ assert(0 && "internal modes cannot be user defined");
+ return NULL;
+
+ case irms_reference:
+ case irms_character:
+ assert(0 && "only integer and floating point modes can be vectorized");
+ return NULL;
+
+ case irms_float_number:
+ assert(0 && "not yet implemented");
+ return NULL;
+
+ case irms_int_number:
+ return register_mode(&mode_tmpl);
+ }
+ return NULL; /* to shut up gcc */
+}
+
/* Functions for the direct access to all attributes od a ir_mode */
modecode
get_mode_modecode(const ir_mode *mode)
return mode->modulo_shift;
}
-void* get_mode_link(const ir_mode *mode)
+unsigned int get_mode_vector_elems(const ir_mode *mode) {
+ return mode->vector_elem;
+}
+
+void *get_mode_link(const ir_mode *mode)
{
ANNOUNCE();
return mode->link;
assert(mode);
return (mode_is_data(mode) || get_mode_modecode(mode) == irm_M);
}
+
+int
+mode_is_float_vector (const ir_mode *mode)
+{
+ ANNOUNCE();
+ assert(mode);
+ return (get_mode_sort(mode) == irms_float_number) && (get_mode_vector_elems(mode) > 1);
+}
+
+int
+mode_is_int_vector (const ir_mode *mode)
+{
+ ANNOUNCE();
+ assert(mode);
+ return (get_mode_sort(mode) == irms_int_number) && (get_mode_vector_elems(mode) > 1);
+}
+
#ifdef MODE_ACCESS_DEFINES
# define mode_is_signed(mode) (mode)->sign
# define mode_is_float(mode) ((mode)->sort == irms_float_number)
# define mode_is_data(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference))
# define mode_is_datab(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference) || ((mode)->sort == irms_internal_boolean))
# define mode_is_dataM(mode) (((mode)->sort == irms_float_number) || ((mode)->sort == irms_int_number) || ((mode)->sort == irms_character) || ((mode)->sort == irms_reference) || ((mode)->code == irm_M))
+# define mode_is_float_vector(mode) (((mode)->sort == irms_float_number) && ((mode)->vector_elem > 1))
+# define mode_is_int_vector(mode) (((mode)->sort == irms_int_number) && ((mode)->vector_elem > 1))
#endif
/* Returns true if sm can be converted to lm without loss. */
int
newmode.align = 0;
newmode.sign = 0;
newmode.modulo_shift = 0;
+ newmode.vector_elem = 0;
newmode.link = NULL;
newmode.tv_priv = NULL;
mode_b = register_mode(&newmode);
/* Data Modes */
+ newmode.vector_elem = 1;
/* Float Number Modes */
newmode.sort = irms_float_number;
Floating point computations can be performed. */
irms_reference, /**< A mode to represent entities.
Restricted int computations can be performed */
- irms_character /**< A mode to represent characters/symbols
+ irms_character, /**< A mode to represent characters/symbols
?? Are computations allowed? as int?? */
} mode_sort;
irma_ieee754 = 256, /**< Values of the mode are represented according to ieee754
floatingpoint standard. Only legal for modes of sort float_number. */
irma_float_BCD, /**< Values of the mode are represented as binary coded decimals
- according to @@@ which standars??? Only legal for modes of
+ according to @@@ which standards??? Only legal for modes of
sort float_number. */
irma_max
} mode_arithmetic;
*
* @note
* It is allowed to construct the default modes. So, a call
- * new_ir_mode("Is", irms_int_number, 32, 4, 1, 32) will return mode_Is.
+ * new_ir_mode("Is", irms_int_number, 32, 4, 1, irma_twos_complement, 32) will return mode_Is.
*/
ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int align, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift);
+/**
+ * Creates a new vector mode.
+ *
+ * @param name the name of the mode to be created
+ * @param sort the mode_sort of the mode to be created
+ * @param bit_size number of bits for one element of this mode
+ * @param num_of_elem number of elements in this vector mode
+ * @param align the byte alignment for an entity of this mode (in bits)
+ * @param sign non-zero if this is a signed mode
+ * @param arithmetic arithmetic operations possible with a mode
+ * @param modulo_shift Is ignored for modes other than integer.
+ *
+ * This function constructs a new vector mode given by the parameters.
+ * If the parameters match an already defined mode, this mode is returned.
+ * If the mode is newly allocated, a new unique mode_code is choosen.
+ * Also, special value tarvals will be calculated such as null,
+ * min, max and can be retrieved using the get_mode_* fuctions
+ *
+ * @return
+ * The new mode or NULL on error.
+ */
+ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int align, int sign,
+ mode_arithmetic arithmetic, unsigned int modulo_shift );
+
/**
* Checks whether a pointer points to a mode.
*
*/
unsigned int get_mode_modulo_shift(const ir_mode *mode);
+/** Attribute vector_elem specifies the number of vector elements of
+ * a vector mode. For non-vector modes it returns 1 for data and 0
+ * for all other modes
+ */
+unsigned int get_mode_vector_elems(const ir_mode *mode);
/** Returns the stored intermediate information. */
void* get_mode_link(const ir_mode *mode);
The set of "dataM" is defined as:
dataM = {data || irm_M}
+
+ Vector "int" and "float" are defined by the arithmetic and vector_elem > 1.
*/
/*@}*/
/* Test for a certain class of modes. */
int mode_is_data (const ir_mode *mode);
int mode_is_datab (const ir_mode *mode);
int mode_is_dataM (const ir_mode *mode);
+int mode_is_float_vector (const ir_mode *mode);
+int mode_is_int_vector (const ir_mode *mode);
/** Returns true if sm can be converted to lm without loss
according to firm definiton */