/** * osl_loop_sprint function: * this function prints the content of an osl_loop_t structure * (*loop) into a string (returned) in the OpenScop textual format. * \param[in] loop The loop structure to print. * \return A string containing the OpenScop dump of the loop structure. */ char * osl_loop_sprint(osl_loop_p loop) { int i; int nloop = 0; int high_water_mark = OSL_MAX_STRING; char *string = NULL; char buffer[OSL_MAX_STRING]; OSL_malloc(string, char *, high_water_mark * sizeof(char)); string[0] = '\0'; sprintf(buffer, "# Number of loops\n%d\n",osl_loop_count(loop)); osl_util_safe_strcat(&string, buffer, &high_water_mark); while (loop != NULL) { sprintf(buffer, "# ===========================================\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "# Loop number %d \n", ++nloop); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "# Iterator name\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "%s\n", loop->iter); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "# Number of stmts\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "%d\n", loop->nb_stmts); osl_util_safe_strcat(&string, buffer, &high_water_mark); if (loop->nb_stmts) { sprintf(buffer, "# Statement identifiers\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); } for (i = 0; i < loop->nb_stmts; i++) { sprintf(buffer, "%d\n", loop->stmt_ids[i]); osl_util_safe_strcat(&string, buffer, &high_water_mark); } sprintf(buffer, "# Private variables\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "%s\n", loop->private_vars); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "# Directive\n"); osl_util_safe_strcat(&string, buffer, &high_water_mark); sprintf(buffer, "%d\n", loop->directive); osl_util_safe_strcat(&string, buffer, &high_water_mark); loop = loop->next; } OSL_realloc(string, char *, (strlen(string) + 1) * sizeof(char)); return string; }
/** * 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; }