Пример #1
0
static vec<tree, va_gc> *
create_array_refs (location_t loc, vec<vec<an_parts> > an_info,
		   vec<an_loop_parts> an_loop_info, size_t size,  size_t rank)
{
  tree ind_mult, ind_incr;
  vec<tree, va_gc> *array_operand = NULL;

  for (size_t ii = 0; ii < size; ii++)
    if (an_info[ii][0].is_vector)
      {
	tree array_opr = an_info[ii][rank - 1].value;
	for (int s_jj = rank -1; s_jj >= 0; s_jj--)
	  {
	    tree start = cp_fold_convert (ptrdiff_type_node, 
					  an_info[ii][s_jj].start);
	    tree stride = cp_fold_convert (ptrdiff_type_node, 
					   an_info[ii][s_jj].stride);
	    tree var = cp_fold_convert (ptrdiff_type_node, 
					an_loop_info[s_jj].var);

	    ind_mult = build2 (MULT_EXPR, TREE_TYPE (var), var, stride);
	    ind_incr = build2 (PLUS_EXPR, TREE_TYPE (var), start, ind_mult);
	    /* Array [ start_index + (induction_var * stride)]  */
	    array_opr = grok_array_decl	(loc, array_opr, ind_incr, false);
	  }
	vec_safe_push (array_operand, array_opr);
      }
    else
      vec_safe_push (array_operand, integer_one_node);
  return array_operand;
}
tree
build_array_notation_ref (location_t loc, tree array, tree start, tree length, 
			  tree stride, tree type)
{
  tree array_ntn_expr = NULL_TREE;

  /* If we enter the then-case of the if-statement below, we have hit a case 
     like this: ARRAY [:].  */
  if (!start && !length)
    {
      if (TREE_CODE (type) != ARRAY_TYPE)
	{
	  error_at (loc, "start-index and length fields necessary for "
		    "using array notation in pointers or records");
	  return error_mark_node;
	}
      tree domain = TYPE_DOMAIN (type);
      if (!domain)
	{
	  error_at (loc, "start-index and length fields necessary for "
		    "using array notation with array of unknown bound");
	  return error_mark_node;
	}
      start = cp_fold_convert (ptrdiff_type_node, TYPE_MINVAL (domain));
      length = size_binop (PLUS_EXPR, TYPE_MAXVAL (domain), size_one_node);
      length = cp_fold_convert (ptrdiff_type_node, length);
    }
    
  if (!stride) 
    stride = build_one_cst (ptrdiff_type_node);
  
  /* When dealing with templates, triplet type-checking will be done in pt.c 
     after type substitution.  */
  if (processing_template_decl 
      && (type_dependent_expression_p (array) 
	  || type_dependent_expression_p (length) 
	  || type_dependent_expression_p (start) 
	  || type_dependent_expression_p (stride))) 
    array_ntn_expr = build_min_nt_loc (loc, ARRAY_NOTATION_REF, array, start, 
				       length, stride, NULL_TREE);
  else 
    { 
      if (!cilkplus_an_triplet_types_ok_p (loc, start, length, stride, type))
	return error_mark_node;
      array_ntn_expr = build4 (ARRAY_NOTATION_REF, NULL_TREE, array, start, 
			       length, stride);
    }
  if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == POINTER_TYPE)
    TREE_TYPE (array_ntn_expr) = TREE_TYPE (type);
  else
    gcc_unreachable ();

  SET_EXPR_LOCATION (array_ntn_expr, loc);
  return array_ntn_expr;
}