--- /dev/null
+/* 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 <http://www.gnu.org/licenses/>.
+*/
+
+/* 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 <config.h>
+#include <system.h>
+#include <coretypes.h>
+#include <tm.h>
+#include <toplev.h>
+#include <tree.h>
+#include <input.h>
+#include <varray.h>
+#include <hashtab.h>
+#include <pointer-set.h>
+#include <splay-tree.h>
+#include <langhooks.h>
+#include <cgraph.h>
+#include <intl.h>
+#include <function.h>
+#include <output.h>
+#include <diagnostic.h>
+#include <timevar.h>
+#include <tree-iterator.h>
+#include <tree-flow.h>
+#include <tree-pass.h>
+#include <plugin.h>
+#include <gimple.h>
+#include <c-common.h>
+
+#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;
+}
--- /dev/null
+#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 <http://www.gnu.org/licenses/>.
+*/
+
+/* 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