Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
To: <gdb-patches@sourceware.org>
Cc: <tom@tromey.com>
Subject: [PATCH v2 16/17] gdb: convert TYPE_ADDRESS_CLASS macro to type::address_class
Date: Wed, 22 Jul 2026 05:42:05 -0500	[thread overview]
Message-ID: <20260722-users-aktemur-type-instance-flags-v2-16-d60dcbc2a76f@amd.com> (raw)
In-Reply-To: <20260722-users-aktemur-type-instance-flags-v2-0-d60dcbc2a76f@amd.com>

Convert the TYPE_ADDRESS_CLASS macro to a method of the type class.  This
is a refactoring.
---
 gdb/avr-tdep.c    | 4 ++--
 gdb/c-typeprint.c | 2 +-
 gdb/ft32-tdep.c   | 2 +-
 gdb/gdbtypes.c    | 8 +++-----
 gdb/gdbtypes.h    | 9 ++++++---
 5 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 682b7e8586d..012022f2b73 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -305,7 +305,7 @@ avr_address_to_pointer (struct gdbarch *gdbarch,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* Is it a data address in flash?  */
-  if (TYPE_ADDRESS_CLASS (type) == AVR_ADDRESS_CLASS_FLASH)
+  if (type->address_class () == AVR_ADDRESS_CLASS_FLASH)
     {
       /* A data pointer in flash is byte addressed.  */
       store_unsigned_integer (buf, type->length (), byte_order,
@@ -337,7 +337,7 @@ avr_pointer_to_address (struct gdbarch *gdbarch,
     = extract_unsigned_integer (buf, type->length (), byte_order);
 
   /* Is it a data address in flash?  */
-  if (TYPE_ADDRESS_CLASS (type) == AVR_ADDRESS_CLASS_FLASH)
+  if (type->address_class () == AVR_ADDRESS_CLASS_FLASH)
     {
       /* A data pointer in flash is already byte addressed.  */
       return avr_make_iaddr (addr);
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 92938270647..07f01c92b15 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -492,7 +492,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
   else if (gdbarch_address_class_id_to_name_p (type->arch ()))
     address_space_id
       = gdbarch_address_class_id_to_name (type->arch (),
-					  TYPE_ADDRESS_CLASS (type));
+					  type->address_class ());
 
   if (address_space_id != nullptr)
     {
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index f951a6f25e3..38b4784ed35 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -332,7 +332,7 @@ ft32_pointer_to_address (struct gdbarch *gdbarch,
   CORE_ADDR addr
     = extract_unsigned_integer (buf, type->length (), byte_order);
 
-  if (TYPE_ADDRESS_CLASS (type) == 1)
+  if (type->address_class () == 1)
     return addr;
   else
     return addr | RAM_BIAS;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 34eaac42e20..f9764fb1da3 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -710,7 +710,7 @@ replace_type (struct type *ntype, struct type *type)
 	 variants.  This assertion shouldn't ever be triggered because
 	 symbol readers which do construct address-class variants don't
 	 call replace_type().  */
-      gdb_assert (TYPE_ADDRESS_CLASS (chain) == 0);
+      gdb_assert (chain->address_class () == 0);
 
       chain->set_length (type->length ());
       chain = chain->chain;
@@ -5029,10 +5029,8 @@ recursive_dump_type (struct type *type, int spaces)
     gdb_puts (" TYPE_CODE_SPACE");
   if (type->is_data_space ())
     gdb_puts (" TYPE_DATA_SPACE");
-  if (TYPE_ADDRESS_CLASS (type) != 0)
-    {
-      gdb_printf (" TYPE_ADDRESS_CLASS(%u)", TYPE_ADDRESS_CLASS (type));
-    }
+  if (type->address_class () != 0)
+    gdb_printf (" TYPE_ADDRESS_CLASS(%u)", type->address_class ());
   if (type->is_restrict ())
     gdb_puts (" TYPE_RESTRICT");
   if (type->is_atomic ())
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 624d468e4f2..ecd71f96497 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -186,9 +186,6 @@ struct type_instance_flags
   (((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)	\
    || ((t)->dyn_prop (DYN_PROP_BIT_SIZE) != nullptr))
 
-#define TYPE_ADDRESS_CLASS(t) \
-  (((t)->instance_flags ()).address_class)
-
 /* Information about a single discriminant.  */
 
 struct discriminant_range
@@ -1231,6 +1228,12 @@ struct type
     return this->m_instance_flags.is_atomic;
   }
 
+  /* Return the address class of this type.  */
+  unsigned int address_class () const
+  {
+    return this->m_instance_flags.address_class;
+  }
+
   /* Get the bounds bounds of this type.  The type must be a range type.  */
   range_bounds *bounds () const
   {

-- 
2.34.1


  parent reply	other threads:[~2026-07-22 10:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 10:41 [PATCH v2 00/17] Rewrite type instance flags as a struct with bitfields Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 01/17] gdb: use type instance macros to query const, volatile, restrict Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 02/17] gdb: convert address_class_type_flags_to_name to address_class_id_to_name Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 03/17] gdb: convert address_class_name_to_type_flags to address_class_name_to_id Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 04/17] gdb: convert address_class_type_flags to address_class_dwarf_to_id Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 05/17] gdb: refactor type_stack::insert methods Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 06/17] gdb: inline address_space_{name, type_instance_flags}_to_{type_instance_flags, name} Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 07/17] gdb: split make_type_with_address_space Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 08/17] gdb: convert type instance flags to bitfields Tankut Baris Aktemur
2026-07-24 19:10   ` Keith Seitz
2026-07-22 10:41 ` [PATCH v2 09/17] gdb: convert TYPE_NOTTEXT macro to type::is_nottext Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 10/17] gdb: convert TYPE_CONST macro to type::is_const Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 11/17] gdb: convert TYPE_VOLATILE macro to type::is_volatile Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 12/17] gdb: convert TYPE_CODE_SPACE macro to type::is_code_space Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 13/17] gdb: convert TYPE_DATA_SPACE macro to type::is_data_space Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 14/17] gdb: convert TYPE_RESTRICT macro to type::is_restrict Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 15/17] gdb: convert TYPE_ATOMIC macro to type::is_atomic Tankut Baris Aktemur
2026-07-22 10:42 ` Tankut Baris Aktemur [this message]
2026-07-22 10:42 ` [PATCH v2 17/17] gdb: remove unnecessary braces in recursive_dump_type Tankut Baris Aktemur
2026-07-22 15:42 ` [PATCH v2 00/17] Rewrite type instance flags as a struct with bitfields Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260722-users-aktemur-type-instance-flags-v2-16-d60dcbc2a76f@amd.com \
    --to=tankutbaris.aktemur@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox