Example #1
0
void
test_ternary_op(const irop_t *op, test_data_t *data)
{
   unsigned num_input_bits, i, bitpos;
   opnd_t *opnds = data->opnds;

   /* For each operand, set a single bit to undefined and observe how
      that propagates to the output. Do this for all bits in each
      operand. */
   for (i = 0; i < 3; ++i) {
      num_input_bits = bitsof_irtype(opnds[i].type);

      opnds[0].vbits = defined_vbits(bitsof_irtype(opnds[0].type));
      opnds[1].vbits = defined_vbits(bitsof_irtype(opnds[1].type));
      opnds[2].vbits = defined_vbits(bitsof_irtype(opnds[2].type));

      for (bitpos = 0; bitpos < num_input_bits; ++bitpos) {
         opnds[i].vbits = onehot_vbits(bitpos, bitsof_irtype(opnds[i].type));

         valgrind_execute_test(op, data);

         check_result_for_ternary(op, data);
      }
   }
}
Example #2
0
int
test_qernary_op(const irop_t *op, test_data_t *data)
{
   unsigned num_input_bits, i, bitpos;
   opnd_t *opnds = data->opnds;
   int tests_done = 0;

   /* Immediate operands are currently not supported here */
   assert(op->immediate_index == 0);

   /* For each operand, set a single bit to undefined and observe how
      that propagates to the output. Do this for all bits in each
      operand. */
   for (i = 0; i < 4; ++i) {
      num_input_bits = bitsof_irtype(opnds[i].type);

      opnds[0].vbits = defined_vbits(bitsof_irtype(opnds[0].type));
      opnds[1].vbits = defined_vbits(bitsof_irtype(opnds[1].type));
      opnds[2].vbits = defined_vbits(bitsof_irtype(opnds[2].type));
      opnds[3].vbits = defined_vbits(bitsof_irtype(opnds[3].type));

      for (bitpos = 0; bitpos < num_input_bits; ++bitpos) {
         opnds[i].vbits = onehot_vbits(bitpos, bitsof_irtype(opnds[i].type));

         valgrind_execute_test(op, data);

         check_result_for_qernary(op, data);

         tests_done++;
      }
   }
   return tests_done;
}
Example #3
0
void
test_unary_op(const irop_t *op, test_data_t *data)
{
    unsigned num_input_bits, bitpos;

    num_input_bits = bitsof_irtype(data->opnds[0].type);

    for (bitpos = 0; bitpos < num_input_bits; ++bitpos) {
        data->opnds[0].vbits = onehot_vbits(bitpos, num_input_bits);

        valgrind_execute_test(op, data);

        check_result_for_unary(op, data);
    }
}
Example #4
0
int
test_unary_op(const irop_t *op, test_data_t *data)
{
   unsigned num_input_bits, bitpos;
   int tests_done = 0;

   /* Immediate operands are currently not supported here */
   assert(op->immediate_index == 0);

   num_input_bits = bitsof_irtype(data->opnds[0].type);

   for (bitpos = 0; bitpos < num_input_bits; ++bitpos) {
      data->opnds[0].vbits = onehot_vbits(bitpos, num_input_bits);

      valgrind_execute_test(op, data);

      check_result_for_unary(op, data);
      tests_done++;
   }
   return tests_done;
}