Unify arch_float_type and init_float_type

This unifies arch_float_type and init_float_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey 2023-03-13 11:30:08 -06:00
parent 46c04ea32f
commit 77c5f49648
21 changed files with 97 additions and 95 deletions

View file

@ -13569,13 +13569,13 @@ public:
add (char_type); add (char_type);
add (init_character_type (alloc, 16, 1, "wide_character")); add (init_character_type (alloc, 16, 1, "wide_character"));
add (init_character_type (alloc, 32, 1, "wide_wide_character")); add (init_character_type (alloc, 32, 1, "wide_wide_character"));
add (arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), add (init_float_type (alloc, gdbarch_float_bit (gdbarch),
"float", gdbarch_float_format (gdbarch))); "float", gdbarch_float_format (gdbarch)));
add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), add (init_float_type (alloc, gdbarch_double_bit (gdbarch),
"long_float", gdbarch_double_format (gdbarch))); "long_float", gdbarch_double_format (gdbarch)));
add (init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), add (init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
0, "long_long_integer")); 0, "long_long_integer"));
add (arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), add (init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
"long_long_float", "long_long_float",
gdbarch_long_double_format (gdbarch))); gdbarch_long_double_format (gdbarch)));
add (init_integer_type (alloc, gdbarch_int_bit (gdbarch), add (init_integer_type (alloc, gdbarch_int_bit (gdbarch),

View file

@ -4904,9 +4904,12 @@ arm_ext_type (struct gdbarch *gdbarch)
arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch); arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
if (!tdep->arm_ext_type) if (!tdep->arm_ext_type)
tdep->arm_ext_type {
= arch_float_type (gdbarch, -1, "builtin_type_arm_ext", type_allocator alloc (gdbarch);
floatformats_arm_ext); tdep->arm_ext_type
= init_float_type (alloc, -1, "builtin_type_arm_ext",
floatformats_arm_ext);
}
return tdep->arm_ext_type; return tdep->arm_ext_type;
} }

View file

@ -737,8 +737,11 @@ csky_register_type (struct gdbarch *gdbarch, int reg_nr)
/* Float register has 64 bits, and only in ck810. */ /* Float register has 64 bits, and only in ck810. */
if ((reg_nr >=CSKY_FR0_REGNUM) && (reg_nr <= CSKY_FR0_REGNUM + 15)) if ((reg_nr >=CSKY_FR0_REGNUM) && (reg_nr <= CSKY_FR0_REGNUM + 15))
return arch_float_type (gdbarch, 64, "builtin_type_csky_ext", {
type_allocator alloc (gdbarch);
return init_float_type (alloc, 64, "builtin_type_csky_ext",
floatformats_ieee_double); floatformats_ieee_double);
}
/* Profiling general register has 48 bits, we use 64bit. */ /* Profiling general register has 48 bits, we use 64bit. */
if ((reg_nr >= CSKY_PROFGR_REGNUM) && (reg_nr <= CSKY_PROFGR_REGNUM + 44)) if ((reg_nr >= CSKY_PROFGR_REGNUM) && (reg_nr <= CSKY_PROFGR_REGNUM + 44))

View file

@ -375,7 +375,7 @@ ctf_init_float_type (struct objfile *objfile,
type_allocator alloc (objfile); type_allocator alloc (objfile);
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
if (format != nullptr) if (format != nullptr)
type = init_float_type (objfile, bits, name, format); type = init_float_type (alloc, bits, name, format);
else else
type = alloc.new_type (TYPE_CODE_ERROR, bits, name); type = alloc.new_type (TYPE_CODE_ERROR, bits, name);

View file

@ -226,13 +226,13 @@ build_d_types (struct gdbarch *gdbarch)
builtin_d_type->builtin_ucent builtin_d_type->builtin_ucent
= init_integer_type (alloc, 128, 1, "ucent"); = init_integer_type (alloc, 128, 1, "ucent");
builtin_d_type->builtin_float builtin_d_type->builtin_float
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), = init_float_type (alloc, gdbarch_float_bit (gdbarch),
"float", gdbarch_float_format (gdbarch)); "float", gdbarch_float_format (gdbarch));
builtin_d_type->builtin_double builtin_d_type->builtin_double
= arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), = init_float_type (alloc, gdbarch_double_bit (gdbarch),
"double", gdbarch_double_format (gdbarch)); "double", gdbarch_double_format (gdbarch));
builtin_d_type->builtin_real builtin_d_type->builtin_real
= arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
"real", gdbarch_long_double_format (gdbarch)); "real", gdbarch_long_double_format (gdbarch));
builtin_d_type->builtin_byte->set_instance_flags builtin_d_type->builtin_byte->set_instance_flags
@ -245,13 +245,13 @@ build_d_types (struct gdbarch *gdbarch)
/* Imaginary and complex types. */ /* Imaginary and complex types. */
builtin_d_type->builtin_ifloat builtin_d_type->builtin_ifloat
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), = init_float_type (alloc, gdbarch_float_bit (gdbarch),
"ifloat", gdbarch_float_format (gdbarch)); "ifloat", gdbarch_float_format (gdbarch));
builtin_d_type->builtin_idouble builtin_d_type->builtin_idouble
= arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), = init_float_type (alloc, gdbarch_double_bit (gdbarch),
"idouble", gdbarch_double_format (gdbarch)); "idouble", gdbarch_double_format (gdbarch));
builtin_d_type->builtin_ireal builtin_d_type->builtin_ireal
= arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
"ireal", gdbarch_long_double_format (gdbarch)); "ireal", gdbarch_long_double_format (gdbarch));
builtin_d_type->builtin_cfloat builtin_d_type->builtin_cfloat
= init_complex_type ("cfloat", builtin_d_type->builtin_float); = init_complex_type ("cfloat", builtin_d_type->builtin_float);

