Filled in aop_join_on for assignment pointcuts.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Wed, 10 Feb 2010 23:00:43 +0000 (18:00 -0500)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Wed, 10 Feb 2010 23:00:43 +0000 (18:00 -0500)
Added joinpoint data structure.

src/aop-pc-assign.c
src/aop-pointcut.h
src/aop-type.c
src/aop-type.h
src/aop.h

index 048599c7634ffb48d6e08c7d67b7fb074c461839..79127326488f12e1291259ea4b3c5996efe78b1c 100644 (file)
 
 #include <config.h>
 #include <system.h>
+#include <coretypes.h>
+#include <tm.h>
+#include <tree.h>
 #include <ggc.h>
+#include <basic-block.h>
+#include <gimple.h>
 
 #include "aop.h"
 #include "aop-pointcut.h"
+#include "aop-type.h"
+
+static bool
+stmt_matches_pointcut (struct aop_pointcut *pc, gimple stmt)
+{
+  if (gimple_has_lhs (stmt))
+    {
+      tree type = TREE_TYPE (gimple_get_lhs (stmt));
+      return does_type_match (type, pc->pc_assign.type);
+    }
+  else
+    {
+      return false;
+    }
+}
 
 static void
 op_join_on_assign (struct aop_pointcut *pc, join_callback cb)
 {
-  aop_assert(pc->kind == ATP_ASSIGN);
+  basic_block bb;
+
+  aop_assert (pc->kind == ATP_ASSIGN);
+
+  FOR_EACH_BB(bb)
+    {
+      gimple_stmt_iterator gsi;
+
+      for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi))
+       {
+         gimple stmt = gsi_stmt (gsi);
+
+         if (stmt_matches_pointcut (pc, stmt))
+           {
+             struct aop_joinpoint jp;
+             jp.pc = pc;
+             jp.gsi = &gsi;
+
+             cb (&jp);
+           }
+       }
+    }
 }
 
 struct aop_pointcut *
index 82beda8475b679acb494e69a1c3339070df757ee..fae1b39d59aa7a16720bc8aa8b5e407f5c7c71dd 100644 (file)
@@ -28,6 +28,12 @@ struct aop_pc_assign {
   struct aop_type *type;
 };
 
+/* An AOP pointcut represents the a set of joinponts: locations in the
+   source code that are available for inserting instrumentation.
+
+   In practice, we do not directly store the set of joinpoints.
+   Instead, we store a description of the set that a join function can
+   use to find matching joinpoints. */
 struct aop_pointcut {
   enum aop_pckind kind;
 
@@ -38,4 +44,17 @@ struct aop_pointcut {
   };
 };
 
+/* An AOP joinpoint represents a specific location in the code where
+   it is possible to insert instrumentation.  Because joinpoints are
+   passed to do_weave functions, they must have all the information
+   necessary to directly add a hook function. */
+struct aop_joinpoint {
+  /* The pointcut that this joinpoint is a member of. */
+  struct aop_pointcut *pc;
+
+  /* A GCC iterator for where weave functions can insert their
+     instrumentation.*/
+  gimple_stmt_iterator *gsi;
+};
+
 #endif
index a7e6587da8ef6198e6a1d7122592fe33e89504ee..3c31ae71fec8b887d072355a9c696d763843d27f 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+/* 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 <stddef.h>
 
+#include <config.h>
+#include <system.h>
+#include <coretypes.h>
+
 #include "aop-type.h"
 
 static struct aop_type _aop_t_all_signed = {
@@ -63,3 +76,10 @@ aop_t_all_pointer ()
 {
   return &_aop_t_all_pointer;
 }
+
+/* Match an actual GCC type with an AOP type specification. */
+bool
+does_type_match (tree gcc_type, struct aop_type *aop_type)
+{
+  return true;
+}
index d4c6c86f6b618d50aa3d436aa879a6fdb2cacea1..66607fb78f5c34acf5e832137e2629d954cc0396 100644 (file)
@@ -35,4 +35,6 @@ struct aop_type {
   const char *tag;
 };
 
+bool does_type_match (tree gcc_type, struct aop_type *aop_type);
+
 #endif
index 134c4f805676fa1e593ae17e0e81c4fd2627f89d..ccd67bfc7229c52d314248af667af64f51c9c771 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
 #define aop_assert(EXPR) ((void)(0 && (EXPR)))
 #endif
 
+struct aop_joinpoint;
 struct aop_pointcut;
 struct aop_type;
 
 typedef unsigned int (*pass_callback) ();
-typedef void (*join_callback) ();
+typedef void (*join_callback) (struct aop_joinpoint *);
 
 extern struct aop_pointcut *aop_match_assignment_by_type (struct aop_type *type);