X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Flibfirm%2Firmode.h;h=a6e7b69fc5799a43ed0f805d8f29a836eb73587b;hb=5bfb295525b0e0811b61106bb47375e2aaf77c54;hp=3be8153136313e46259c98d7296a22d3e15f25cc;hpb=862c317753cda7a38858113dc3b3e7858b8b2f38;p=libfirm diff --git a/include/libfirm/irmode.h b/include/libfirm/irmode.h index 3be815313..a6e7b69fc 100644 --- a/include/libfirm/irmode.h +++ b/include/libfirm/irmode.h @@ -23,7 +23,7 @@ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil, * Michael Beck * @version $Id$ - * @summary + * @brief * This module specifies the modes that type the firm nodes. It defines * a datasturcture that describes a mode and implements constructors and * access routines to this datastructure. Further it defines a set of @@ -36,60 +36,48 @@ #define FIRM_IR_IRMODE_H #include "firm_types.h" -#include "ident.h" /* ********** Predefined modes ********** */ +/** 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 */ +}; + /** - * Predefined mode according to tech report 1999-14. - */ -typedef enum { /* irm is short for `ir mode' */ - irm_BB, /**< basic block */ - irm_X, /**< execution */ - irm_F, /**< float(32) */ - irm_D, /**< double(64) */ - irm_E, /**< extended(80) */ - irm_Bs, /**< signed byte(8) */ - irm_Bu, /**< unsigned byte(8) */ - irm_Hs, /**< signed short(16) */ - irm_Hu, /**< unsigned short(16) */ - irm_Is, /**< signed int(32) */ - irm_Iu, /**< unsigned int(32) */ - irm_Ls, /**< signed long(64) */ - irm_Lu, /**< unsigned long(64) */ - irm_LLs, /**< signed long long(128) */ - irm_LLu, /**< unsigned long long(128) */ - irm_P, /**< pointer */ - irm_b, /**< internal boolean */ - irm_M, /**< memory */ - irm_T, /**< tuple */ - irm_ANY, /**< undefined mode */ - irm_BAD, /**< bad mode */ - irm_max /**< maximum value for ir_modecode */ -} ir_modecode; - -/** These values represent the different mode classes of value representations. - */ -typedef enum { + * 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 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. */ @@ -107,6 +95,8 @@ typedef enum { irma_max } ir_mode_arithmetic; +/** Returns the name of the arithmetic type. */ +const char *get_mode_arithmetic_name(ir_mode_arithmetic ari); /* ********** Constructor for user defined modes **************** */ /** @@ -167,13 +157,10 @@ ir_mode *new_ir_vector_mode(const char *name, ir_mode_sort sort, int bit_size, u * @return * true if the thing is a mode, else false */ -int is_mode(void *thing); +int is_mode(const void *thing); /* ********** Access methods to read mode information *********** */ -/** Returns the classification of the mode */ -ir_modecode get_mode_modecode(const ir_mode *mode); - /** Returns the ident* of the mode */ ident *get_mode_ident(const ir_mode *mode); @@ -363,8 +350,9 @@ void set_modeP_code(ir_mode *p); */ void set_modeP_data(ir_mode *p); +/*@{*/ /** - Functions to check, whether a ir_modecode is signed, float, int, character, + Functions to check, whether a mode is signed, float, int, character, reference, num, data, datab or dataM. For more exact definitions read the corresponding pages @@ -393,7 +381,6 @@ void set_modeP_data(ir_mode *p); Vector "int" and "float" are defined by the arithmetic and vector_elem > 1. */ -/*@}*/ /* Test for a certain class of modes. */ int mode_is_signed (const ir_mode *mode); int mode_is_float (const ir_mode *mode); @@ -405,11 +392,28 @@ 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 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. @@ -467,4 +471,16 @@ 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); + +/** + * Returns the primitive type matching the given mode + */ +ir_type *get_type_for_mode(const ir_mode *mode); + #endif