View file

@ -15014,7 +15014,7 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
type_allocator alloc (objfile); type_allocator alloc (objfile);
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
if (format) if (format)
type = init_float_type (objfile, bits, name, format, byte_order); type = init_float_type (alloc, bits, name, format, byte_order);
else else
type = alloc.new_type (TYPE_CODE_ERROR, bits, name); type = alloc.new_type (TYPE_CODE_ERROR, bits, name);

View file

@ -1759,20 +1759,20 @@ build_fortran_types (struct gdbarch *gdbarch)
"integer*8"); "integer*8");
builtin_f_type->builtin_real builtin_f_type->builtin_real
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), = init_float_type (alloc, gdbarch_float_bit (gdbarch),
"real*4", gdbarch_float_format (gdbarch)); "real*4", gdbarch_float_format (gdbarch));
builtin_f_type->builtin_real_s8 builtin_f_type->builtin_real_s8
= arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), = init_float_type (alloc, gdbarch_double_bit (gdbarch),
"real*8", gdbarch_double_format (gdbarch)); "real*8", gdbarch_double_format (gdbarch));
auto fmt = gdbarch_floatformat_for_type (gdbarch, "real(kind=16)", 128); auto fmt = gdbarch_floatformat_for_type (gdbarch, "real(kind=16)", 128);
if (fmt != nullptr) if (fmt != nullptr)
builtin_f_type->builtin_real_s16 builtin_f_type->builtin_real_s16
= arch_float_type (gdbarch, 128, "real*16", fmt); = init_float_type (alloc, 128, "real*16", fmt);
else if (gdbarch_long_double_bit (gdbarch) == 128) else if (gdbarch_long_double_bit (gdbarch) == 128)
builtin_f_type->builtin_real_s16 builtin_f_type->builtin_real_s16
= arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
"real*16", gdbarch_long_double_format (gdbarch)); "real*16", gdbarch_long_double_format (gdbarch));
else else
builtin_f_type->builtin_real_s16 builtin_f_type->builtin_real_s16

View file

@ -3451,29 +3451,24 @@ init_boolean_type (type_allocator &alloc,
return t; return t;
} }
/* Allocate a TYPE_CODE_FLT type structure associated with OBJFILE. /* See gdbtypes.h. */
BIT is the type size in bits; if BIT equals -1, the size is
determined by the floatformat. NAME is the type name. Set the
TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order
to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
order of the objfile's architecture is used. */
struct type * struct type *
init_float_type (struct objfile *objfile, init_float_type (type_allocator &alloc,
int bit, const char *name, int bit, const char *name,
const struct floatformat **floatformats, const struct floatformat **floatformats,
enum bfd_endian byte_order) enum bfd_endian byte_order)
{ {
if (byte_order == BFD_ENDIAN_UNKNOWN) if (byte_order == BFD_ENDIAN_UNKNOWN)
{ {
struct gdbarch *gdbarch = objfile->arch (); struct gdbarch *gdbarch = alloc.arch ();
byte_order = gdbarch_byte_order (gdbarch); byte_order = gdbarch_byte_order (gdbarch);
} }
const struct floatformat *fmt = floatformats[byte_order]; const struct floatformat *fmt = floatformats[byte_order];
struct type *t; struct type *t;
bit = verify_floatformat (bit, fmt); bit = verify_floatformat (bit, fmt);
t = type_allocator (objfile).new_type (TYPE_CODE_FLT, bit, name); t = alloc.new_type (TYPE_CODE_FLT, bit, name);
TYPE_FLOATFORMAT (t) = fmt; TYPE_FLOATFORMAT (t) = fmt;
return t; return t;
@ -5746,26 +5741,6 @@ copy_type (const struct type *type)
/* Helper functions to initialize architecture-specific types. */ /* Helper functions to initialize architecture-specific types. */
/* Allocate a TYPE_CODE_FLT type structure associated with GDBARCH.
BIT is the type size in bits; if BIT equals -1, the size is
determined by the floatformat. NAME is the type name. Set the
TYPE_FLOATFORMAT from FLOATFORMATS. */
struct type *
arch_float_type (struct gdbarch *gdbarch,
int bit, const char *name,
const struct floatformat **floatformats)
{
const struct floatformat *fmt = floatformats[gdbarch_byte_order (gdbarch)];
struct type *t;
bit = verify_floatformat (bit, fmt);
t = type_allocator (gdbarch).new_type (TYPE_CODE_FLT, bit, name);
TYPE_FLOATFORMAT (t) = fmt;
return t;
}
/* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH. /* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH.
BIT is the type size in bits. NAME is the type name. */ BIT is the type size in bits. NAME is the type name. */
@ -6063,19 +6038,19 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
= init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
1, "unsigned long long"); 1, "unsigned long long");
builtin_type->builtin_half builtin_type->builtin_half
= arch_float_type (gdbarch, gdbarch_half_bit (gdbarch), = init_float_type (alloc, gdbarch_half_bit (gdbarch),
"half", gdbarch_half_format (gdbarch)); "half", gdbarch_half_format (gdbarch));
builtin_type->builtin_float builtin_type->builtin_float
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), = init_float_type (alloc, gdbarch_float_bit (gdbarch),
"float", gdbarch_float_format (gdbarch)); "float", gdbarch_float_format (gdbarch));
builtin_type->builtin_bfloat16 builtin_type->builtin_bfloat16
= arch_float_type (gdbarch, gdbarch_bfloat16_bit (gdbarch), = init_float_type (alloc, gdbarch_bfloat16_bit (gdbarch),
"bfloat16", gdbarch_bfloat16_format (gdbarch)); "bfloat16", gdbarch_bfloat16_format (gdbarch));
builtin_type->builtin_double builtin_type->builtin_double
= arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), = init_float_type (alloc, gdbarch_double_bit (gdbarch),
"double", gdbarch_double_format (gdbarch)); "double", gdbarch_double_format (gdbarch));
builtin_type->builtin_long_double builtin_type->builtin_long_double
= arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
"long double", gdbarch_long_double_format (gdbarch)); "long double", gdbarch_long_double_format (gdbarch));
builtin_type->builtin_complex builtin_type->builtin_complex
= init_complex_type ("complex", builtin_type->builtin_float); = init_complex_type ("complex", builtin_type->builtin_float);
@ -6240,13 +6215,13 @@ objfile_type (struct objfile *objfile)
= init_integer_type (alloc, gdbarch_long_long_bit (gdbarch), = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
1, "unsigned long long"); 1, "unsigned long long");
objfile_type->builtin_float objfile_type->builtin_float
= init_float_type (objfile, gdbarch_float_bit (gdbarch), = init_float_type (alloc, gdbarch_float_bit (gdbarch),
"float", gdbarch_float_format (gdbarch)); "float", gdbarch_float_format (gdbarch));
objfile_type->builtin_double objfile_type->builtin_double
= init_float_type (objfile, gdbarch_double_bit (gdbarch), = init_float_type (alloc, gdbarch_double_bit (gdbarch),
"double", gdbarch_double_format (gdbarch)); "double", gdbarch_double_format (gdbarch));
objfile_type->builtin_long_double objfile_type->builtin_long_double
= init_float_type (objfile, gdbarch_long_double_bit (gdbarch), = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
"long double", gdbarch_long_double_format (gdbarch)); "long double", gdbarch_long_double_format (gdbarch));
/* This type represents a type that was unrecognized in symbol read-in. */ /* This type represents a type that was unrecognized in symbol read-in. */

