X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Flibfirm%2Firmode.h;h=3d6db300f1cbabd7f0ad3a6c2d8f9a8f17fbae23;hb=1da43c3844e6865b0384d4370810fc936e828c32;hp=3ad6905b076500be7a7ccb47045303261dc2d293;hpb=bbd7f069d53814c921e888ef652c20213ca2500e;p=libfirm diff --git a/include/libfirm/irmode.h b/include/libfirm/irmode.h index 3ad6905b0..3d6db300f 100644 --- a/include/libfirm/irmode.h +++ b/include/libfirm/irmode.h @@ -36,14 +36,13 @@ #define FIRM_IR_IRMODE_H #include "firm_types.h" -#include "ident.h" /* ********** Predefined modes ********** */ /** * Predefined mode according to tech report 1999-14. */ -typedef enum { /* irm is short for `ir mode' */ +typedef enum ir_modecode { /* irm is short for `ir mode' */ irm_BB, /**< basic block */ irm_X, /**< execution */ irm_F, /**< float(32) */ @@ -68,28 +67,45 @@ typedef enum { /* irm is short for `ir mode' */ irm_max /**< maximum value for ir_modecode */ } ir_modecode; -/** These values represent the different mode classes of value representations. +/** Helper values for ir_mode_sort. */ +enum ir_mode_sort_helper { + irmsh_is_num = 0x10, /**< mode represents a number */ + irmsh_is_data = 0x20, /**< mode represents data (can be carried in registers) */ + irmsh_is_datab = 0x40, /**< mode represents data or is internal boolean */ + irmsh_is_dataM = 0x80, /**< mode represents data or is memory */ +}; + +/** + * These values represent the different mode classes of value representations. + * Beware: do not change the order of these values without checking + * the mode_is */ -typedef enum { +typedef enum ir_mode_sort { /* Predefined sorts of modes */ - irms_auxiliary, /**< Only for Firm use. Not extensible. (irm_T) */ - irms_control_flow, /**< Marks all control flow modes. Not extensible. (irm_BB, irm_X) */ - irms_memory, /**< Marks the memory mode. Not extensible. (irm_M) */ - irms_internal_boolean, /**< Internal boolean representation. - Storing to memory impossible, convert first. (irm_b) */ + irms_auxiliary = 0, /**< Only for Firm use. Not extensible. (irm_T) */ + irms_control_flow = 1, /**< Marks all control flow modes. Not extensible. (irm_BB, irm_X) */ + irms_memory = 2 | irmsh_is_dataM, /**< Marks the memory mode. Not extensible. (irm_M) */ + + /** Internal boolean representation. + Storing to memory impossible, convert first. (irm_b) */ + irms_internal_boolean = 3 | irmsh_is_datab, + /* user-extensible sorts of modes */ - 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 */ + /** A mode to represent entities. + Restricted int computations can be performed */ + irms_reference = 4 | irmsh_is_data | irmsh_is_datab | irmsh_is_dataM, + /** A mode to represent int numbers. + Integer computations can be performed. */ + irms_int_number = 5 | irmsh_is_data | irmsh_is_datab | irmsh_is_dataM | irmsh_is_num, + /** A mode to represent float numbers. + Floating point computations can be performed. */ + irms_float_number = 6 | irmsh_is_data | irmsh_is_datab | irmsh_is_dataM | irmsh_is_num, } ir_mode_sort; /** These values represent the different arithmetic operations possible with a mode. Further arithmetics can be defined, e.g., for @@@ modes. */ -typedef enum { +typedef enum ir_mode_arithmetic { irma_uninitialized = 0, irma_none = 1, /**< For modes for which no representation is specified. These are modes of sort auxiliary, internal_boolean and character. */ @@ -407,10 +423,26 @@ 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 definition */ +/** + * Returns true if sm can be converted to lm without loss + * according to firm definition. + * + * Note that mode_Iu is NOT smaller than mode_Is here. + * + * @see values_in_mode() + */ int smaller_mode(const ir_mode *sm, const ir_mode *lm); +/** + * Returns true if a value of mode sm can be converted into mode lm + * and backwards without loss. + * + * Note that mode_Iu values CAN be converted in mode_Is and back. + * + * @see smaller_mode() + */ +int values_in_mode(const ir_mode *sm, const ir_mode *lm); + /** * Returns a matching unsigned mode for a given integer signed mode. * Returns NULL if no matching mode exists. @@ -468,4 +500,11 @@ ir_mode *get_reference_mode_unsigned_eq(ir_mode *mode); */ void set_reference_mode_unsigned_eq(ir_mode *ref_mode, ir_mode *int_mode); +/** + * Returns non-zero if the cast from mode src to mode dst is a + * reinterpret cast (ie. only the bit pattern is reinterpreted, + * no conversion is done) + */ +int is_reinterpret_cast(const ir_mode *src, const ir_mode *dst); + #endif