Commit 5010492f authored by Matthias Braun's avatar Matthias Braun
Browse files

- always sign extend in get_tarval (this fixes results of tarval_and, tarval_or

  and tarval_eor not getting correctly hashed)
- tarval_null and tarval_one are defined for irms_reference now
- introduce get_tarvall_all_one and get_mode_all_one which returns the value
  where all bits are 1 (defined for int, boolean and reference modes)
- fix TARVAL_CLASSIFY_ALL_ONE with this

[r15817]
parent 3244e5da
......@@ -132,6 +132,7 @@ static ir_mode *find_mode(const ir_mode *m) {
*/
static void set_mode_values(ir_mode* mode) {
switch (get_mode_sort(mode)) {
case irms_reference:
case irms_int_number:
case irms_float_number:
mode->min = get_tarval_min(mode);
......@@ -139,6 +140,11 @@ static void set_mode_values(ir_mode* mode) {
mode->null = get_tarval_null(mode);
mode->one = get_tarval_one(mode);
mode->minus_one = get_tarval_minus_one(mode);
if(get_mode_sort(mode) != irms_float_number) {
mode->all_one = get_tarval_all_one(mode);
} else {
mode->all_one = tarval_bad;
}
break;
case irms_internal_boolean:
......@@ -147,14 +153,7 @@ static void set_mode_values(ir_mode* mode) {
mode->null = tarval_b_false;
mode->one = tarval_b_true;
mode->minus_one = tarval_bad;
break;
case irms_reference:
mode->min = tarval_bad;
mode->max = tarval_bad;
mode->null = get_tarval_null(mode);
mode->one = tarval_bad;
mode->minus_one = tarval_bad;
mode->all_one = tarval_b_true;
break;
case irms_auxiliary:
......@@ -486,6 +485,14 @@ get_mode_minus_one(ir_mode *mode) {
return mode->minus_one;
}
tarval *
get_mode_all_one(ir_mode *mode) {
assert(mode);
assert(get_mode_modecode(mode) < (modecode) num_modes);
assert(mode_is_data(mode));
return mode->all_one;
}
tarval *
get_mode_infinite(ir_mode *mode) {
assert(mode);
......
......@@ -102,6 +102,7 @@ struct ir_mode {
tarval *null; /**< the value 0 */
tarval *one; /**< the value 1 */
tarval *minus_one; /**< the value -1 */
tarval *all_one; /**< the value ~0 */
ir_mode *eq_signed; /**< For pointer modes, the equivalent signed integer one. */
ir_mode *eq_unsigned; /**< For pointer modes, the equivalent unsigned integer one. */
void *link; /**< To store some intermediate information */
......@@ -344,6 +345,7 @@ struct ir_node {
struct dbg_info *dbi; /**< A pointer to information for debug support. */
/* ------- For debugging ------- */
#ifdef DEBUG_libfirm
unsigned flags;
int out_valid;
long node_nr; /**< A unique node number for each node to make output
readable. */
......
......@@ -168,7 +168,10 @@ static tarval *get_tarval(const void *value, int length, ir_mode *mode) {
if (length > 0) {
/* if there already is such a value, it is returned, else value
* is copied into the set */
tv.value = INSERT_VALUE(value, length);
char *temp = alloca(sc_get_buffer_length());
memcpy(temp, value, sc_get_buffer_length());
sign_extend(temp, mode);
tv.value = INSERT_VALUE(temp, length);
} else {
tv.value = value;
}
......@@ -324,7 +327,6 @@ tarval *new_tarval_from_long(long l, ir_mode *mode) {
/* same as integer modes */
case irms_int_number:
sc_val_from_long(l, NULL);
sign_extend(sc_get_buffer(), mode);
return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
case irms_float_number:
......@@ -541,6 +543,7 @@ tarval *get_tarval_one(ir_mode *mode) {
if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
assert(0);
return tarval_bad;
}
......@@ -548,26 +551,28 @@ tarval *get_tarval_one(ir_mode *mode) {
case irms_control_flow:
case irms_memory:
case irms_auxiliary:
case irms_internal_boolean:
case irms_reference:
assert(0);
break;
case irms_internal_boolean:
return tarval_b_true;
case irms_float_number:
return new_tarval_from_double(1.0, mode);
case irms_reference:
case irms_int_number:
return new_tarval_from_long(1l, mode);
break;
}
return tarval_bad;
}
tarval *get_tarval_minus_one(ir_mode *mode) {
tarval *get_tarval_all_one(ir_mode *mode) {
assert(mode);
if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
assert(0);
return tarval_bad;
}
......@@ -575,11 +580,40 @@ tarval *get_tarval_minus_one(ir_mode *mode) {
case irms_control_flow:
case irms_memory:
case irms_auxiliary:
assert(0);
return tarval_bad;
case irms_int_number:
case irms_internal_boolean:
case irms_reference:
return tarval_not(get_mode_null(mode));
case irms_float_number:
return new_tarval_from_double(1.0, mode);
}
return tarval_bad;
}
tarval *get_tarval_minus_one(ir_mode *mode) {
assert(mode);
if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
switch(get_mode_sort(mode)) {
case irms_control_flow:
case irms_memory:
case irms_auxiliary:
case irms_internal_boolean:
assert(0);
break;
case irms_reference:
return tarval_bad;
case irms_float_number:
return mode_is_signed(mode) ? new_tarval_from_double(-1.0, mode) : tarval_bad;
......@@ -917,6 +951,7 @@ tarval *tarval_not(tarval *a) {
/* works for vector mode without changes */
switch (get_mode_sort(a->mode)) {
case irms_reference:
case irms_int_number:
buffer = alloca(sc_get_buffer_length());
sc_not(a->value, buffer);
......@@ -1550,8 +1585,7 @@ tarval_classification_t classify_tarval(tarval *tv) {
return TV_CLASSIFY_NULL;
else if (tv == get_mode_one(tv->mode))
return TV_CLASSIFY_ONE;
else if ((get_mode_sort(tv->mode) == irms_int_number)
&& (tv == get_mode_minus_one(tv->mode)))
else if (tv == get_mode_all_one(tv->mode))
return TV_CLASSIFY_ALL_ONE;
return TV_CLASSIFY_OTHER;
......
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