From 452c979b375f4e387be9a8efb4fb0c752dbdbaa8 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 23 Sep 2003 16:25:55 +0000 Subject: [PATCH] Fixed sc_neg() and sc_not(), added tarval_not(), fixed tarval_eor() [r1861] --- ir/tv/strcalc.c | 4 ++-- ir/tv/tv.c | 27 +++++++++++++++++++++++++-- ir/tv/tv.h | 5 ++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c index bd69ca8ed..5978beffb 100644 --- a/ir/tv/strcalc.c +++ b/ir/tv/strcalc.c @@ -1141,7 +1141,7 @@ void sc_calc(const void* value1, const void* value2, unsigned op, void *buffer) case SC_NEG: _negate(val1, calc_buffer); DEBUGPRINTF_COMPUTATION(("negated: %s\n", sc_print_hex(calc_buffer))); - return; + break; case SC_OR: DEBUGPRINTF_COMPUTATION(("| ")); _bitor(val1, val2, calc_buffer); @@ -1157,7 +1157,7 @@ void sc_calc(const void* value1, const void* value2, unsigned op, void *buffer) case SC_NOT: _bitnot(val1, calc_buffer); DEBUGPRINTF_COMPUTATION(("bit-negated: %s\n", sc_print_hex(calc_buffer))); - return; + break; case SC_ADD: DEBUGPRINTF_COMPUTATION(("+ ")); _add(val1, val2, calc_buffer); diff --git a/ir/tv/tv.c b/ir/tv/tv.c index 600cd93e5..8379e3550 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -875,7 +875,30 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m) } /* - * negation + * bitwise negation + */ +tarval *tarval_not(tarval *a) +{ + char *buffer; + + ANNOUNCE(); + assert(a); + assert(mode_is_int(a->mode)); /* bitwise negation is only allowed for integer */ + + switch (get_mode_sort(a->mode)) + { + case irms_int_number: + buffer = alloca(sc_get_buffer_length()); + sc_not(a->value, buffer); + return get_tarval(buffer, a->length, a->mode); + + default: + return tarval_bad; + } +} + +/* + * arithmetic negation */ tarval *tarval_neg(tarval *a) { @@ -1143,7 +1166,7 @@ tarval *tarval_eor(tarval *a, tarval *b) return (a == b)? tarval_b_false : tarval_b_true; case irms_int_number: - sc_or(a->value, b->value, NULL); + sc_xor(a->value, b->value, NULL); return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode); default: diff --git a/ir/tv/tv.h b/ir/tv/tv.h index cd430af21..7b9b6c854 100644 --- a/ir/tv/tv.h +++ b/ir/tv/tv.h @@ -396,7 +396,10 @@ tarval *tarval_convert_to(tarval *src, ir_mode *m); * The sort member of the struct mode defines which operations are valid */ -/** Negation of a tarval. */ +/** bitwise Negation of a tarval. */ +tarval *tarval_not(tarval *a); + +/** arithmetic Negation of a tarval. */ tarval *tarval_neg(tarval *a); /** Addition of two tarvals. */ -- 2.20.1