diff options
author | Andrea Ornstein <andrea.ornstein@st.com> | 2009-07-23 09:00:56 +0000 |
---|---|---|
committer | Andrea Ornstein <andrea.ornstein@st.com> | 2009-07-23 09:00:56 +0000 |
commit | 4ae50c54e76ae5eb4a6d08e03288f090e1ee192b (patch) | |
tree | b8e68136a64ba0c4adac4fddb28e1679f9a39d9e | |
parent | 49adc495c4ed93e7d7663df83d8de98e19641e1e (diff) |
rewrite code using tree_last and list_length
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/st/cli-be@149977 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/config/cil32/cil-dump.c | 16 | ||||
-rw-r--r-- | gcc/config/cil32/cil-stmt.c | 5 | ||||
-rw-r--r-- | gcc/config/cil32/emit-cil.c | 29 | ||||
-rw-r--r-- | gcc/config/cil32/gimple-to-cil.c | 9 |
4 files changed, 15 insertions, 44 deletions
diff --git a/gcc/config/cil32/cil-dump.c b/gcc/config/cil32/cil-dump.c index 76490a8dd32..09331b26169 100644 --- a/gcc/config/cil32/cil-dump.c +++ b/gcc/config/cil32/cil-dump.c @@ -120,18 +120,12 @@ dump_fun (const_tree fun) args_type = TYPE_ARG_TYPES (fun_type); - if (args_type != NULL) - { - last_arg_type = args_type; - - while (TREE_CHAIN (last_arg_type)) - last_arg_type = TREE_CHAIN (last_arg_type); + last_arg_type = tree_last (args_type); - if (TREE_VALUE (last_arg_type) != void_type_node) - { - last_arg_type = NULL; - varargs = TRUE; - } + if (last_arg_type && TREE_VALUE (last_arg_type) != void_type_node) + { + last_arg_type = NULL; + varargs = true; } printf ("%s", varargs ? "vararg " : ""); diff --git a/gcc/config/cil32/cil-stmt.c b/gcc/config/cil32/cil-stmt.c index 455c78276aa..cb5b4fcf03b 100644 --- a/gcc/config/cil32/cil-stmt.c +++ b/gcc/config/cil32/cil-stmt.c @@ -220,10 +220,7 @@ cil_build_call_generic_list (enum cil_opcode opcode, bool va, arg_types = TYPE_ARG_TYPES (arg->ftype); - if (arg_types == NULL) - nargs_base = 0; - else - nargs_base = list_length (arg_types); + nargs_base = list_length (arg_types); arg->nargs = nargs_base + VEC_length (tree, arglist); diff --git a/gcc/config/cil32/emit-cil.c b/gcc/config/cil32/emit-cil.c index 1649233e42f..345c3941bf5 100644 --- a/gcc/config/cil32/emit-cil.c +++ b/gcc/config/cil32/emit-cil.c @@ -454,18 +454,13 @@ dump_fun_type (FILE *file, tree fun_type, tree fun, const char *name, bool ref) "Missing function %s prototype, guessing it, you should fix the " "code", fun ? IDENTIFIER_POINTER (DECL_NAME (fun)) : ""); } - else - { - last_arg_type = args_type; - while (TREE_CHAIN (last_arg_type)) - last_arg_type = TREE_CHAIN (last_arg_type); + last_arg_type = tree_last (args_type); - if (TREE_VALUE (last_arg_type) != void_type_node) - { - last_arg_type = NULL; - varargs = TRUE; - } + if (last_arg_type && TREE_VALUE (last_arg_type) != void_type_node) + { + last_arg_type = NULL; + varargs = true; } fprintf (file, "%s", varargs ? "vararg " : ""); @@ -1558,14 +1553,7 @@ emit_cil_stmt (FILE *file, const_cil_stmt stmt) static void emit_start_function (FILE *file, struct function *fun) { - size_t nargs = 0; - tree args = DECL_ARGUMENTS (fun->decl); - - while (args) - { - args = TREE_CHAIN (args); - nargs++; - } + size_t nargs = list_length (DECL_ARGUMENTS (fun->decl)); fprintf (file, "\n.method public static void '.start'(class [mscorlib]System.String[] 'args') cil managed" @@ -1865,10 +1853,9 @@ emit_function_header (FILE *file, struct function *fun) if (args_type != NULL) { - while (TREE_CHAIN (args_type)) - args_type = TREE_CHAIN (args_type); + tree last_args_type = tree_last (args_type); - if (TREE_VALUE (args_type) != void_type_node) + if (TREE_VALUE (last_args_type) != void_type_node) varargs = true; } else diff --git a/gcc/config/cil32/gimple-to-cil.c b/gcc/config/cil32/gimple-to-cil.c index a5763f52c16..ccb1d90da0f 100644 --- a/gcc/config/cil32/gimple-to-cil.c +++ b/gcc/config/cil32/gimple-to-cil.c @@ -2181,14 +2181,7 @@ gen_call_expr (cil_stmt_iterator *csi, tree node) { if (TREE_ASM_WRITTEN (fdecl)) { - tree c_args; - max_nargs = 0; - for (c_args = DECL_ARGUMENTS (fdecl); - c_args != NULL_TREE; - c_args = TREE_CHAIN (c_args)) - { - ++max_nargs; - } + max_nargs = list_length (DECL_ARGUMENTS (fdecl)); if (max_nargs < nargs) { warning (OPT_Wcil_missing_prototypes, |