Beispiel #1
0
/**
 * osl_body_equal function:
 * this function returns true if the two bodies are the same, false
 * otherwise (the usr field is not tested). However, let us
 * recall here that non-string elements are untouched by the OpenScop Library.
 * \param[in] b1 The first body.
 * \param[in] b2 The second body.
 * \return 1 if b1 and b2 are the same (content-wise), 0 otherwise.
 */
int osl_body_equal(osl_body_p b1, osl_body_p b2) {
  
  if (b1 == b2)
    return 1;
 
  if (((b1 != NULL) && (b2 == NULL)) ||
      ((b1 == NULL) && (b2 != NULL))) {
    OSL_info("bodies are not the same"); 
    return 0;
  }

  if (!osl_strings_equal(b1->iterators, b2->iterators)) {
    OSL_info("body iterators are not the same");
    return 0;
  }
  
  if (!osl_strings_equal(b1->expression, b2->expression)) {
    OSL_info("body expressions are not the same");
    return 0;
  }

  return 1;
}
Beispiel #2
0
/**
 * osl_loop_equal function:
 * this function returns true if the two loop lists are the same
 * (content-wise), false otherwise. Two lists are equal if one contains
 * all the elements of the other and vice versa. The exact order of the
 * nodes is not taken into account by this function.
 *
 * \param[in] a1  The first loop list.
 * \param[in] a2  The second loop list.
 * \return        1 if a1 and a2 are the same (content-wise), 0 otherwise.
 */
int osl_loop_equal(osl_loop_p a1, osl_loop_p a2) {
  int found = 0;

  if (a1 == a2)
    return 1;

  if (((a1 == NULL) && (a2 != NULL)) || ((a1 != NULL) && (a2 == NULL))) {
    OSL_info("lists of loops are not the same (compare with NULL)");
    return 0;
  }

  if (osl_loop_count(a1) != osl_loop_count(a2)) {
      OSL_info("list of loops are not the same");
      return 0;
  }

  while (a1) {
    found = 0;
    osl_loop_p temp = a2;

    while (temp) {
      if(osl_loop_equal_one(a1, temp)==1){
        found= 1;
        break;
      }
      temp = temp->next;
    }

    if(found!=1){
      OSL_info("list of loops are not the same");
      return 0;
    }
    a1 = a1->next;
  }

  return 1;
}
Beispiel #3
0
/**
 * osl_scop_equal function:
 * this function returns true if the two scops are the same, false
 * otherwise (the usr field is not tested).
 * \param s1 The first scop.
 * \param s2 The second scop.
 * \return 1 if s1 and s2 are the same (content-wise), 0 otherwise.
 */
int osl_scop_equal(osl_scop_p s1, osl_scop_p s2) {

  while ((s1 != NULL) && (s2 != NULL)) {
    if (s1 == s2)
      return 1;

    if (s1->version != s2->version) {
      OSL_info("versions are not the same"); 
      return 0;
    }

    if (strcmp(s1->language, s2->language) != 0) {
      OSL_info("languages are not the same"); 
      return 0;
    }

    if (!osl_relation_equal(s1->context, s2->context)) {
      OSL_info("contexts are not the same"); 
      return 0;
    }

    if (!osl_generic_equal(s1->parameters, s2->parameters)) {
      OSL_info("parameters are not the same"); 
      return 0;
    }

    if (!osl_statement_equal(s1->statement, s2->statement)) {
      OSL_info("statements are not the same"); 
      return 0;
    }

    if (!osl_interface_equal(s1->registry, s2->registry)) {
      OSL_info("registries are not the same"); 
      return 0;
    }

    if (!osl_generic_equal(s1->extension, s2->extension)) {
      OSL_info("extensions are not the same"); 
      return 0;
    }

    s1 = s1->next;
    s2 = s2->next;
  }
  
  if (((s1 == NULL) && (s2 != NULL)) || ((s1 != NULL) && (s2 == NULL)))
    return 0;

  return 1;
}