From 32a2398b0e842a649c8660b50b46cc493b4b4bc9 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 3 Aug 2005 11:48:28 +0000 Subject: [PATCH] split modeP_mach into modeP_code and modeP_data all modes are now kept in a list in the irp [r6365] --- ir/ir/irmode.c | 35 +++++++++++++++++++++++++++-------- ir/ir/irmode.h | 24 ++++++++++++++++++------ ir/ir/irmode_t.h | 15 ++++++--------- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index 61635c348..a9058f95f 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -22,6 +22,7 @@ # include +# include "irprog_t.h" # include "irmode_t.h" # include "ident.h" # include "tv_t.h" @@ -200,7 +201,8 @@ ir_mode *mode_b; ir_mode *mode_P; /* machine specific modes */ -ir_mode *mode_P_mach; /* machine specific pointer mode */ +ir_mode *mode_P_code; /**< machine specific pointer mode for code addresses */ +ir_mode *mode_P_data; /**< machine specific pointer mode for data addresses */ /* * * * functions defined in irmode.h @@ -230,14 +232,26 @@ INLINE ir_mode *get_modeANY(void) { ANNOUNCE(); return mode_ANY; } INLINE ir_mode *get_modeBAD(void) { ANNOUNCE(); return mode_BAD; } -ir_mode *(get_modeP_mach)(void) { +ir_mode *(get_modeP_code)(void) { ANNOUNCE(); - return _get_modeP_mach(); + return _get_modeP_code(); } -void (set_modeP_mach)(ir_mode *p) { +ir_mode *(get_modeP_data)(void) { ANNOUNCE(); - _set_modeP_mach(p); + return _get_modeP_data(); +} + +void set_modeP_code(ir_mode *p) { + assert(mode_is_reference(p)); + + mode_P_code = p; +} + +void set_modeP_data(ir_mode *p) { + assert(mode_is_reference(p)); + + mode_P_data = p; } /** @@ -259,6 +273,9 @@ static ir_mode *register_mode(const ir_mode *new_mode) if (num_modes >= irm_max) mode->code = num_modes; num_modes++; + /* add the new mode to the irp list of modes */ + add_irp_mode(mode); + set_mode_values(mode); hook_new_mode(new_mode, mode); @@ -364,7 +381,7 @@ ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsi return mode; } -/* Functions for the direct access to all attributes od a ir_mode */ +/* Functions for the direct access to all attributes of an ir_mode */ modecode (get_mode_modecode)(const ir_mode *mode) { @@ -901,7 +918,8 @@ init_mode (void) mode_P = register_mode(&newmode); /* set the machine specific modes to the predefined ones */ - mode_P_mach = mode_P; + mode_P_code = mode_P; + mode_P_data = mode_P; } /* find a signed mode for an unsigned integer mode */ @@ -998,5 +1016,6 @@ void finish_mode(void) { mode_b = NULL; mode_P = NULL; - mode_P_mach = NULL; + mode_P_code = NULL; + mode_P_data = NULL; } diff --git a/ir/ir/irmode.h b/ir/ir/irmode.h index 9c973b72a..488124dcb 100644 --- a/ir/ir/irmode.h +++ b/ir/ir/irmode.h @@ -321,8 +321,11 @@ 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_mach; /**< A pointer mode that is set by the client of libfirm. This mode - represents the pointer size of the target machine. Is initialized +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 + to mode_P. */ +extern ir_mode *mode_P_data; /**< A pointer mode that is set by the client of libfirm. This mode + represents the pointer size of the target machine data addresses. Is initialized to mode_P. */ /* -- Auxiliary modes necessary for the Firm representation -- */ @@ -359,14 +362,23 @@ ir_mode *get_modeT(void); ir_mode *get_modeANY(void); ir_mode *get_modeBAD(void); -/** Returns the machine specific pointer mode. */ -ir_mode *get_modeP_mach(void); +/** Returns the machine specific pointer mode for code addresses. */ +ir_mode *get_modeP_code(void); + +/** Returns the machine specific pointer mode for data addresses. */ +ir_mode *get_modeP_data(void); + +/** + * Sets the machine specific pointer mode for code addresses. + * If not set, the predefined mode mode_P will be used. + */ +void set_modeP_code(ir_mode *p); /** - * Sets the machine specific pointer mode. + * Sets the machine specific pointer mode for data addresses. * If not set, the predefined mode mode_P will be used. */ -void set_modeP_mach(ir_mode *p); +void set_modeP_data(ir_mode *p); /** Functions to check, whether a modecode is signed, float, int, character, diff --git a/ir/ir/irmode_t.h b/ir/ir/irmode_t.h index 6e79a80ed..2883e1534 100644 --- a/ir/ir/irmode_t.h +++ b/ir/ir/irmode_t.h @@ -54,16 +54,13 @@ struct ir_mode { /* ------------------------------- * * inline functions * * ------------------------------- */ -extern ir_mode *mode_P_mach; +extern ir_mode *mode_P_code, *mode_P_data; static INLINE ir_mode * -_get_modeP_mach(void) { return mode_P_mach; } +_get_modeP_code(void) { return mode_P_code; } -static INLINE void -_set_modeP_mach(ir_mode *p) { - assert(mode_is_reference(p)); - mode_P_mach = p; -} +static INLINE ir_mode * +_get_modeP_data(void) { return mode_P_data; } static INLINE modecode _get_mode_modecode(const ir_mode *mode) { return mode->code; } @@ -217,8 +214,8 @@ void init_mode(void); /** mode module finalization. frees all memory. */ void finish_mode(void); -#define get_modeP_mach() _get_modeP_mach() -#define set_modeP_mach(p) _set_modeP_mach(p) +#define get_modeP_code() _get_modeP_code() +#define get_modeP_data() _get_modeP_data() #define get_mode_modecode(mode) _get_mode_modecode(mode) #define get_mode_ident(mode) _get_mode_ident(mode) #define get_mode_sort(mode) _get_mode_sort(mode) -- 2.20.1