Fixed sc_neg() and sc_not(), added tarval_not(), fixed tarval_eor()
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 23 Sep 2003 16:25:55 +0000 (16:25 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 23 Sep 2003 16:25:55 +0000 (16:25 +0000)
[r1861]

ir/tv/strcalc.c
ir/tv/tv.c
ir/tv/tv.h

index bd69ca8..5978bef 100644 (file)
@@ -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);
index 600cd93..8379e35 100644 (file)
@@ -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:
index cd430af..7b9b6c8 100644 (file)
@@ -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. */