new dump function

This commit is contained in:
fanfuqiang 2018-09-03 12:53:58 +08:00
parent c41757ddc6
commit f7916b3a44
2 changed files with 41 additions and 27 deletions

View File

@ -1,27 +1,19 @@
/* The impelmentation code of optimization pass for RAP.
We supply the API for RAP */
Supply the API for RAP */
#ifndef RAP_OPT_H
#define RAP_OPT_H
/* Contains the beed called optimization level of GCC */
extern int gcc_optimize_level;
/* Count how many function we have optimized */
extern int rap_opt_statistics;
//extern int rap_available_naive(tree p, tree func);
/* This function is defined in gcc/c-decl.c */
//extern tree lookup_name(tree);
/* */
//#define I_SYMBOL_BINDING(node) \
// (((struct lang_identifier *) IDENTIFIER_NODE_CHECK(node))->symbol_binding)
//#define RAP_POINTER_TO_FUNCTION(P)
/* This is defined in gcc/c-decl.c but as static linkage, so we reuse it here.
And the depth of external scope is 0.
If scope depth is more than 1 it's local scope */
//#define FILE_SCOPE_DEPTH 1
/* File scope function*/
extern bool is_rap_function_never_escape (tree t);
/* Try make GCC call ipa-pta pass if optimization level is NOT 0 */
void rap_try_call_ipa_pta (void* gcc_data, void* user_data);
void rap_gather_function_targets ();
int is_rap_function_maybe_roped (tree f);
void rap_opt_statistics ();
void rap_optimization_clean ();
#endif /* RAP_OPT_H */

View File

@ -1,8 +1,8 @@
/* The impelmentation code of optimization pass for RAP.
We supply the API for RAP */
Supply the API for RAP */
#include "../gcc-common.h"
#include "bitmap.h"
#include <stdio.h>
/* There are many optimization methrod can do for RAP.
From simple to complex and aside with the gcc internal work stage.
@ -20,16 +20,16 @@
2, Global alias anylysis for the avail function set. */
/* This variable defined in GCC source */
struct opt_pass *current_pass;
struct simple_ipa_opt_pass pass_ipa_pta;
// Hold all the ROP target functions.
bitmap sensi_funcs = BITMAP_ALLOC (NULL);
/* Contains the beed called optimization level of GCC */
int gcc_optimize_level = 0;
/* Count how many function we have optimized */
int rap_opt_statistics = 0;
/* Contain the statistics data, maybe gcc will called many times, we need output
data in the same file, for the conventices of scripts process. */
char *dump_rap_opt_statistics_filename = "rap_opt_statistics";
FILE *dump_rap_opt_statistics_fd;
// Hold all the ROP target functions.
static bitmap sensi_funcs = BITMAP_ALLOC (NULL);
/* Contains the type database which are pointer analysis can not sloved */
static struct pointer_set_t *pointer_types;
@ -210,3 +210,25 @@ is_rap_function_maybe_roped (tree f)
return ! bitmap_bit_p (DECL_UID (f))
}
/* Write some statistics for our algorithm */
void
dump_rap_opt_statistics ()
{
dump_rap_opt_statistics_fd = fopen (dump_rap_opt_statistics_filename, "a");
fprintf (dump_rap_opt_statistics_fd, "%d\n", rap_opt_statistics);
return;
}
/* Clean and cloese function for optimizations */
void
rap_optimization_clean ()
{
/* Now we have finish our job, close file and destroy the GCC allocated data*/
fclose (dump_rap_opt_statistics_fd);
bitmap_clear (sensi_funcs);
pointer_set_destroy (pointer_types);
return;
}