*/
typedef enum {
/* Predefined sorts of modes */
- auxiliary, /**< Only for Firm use, predefined. */
- internal_boolean, /**< Internal boolean representation.
- Storing to memory impossible, convert first. */
+ irms_auxiliary, /**< Only for Firm use, predefined. */
+ irms_internal_boolean, /**< Internal boolean representation.
+ Storing to memory impossible, convert first. */
/** user-extensible sorts of modes **/
- int_number, /**< A mode to represent int numbers.
- Integer computations can be performed. */
- float_number, /**< A mode to represent float numbers.
- Floating point computations can be performed. */
- reference, /**< A mode to represent entities.
- Restricted int computations can be performed */
- character /**< A mode to represent characters/symbols
- ?? Are computations allowed? as int?? */
+ irms_int_number, /**< A mode to represent int numbers.
+ Integer computations can be performed. */
+ irms_float_number, /**< A mode to represent float numbers.
+ 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
+ ?? Are computations allowed? as int?? */
} mode_sort;
/* ********** Constructor for user defined modes **************** */
/**
- * Registers a new mode.
- * Must be called BEFORE init_mode2() !!!
+ * Creates a new mode.
*
- * The information for new mode is retrieved from the mode
- * struct passed as parameter, the code field is ignored.
- * The struct is copied into the internal mode array and the code
- * field will be set to a unique integer.
+ * @param name the name of the mode to be created
+ * @param sort the mode_sort of teh mode to be created
+ * @param bit_size number of bits this mode allocate
+ * @param align the byte alignment for an entity of this mode (in bits)
+ * @param sign non-zero if this is a signed mode
+ *
+ * This function constructs a new mode given by the parameters.
+ * If the parameters match an already defined mode, this mode is returned
+ * (including the default modes).
+ * 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
*
- * If a mode with the given characteristics already exists,
- * it will be returned instead of creating a new one.
+ * @return
+ * The new mode or NULL on error.
*
- * The passed struct can be safely deallocated after the function
- * returns.
- * To access the new mode the returned mode pointer must be used!
+ * @note
+ * FIRM modes are unique independant of its name. So, you cannot expect
+ * that the returned mode will have the mode name.
+ * It is allowed to construct the default modes. So, a call
+ * new_ir_mode("Int", irms_int_number, 32, 4, 1) will return mode_Is.
*/
-ir_mode *register_mode(ir_mode* new_mode);
+ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int align, int sign);
/* ********** Access methods to read mode information *********** */
-#ifdef MODE_ACCESS_DEFINES
-# include "irmode_t.h"
-# define get_mode_modecode(mode) (mode)->code
-# define get_mode_ident(mode) (mode)->name
-# define get_mode_name(mode) id_to_str((mode)->name)
-# define get_mode_sort(mode) (mode)->sort
-# define get_mode_size_bits(mode) (mode)->size
-# define get_mode_align(mode) (mode)->align
-#else
/** Returns the classification of the mode */
modecode get_mode_modecode(ir_mode *mode);
/** Returns the alignment of values of the mode in bytes. */
int get_mode_align(ir_mode *mode);
-#endif
+
+/** Returns the signess of a mode */
+int get_mode_sign (ir_mode *mode);
/**
* Returns the smallest representable value of a given mode.
*/
/*@}*/
/* Test for a certain class of modes. */
-#ifdef MODE_ACCESS_DEFINES
-# define mode_is_signed(mode) (mode)->sign
-# define mode_is_float(mode) ((mode)->sort == float_number)
-# define mode_is_int(mode) ((mode)->sort == int_number)
-# define mode_is_num(mode) (((mode)->sort == float_number) || ((mode)->sort == int_number))
-# define mode_is_data(mode) (((mode)->sort == float_number) || ((mode)->sort == int_number) || ((mode)->sort == character) || ((mode)->sort == reference))
-# define mode_is_datab(mode) (((mode)->sort == float_number) || ((mode)->sort == int_number) || ((mode)->sort == character) || ((mode)->sort == reference) || ((mode)->sort == internal_boolean))
-# define mode_is_dataM(mode) (((mode)->sort == float_number) || ((mode)->sort == int_number) || ((mode)->sort == character) || ((mode)->sort == reference) || ((mode)->code == irm_M))
-#else
int mode_is_signed (ir_mode *mode);
int mode_is_float (ir_mode *mode);
int mode_is_int (ir_mode *mode);
int mode_is_data (ir_mode *mode);
int mode_is_datab (ir_mode *mode);
int mode_is_dataM (ir_mode *mode);
-#endif
/** Returns true if sm can be converted to lm without loss
according to firm definiton */
int smaller_mode(ir_mode *sm, ir_mode *lm);