Exemplo n.º 1
0
ScopLib::~ScopLib() {
  if (!scoplib)
    return;

  // Free array names.
  for (int i = 0; i < scoplib->nb_arrays; ++i)
    free(scoplib->arrays[i]);

  free(scoplib->arrays);
  scoplib->arrays = NULL;
  scoplib->nb_arrays = 0;

  // Free parameters
  for (int i = 0; i < scoplib->nb_parameters; ++i)
    free(scoplib->parameters[i]);

  free(scoplib->parameters);
  scoplib->parameters = NULL;
  scoplib->nb_parameters = 0;

  scoplib_statement_p stmt = scoplib->statement;

  // Free Statements
  while (stmt) {
    scoplib_statement_p TempStmt = stmt->next;
    stmt->next = NULL;
    freeStatement(stmt);
    stmt = TempStmt;
  }

  scoplib->statement = NULL;

  scoplib_scop_free(scoplib);
}
Exemplo n.º 2
0
/*zw: read the transformation function from .scop file*/
char* candl_program_read_scop_transform(FILE* file){
    scoplib_scop_p scop;
    scop = scoplib_scop_read(file);
    char* candl_opts = scoplib_scop_tag_content(scop, "<candl>", "</candl>");
    scoplib_scop_free(scop);
    if (!candl_opts)
        return NULL;
    char* transformation = scoplib_scop_tag_content_from_string(candl_opts, "<Transformation>", "</Transformation>");
    free (candl_opts);
    if (! transformation)
        return NULL;
    else
        return transformation;
}
Exemplo n.º 3
0
candl_program_p candl_program_read_scop(FILE * file)
{
  int i;

  /* Read the scop. */

  scoplib_scop_p scop = scoplib_scop_read(file);
  /* Check for the <candl> tag in the options of the .scop file. */
  int** indices = candl_program_scop_get_opt_indices(scop);
  /* Convert the scop. */
  candl_program_p res = candl_program_convert_scop(scop, indices);

  /* Clean temporary data. */
  if (indices)
    {
      for (i = 0; i < res->nb_statements; ++i)
	free(indices[i]);
      free(indices);
    }
  scoplib_scop_free(scop);

  return res;
}
Exemplo n.º 4
0
int main(int argc, char * argv[])
{
  scoplib_scop_p scop;
  clan_options_p options;
  FILE * input;
  FILE * output;

  /* Options and input/output file setting. */
  options = clan_options_read(argc,argv,&input,&output);

  /* Extraction of the polyhedral representation of the SCoP from the input. */
  if (options->inputscop)
    /* Input is a .scop file. */
    scop = scoplib_scop_read(input);
  else
    /* Input is a source code. */
    scop = clan_scop_extract(input,options);

  /* Printing of the internal data structure of the SCoP if asked. */
  if (options->structure)
    scoplib_scop_print(stdout,scop);

  /* Generation of the .scop output file. */
  int sopt = 0;
  if (options->castle)
    sopt |= SCOPLIB_SCOP_PRINT_CASTLE;
  if (options->arraystag)
    sopt |= SCOPLIB_SCOP_PRINT_ARRAYSTAG;
  scoplib_scop_print_dot_scop_options(output,scop,sopt);

  /* Save the planet. */
  clan_options_free(options);
  scoplib_scop_free(scop);

  return 0;
}