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);
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);
}
/*
- * 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)
{
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:
* 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. */