View file

@ -2315,9 +2315,18 @@ extern struct type *init_character_type (type_allocator &alloc, int bit,
extern struct type *init_boolean_type (type_allocator &alloc, int bit, extern struct type *init_boolean_type (type_allocator &alloc, int bit,
int unsigned_p, const char *name); int unsigned_p, const char *name);
extern struct type *init_float_type (struct objfile *, int, const char *, /* Allocate a TYPE_CODE_FLT type structure using ALLOC.
const struct floatformat **, BIT is the type size in bits; if BIT equals -1, the size is
enum bfd_endian = BFD_ENDIAN_UNKNOWN); determined by the floatformat. NAME is the type name. Set the
TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order
to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
order of the objfile's architecture is used. */
extern struct type *init_float_type
(type_allocator &alloc, int bit, const char *name,
const struct floatformat **floatformats,
enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN);
extern struct type *init_decfloat_type (struct objfile *, int, const char *); extern struct type *init_decfloat_type (struct objfile *, int, const char *);
extern bool can_create_complex_type (struct type *); extern bool can_create_complex_type (struct type *);
extern struct type *init_complex_type (const char *, struct type *); extern struct type *init_complex_type (const char *, struct type *);
@ -2327,8 +2336,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int,
const char *); const char *);
/* Helper functions to construct architecture-owned types. */ /* Helper functions to construct architecture-owned types. */
extern struct type *arch_float_type (struct gdbarch *, int, const char *,
const struct floatformat **);
extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *); extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *);
extern struct type *arch_pointer_type (struct gdbarch *, int, const char *, extern struct type *arch_pointer_type (struct gdbarch *, int, const char *,
struct type *); struct type *);

View file

@ -512,9 +512,9 @@ build_go_types (struct gdbarch *gdbarch)
builtin_go_type->builtin_uint64 builtin_go_type->builtin_uint64
= init_integer_type (alloc, 64, 1, "uint64"); = init_integer_type (alloc, 64, 1, "uint64");
builtin_go_type->builtin_float32 builtin_go_type->builtin_float32
= arch_float_type (gdbarch, 32, "float32", floatformats_ieee_single); = init_float_type (alloc, 32, "float32", floatformats_ieee_single);
builtin_go_type->builtin_float64 builtin_go_type->builtin_float64
= arch_float_type (gdbarch, 64, "float64", floatformats_ieee_double); = init_float_type (alloc, 64, "float64", floatformats_ieee_double);
builtin_go_type->builtin_complex64 builtin_go_type->builtin_complex64
= init_complex_type ("complex64", builtin_go_type->builtin_float32); = init_complex_type ("complex64", builtin_go_type->builtin_float32);
builtin_go_type->builtin_complex128 builtin_go_type->builtin_complex128

