// Increment count in _access_count[tag]
void ScanBlocks::accumulate_access(int index, ValueTag tag, int count) {
  increment_count(tag, index, count);
  update_type(index, tag);
  if (tag == doubleTag || tag == longTag) {
    update_type(index + 1, tag);
  }
}
Example #2
0
/**
 * Reassociates a constant down a tree of adds or multiplies.
 *
 * Consider (2 * (a * (b * 0.5))).  We want to send up with a * b.
 */
bool
ir_algebraic_visitor::reassociate_constant(ir_expression *ir1, int const_index,
					   ir_constant *constant,
					   ir_expression *ir2)
{
   if (!ir2 || ir1->operation != ir2->operation)
      return false;

   /* Don't want to even think about matrices. */
   if (ir1->operands[0]->type->is_matrix() ||
       ir1->operands[1]->type->is_matrix() ||
       ir2->operands[0]->type->is_matrix() ||
       ir2->operands[1]->type->is_matrix())
      return false;

   ir_constant *ir2_const[2];
   ir2_const[0] = ir2->operands[0]->constant_expression_value();
   ir2_const[1] = ir2->operands[1]->constant_expression_value();

   if (ir2_const[0] && ir2_const[1])
      return false;

   if (ir2_const[0]) {
      reassociate_operands(ir1, const_index, ir2, 1);
      return true;
   } else if (ir2_const[1]) {
      reassociate_operands(ir1, const_index, ir2, 0);
      return true;
   }

   if (reassociate_constant(ir1, const_index, constant,
			    ir2->operands[0]->as_expression())) {
      update_type(ir2);
      return true;
   }

   if (reassociate_constant(ir1, const_index, constant,
			    ir2->operands[1]->as_expression())) {
      update_type(ir2);
      return true;
   }

   return false;
}
Example #3
0
void region_tt::set_rect( int left, int top, int right, int bottom )
{
    if ((left != right) && (top != bottom))
    {
        rgn->extents.set( left, top, right, bottom );
        rgn->extents.fix();
        numRects = 1;
        rects[0] = rgn->extents;
        update_type();
    }
    else
        empty_region();
}
Example #4
0
void
ir_algebraic_visitor::reassociate_operands(ir_expression *ir1,
					   int op1,
					   ir_expression *ir2,
					   int op2)
{
   ir_rvalue *temp = ir2->operands[op2];
   ir2->operands[op2] = ir1->operands[op1];
   ir1->operands[op1] = temp;

   /* Update the type of ir2.  The type of ir1 won't have changed --
    * base types matched, and at least one of the operands of the 2
    * binops is still a vector if any of them were.
    */
   update_type(ir2);

   this->progress = true;
}
Example #5
0
INT region_tt::intersect_rgn( region_tt *reg1, region_tt *reg2 )
{
    dprintf("%ld %ld\n", reg1->numRects, reg2->numRects);
    /* check for trivial reject */
    if ( !reg1->numRects || !reg2->numRects ||
            !reg1->rgn->extents.overlaps( reg2->rgn->extents ))
    {
        empty_region();
        return rgn->type;
    }

    // FIXME: implement more complicated regions
    assert(reg1->rgn->type == SIMPLEREGION);
    assert(reg2->rgn->type == SIMPLEREGION);

    rgn->extents = reg1->rgn->extents;
    rgn->extents.dump();
    rgn->extents.intersect( reg2->rgn->extents );
    rgn->extents.dump();

    return update_type();
}
Example #6
0
int read_rules(FILE * fp)
{
    char buf[1024];
    DCELL oLow, oHigh, nLow, nHigh;
    int line, n;

    in_type = DCELL_TYPE;
    out_type = CELL_TYPE;

    rules = (char **)G_malloc(INCR * sizeof(char *));
    rule_size = INCR;

    if (isatty(fileno(fp))) {
	report_range();
	G_message(_("Enter the rule or 'help' for the format description"));
    }
    Rast_fpreclass_init(&rcl_struct);
    for (line = 1;; line++) {
	if (isatty(fileno(fp)))
	    fprintf(stderr, "> ");

	if (!G_getl2(buf, 1024, fp))
	    return nrules;

	G_debug(5, "buf = [%s], strlen(buf)=%d", buf, strlen(buf));

	for (n = 0; buf[n]; n++)
	    if (buf[n] == ',')
		buf[n] = ' ';
	G_strip(buf);
	if (*buf == 0)
	    continue;
	if (*buf == '#')
	    continue;
	if (strcmp(buf, "end") == 0)
	    break;

	if (strcmp(buf, "help") == 0) {
	    G_message(_("Enter a rule in one of these formats:"));
	    G_message(" ");
	    G_message(_("old_low:old_high:new_low:new_high"));
	    G_message(_("old_low:old_high:new_val      (i.e. new_high == new_low)"));
	    G_message(_("*:old_val:new_val             (interval [inf, old_val])"));
	    G_message(_("old_val:*:new_val             (interval [old_val, inf])"));
	    G_message(" ");
	    G_message(_("When finished type \"end\"."));

	    continue;
	}

	/* we read and record into quant table all values, even int as doubles
	   we convert the range and domain values to the right format when we 
	   lookup the values in the quant table */
	switch (sscanf(buf, "%lf:%lf:%lf:%lf", &oLow, &oHigh, &nLow, &nHigh)) {
	case 3:
	    update_type(&out_type, nLow);
	    update_rules(buf);
	    Rast_fpreclass_add_rule(&rcl_struct, oLow, oHigh, nLow, nLow);
	    break;

	case 4:
	    update_type(&out_type, nLow);
	    update_type(&out_type, nHigh);
	    update_rules(buf);
	    Rast_fpreclass_add_rule(&rcl_struct, oLow, oHigh, nLow, nHigh);
	    break;

	default:
	    if (sscanf(buf, "%lf:*:%lf", &oLow, &nLow) == 2) {
		update_type(&out_type, nLow);
		update_rules(buf);
		Rast_fpreclass_set_pos_infinite_rule(&rcl_struct, oLow, nLow);
	    }
	    else if (sscanf(buf, "*:%lf:%lf", &oHigh, &nLow) == 2) {
		update_type(&out_type, nLow);
		update_rules(buf);
		Rast_fpreclass_set_neg_infinite_rule(&rcl_struct, oHigh, nLow);
	    }
	    else
		G_message(_("%s is not a valid rule"), buf);
	    break;
	}			/* switch */
    }				/* loop */
    return nrules;
}