Ejemplo n.º 1
0
/**
 * osl_body_print_scoplib function:
 * this function prints the content of an osl_body_t structure
 * (*body) into a file (file, possibly stdout) in the SCoPLib format.
 * \param[in] file  File where informations are printed.
 * \param[in] body  The body whose information has to be printed.
 */
void osl_body_print_scoplib(FILE * file, osl_body_p body) {
  int nb_iterators;

  if (body != NULL) {
    nb_iterators = osl_strings_size(body->iterators);

    if (nb_iterators > 0) {
      fprintf(file, "# List of original iterators\n");
      osl_strings_print(file, body->iterators);
    } else {
      fprintf(file, "fakeiter\n");
    }

    fprintf(file, "# Statement body expression\n");
    osl_strings_print(file, body->expression);
  }
  else {
    fprintf(file, "# NULL statement body\n");
  }
}
Ejemplo n.º 2
0
/**
 * osl_scop_print_scoplib function:
 * this function prints the content of an osl_scop_t structure (*scop)
 * into a file (file, possibly stdout) in the ScopLib textual format.
 * \param file The file where the information has to be printed.
 * \param scop The scop structure whose information has to be printed.
 */
void osl_scop_print_scoplib(FILE * file, osl_scop_p scop) {
    int parameters_backedup = 0;
    int arrays_backedup = 0;
    osl_strings_p parameters_backup = NULL;
    osl_strings_p arrays_backup = NULL;
    osl_names_p names;
    osl_arrays_p arrays;

    if (scop == NULL) {
        fprintf(file, "# NULL scop\n");
        return;
    }
    else {
        fprintf(file, "# [File generated by the OpenScop Library %s]\n"
                "# [SCoPLib format]\n",
                OSL_RELEASE);
    }

    if (osl_scop_check_compatible_scoplib(scop) == 0) {
        OSL_error("SCoP integrity check failed. Something may go wrong.");
        exit(1);
    }

    // Generate the names for the various dimensions.
    names = osl_scop_names(scop);

    while (scop != NULL) {
        // If possible, replace parameter names with scop parameter names.
        if (osl_generic_has_URI(scop->parameters, OSL_URI_STRINGS)) {
            parameters_backedup = 1;
            parameters_backup = names->parameters;
            names->parameters = scop->parameters->data;
        }

        // If possible, replace array names with arrays extension names.
        arrays = osl_generic_lookup(scop->extension, OSL_URI_ARRAYS);
        if (arrays != NULL) {
            arrays_backedup = 1;
            arrays_backup = names->arrays;
            names->arrays = osl_arrays_to_strings(arrays);
        }

        fprintf(file, "\nSCoP\n\n");
        fprintf(file, "# =============================================== "
                "Global\n");
        fprintf(file, "# Language\n");
        fprintf(file, "%s\n\n", scop->language);

        fprintf(file, "# Context\n");

        osl_relation_pprint_scoplib(file, scop->context, names, 0, 0);
        fprintf(file, "\n");

        osl_util_print_provided(file,
                                osl_generic_has_URI(scop->parameters, OSL_URI_STRINGS),
                                "Parameters are");

        if (scop->parameters) {
            fprintf(file, "# Parameter names\n");
            osl_strings_print(file, scop->parameters->data);
        }

        fprintf(file, "\n# Number of statements\n");
        fprintf(file, "%d\n\n",osl_statement_number(scop->statement));

        osl_statement_pprint_scoplib(file, scop->statement, names);

        if (scop->extension) {
            fprintf(file, "# =============================================== "
                    "Options\n");
            osl_generic_print_options_scoplib(file, scop->extension);
        }

        // If necessary, switch back parameter names.
        if (parameters_backedup) {
            parameters_backedup = 0;
            names->parameters = parameters_backup;
        }

        // If necessary, switch back array names.
        if (arrays_backedup) {
            arrays_backedup = 0;
            osl_strings_free(names->arrays);
            names->arrays = arrays_backup;
        }

        scop = scop->next;
    }

    osl_names_free(names);
}