From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id B87DF3858C2D for ; Mon, 13 Mar 2023 22:08:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B87DF3858C2D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 1523E100423F4 for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupfLHZHIU4bqKupFyBK; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NfUja0P4 c=1 sm=1 tr=0 ts=640f9ec8 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=k__wU0fu6RkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=shZJrdpwEmwBhyjc-I4A:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pdp9UdLalgLHBGAaKDVUexvDYezsUoC+uoYD6hb/uK8=; b=jVkNrkdYlV9GMWNH/FpNU7rh3L 2MdWK82/hnhYINoPms04KfABe8uFpXyfTtpMMfaspi+RYNh+Y+GgKk8GVyd2HXFRulijgG2MOrxNR 96D3/7NOPsm1TD3qKLbfSpng6; Received: from 71-211-185-113.hlrn.qwest.net ([71.211.185.113]:52788 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pbqKt-000u2m-Sy for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:07 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:10 -0600 Subject: [PATCH 10/20] Unify arch_boolean_type and init_boolean_type MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230313-split-objfile-type-allocator-2-v1-10-69ba773ac17b@tromey.com> References: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com> In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.185.113 X-Source-L: No X-Exim-ID: 1pbqKt-000u2m-Sy X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-185-113.hlrn.qwest.net ([192.168.0.21]) [71.211.185.113]:52788 X-Source-Auth: tom+tromey.com X-Email-Count: 11 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This unifies arch_boolean_type and init_boolean_type by using a type allocator. --- gdb/ctfread.c | 2 +- gdb/d-lang.c | 2 +- gdb/dwarf2/read.c | 2 +- gdb/f-lang.c | 8 ++++---- gdb/gdbtypes.c | 27 ++++----------------------- gdb/gdbtypes.h | 10 +++++++--- gdb/go-lang.c | 2 +- gdb/m2-lang.c | 2 +- gdb/opencl-lang.c | 2 +- gdb/rust-lang.c | 2 +- gdb/stabsread.c | 12 ++++++------ 11 files changed, 28 insertions(+), 43 deletions(-) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 3940a4f8c67..72cd8b7cc5d 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -568,7 +568,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid) if (ischar) type = init_character_type (alloc, TARGET_CHAR_BIT, !issigned, name); else if (isbool) - type = init_boolean_type (of, gdbarch_int_bit (gdbarch), + type = init_boolean_type (alloc, gdbarch_int_bit (gdbarch), !issigned, name); else { diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 8e5262d170a..a970281800a 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -204,7 +204,7 @@ build_d_types (struct gdbarch *gdbarch) type_allocator alloc (gdbarch); builtin_d_type->builtin_void = builtin_type (gdbarch)->builtin_void; builtin_d_type->builtin_bool - = arch_boolean_type (gdbarch, 8, 1, "bool"); + = init_boolean_type (alloc, 8, 1, "bool"); builtin_d_type->builtin_byte = init_integer_type (alloc, 8, 0, "byte"); builtin_d_type->builtin_ubyte diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index bb77f75179a..6cac75b847a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15238,7 +15238,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type = init_pointer_type (objfile, bits, name, type); break; case DW_ATE_boolean: - type = init_boolean_type (objfile, bits, 1, name); + type = init_boolean_type (alloc, bits, 1, name); break; case DW_ATE_complex_float: type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name, diff --git a/gdb/f-lang.c b/gdb/f-lang.c index cb63c3704c1..482ae68c5fa 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1733,16 +1733,16 @@ build_fortran_types (struct gdbarch *gdbarch) = alloc.new_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character"); builtin_f_type->builtin_logical_s1 - = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1"); + = init_boolean_type (alloc, TARGET_CHAR_BIT, 1, "logical*1"); builtin_f_type->builtin_logical_s2 - = arch_boolean_type (gdbarch, gdbarch_short_bit (gdbarch), 1, "logical*2"); + = init_boolean_type (alloc, gdbarch_short_bit (gdbarch), 1, "logical*2"); builtin_f_type->builtin_logical - = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "logical*4"); + = init_boolean_type (alloc, gdbarch_int_bit (gdbarch), 1, "logical*4"); builtin_f_type->builtin_logical_s8 - = arch_boolean_type (gdbarch, gdbarch_long_long_bit (gdbarch), 1, + = init_boolean_type (alloc, gdbarch_long_long_bit (gdbarch), 1, "logical*8"); builtin_f_type->builtin_integer_s1 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 49f88ce6026..cf2862f514c 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3432,17 +3432,15 @@ init_character_type (type_allocator &alloc, return t; } -/* Allocate a TYPE_CODE_BOOL type structure associated with OBJFILE. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ +/* See gdbtypes.h. */ struct type * -init_boolean_type (struct objfile *objfile, +init_boolean_type (type_allocator &alloc, int bit, int unsigned_p, const char *name) { struct type *t; - t = type_allocator (objfile).new_type (TYPE_CODE_BOOL, bit, name); + t = alloc.new_type (TYPE_CODE_BOOL, bit, name); if (unsigned_p) t->set_is_unsigned (true); @@ -5748,23 +5746,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_BOOL type structure associated with GDBARCH. - BIT is the type size in bits. If UNSIGNED_P is non-zero, set - the type's TYPE_UNSIGNED flag. NAME is the type name. */ - -struct type * -arch_boolean_type (struct gdbarch *gdbarch, - int bit, int unsigned_p, const char *name) -{ - struct type *t; - - t = type_allocator (gdbarch).new_type (TYPE_CODE_BOOL, bit, name); - if (unsigned_p) - t->set_is_unsigned (true); - - return t; -} - /* 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 @@ -6103,7 +6084,7 @@ create_gdbtypes_data (struct gdbarch *gdbarch) builtin_type->builtin_string = alloc.new_type (TYPE_CODE_STRING, TARGET_CHAR_BIT, "string"); builtin_type->builtin_bool - = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool"); + = init_boolean_type (alloc, TARGET_CHAR_BIT, 1, "bool"); /* The following three are about decimal floating point types, which are 32-bits, 64-bits and 128-bits respectively. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 178a8b9a663..a42054ba585 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2307,8 +2307,14 @@ extern struct type *init_integer_type (type_allocator &, int, int, extern struct type *init_character_type (type_allocator &, int, int, const char *); -extern struct type *init_boolean_type (struct objfile *, int, int, + +/* Allocate a TYPE_CODE_BOOL type structure using ALLOC. BIT is the + type size in bits. If UNSIGNED_P is non-zero, set the type's + TYPE_UNSIGNED flag. NAME is the type name. */ + +extern struct type *init_boolean_type (type_allocator &, int, int, const char *); + extern struct type *init_float_type (struct objfile *, int, const char *, const struct floatformat **, enum bfd_endian = BFD_ENDIAN_UNKNOWN); @@ -2321,8 +2327,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int, const char *); /* Helper functions to construct architecture-owned types. */ -extern struct type *arch_boolean_type (struct gdbarch *, int, int, - const char *); 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 *); diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 6d0d43530f8..4b6027da77d 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -488,7 +488,7 @@ build_go_types (struct gdbarch *gdbarch) builtin_go_type->builtin_char = init_character_type (alloc, 8, 1, "char"); builtin_go_type->builtin_bool - = arch_boolean_type (gdbarch, 8, 0, "bool"); + = init_boolean_type (alloc, 8, 0, "bool"); builtin_go_type->builtin_int = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 0, "int"); builtin_go_type->builtin_uint diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index d2fa1a46364..03c57530878 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -294,7 +294,7 @@ build_m2_types (struct gdbarch *gdbarch) builtin_m2_type->builtin_char = init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR"); builtin_m2_type->builtin_bool - = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "BOOLEAN"); + = init_boolean_type (alloc, gdbarch_int_bit (gdbarch), 1, "BOOLEAN"); return builtin_m2_type; } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 94f865e5ad5..9a3c6d790fc 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -933,7 +933,7 @@ class opencl_language : public language_defn el_type = add (arch_float_type (gdbarch, 64, "double", floatformats_ieee_double)); BUILD_OCL_VTYPES (double, el_type); - add (arch_boolean_type (gdbarch, 8, 1, "bool")); + add (init_boolean_type (alloc, 8, 1, "bool")); add (init_integer_type (alloc, 8, 1, "unsigned char")); add (init_integer_type (alloc, 16, 1, "unsigned short")); add (init_integer_type (alloc, 32, 1, "unsigned int")); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index be0a7100f56..20292329af2 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1596,7 +1596,7 @@ rust_language::language_arch_info (struct gdbarch *gdbarch, type_allocator alloc (gdbarch); struct type *bool_type - = add (arch_boolean_type (gdbarch, 8, 1, "bool")); + = add (init_boolean_type (alloc, 8, 1, "bool")); add (init_character_type (alloc, 32, 1, "char")); add (init_integer_type (alloc, 8, 0, "i8")); struct type *u8_type diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 4c7b88f30cd..fc02c98962c 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2144,7 +2144,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = init_integer_type (alloc, 32, 0, "integer"); break; case 16: - rettype = init_boolean_type (objfile, 32, 1, "boolean"); + rettype = init_boolean_type (alloc, 32, 1, "boolean"); break; case 17: rettype = init_float_type (objfile, 32, "short real", @@ -2161,16 +2161,16 @@ rs6000_builtin_type (int typenum, struct objfile *objfile) rettype = init_character_type (alloc, 8, 1, "character"); break; case 21: - rettype = init_boolean_type (objfile, 8, 1, "logical*1"); + rettype = init_boolean_type (alloc, 8, 1, "logical*1"); break; case 22: - rettype = init_boolean_type (objfile, 16, 1, "logical*2"); + rettype = init_boolean_type (alloc, 16, 1, "logical*2"); break; case 23: - rettype = init_boolean_type (objfile, 32, 1, "logical*4"); + rettype = init_boolean_type (alloc, 32, 1, "logical*4"); break; case 24: - rettype = init_boolean_type (objfile, 32, 1, "logical"); + rettype = init_boolean_type (alloc, 32, 1, "logical"); break; case 25: /* Complex type consisting of two IEEE single precision values. */ @@ -3759,7 +3759,7 @@ read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile } if (boolean_type) - return init_boolean_type (objfile, type_bits, unsigned_type, NULL); + return init_boolean_type (alloc, type_bits, unsigned_type, NULL); else return init_integer_type (alloc, type_bits, unsigned_type, NULL); } -- 2.39.1