コード例 #1
0
ファイル: scop.c プロジェクト: MaddTheSane/haiku-buildtools
/**
 * osl_scop_clone function:
 * This functions builds and returns a "hard copy" (not a pointer copy)
 * of a osl_statement_t data structure provided as parameter.
 * Note that the usr field is not touched by this function.
 * \param scop The pointer to the scop we want to clone.
 * \return A pointer to the full clone of the scop provided as parameter.
 */
osl_scop_p osl_scop_clone(osl_scop_p scop) {
  osl_scop_p clone = NULL, node, previous = NULL;
  int first = 1;
  
  while (scop != NULL) {
    node                 = osl_scop_malloc();
    node->version        = scop->version;
    if (scop->language != NULL)
      node->language     = strdup(scop->language);
    node->context        = osl_relation_clone(scop->context);
    node->parameters     = osl_generic_clone(scop->parameters);
    node->statement      = osl_statement_clone(scop->statement);
    node->registry       = osl_interface_clone(scop->registry);
    node->extension      = osl_generic_clone(scop->extension);
    
    if (first) {
      first = 0;
      clone = node;
      previous = node;
    }
    else {
      previous->next = node;
      previous = previous->next;
    }

    scop = scop->next;
  }

  return clone;
}
コード例 #2
0
ファイル: relation.c プロジェクト: periscop/clay
int clay_relation_nb_explicit_dim(osl_relation_p relation) {
  int result;
  osl_relation_p copy = osl_relation_clone(relation);
  result = clay_relation_nb_explicit_dim_intrusive(copy);
  osl_relation_free(copy);
  return result;
}
コード例 #3
0
ファイル: statement_profile.c プロジェクト: Ced/substrate
/**
 * @brief Aggregate two osl_statement into one.
 *
 * A new osl_statement is created from the two osl_statement given as parameters.
 * The parameters are not modified.
 *
 * @param[in] stmt1 The first osl_statement of the aggregation.
 * @param[in] stmt2 The second osl_statement of the aggregation.
 *
 * @return A new osl_statement created from the aggregation of \a stmt1 and \a stmt2 .
 */
struct osl_statement * substrate_osl_statement_fusion(
        struct osl_statement * stmt1,
        struct osl_statement * stmt2)
{
    struct osl_statement * res = NULL;
    //For now, the two statement MUST have the same domain & scattering
    //TODO : allow aggregation of statement with diff domain (→replace the clone
    //of the domain [and scattering]).
    res = osl_statement_malloc();
    res->domain = osl_relation_clone(stmt1->domain);
    res->scattering = osl_relation_clone(stmt1->scattering);
    res->access = NULL;
    res->access = substrate_osl_relation_list_fusion(stmt1->access, stmt2->access);
    res->extension = substrate_osl_generic_fusion(stmt1->extension, stmt2->extension);
    res->usr = NULL;
    res->next = stmt2->next;
    
    return res;
}
コード例 #4
0
ファイル: dependence.c プロジェクト: ArtemL/GCC
/**
 * osl_dependence_nclone function:
 * This function builds and returns a "hard copy" (not a pointer copy) of the
 * n first elements of an osl_dependence_t list.
 * \param statement The pointer to the dependence structure we want to clone.
 * \param n         The number of nodes we want to copy (-1 for infinity).
 * \return The clone of the n first nodes of the dependence list.
 */
osl_dependence_p osl_dependence_nclone(osl_dependence_p dep, int n) {
  int first = 1, i = 0;
  osl_dependence_p clone = NULL, node, previous = NULL;

  while ((dep != NULL) && ((n == -1) || (i < n))) {
    node = osl_dependence_malloc();
    node->stmt_source_ptr = dep->stmt_source_ptr;
    node->stmt_target_ptr = dep->stmt_target_ptr;
    node->depth = dep->depth;
    node->type = dep->type;
    node->label_source = dep->label_source;
    node->label_target = dep->label_target;
    node->ref_source = dep->ref_source;
    node->ref_target = dep->ref_target;
    node->domain     = osl_relation_clone(dep->domain);
    node->source_nb_output_dims_domain = dep->source_nb_output_dims_domain;
    node->source_nb_output_dims_access = dep->source_nb_output_dims_access;
    node->target_nb_output_dims_domain = dep->target_nb_output_dims_domain;
    node->target_nb_output_dims_access = dep->target_nb_output_dims_access;
    node->source_nb_local_dims_domain  = dep->source_nb_local_dims_domain;
    node->source_nb_local_dims_access  = dep->source_nb_local_dims_access;
    node->target_nb_local_dims_domain  = dep->target_nb_local_dims_domain;
    node->target_nb_local_dims_access  = dep->target_nb_local_dims_access;
    node->next       = NULL;
    node->usr        = NULL;

    if (first) {
      first = 0;
      clone = node;
      previous = node;
    }
    else {
      previous->next = node;
      previous = previous->next;
    }

    i++;
    dep = dep->next;
  }

  return clone;
}
コード例 #5
0
ファイル: relation.c プロジェクト: periscop/clay
// Do a copy of relation before intrusive rank computation.
int clay_relation_rank(osl_relation_p relation) {
  osl_relation_p copy = osl_relation_clone(relation);
  int rank = clay_relation_rank_intrusive(copy);
  osl_relation_free(copy);
  return rank;
}