[PATCH 13/22] gdb: add type::is_vector / type::set_is_vector
Simon Marchi
simon.marchi@efficios.com
Tue Aug 18 16:58:32 GMT 2020
Add the `is_vector` and `set_is_vector` methods on `struct type`, in
order to remove the `TYPE_VECTOR` macro. In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly. The
next patch will remove the macro completely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <is_vector, set_is_vector>: New methods.
(TYPE_VECTOR): Use type::is_vector, change all write call sites to
use type::set_is_vector.
Change-Id: I415e8d169f058662e0750329bfa4017bea3ca0cb
---
gdb/arm-tdep.c | 4 ++--
gdb/csky-tdep.c | 2 +-
gdb/gdbtypes.c | 2 +-
gdb/gdbtypes.h | 14 ++++++++++++--
gdb/i386-tdep.c | 6 +++---
gdb/riscv-tdep.c | 2 +-
gdb/rs6000-tdep.c | 4 ++--
gdb/target-descriptions.c | 2 +-
8 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index cd0881fc4c4..0bb0821080f 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3919,7 +3919,7 @@ arm_neon_double_type (struct gdbarch *gdbarch)
elem = builtin_type (gdbarch)->builtin_double;
append_composite_type_field (t, "f64", elem);
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("neon_d");
tdep->neon_double_type = t;
}
@@ -3958,7 +3958,7 @@ arm_neon_quad_type (struct gdbarch *gdbarch)
elem = builtin_type (gdbarch)->builtin_double;
append_composite_type_field (t, "f64", init_vector_type (elem, 2));
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("neon_q");
tdep->neon_quad_type = t;
}
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index 7e5b71eece0..c9245fc4ac7 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -266,7 +266,7 @@ csky_vector_type (struct gdbarch *gdbarch)
append_composite_type_field (t, "u8",
init_vector_type (bt->builtin_int8, 16));
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("builtin_type_vec128i");
return t;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index efd10588a37..6f60466e289 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1424,7 +1424,7 @@ make_vector_type (struct type *array_type)
TYPE_TARGET_TYPE (inner_array) = elt_type;
}
- TYPE_VECTOR (array_type) = 1;
+ array_type->set_is_vector (true);
}
struct type *
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index cef1964c597..c4e58e18a2e 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -219,7 +219,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
/* * Identify a vector type. Gcc is handling this by adding an extra
attribute to the array type. We slurp that in as a new flag of a
type. This is used only in dwarf2read.c. */
-#define TYPE_VECTOR(t) (TYPE_MAIN_TYPE (t)->flag_vector)
+#define TYPE_VECTOR(t) ((t)->is_vector ())
/* * The debugging formats (especially STABS) do not contain enough
information to represent all Ada types---especially those whose
@@ -824,7 +824,7 @@ struct main_type
unsigned int m_flag_target_stub : 1;
unsigned int m_flag_prototyped : 1;
unsigned int m_flag_varargs : 1;
- unsigned int flag_vector : 1;
+ unsigned int m_flag_vector : 1;
unsigned int flag_stub_supported : 1;
unsigned int flag_gnu_ifunc : 1;
unsigned int flag_fixed_instance : 1;
@@ -1116,6 +1116,16 @@ struct type
this->main_type->m_flag_varargs = has_varargs;
}
+ bool is_vector () const
+ {
+ return this->main_type->m_flag_vector;
+ }
+
+ void set_is_vector (bool is_vector)
+ {
+ this->main_type->m_flag_vector = is_vector;
+ }
+
/* * Return the dynamic property of the requested KIND from this type's
list of dynamic properties. */
dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 9b905c1996a..fd680f2699f 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3132,7 +3132,7 @@ i386_zmm_type (struct gdbarch *gdbarch)
append_composite_type_field (t, "v4_int128",
init_vector_type (bt->builtin_int128, 4));
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("builtin_type_vec512i");
tdep->i386_zmm_type = t;
}
@@ -3185,7 +3185,7 @@ i386_ymm_type (struct gdbarch *gdbarch)
append_composite_type_field (t, "v2_int128",
init_vector_type (bt->builtin_int128, 2));
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("builtin_type_vec256i");
tdep->i386_ymm_type = t;
}
@@ -3227,7 +3227,7 @@ i386_mmx_type (struct gdbarch *gdbarch)
append_composite_type_field (t, "v8_int8",
init_vector_type (bt->builtin_int8, 8));
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("builtin_type_vec64i");
tdep->i386_mmx_type = t;
}
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index a79b5f5b0cf..0e8cf38e50c 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -674,7 +674,7 @@ riscv_fpreg_d_type (struct gdbarch *gdbarch)
"__gdb_builtin_type_fpreg_d", TYPE_CODE_UNION);
append_composite_type_field (t, "float", bt->builtin_float);
append_composite_type_field (t, "double", bt->builtin_double);
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("builtin_type_fpreg_d");
tdep->riscv_fpreg_d_type = t;
}
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 84278e708e7..adb39d90d11 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2273,7 +2273,7 @@ rs6000_builtin_type_vec64 (struct gdbarch *gdbarch)
append_composite_type_field (t, "v8_int8",
init_vector_type (bt->builtin_int8, 8));
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("ppc_builtin_type_vec64");
tdep->ppc_builtin_type_vec64 = t;
}
@@ -2320,7 +2320,7 @@ rs6000_builtin_type_vec128 (struct gdbarch *gdbarch)
append_composite_type_field (t, "v16_int8",
init_vector_type (bt->builtin_int8, 16));
- TYPE_VECTOR (t) = 1;
+ t->set_is_vector (true);
t->set_name ("ppc_builtin_type_vec128");
tdep->ppc_builtin_type_vec128 = t;
}
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 86812bbbc48..798379ef8e4 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -259,7 +259,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
union as a vector also. This allows e.g. a union of two
vector types to show up automatically in "info vector". */
if (TYPE_VECTOR (field_gdb_type))
- TYPE_VECTOR (m_type) = 1;
+ m_type->set_is_vector (true);
}
}
--
2.28.0
More information about the Gdb-patches
mailing list