X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=include%2Flibfirm%2Firmode.h;h=7f55e3ce711c4325d5c357b9d4d38ab8ab5c1ded;hb=f7a0dee11313faad6f2ff54edc8eaadabd03e433;hp=769fd0f4e47051c56e6276f3d1dd6927328c27de;hpb=17dd11192f8a80c43bb7ec3e470b8764a842ce60;p=libfirm diff --git a/include/libfirm/irmode.h b/include/libfirm/irmode.h index 769fd0f4e..7f55e3ce7 100644 --- a/include/libfirm/irmode.h +++ b/include/libfirm/irmode.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -43,7 +43,7 @@ /** * 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) */ @@ -59,20 +59,18 @@ typedef enum { /* irm is short for `ir mode' */ irm_Lu, /**< unsigned long(64) */ irm_LLs, /**< signed long long(128) */ irm_LLu, /**< unsigned long long(128) */ - irm_C, /**< character */ irm_P, /**< pointer */ irm_b, /**< internal boolean */ irm_M, /**< memory */ irm_T, /**< tuple */ - irm_U, /**< unicode character */ irm_ANY, /**< undefined mode */ irm_BAD, /**< bad mode */ - irm_max /**< maximum value for modecode */ -} modecode; + irm_max /**< maximum value for ir_modecode */ +} ir_modecode; /** These values represent the different mode classes of value representations. */ -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) */ @@ -84,16 +82,14 @@ typedef enum { 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. + 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; +} 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. */ @@ -109,7 +105,7 @@ typedef enum { according to @@@ which standards??? Only legal for modes of sort float_number. */ irma_max -} mode_arithmetic; +} ir_mode_arithmetic; /* ********** Constructor for user defined modes **************** */ @@ -117,7 +113,7 @@ typedef enum { * Creates a new mode. * * @param name the name of the mode to be created - * @param sort the mode_sort of the mode to be created + * @param sort the ir_mode_sort of the mode to be created * @param bit_size number of bits this mode allocate * @param sign non-zero if this is a signed mode * @param arithmetic arithmetic operations possible with a mode @@ -137,13 +133,14 @@ typedef enum { * It is allowed to construct the default modes. So, a call * new_ir_mode("Is", irms_int_number, 32, 1, irma_twos_complement, 32) will return mode_Is. */ -ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift); +ir_mode *new_ir_mode(const char *name, ir_mode_sort sort, int bit_size, int sign, + ir_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 sort the ir_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 sign non-zero if this is a signed mode @@ -159,8 +156,8 @@ ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int sign, m * @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 sign, - mode_arithmetic arithmetic, unsigned int modulo_shift); +ir_mode *new_ir_vector_mode(const char *name, ir_mode_sort sort, int bit_size, unsigned num_of_elem, int sign, + ir_mode_arithmetic arithmetic, unsigned int modulo_shift); /** * Checks whether a pointer points to a mode. @@ -175,7 +172,7 @@ int is_mode(void *thing); /* ********** Access methods to read mode information *********** */ /** Returns the classification of the mode */ -modecode get_mode_modecode(const ir_mode *mode); +ir_modecode get_mode_modecode(const ir_mode *mode); /** Returns the ident* of the mode */ ident *get_mode_ident(const ir_mode *mode); @@ -184,14 +181,14 @@ ident *get_mode_ident(const ir_mode *mode); const char *get_mode_name(const ir_mode *mode); /** Returns a coarse classification of the mode. */ -mode_sort get_mode_sort(const ir_mode *mode); +ir_mode_sort get_mode_sort(const ir_mode *mode); /** Returns the size of values of the mode in bits. */ -int get_mode_size_bits(const ir_mode *mode); +unsigned get_mode_size_bits(const ir_mode *mode); /** Returns the size of values of the mode in bytes. * If the size is not dividable by 8 returns -1. */ -int get_mode_size_bytes(const ir_mode *mode); +unsigned get_mode_size_bytes(const ir_mode *mode); /** Returns the signess of a mode. * @@ -199,7 +196,7 @@ int get_mode_size_bytes(const ir_mode *mode); int get_mode_sign(const ir_mode *mode); /** Returns the arithmetic of a mode */ -int get_mode_arithmetic(const ir_mode *mode); +ir_mode_arithmetic get_mode_arithmetic(const ir_mode *mode); /** Get the modulo shift attribute. * @@ -266,6 +263,13 @@ tarval *get_mode_one(ir_mode *mode); */ tarval *get_mode_minus_one(ir_mode *mode); +/** + * Returns the value where all bits are One, represented in this mode. + * + * All One is defined only for modes integer, reference and boolean modes + */ +tarval *get_mode_all_one(ir_mode *mode); + /** * Returns the positive infinite value of a mode. * @@ -299,9 +303,6 @@ extern ir_mode *mode_Lu; /**< unsigned long integer */ extern ir_mode *mode_LLs; /**< signed long long integer */ extern ir_mode *mode_LLu; /**< unsigned long long integer */ -extern ir_mode *mode_C; /**< 8 bit char */ -extern ir_mode *mode_U; /**< 16 bit unicode char */ - extern ir_mode *mode_P; /**< pointer */ extern ir_mode *mode_P_code; /**< A pointer mode that is set by the client of libfirm. This mode represents the pointer size of the target machine code addresses. Is initialized @@ -335,8 +336,6 @@ ir_mode *get_modeLs(void); ir_mode *get_modeLu(void); ir_mode *get_modeLLs(void); ir_mode *get_modeLLu(void); -ir_mode *get_modeC(void); -ir_mode *get_modeU(void); ir_mode *get_modeP(void); ir_mode *get_modeb(void); ir_mode *get_modeX(void); @@ -364,9 +363,10 @@ void set_modeP_code(ir_mode *p); */ void set_modeP_data(ir_mode *p); +/*@{*/ /** - Functions to check, whether a modecode is signed, float, int, character, - reference, num, numP, data, datab or dataM. + Functions to check, whether a ir_modecode is signed, float, int, character, + reference, num, data, datab or dataM. For more exact definitions read the corresponding pages in the firm documentation or the following enumeration @@ -377,20 +377,14 @@ void set_modeP_data(ir_mode *p); The set of "int" is defined as: int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu} - The set of "character" is defined as: - character = {irm_C, irm_U} - The set of "reference" is defined as: reference = {irm_P} The set of "num" is defined as: num = {float || int} - The set of "numP" is defined as: - numP = {float || int || reference} - The set of "data" is defined as: - data = {num || character || reference} + data = {num || reference} The set of "datab" is defined as: datab = {data || irm_b } @@ -400,25 +394,39 @@ 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); int mode_is_int (const ir_mode *mode); -int mode_is_character (const ir_mode *mode); int mode_is_reference (const ir_mode *mode); int mode_is_num (const ir_mode *mode); -int mode_is_numP (const ir_mode *mode); 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 */ +/** + * 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. @@ -476,4 +484,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