View file

@ -313,9 +313,12 @@ ia64_ext_type (struct gdbarch *gdbarch)
ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch); ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
if (!tdep->ia64_ext_type) if (!tdep->ia64_ext_type)
tdep->ia64_ext_type {
= arch_float_type (gdbarch, 128, "builtin_type_ia64_ext", type_allocator alloc (gdbarch);
floatformats_ia64_ext); tdep->ia64_ext_type
= init_float_type (alloc, 128, "builtin_type_ia64_ext",
floatformats_ia64_ext);
}
return tdep->ia64_ext_type; return tdep->ia64_ext_type;
} }

View file

@ -289,7 +289,7 @@ build_m2_types (struct gdbarch *gdbarch)
builtin_m2_type->builtin_card builtin_m2_type->builtin_card
= init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "CARDINAL"); = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "CARDINAL");
builtin_m2_type->builtin_real builtin_m2_type->builtin_real
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL", = init_float_type (alloc, gdbarch_float_bit (gdbarch), "REAL",
gdbarch_float_format (gdbarch)); gdbarch_float_format (gdbarch));
builtin_m2_type->builtin_char builtin_m2_type->builtin_char
= init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR"); = init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR");

View file

@ -102,9 +102,12 @@ m68881_ext_type (struct gdbarch *gdbarch)
m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch); m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
if (!tdep->m68881_ext_type) if (!tdep->m68881_ext_type)
tdep->m68881_ext_type {
= arch_float_type (gdbarch, -1, "builtin_type_m68881_ext", type_allocator alloc (gdbarch);
floatformats_m68881_ext); tdep->m68881_ext_type
= init_float_type (alloc, -1, "builtin_type_m68881_ext",
floatformats_m68881_ext);
}
return tdep->m68881_ext_type; return tdep->m68881_ext_type;
} }

View file

@ -1433,12 +1433,12 @@ basic_type (int bt, struct objfile *objfile)
break; break;
case btFloat: case btFloat:
tp = init_float_type (objfile, gdbarch_float_bit (gdbarch), tp = init_float_type (alloc, gdbarch_float_bit (gdbarch),
"float", gdbarch_float_format (gdbarch)); "float", gdbarch_float_format (gdbarch));
break; break;
case btDouble: case btDouble:
tp = init_float_type (objfile, gdbarch_double_bit (gdbarch), tp = init_float_type (alloc, gdbarch_double_bit (gdbarch),
"double", gdbarch_double_format (gdbarch)); "double", gdbarch_double_format (gdbarch));
break; break;

View file

@ -403,8 +403,11 @@ nds32_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
/* Currently, only FSRs could be defined as pseudo registers. */ /* Currently, only FSRs could be defined as pseudo registers. */
if (regnum < gdbarch_num_pseudo_regs (gdbarch)) if (regnum < gdbarch_num_pseudo_regs (gdbarch))
return arch_float_type (gdbarch, -1, "builtin_type_ieee_single", {
floatformats_ieee_single); type_allocator alloc (gdbarch);
return init_float_type (alloc, -1, "builtin_type_ieee_single",
floatformats_ieee_single);
}
warning (_("Unknown nds32 pseudo register %d."), regnum); warning (_("Unknown nds32 pseudo register %d."), regnum);
return NULL; return NULL;

View file

