aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandreao <andreao@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-10 15:23:34 +0000
committerandreao <andreao@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-10 15:23:34 +0000
commita26b8b0566c7045d594bea66348820136635ac90 (patch)
tree713c6cee919edb5082b630a70450932ce35fae66
parent14ea46d8577c0437a7e1d53b323037b71a767209 (diff)
add convenient function cil_call_nargs_full that returns the # of arguments including the staic chain if present and the function pointer if an indirect call
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/st/cli-be@149478 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/config/cil32/cil-stack.c14
-rw-r--r--gcc/config/cil32/cil-stmt-inline.h28
-rw-r--r--gcc/config/cil32/cil-stmt.c15
-rw-r--r--gcc/config/cil32/cil-stmt.h1
-rw-r--r--gcc/config/cil32/remove-temps.c11
5 files changed, 29 insertions, 40 deletions
diff --git a/gcc/config/cil32/cil-stack.c b/gcc/config/cil32/cil-stack.c
index bfaca5325c0..6d171c19066 100644
--- a/gcc/config/cil32/cil-stack.c
+++ b/gcc/config/cil32/cil-stack.c
@@ -343,20 +343,8 @@ cil_stack_after_stmt (cil_stack stack, cil_stmt stmt)
case CIL_CALL:
case CIL_JMP:
case CIL_NEWOBJ:
- i = cil_call_nargs (stmt) + (cil_call_static_chain (stmt) ? 1 : 0);
-
- while (i-- != 0)
- VEC_pop (cil_type_t, vstack);
-
- type = TREE_TYPE (cil_call_ftype (stmt));
-
- if (!VOID_TYPE_P (type))
- VEC_safe_push (cil_type_t, heap, vstack, type_to_cil (type));
-
- break;
-
case CIL_CALLI:
- i = cil_call_nargs (stmt) + 1 + (cil_call_static_chain (stmt) ? 1 : 0);
+ i = cil_call_nargs_full (stmt);
while (i-- != 0)
VEC_pop (cil_type_t, vstack);
diff --git a/gcc/config/cil32/cil-stmt-inline.h b/gcc/config/cil32/cil-stmt-inline.h
index 43155fe5c70..f52225467e5 100644
--- a/gcc/config/cil32/cil-stmt-inline.h
+++ b/gcc/config/cil32/cil-stmt-inline.h
@@ -291,18 +291,40 @@ cil_call_fdecl (const_cil_stmt stmt)
return stmt->arg.fcall->fdecl;
}
-/* Return the number of arguments passed to the callee of a CIL CALL, CALLI or
- JMP statement. */
+/* Return the number of arguments passed to the callee of a CIL CALL, CALLI,
+ JMP or NEWOBJ statement. */
static inline size_t
cil_call_nargs (const_cil_stmt stmt)
{
gcc_assert (stmt->opcode == CIL_CALL || stmt->opcode == CIL_CALLI ||
- stmt->opcode == CIL_NEWOBJ);
+ stmt->opcode == CIL_JMP || stmt->opcode == CIL_NEWOBJ);
return stmt->arg.fcall->nargs;
}
+/* Return the total number of arguments passed to the callee of a CIL CALL,
+ CALLI, JMP or NEWOBJ statement. Includes STatic_chain if present and
+ function pointer if indirect call */
+
+static inline size_t
+cil_call_nargs_full (const_cil_stmt stmt)
+{
+ size_t result = 0;
+ gcc_assert (stmt->opcode == CIL_CALL || stmt->opcode == CIL_CALLI ||
+ stmt->opcode == CIL_JMP || stmt->opcode == CIL_NEWOBJ);
+
+ if (stmt->opcode == CIL_CALLI)
+ result = 1;
+
+ if (stmt->arg.fcall->static_chain_p)
+ ++result;
+
+ result += stmt->arg.fcall->nargs;
+
+ return result;
+}
+
/* Return the I-th argument passed to the callee of a CIL CALL, CALLI, JMP or
NEWOBJ statement. */
diff --git a/gcc/config/cil32/cil-stmt.c b/gcc/config/cil32/cil-stmt.c
index de59b2d8850..2f10e49989d 100644
--- a/gcc/config/cil32/cil-stmt.c
+++ b/gcc/config/cil32/cil-stmt.c
@@ -862,21 +862,8 @@ cil_seq_stack_depth (cil_seq seq, bool ret, unsigned int init, bool max)
case CIL_CALL:
case CIL_JMP:
case CIL_NEWOBJ:
- nargs = cil_call_nargs (cs) + (cil_call_static_chain (cs) ? 1 : 0);
- gcc_assert (depth >= nargs);
- depth -= nargs;
-
- if (!VOID_TYPE_P (TREE_TYPE (cil_call_ftype (cs))))
- {
- depth++;
- max_depth = (depth > max_depth) ? depth : max_depth;
- }
-
- break;
-
case CIL_CALLI:
- nargs = cil_call_nargs (cs) + 1
- + (cil_call_static_chain (cs) ? 1 : 0);
+ nargs = cil_call_nargs_full (cs);
gcc_assert (depth >= nargs);
depth -= nargs;
diff --git a/gcc/config/cil32/cil-stmt.h b/gcc/config/cil32/cil-stmt.h
index fa7e5dc0794..b5e2d98f9ec 100644
--- a/gcc/config/cil32/cil-stmt.h
+++ b/gcc/config/cil32/cil-stmt.h
@@ -85,6 +85,7 @@ static inline cil_stmt cil_build_jmp_mp (tree, VEC (tree, heap) *);
static inline tree cil_call_ftype (const_cil_stmt);
static inline tree cil_call_fdecl (const_cil_stmt);
static inline size_t cil_call_nargs (const_cil_stmt);
+static inline size_t cil_call_nargs_full (const_cil_stmt);
static inline tree cil_call_arg_type (const_cil_stmt, size_t);
static inline void cil_call_set_static_chain (cil_stmt, tree);
static inline tree cil_call_static_chain (const_cil_stmt);
diff --git a/gcc/config/cil32/remove-temps.c b/gcc/config/cil32/remove-temps.c
index 74ba52763e5..47a32c6d52a 100644
--- a/gcc/config/cil32/remove-temps.c
+++ b/gcc/config/cil32/remove-temps.c
@@ -313,17 +313,8 @@ remove_matching_ldloc (cil_stmt_iterator csi, cil_stack stack, tree var,
case CIL_CALL:
case CIL_JMP:
- nargs = cil_call_nargs (stmt)
- + (cil_call_static_chain (stmt) ? 1 : 0);
-
- if (cil_stack_depth (stack) - nargs < min_depth)
- return false;
-
- break;
-
case CIL_CALLI:
- nargs = cil_call_nargs (stmt) + 1
- + (cil_call_static_chain (stmt) ? 1 : 0);
+ nargs = cil_call_nargs_full (stmt);
if (cil_stack_depth (stack) - nargs < min_depth)
return false;