From: Justin Seyster Date: Wed, 24 Mar 2010 23:29:45 +0000 (-0400) Subject: Added an op in the aop_pointcut op vector for inserting a gimple stmt. X-Git-Tag: release-v1.0~116 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=99e972f868391544dbd7aae26cdebe1ca58885c2;p=interaspect.git Added an op in the aop_pointcut op vector for inserting a gimple stmt. --- diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c index 90859c1..0e54209 100644 --- a/src/aop-pc-assign.c +++ b/src/aop-pc-assign.c @@ -115,6 +115,7 @@ aop_match_assignment_by_type (const struct aop_type *type) pc = ggc_alloc (sizeof (struct aop_pointcut *)); pc->kind = ATP_ASSIGN; pc->join_on = op_join_on_assign; + pc->insert_before = op_default_insert_before; pc->pc_assign.type = type; diff --git a/src/aop-pc-entry.c b/src/aop-pc-entry.c index a18d51f..74c7c3f 100644 --- a/src/aop-pc-entry.c +++ b/src/aop-pc-entry.c @@ -67,6 +67,7 @@ aop_match_function_entry () pc = ggc_alloc (sizeof (struct aop_pointcut *)); pc->kind = ATP_ENTRY; pc->join_on = op_join_on_function_entry; + pc->insert_before = op_default_insert_before; return pc; } diff --git a/src/aop-pc-exit.c b/src/aop-pc-exit.c index eb4f986..97f8891 100644 --- a/src/aop-pc-exit.c +++ b/src/aop-pc-exit.c @@ -37,7 +37,6 @@ #include "aop-pointcut.h" #include "aop-type.h" - static void op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb, void *callback_param) @@ -72,6 +71,7 @@ aop_match_function_exit () pc = ggc_alloc (sizeof (struct aop_pointcut *)); pc->kind = ATP_EXIT; pc->join_on = op_join_on_function_exit; + pc->insert_before = op_default_insert_before; return pc; } diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h index f267501..cfba5fc 100644 --- a/src/aop-pointcut.h +++ b/src/aop-pointcut.h @@ -40,6 +40,7 @@ struct aop_pointcut { enum aop_pckind kind; void (*join_on) (struct aop_pointcut *, join_callback, void *); + void (*insert_before) (struct aop_joinpoint *, gimple); union { struct aop_pc_assign pc_assign; @@ -59,4 +60,6 @@ struct aop_joinpoint { gimple_stmt_iterator *gsi; }; +void op_default_insert_before (struct aop_joinpoint *jp, gimple stmt); + #endif diff --git a/src/aop-weave.c b/src/aop-weave.c index c6ad9b0..a883a80 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -115,15 +115,29 @@ build_gcc_call (const char *func_name, tree return_type, va_list argp) return func_call; } +/* This is the default insert_before() operation for aop_pointcut + objects. It just inserts a gimple statement before the iterator in + the aop_joinpoint object. This function holds to the requirement + that inserting multiple gimple statements at the joinpoint will + result in those statements appearing in the order they were + added. */ +void +op_default_insert_before (struct aop_joinpoint *jp, gimple stmt) +{ + gsi_insert_before (jp->gsi, stmt, GSI_SAME_STMT); +} + void aop_insert_advice (struct aop_joinpoint *jp, const char *func_name, ...) { va_list argp; gimple func_call; + struct aop_pointcut *pc; va_start (argp, func_name); func_call = build_gcc_call (func_name, void_type_node, argp); va_end (argp); - gsi_insert_before (jp->gsi, func_call, GSI_SAME_STMT); + pc = jp->pc; + pc->insert_before(jp, func_call); }