@ -926,11 +926,11 @@ public:
BUILD_OCL_VTYPES (long, el_type); BUILD_OCL_VTYPES (long, el_type);
el_type = add (init_integer_type (alloc, 64, 1, "ulong")); el_type = add (init_integer_type (alloc, 64, 1, "ulong"));
BUILD_OCL_VTYPES (ulong, el_type); BUILD_OCL_VTYPES (ulong, el_type);
el_type = add (arch_float_type (gdbarch, 16, "half", floatformats_ieee_half)); el_type = add (init_float_type (alloc, 16, "half", floatformats_ieee_half));
BUILD_OCL_VTYPES (half, el_type); BUILD_OCL_VTYPES (half, el_type);
el_type = add (arch_float_type (gdbarch, 32, "float", floatformats_ieee_single)); el_type = add (init_float_type (alloc, 32, "float", floatformats_ieee_single));
BUILD_OCL_VTYPES (float, el_type); BUILD_OCL_VTYPES (float, el_type);
el_type = add (arch_float_type (gdbarch, 64, "double", floatformats_ieee_double)); el_type = add (init_float_type (alloc, 64, "double", floatformats_ieee_double));
BUILD_OCL_VTYPES (double, el_type); BUILD_OCL_VTYPES (double, el_type);
add (init_boolean_type (alloc, 8, 1, "bool")); add (init_boolean_type (alloc, 8, 1, "bool"));

View file

@ -2432,8 +2432,9 @@ rs6000_builtin_type_vec128 (struct gdbarch *gdbarch)
*/ */
/* PPC specific type for IEEE 128-bit float field */ /* PPC specific type for IEEE 128-bit float field */
type_allocator alloc (gdbarch);
struct type *t_float128 struct type *t_float128
= arch_float_type (gdbarch, 128, "float128_t", floatformats_ieee_quad); = init_float_type (alloc, 128, "float128_t", floatformats_ieee_quad);
struct type *t; struct type *t;

View file

@ -1613,8 +1613,8 @@ rust_language::language_arch_info (struct gdbarch *gdbarch,
struct type *usize_type struct type *usize_type
= add (init_integer_type (alloc, length, 1, "usize")); = add (init_integer_type (alloc, length, 1, "usize"));
add (arch_float_type (gdbarch, 32, "f32", floatformats_ieee_single)); add (init_float_type (alloc, 32, "f32", floatformats_ieee_single));
add (arch_float_type (gdbarch, 64, "f64", floatformats_ieee_double)); add (init_float_type (alloc, 64, "f64", floatformats_ieee_double));
add (init_integer_type (alloc, 0, 1, "()")); add (init_integer_type (alloc, 0, 1, "()"));
struct type *tem = make_cv_type (1, 0, u8_type, NULL); struct type *tem = make_cv_type (1, 0, u8_type, NULL);

View file

@ -1516,9 +1516,12 @@ sh_littlebyte_bigword_type (struct gdbarch *gdbarch)
sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch); sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
if (tdep->sh_littlebyte_bigword_type == NULL) if (tdep->sh_littlebyte_bigword_type == NULL)
tdep->sh_littlebyte_bigword_type {
= arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword", type_allocator alloc (gdbarch);
floatformats_ieee_double_littlebyte_bigword); tdep->sh_littlebyte_bigword_type
= init_float_type (alloc, -1, "builtin_type_sh_littlebyte_bigword",
floatformats_ieee_double_littlebyte_bigword);
}
return tdep->sh_littlebyte_bigword_type; return tdep->sh_littlebyte_bigword_type;
} }

View file

