From: Justin Seyster Date: Tue, 2 Feb 2010 21:40:55 +0000 (-0500) Subject: Initialized git repo. X-Git-Tag: release-v1.0~132 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=7597caa09ff9d133633d0fd4bad83edb85930238;p=interaspect.git Initialized git repo. --- 7597caa09ff9d133633d0fd4bad83edb85930238 diff --git a/src/aop-main.c b/src/aop-main.c new file mode 100644 index 0000000..e80f106 --- /dev/null +++ b/src/aop-main.c @@ -0,0 +1,108 @@ +/* This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* aop-main.c: Basic setup functions. */ + +/* Whether we want them or not (we don't), Autoconf _insists_ on + defining these. Since GCC's config.h (which we must include) also + defines them, we have to undef them here. */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "aop-main.c" + +static struct opt_pass template_pass = { + .type = GIMPLE_PASS, + .name = NULL, + .gate = NULL, + .execute = NULL, + .sub = NULL, + .next = NULL, + .static_pass_number = 0, + .tv_id = 0, + .properties_required = 0, + .properties_provided = 0, + .properties_destroyed = 0, + .todo_flags_start = 0, + .todo_flags_finish = TODO_update_ssa, +} + +void aop_register_pass (const char *pass_name, pass_callback callback) +{ + struct opt_pass *pass_aop; + struct register_pass_info pass_info; + + pass_aop = xmalloc (sizeof (struct opt_pass)); + pass_aop->name = xstrdup (pass_name); + pass_aop->execute = callback; + + pass_info.pass = pass_aop; + pass_info.reference_pass_name = "*all_optimizations"; + pass_info.ref_pass_instance_number = 0; + pass_info.pos_op = PASS_POS_INSERT_BEFORE; + + register_callback (aop_plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, + &pass_info); +} + +/* This is the last plug-in function called before GCC exits. Clean + up all the memory we allocated. */ +static void cleanup (void *event_date, void *data) +{ +} + +/* GCC calls this to initialize a plug-in. Once InterAspect + initializes, it calls down into its client plug-in's + initialization. */ +int plugin_init (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version) +{ + fprintf (stderr, "InterAspect init.\n"); + + /* Register our cleanup function. */ + register_callback (plugin_name, PLUGIN_FINISH, aop_cleanup, NULL); + + /* Give the client plug-in its chance to register a pass. */ + aop_main (); + + return 0; +} diff --git a/src/aop.h b/src/aop.h new file mode 100644 index 0000000..0ce560d --- /dev/null +++ b/src/aop.h @@ -0,0 +1,37 @@ +#ifndef __AOP_H_ +#define __AOP_H_ + +/* This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* The InterAspect package for GCC is a framework for building GCC plug-ins + that perform instrumentation. InterAspect has two goals: + 1: to serve as the interposition backend for a GCC + Aspect-Oriented Programming (AOP) utility; + 2: to make it simple to write stand-alone plug-ins that implement + custom instrumentation. + + For both of these goals, InterAspect provides functions to + interpose on a variety of program events. The framework can insert + calls to "advice" functions at the points in the program where + these events occur (known as "join points"). Furthermore, inserted + calls can pass values from the running program to the advice + function. */ + +typedef (unsigned int)(*pass_callback)(); + +void aop_register_pass(const char *pass_name, pass_callback callback); +void aop_main(); + +#endif