* \{
*/
+static tree
+get_lhs_var (struct aop_joinpoint *jp)
+{
+ gimple stmt;
+ tree lhs;
+
+ aop_assert (jp->pc->kind == ATP_ASSIGN);
+
+ stmt = gsi_stmt (*jp->gsi);
+ aop_assert (gimple_has_lhs (stmt));
+ lhs = gimple_get_lhs (stmt);
+
+ if (TREE_CODE (lhs) == SSA_NAME)
+ lhs = SSA_NAME_VAR (lhs);
+
+ if (lhs != NULL)
+ return lhs;
+ else
+ return NULL;
+}
+
/**
* Get the name of the variable being assigned to in an assignment
* joinpoint.
const char *
aop_capture_lhs_name (struct aop_joinpoint *jp)
{
- gimple stmt;
tree lhs;
aop_assert (jp->pc->kind == ATP_ASSIGN);
- stmt = gsi_stmt (*jp->gsi);
- aop_assert (gimple_has_lhs (stmt));
- lhs = gimple_get_lhs (stmt);
-
- if (TREE_CODE (lhs) == SSA_NAME)
- lhs = SSA_NAME_VAR (lhs);
-
+ lhs = get_lhs_var (jp);
if (lhs != NULL && DECL_P (lhs))
{
tree name = DECL_NAME (lhs);
}
}
+
/* Given an expression from the lhs of an assignment, return true
unless it is a temporary variable created by the compiler.
return pc;
}
+/**
+ * Returns scope of the LHS variable of the assignment statement.
+ * \param jp The joinpoint corresponding to the assignment statement.
+ * \return The scope of the LHS variable.
+ */
+enum aop_scope
+aop_capture_lhs_var_scope (struct aop_joinpoint *jp)
+{
+ tree lhs;
+ lhs = get_lhs_var (jp);
+ if (lhs != NULL_TREE)
+ {
+ if (DECL_FILE_SCOPE_P (lhs))
+ {
+ if (!TREE_PUBLIC (lhs))
+ {
+ return AOP_FILE_SCOPE;
+ }
+ else
+ {
+ return AOP_GLOBAL_SCOPE;
+ }
+ }
+ else if (TREE_CODE (DECL_CONTEXT (lhs)) == FUNCTION_DECL)
+ {
+ return AOP_FUNCTION_SCOPE;
+ }
+ else
+ {
+ return AOP_MEMORY_SCOPE;
+ }
+ }
+ else
+ {
+ return AOP_MEMORY_SCOPE;
+ }
+}
+
/* Close Doxygen defgroup block. */
/**
* /}