@ -374,7 +374,7 @@ dbx_init_float_type (struct objfile *objfile, int bits)
format = gdbarch_floatformat_for_type (gdbarch, NULL, bits); format = gdbarch_floatformat_for_type (gdbarch, NULL, bits);
type_allocator alloc (objfile); type_allocator alloc (objfile);
if (format) if (format)
type = init_float_type (objfile, bits, NULL, format); type = init_float_type (alloc, bits, NULL, format);
else else
type = alloc.new_type (TYPE_CODE_ERROR, bits, NULL); type = alloc.new_type (TYPE_CODE_ERROR, bits, NULL);
@ -2125,19 +2125,19 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
break; break;
case 12: case 12:
/* IEEE single precision (32 bit). */ /* IEEE single precision (32 bit). */
rettype = init_float_type (objfile, 32, "float", rettype = init_float_type (alloc, 32, "float",
floatformats_ieee_single); floatformats_ieee_single);
break; break;
case 13: case 13:
/* IEEE double precision (64 bit). */ /* IEEE double precision (64 bit). */
rettype = init_float_type (objfile, 64, "double", rettype = init_float_type (alloc, 64, "double",
floatformats_ieee_double); floatformats_ieee_double);
break; break;
case 14: case 14:
/* This is an IEEE double on the RS/6000, and different machines with /* This is an IEEE double on the RS/6000, and different machines with
different sizes for "long double" should use different negative different sizes for "long double" should use different negative
type numbers. See stabs.texinfo. */ type numbers. See stabs.texinfo. */
rettype = init_float_type (objfile, 64, "long double", rettype = init_float_type (alloc, 64, "long double",
floatformats_ieee_double); floatformats_ieee_double);
break; break;
case 15: case 15:
@ -2147,11 +2147,11 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
rettype = init_boolean_type (alloc, 32, 1, "boolean"); rettype = init_boolean_type (alloc, 32, 1, "boolean");
break; break;
case 17: case 17:
rettype = init_float_type (objfile, 32, "short real", rettype = init_float_type (alloc, 32, "short real",
floatformats_ieee_single); floatformats_ieee_single);
break; break;
case 18: case 18:
rettype = init_float_type (objfile, 64, "real", rettype = init_float_type (alloc, 64, "real",
floatformats_ieee_double); floatformats_ieee_double);
break; break;
case 19: case 19:

View file

@ -116,34 +116,35 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
if (m_type != NULL) if (m_type != NULL)
return; return;
type_allocator alloc (m_gdbarch);
switch (e->kind) switch (e->kind)
{ {
case TDESC_TYPE_IEEE_HALF: case TDESC_TYPE_IEEE_HALF:
m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_half", m_type = init_float_type (alloc, -1, "builtin_type_ieee_half",
floatformats_ieee_half); floatformats_ieee_half);
return; return;
case TDESC_TYPE_IEEE_SINGLE: case TDESC_TYPE_IEEE_SINGLE:
m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_single", m_type = init_float_type (alloc, -1, "builtin_type_ieee_single",
floatformats_ieee_single); floatformats_ieee_single);
return; return;
case TDESC_TYPE_IEEE_DOUBLE: case TDESC_TYPE_IEEE_DOUBLE:
m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_double", m_type = init_float_type (alloc, -1, "builtin_type_ieee_double",
floatformats_ieee_double); floatformats_ieee_double);
return; return;
case TDESC_TYPE_ARM_FPA_EXT: case TDESC_TYPE_ARM_FPA_EXT:
m_type = arch_float_type (m_gdbarch, -1, "builtin_type_arm_ext", m_type = init_float_type (alloc, -1, "builtin_type_arm_ext",
floatformats_arm_ext); floatformats_arm_ext);
return; return;
case TDESC_TYPE_I387_EXT: case TDESC_TYPE_I387_EXT:
m_type = arch_float_type (m_gdbarch, -1, "builtin_type_i387_ext", m_type = init_float_type (alloc, -1, "builtin_type_i387_ext",
floatformats_i387_ext); floatformats_i387_ext);
return; return;
case TDESC_TYPE_BFLOAT16: case TDESC_TYPE_BFLOAT16:
m_type = arch_float_type (m_gdbarch, -1, "builtin_type_bfloat16", m_type = init_float_type (alloc, -1, "builtin_type_bfloat16",
floatformats_bfloat16); floatformats_bfloat16);
return; return;
} }