From 354ecfd5f7127b2a8aee435e081067d602fb177b Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 17 Sep 2012 08:52:18 +0000 Subject: [PATCH] * m2-valprint.c (m2_print_array_contents): Eliminate variable ELTLEN and use TYPE_LENGTH directly. (m2_val_print): Likewise. * m68k-tdep.c (m68k_svr4_extract_return_value): Eliminate variable LEN and use TYPE_LENGTH directly. (m68k_svr4_store_return_value): Likewise. * mips-tdep.c (mips_o32_push_dummy_call): Eliminate variable ARGLEN and use TYPE_LENGTH directly. (mips_o64_push_dummy_call): Likewise. * s390-tdep (s390_function_arg_pass_by_reference): Eliminate variable LENGTH and use TYPE_LENGTH directly. (s390_function_arg_float): Likewise. (s390_function_arg_integer): Likewise. (s390_push_dummy_call): Likewise. (s390_return_value_convention): Likewise. * spu-tdep.c (spu_push_dummy_call): Eliminate LEN and use TYPE_LENGTH directly. --- gdb/ChangeLog | 20 ++++++++++++++++++++ gdb/m2-valprint.c | 10 +++------- gdb/m68k-tdep.c | 6 ++---- gdb/mips-tdep.c | 6 ++---- gdb/s390-tdep.c | 17 ++++++----------- gdb/spu-tdep.c | 3 +-- 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f73ad65..d373887 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,23 @@ +2012-09-17 Siddhesh Poyarekar + + * m2-valprint.c (m2_print_array_contents): Eliminate variable + ELTLEN and use TYPE_LENGTH directly. + (m2_val_print): Likewise. + * m68k-tdep.c (m68k_svr4_extract_return_value): Eliminate + variable LEN and use TYPE_LENGTH directly. + (m68k_svr4_store_return_value): Likewise. + * mips-tdep.c (mips_o32_push_dummy_call): Eliminate variable + ARGLEN and use TYPE_LENGTH directly. + (mips_o64_push_dummy_call): Likewise. + * s390-tdep (s390_function_arg_pass_by_reference): Eliminate + variable LENGTH and use TYPE_LENGTH directly. + (s390_function_arg_float): Likewise. + (s390_function_arg_integer): Likewise. + (s390_push_dummy_call): Likewise. + (s390_return_value_convention): Likewise. + * spu-tdep.c (spu_push_dummy_call): Eliminate LEN and use + TYPE_LENGTH directly. + 2012-09-17 Yao Qi * cli/cli-decode.c (add_setshow_zuinteger_unlimited_cmd): New. diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index 3d3127e..92a073a 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -269,16 +269,14 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr, const struct value_print_options *options, int len) { - int eltlen; CHECK_TYPEDEF (type); if (TYPE_LENGTH (type) > 0) { - eltlen = TYPE_LENGTH (type); if (options->prettyprint_arrays) print_spaces_filtered (2 + 2 * recurse, stream); /* For an array of chars, print with string syntax. */ - if (eltlen == 1 && + if (TYPE_LENGTH (type) == 1 && ((TYPE_CODE (type) == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (TYPE_CODE (type) == TYPE_CODE_CHAR))) @@ -320,7 +318,6 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, unsigned int i = 0; /* Number of characters printed. */ unsigned len; struct type *elttype; - unsigned eltlen; CORE_ADDR addr; CHECK_TYPEDEF (type); @@ -330,12 +327,11 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) { elttype = check_typedef (TYPE_TARGET_TYPE (type)); - eltlen = TYPE_LENGTH (elttype); - len = TYPE_LENGTH (type) / eltlen; + len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype); if (options->prettyprint_arrays) print_spaces_filtered (2 + 2 * recurse, stream); /* For an array of chars, print with string syntax. */ - if (eltlen == 1 && + if (TYPE_LENGTH (elttype) == 1 && ((TYPE_CODE (elttype) == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index b507c37..b45a80f 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -315,7 +315,6 @@ static void m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); gdb_byte buf[M68K_MAX_REGISTER_SIZE]; struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -326,7 +325,7 @@ m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache, regcache_raw_read (regcache, M68K_FP0_REGNUM, buf); convert_typed_floating (buf, fpreg_type, valbuf, type); } - else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4) + else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == 4) regcache_raw_read (regcache, M68K_A0_REGNUM, valbuf); else m68k_extract_return_value (type, regcache, valbuf); @@ -357,7 +356,6 @@ static void m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - int len = TYPE_LENGTH (type); struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -368,7 +366,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, convert_typed_floating (valbuf, type, buf, fpreg_type); regcache_raw_write (regcache, M68K_FP0_REGNUM, buf); } - else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4) + else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == 4) { regcache_raw_write (regcache, M68K_A0_REGNUM, valbuf); regcache_raw_write (regcache, M68K_D0_REGNUM, valbuf); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 56fa56c..2af4c89 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -5174,13 +5174,12 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argnum = 0; argnum < nargs; argnum++) { struct type *arg_type = check_typedef (value_type (args[argnum])); - int arglen = TYPE_LENGTH (arg_type); /* Align to double-word if necessary. */ if (mips_type_needs_double_align (arg_type)) len = align_up (len, MIPS32_REGSIZE * 2); /* Allocate space on the stack. */ - len += align_up (arglen, MIPS32_REGSIZE); + len += align_up (TYPE_LENGTH (arg_type), MIPS32_REGSIZE); } sp -= align_up (len, 16); @@ -5703,10 +5702,9 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argnum = 0; argnum < nargs; argnum++) { struct type *arg_type = check_typedef (value_type (args[argnum])); - int arglen = TYPE_LENGTH (arg_type); /* Allocate space on the stack. */ - len += align_up (arglen, MIPS64_REGSIZE); + len += align_up (TYPE_LENGTH (arg_type), MIPS64_REGSIZE); } sp -= align_up (len, 16); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 620eaea..ed06740 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -2489,8 +2489,7 @@ is_power_of_two (unsigned int n) static int s390_function_arg_pass_by_reference (struct type *type) { - unsigned length = TYPE_LENGTH (type); - if (length > 8) + if (TYPE_LENGTH (type) > 8) return 1; return (is_struct_like (type) && !is_power_of_two (TYPE_LENGTH (type))) @@ -2503,8 +2502,7 @@ s390_function_arg_pass_by_reference (struct type *type) static int s390_function_arg_float (struct type *type) { - unsigned length = TYPE_LENGTH (type); - if (length > 8) + if (TYPE_LENGTH (type) > 8) return 0; return is_float_like (type); @@ -2515,13 +2513,12 @@ s390_function_arg_float (struct type *type) static int s390_function_arg_integer (struct type *type) { - unsigned length = TYPE_LENGTH (type); - if (length > 8) + if (TYPE_LENGTH (type) > 8) return 0; return is_integer_like (type) || is_pointer_like (type) - || (is_struct_like (type) && is_power_of_two (length)); + || (is_struct_like (type) && is_power_of_two (TYPE_LENGTH (type))); } /* Return ARG, a `SIMPLE_ARG', sign-extended or zero-extended to a full @@ -2616,11 +2613,10 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { struct value *arg = args[i]; struct type *type = check_typedef (value_type (arg)); - unsigned length = TYPE_LENGTH (type); if (s390_function_arg_pass_by_reference (type)) { - sp -= length; + sp -= TYPE_LENGTH (type); sp = align_down (sp, alignment_of (type)); copy_addr[i] = sp; } @@ -2799,8 +2795,7 @@ s390_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) static enum return_value_convention s390_return_value_convention (struct gdbarch *gdbarch, struct type *type) { - int length = TYPE_LENGTH (type); - if (length > 8) + if (TYPE_LENGTH (type) > 8) return RETURN_VALUE_STRUCT_CONVENTION; switch (TYPE_CODE (type)) diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c index f05a26b..8419a5a 100644 --- a/gdb/spu-tdep.c +++ b/gdb/spu-tdep.c @@ -1373,8 +1373,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct value *arg = args[i]; struct type *type = check_typedef (value_type (arg)); const gdb_byte *contents = value_contents (arg); - int len = TYPE_LENGTH (type); - int n_regs = align_up (len, 16) / 16; + int n_regs = align_up (TYPE_LENGTH (type), 16) / 16; /* If the argument doesn't wholly fit into registers, it and all subsequent arguments go to the stack. */ -- 2.7.4