From patchwork Mon Mar 13 22:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 66336 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 957EF3858298 for ; Mon, 13 Mar 2023 22:09:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from gproxy4-pub.mail.unifiedlayer.com (gproxy4-pub.mail.unifiedlayer.com [69.89.23.142]) by sourceware.org (Postfix) with ESMTPS id 1ACB93858C2F for ; Mon, 13 Mar 2023 22:08:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1ACB93858C2F 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 cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway6.mail.pro1.eigbox.com (Postfix) with ESMTP id 6C4641003FCFF for ; Mon, 13 Mar 2023 22:08:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id bqKupXv6BNX2abqKupEw7C; Mon, 13 Mar 2023 22:08:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=NMAQR22g 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=OBYFFSvtVDWmvnek53kA: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=EFf3DDQnopDt3BINWPcdvh2g1T5KnYWI0rXJCcJgPps=; b=up6ccxmi0m1pXRdU15ZQQ6kPZ0 yzgAAOIt6KvK5lSFEg7t7L5vohPurn4bB6AvN5wAdN04c6CKcjw9G+OBVGkFruePo5Asi8IZmdA2c a2heyCo2EMYzznbKQkg+pVYPr; 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 1pbqKu-000u2m-5a for gdb-patches@sourceware.org; Mon, 13 Mar 2023 16:08:08 -0600 From: Tom Tromey Date: Mon, 13 Mar 2023 16:08:12 -0600 Subject: [PATCH 12/20] Unify arch_decfloat_type and init_decfloat_type MIME-Version: 1.0 Message-Id: <20230313-split-objfile-type-allocator-2-v1-12-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: 1pbqKu-000u2m-5a 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: 13 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" This unifies arch_decfloat_type and init_decfloat_type by using a type allocator. --- gdb/dwarf2/read.c | 2 +- gdb/gdbtypes.c | 25 ++++++------------------- gdb/gdbtypes.h | 7 +++++-- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 857206ae034..21c9fa7c543 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15258,7 +15258,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type = init_complex_type (name, type); break; case DW_ATE_decimal_float: - type = init_decfloat_type (objfile, bits, name); + type = init_decfloat_type (alloc, bits, name); break; case DW_ATE_float: type = dwarf2_init_float_type (objfile, bits, name, name, byte_order); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 02711e0af6a..df10ffea383 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3474,13 +3474,12 @@ init_float_type (type_allocator &alloc, return t; } -/* Allocate a TYPE_CODE_DECFLOAT type structure associated with OBJFILE. - BIT is the type size in bits. NAME is the type name. */ +/* See gdbtypes.h. */ struct type * -init_decfloat_type (struct objfile *objfile, int bit, const char *name) +init_decfloat_type (type_allocator &alloc, int bit, const char *name) { - return type_allocator (objfile).new_type (TYPE_CODE_DECFLOAT, bit, name); + return alloc.new_type (TYPE_CODE_DECFLOAT, bit, name); } /* Return true if init_complex_type can be called with TARGET_TYPE. */ @@ -5741,18 +5740,6 @@ copy_type (const struct type *type) /* Helper functions to initialize architecture-specific types. */ -/* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH. - BIT is the type size in bits. NAME is the type name. */ - -struct type * -arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name) -{ - struct type *t; - - t = type_allocator (gdbarch).new_type (TYPE_CODE_DECFLOAT, bit, name); - return t; -} - /* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH. BIT is the pointer type size in bits. NAME is the type name. TARGET_TYPE is the pointer target type. Always sets the pointer type's @@ -6064,11 +6051,11 @@ create_gdbtypes_data (struct gdbarch *gdbarch) /* The following three are about decimal floating point types, which are 32-bits, 64-bits and 128-bits respectively. */ builtin_type->builtin_decfloat - = arch_decfloat_type (gdbarch, 32, "_Decimal32"); + = init_decfloat_type (alloc, 32, "_Decimal32"); builtin_type->builtin_decdouble - = arch_decfloat_type (gdbarch, 64, "_Decimal64"); + = init_decfloat_type (alloc, 64, "_Decimal64"); builtin_type->builtin_declong - = arch_decfloat_type (gdbarch, 128, "_Decimal128"); + = init_decfloat_type (alloc, 128, "_Decimal128"); /* "True" character types. */ builtin_type->builtin_true_char diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 4613fd4a0fd..32662d5cd3f 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2326,7 +2326,11 @@ extern struct type *init_float_type (type_allocator &, int, const char *, const struct floatformat **, enum bfd_endian = BFD_ENDIAN_UNKNOWN); -extern struct type *init_decfloat_type (struct objfile *, int, const char *); +/* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC. + BIT is the type size in bits. NAME is the type name. */ + +extern struct type *init_decfloat_type (type_allocator &, int, const char *); + extern bool can_create_complex_type (struct type *); extern struct type *init_complex_type (const char *, struct type *); extern struct type *init_pointer_type (struct objfile *, int, const char *, @@ -2335,7 +2339,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_decfloat_type (struct gdbarch *, int, const char *); extern struct type *arch_pointer_type (struct gdbarch *, int, const char *, struct type *);