Commit 9baf0cd6 authored by Michael Beck's avatar Michael Beck
Browse files

removed character modes, use integer modes instead

[r15057]
parent a36f85bc
......@@ -86,8 +86,6 @@ typedef enum {
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;
/** These values represent the different arithmetic operations possible with a mode.
......@@ -299,9 +297,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 +330,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);
......@@ -366,7 +359,7 @@ 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.
reference, num, data, datab or dataM.
For more exact definitions read the corresponding pages
in the firm documentation or the following enumeration
......@@ -377,20 +370,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 }
......@@ -405,10 +392,8 @@ void set_modeP_data(ir_mode *p);
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);
......@@ -416,7 +401,7 @@ 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 */
according to firm definition */
int smaller_mode(const ir_mode *sm, const ir_mode *lm);
/**
......
......@@ -19,7 +19,7 @@
/**
* @file
* @brief architecture dependand IR operations
* @brief architecture dependant IR operations
* @version $Id$
*/
#ifdef HAVE_CONFIG_H
......@@ -310,7 +310,7 @@ static int verify_node_MinMax(ir_node *n, ir_graph *irg) {
/* MinMax: BB x numP x numP --> numP */
op1mode == mymode &&
op2mode == mymode &&
mode_is_numP(mymode),
mode_is_data(mymode),
"Min or Max node", 0
);
return 1;
......
......@@ -751,7 +751,7 @@ static void emit_be_Copy(arm_emit_env_t *env, const ir_node *irn) {
assert(0 && "move not supported for this mode");
panic("emit_be_Copy: move not supported for this mode");
}
} else if (mode_is_numP(mode)) {
} else if (mode_is_data(mode)) {
be_emit_cstring(env->emit, "\tmov ");
arm_emit_dest_register(env, irn, 0);
be_emit_cstring(env->emit, ", ");
......
......@@ -74,7 +74,7 @@ extern ir_op *get_op_Mulh(void);
****************************************************************************************************/
static INLINE int mode_needs_gp_reg(ir_mode *mode) {
return mode_is_int(mode) || mode_is_character(mode) || mode_is_reference(mode);
return mode_is_int(mode) || mode_is_reference(mode);
}
typedef struct vals_ {
......@@ -393,7 +393,7 @@ static ir_node *gen_Add(ir_node *node) {
return NULL;
}
} else {
assert(mode_is_numP(mode));
assert(mode_is_data(mode));
mode = mode_Iu;
if (is_arm_Mov_i(new_op1))
......@@ -469,7 +469,7 @@ static ir_node *gen_Mul(ir_node *node) {
return NULL;
}
}
assert(mode_is_numP(mode));
assert(mode_is_data(mode));
mode = mode_Iu;
return new_rd_arm_Mul(dbg, irg, block, new_op1, new_op2, mode);
}
......@@ -603,7 +603,7 @@ static ir_node *gen_Sub(ir_node *node) {
}
}
else {
assert(mode_is_numP(mode) && "unknown mode for Sub");
assert(mode_is_data(mode) && "unknown mode for Sub");
mode = mode_Iu;
if (is_arm_Mov_i(new_op1))
......@@ -735,7 +735,7 @@ static ir_node *gen_Abs(ir_node *node) {
panic("Softfloat not supported yet\n");
}
}
assert(mode_is_numP(mode));
assert(mode_is_data(mode));
mode = mode_Iu;
return new_rd_arm_Abs(dbg, current_ir_graph, block, new_op, mode);
}
......@@ -764,7 +764,7 @@ static ir_node *gen_Minus(ir_node *node) {
panic("Softfloat not supported yet\n");
}
}
assert(mode_is_numP(mode));
assert(mode_is_data(mode));
mode = mode_Iu;
return new_rd_arm_Rsb_i(dbg, current_ir_graph, block, new_op, mode, get_mode_null(mode));
}
......@@ -798,7 +798,7 @@ static ir_node *gen_Load(ir_node *node) {
}
}
else {
assert(mode_is_numP(mode) && "unsupported mode for Load");
assert(mode_is_data(mode) && "unsupported mode for Load");
if (mode_is_signed(mode)) {
/* sign extended loads */
......@@ -873,7 +873,7 @@ static ir_node *gen_Store(ir_node *node) {
panic("Softfloat not supported yet\n");
}
} else {
assert(mode_is_numP(mode) && "unsupported mode for Store");
assert(mode_is_data(mode) && "unsupported mode for Store");
switch (get_mode_size_bits(mode)) {
case 8:
new_store = new_rd_arm_Storeb(dbg, irg, block, new_ptr, new_val, new_mem);
......
......@@ -207,7 +207,7 @@ static void gen_primitive_type(stabs_handle *h, ir_type *tp) {
type_num = get_type_number(h, tp);
if (mode_is_int(mode) || mode_is_character(mode)) {
if (mode_is_int(mode)) {
char buf[64];
fprintf(h->f, "\t.stabs\t\"%s:t%u=r%u;", get_type_name(tp), type_num, type_num);
tarval_snprintf(buf, sizeof(buf), get_mode_min(mode));
......
......@@ -162,7 +162,7 @@ char get_mode_suffix(const ir_mode *mode) {
return 't';
}
} else {
assert(mode_is_int(mode) || mode_is_reference(mode) || mode_is_character(mode));
assert(mode_is_int(mode) || mode_is_reference(mode));
switch(get_mode_size_bits(mode)) {
case 64:
return 'q';
......
......@@ -124,8 +124,7 @@ static ir_node *create_immediate_or_transform(ir_node *node,
static INLINE int mode_needs_gp_reg(ir_mode *mode) {
if(mode == mode_fpcw)
return 0;
return mode_is_int(mode) || mode_is_character(mode)
|| mode_is_reference(mode) || mode == mode_b;
return mode_is_int(mode) || mode_is_reference(mode) || mode == mode_b;
}
/**
......@@ -2279,8 +2278,7 @@ ir_node *try_create_Immediate(ir_node *node, char immediate_constraint_type)
ir_node *block;
mode = get_irn_mode(node);
if(!mode_is_int(mode) && !mode_is_character(mode) &&
!mode_is_reference(mode)) {
if(!mode_is_int(mode) && !mode_is_reference(mode)) {
return NULL;
}
......
......@@ -77,8 +77,7 @@ typedef ir_node *construct_binop_func(dbg_info *db, ir_graph *irg,
ir_node *block, ir_node *left, ir_node *right);
static INLINE int mode_needs_gp_reg(ir_mode *mode) {
return mode_is_int(mode) || mode_is_character(mode)
|| mode_is_reference(mode);
return mode_is_int(mode) || mode_is_reference(mode);
}
ir_node *mips_create_Immediate(long val)
......
......@@ -77,7 +77,7 @@ ir_mode *get_ppc32_mode_Cond(void) {
if (ppc32_mode_Cond)
return ppc32_mode_Cond;
else {
ppc32_mode_Cond = new_ir_mode("mode_Cond", irms_character, 4, 0, irma_none, 0);
ppc32_mode_Cond = new_ir_mode("mode_Cond", irms_int_number, 4, 0, irma_none, 0);
return ppc32_mode_Cond;
}
}
......
......@@ -132,7 +132,6 @@ static ir_mode *find_mode(const ir_mode *m) {
*/
static void set_mode_values(ir_mode* mode) {
switch (get_mode_sort(mode)) {
case irms_character:
case irms_int_number:
case irms_float_number:
mode->min = get_tarval_min(mode);
......@@ -200,8 +199,6 @@ ir_mode *mode_Lu;
ir_mode *mode_LLs; /* 128 bit */
ir_mode *mode_LLu;
ir_mode *mode_C;
ir_mode *mode_U;
ir_mode *mode_b;
ir_mode *mode_P;
......@@ -228,8 +225,6 @@ ir_mode *get_modeLs(void) { return mode_Ls; }
ir_mode *get_modeLu(void) { return mode_Lu; }
ir_mode *get_modeLLs(void){ return mode_LLs; }
ir_mode *get_modeLLu(void){ return mode_LLu; }
ir_mode *get_modeC(void) { return mode_C; }
ir_mode *get_modeU(void) { return mode_U; }
ir_mode *get_modeb(void) { return mode_b; }
ir_mode *get_modeP(void) { return mode_P; }
ir_mode *get_modeX(void) { return mode_X; }
......@@ -320,7 +315,6 @@ ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int sign,
case irms_float_number:
case irms_int_number:
case irms_reference:
case irms_character:
mode = register_mode(&mode_tmpl);
}
return mode;
......@@ -366,7 +360,6 @@ ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsi
break;
case irms_reference:
case irms_character:
assert(0 && "only integer and floating point modes can be vectorized");
break;
......@@ -532,11 +525,6 @@ int
return _mode_is_int(mode);
}
int
(mode_is_character)(const ir_mode *mode) {
return _mode_is_character(mode);
}
int
(mode_is_reference)(const ir_mode *mode) {
return _mode_is_reference(mode);
......@@ -547,11 +535,6 @@ int
return _mode_is_num(mode);
}
int
(mode_is_numP)(const ir_mode *mode) {
return _mode_is_numP(mode);
}
int
(mode_is_data)(const ir_mode *mode) {
return _mode_is_data(mode);
......@@ -870,29 +853,8 @@ init_mode (void) {
mode_LLu = register_mode(&newmode);
/* Character Modes */
newmode.sort = irms_character;
newmode.arithmetic = irma_twos_complement;
newmode.modulo_shift = 0;
/* Character */
newmode.name = new_id_from_chars("C", 1);
newmode.code = irm_C;
newmode.sign = 0;
newmode.size = 8;
mode_C = register_mode(&newmode);
/* Unicode character */
newmode.name = new_id_from_chars("U", 1);
newmode.code = irm_U;
newmode.sign = 0;
newmode.size = 16;
mode_U = register_mode(&newmode);
/* Reference Modes */
newmode.sort = irms_reference;
/* Reference Mode */
newmode.sort = irms_reference;
newmode.arithmetic = irma_twos_complement;
/* pointer */
......@@ -998,11 +960,9 @@ void finish_mode(void) {
mode_Ls = NULL;
mode_Lu = NULL;
mode_C = NULL;
mode_U = NULL;
mode_b = NULL;
mode_P = NULL;
mode_P = NULL;
mode_P_code = NULL;
mode_P_data = NULL;
}
......@@ -134,12 +134,6 @@ _mode_is_int(const ir_mode *mode) {
return (_get_mode_sort(mode) == irms_int_number);
}
static INLINE int
_mode_is_character(const ir_mode *mode) {
assert(mode);
return (_get_mode_sort(mode) == irms_character);
}
static INLINE int
_mode_is_reference(const ir_mode *mode) {
assert(mode);
......@@ -152,16 +146,9 @@ _mode_is_num(const ir_mode *mode) {
return (_mode_is_int(mode) || _mode_is_float(mode));
}
static INLINE int
_mode_is_numP(const ir_mode *mode) {
assert(mode);
return (_mode_is_int(mode) || _mode_is_float(mode) || _mode_is_reference(mode));
}
static INLINE int
_mode_is_data(const ir_mode *mode) {
assert(mode);
return (_mode_is_numP(mode) || _get_mode_sort(mode) == irms_character);
return (_mode_is_int(mode) || _mode_is_float(mode) || _mode_is_reference(mode));
}
static INLINE int
......@@ -210,10 +197,8 @@ void finish_mode(void);
#define mode_is_signed(mode) _mode_is_signed(mode)
#define mode_is_float(mode) _mode_is_float(mode)
#define mode_is_int(mode) _mode_is_int(mode)
#define mode_is_character(mode) _mode_is_character(mode)
#define mode_is_reference(mode) _mode_is_reference(mode)
#define mode_is_num(mode) _mode_is_num(mode)
#define mode_is_numP(mode) _mode_is_numP(mode)
#define mode_is_data(mode) _mode_is_data(mode)
#define mode_is_datab(mode) _mode_is_datab(mode)
#define mode_is_dataM(mode) _mode_is_dataM(mode)
......
......@@ -1160,7 +1160,7 @@ static ir_node *equivalent_node_Conv(ir_node *n) {
if (n_mode == mode_b) {
n = b; /* Convb(Conv*(xxxb(...))) == xxxb(...) */
DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_CONV);
} else if (mode_is_int(n_mode) || mode_is_character(n_mode)) {
} else if (mode_is_int(n_mode)) {
if (smaller_mode(b_mode, a_mode)){
n = b; /* ConvS(ConvL(xxxS(...))) == xxxS(...) */
DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_CONV);
......
......@@ -1185,7 +1185,7 @@ static int verify_node_Add(ir_node *n, ir_graph *irg) {
ASSERT_AND_RET_DBG(
(
/* common Add: BB x numP x numP --> numP */
(op1mode == mymode && op2mode == op1mode && mode_is_numP(mymode)) ||
(op1mode == mymode && op2mode == op1mode && mode_is_data(mymode)) ||
/* Pointer Add: BB x ref x int --> ref */
(mode_is_reference(op1mode) && mode_is_int(op2mode) && op1mode == mymode) ||
/* Pointer Add: BB x int x ref --> ref */
......@@ -1211,7 +1211,7 @@ static int verify_node_Sub(ir_node *n, ir_graph *irg) {
ASSERT_AND_RET_DBG(
(
/* common Sub: BB x numP x numP --> numP */
(mymode ==op1mode && mymode == op2mode && mode_is_numP(op1mode)) ||
(mymode ==op1mode && mymode == op2mode && mode_is_data(op1mode)) ||
/* Pointer Sub: BB x ref x int --> ref */
(op1mode == mymode && mode_is_int(op2mode) && mode_is_reference(mymode)) ||
/* Pointer Sub: BB x int x ref --> ref */
......@@ -1743,7 +1743,7 @@ static int verify_node_Mux(ir_node *n, ir_graph *irg) {
op1mode == mode_b &&
op2mode == mymode &&
op3mode == mymode &&
mode_is_numP(mymode),
mode_is_data(mymode),
"Mux node", 0
);
return 1;
......
......@@ -163,8 +163,7 @@ static ir_node *lower_node(ir_node *node)
ir_node *left = get_Cmp_left(pred);
ir_node *right = get_Cmp_right(pred);
if( (mode_is_int(mode) || mode_is_character(mode)
|| mode_is_reference(mode)) &&
if( (mode_is_int(mode) || mode_is_reference(mode)) &&
(get_mode_size_bits(mode) < get_mode_size_bits(lowered_mode)
|| classify_Const(right) == CNST_NULL)) {
int pnc = get_Proj_proj(node);
......
......@@ -1079,7 +1079,7 @@ static void mark_address_calc(ir_node *node, void *env) {
int i, n;
unsigned mark_preds = MARK_REF_NON_ADR;
if (! mode_is_numP(mode))
if (! mode_is_data(mode))
return;
if (mode_is_reference(mode)) {
......@@ -1104,7 +1104,7 @@ static void mark_address_calc(ir_node *node, void *env) {
ir_node *pred = get_irn_n(node, i);
mode = get_irn_op_mode(pred);
if (! mode_is_numP(mode))
if (! mode_is_data(mode))
continue;
set_adr_mark(graph, pred, get_adr_mark(graph, pred) | mark_preds);
......
......@@ -48,14 +48,43 @@
#include "callgraph.h" /* for dumping debug output */
/*******************************************************************/
/**
* An interval initializer.
*/
typedef struct interval_initializer interval_initializer;
/**
* A value initializer.
*/
typedef struct value_initializer value_initializer;
struct interval_initializer {
int first_index; /**< The first index of the initialized interval. */
int last_index; /**< The last index of the initialized interval. */
interval_initializer *next; /**< Points to the next interval initializer. */
};
struct value_initializer {
ir_entity *ent; /**< The initialized entity. */
value_initializer *next; /**< Points to the next value initializer. */
};
typedef union initializer {
ir_node *value; /**< The value of the initializer. */
ir_node **values; /**< The values of an interval. */
value_initializer *val_init; /**< Points the the head of the next value initializers. */
interval_initializer *int_init; /**< Points to the head of the next value initializers. */
} initializer;
/*-----------------------------------------------------------------*/
/** general **/
/*******************************************************************/
/*-----------------------------------------------------------------*/
ir_entity *unknown_entity = NULL;
ir_entity *get_unknown_entity(void) { return unknown_entity; }
/** The name of the unknown entity. */
#define UNKNOWN_ENTITY_NAME "unknown_entity"
/*-----------------------------------------------------------------*/
......@@ -202,7 +231,7 @@ static void free_entity_attrs(ir_entity *ent) {
}
if (is_compound_entity(ent)) {
if (ent->attr.cmpd_attr.val_paths) {
for (i = 0; i < get_compound_ent_n_values(ent); i++)
for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i)
if (ent->attr.cmpd_attr.val_paths[i]) {
/* free_compound_graph_path(ent->attr.cmpd_attr.val_paths[i]) ; * @@@ warum nich? */
/* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
......
......@@ -291,7 +291,6 @@ tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode)
case irms_reference:
/* same as integer modes */
case irms_int_number:
case irms_character:
sc_val_from_str(str, len, NULL, mode);
return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
}
......@@ -314,7 +313,6 @@ tarval *new_tarval_from_long(long l, ir_mode *mode) {
case irms_reference:
/* same as integer modes */
case irms_int_number:
case irms_character:
sc_val_from_long(l, NULL);
return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
......@@ -329,9 +327,7 @@ tarval *new_tarval_from_long(long l, ir_mode *mode) {
/* returns non-zero if can be converted to long */
int tarval_is_long(tarval *tv) {
mode_sort sort = get_mode_sort(tv->mode);
if (sort != irms_int_number && sort != irms_character) return 0;
if (!mode_is_int(tv->mode)) return 0;
if (get_mode_size_bits(tv->mode) > (int) (sizeof(long) << 3)) {
/* the value might be too big to fit in a long */
......@@ -451,7 +447,6 @@ tarval *get_tarval_max(ir_mode *mode) {
return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
case irms_int_number:
case irms_character:
sc_max_from_bits(get_mode_size_bits(mode), mode_is_signed(mode), NULL);
return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
}
......@@ -492,7 +487,6 @@ tarval *get_tarval_min(ir_mode *mode) {
return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
case irms_int_number:
case irms_character:
sc_min_from_bits(get_mode_size_bits(mode), mode_is_signed(mode), NULL);
return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
}
......@@ -522,7 +516,6 @@ tarval *get_tarval_null(ir_mode *mode) {
return new_tarval_from_double(0.0, mode);
case irms_int_number:
case irms_character:
return new_tarval_from_long(0l, mode);
case irms_reference:
......@@ -552,7 +545,6 @@ tarval *get_tarval_one(ir_mode *mode) {
return new_tarval_from_double(1.0, mode);
case irms_int_number:
case irms_character:
return new_tarval_from_long(1l, mode);
break;
}
......@@ -580,7 +572,6 @@ tarval *get_tarval_minus_one(ir_mode *mode) {
return mode_is_signed(mode) ? new_tarval_from_double(-1.0, mode) : tarval_bad;
case irms_int_number:
case irms_character:
return mode_is_signed(mode) ? new_tarval_from_long(-1l, mode) : tarval_bad;
}
return tarval_bad;
......@@ -764,7 +755,6 @@ pn_Cmp tarval_cmp(tarval *a, tarval *b) {
default: return pn_Cmp_False;
}
case irms_int_number:
case irms_character:
if (a == b)
return pn_Cmp_Eq;
return sc_comp(a->value, b->value) == 1 ? pn_Cmp_Gt : pn_Cmp_Lt;
......@@ -844,10 +834,8 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m) {
/* cast int/characters to something */
case irms_int_number:
case irms_character:
switch (get_mode_sort(m)) {
case irms_int_number:
case irms_character:
buffer = alloca(sc_get_buffer_length());
memcpy(buffer, src->value, sc_get_buffer_length());
sign_extend(buffer, m);
......@@ -999,7 +987,6 @@ tarval *tarval_add(tarval *a, tarval *b) {
}
switch (get_mode_sort(a->mode)) {
case irms_character:
case irms_int_number:
/* modes of a,b are equal, so result has mode of a as this might be the character */
buffer = alloca(sc_get_buffer_length());
......@@ -1033,7 +1020,6 @@ tarval *tarval_sub(tarval *a, tarval *b) {
return tarval_bad;
}
switch (get_mode_sort(a->mode)) {
case irms_character:
case irms_int_number:
/* modes of a,b are equal, so result has mode of a as this might be the character */
buffer = alloca(sc_get_buffer_length());
......@@ -1396,7 +1382,6 @@ int tarval_snprintf(char *buf, size_t len, tarval *tv) {
if (tv == tv->mode->null) return snprintf(buf, len, "NULL");
/* fall through */
case irms_int_number:
case irms_character:
switch (mode_info->mode_output) {
case TVO_DECIMAL:
......@@ -1636,8 +1621,6 @@ void init_tarval_2(void) {
* assign output modes that are compatible with the
* old implementation: Hex output
*/
set_tarval_mode_output_option(mode_U, &hex_output);
set_tarval_mode_output_option(mode_C, &hex_output);
set_tarval_mode_output_option(mode_Bs, &hex_output);
set_tarval_mode_output_option(mode_Bu, &hex_output);
set_tarval_mode_output_option(mode_Hs, &hex_output);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment