Replace ../include/wait.h with gdb_wait.h.
[deliverable/binutils-gdb.git] / gdb / gdbtypes.c
index 6e013af43e703d4347a6d736a06a9a626e9fcbff..20166722d3f3d4b8de0524f7c9c9b5f29f60fa25 100644 (file)
@@ -65,6 +65,14 @@ struct type *builtin_type_uint32;
 struct type *builtin_type_int64;
 struct type *builtin_type_uint64;
 struct type *builtin_type_bool;
+struct type *builtin_type_v4sf;
+struct type *builtin_type_v4si;
+struct type *builtin_type_v8qi;
+struct type *builtin_type_v4hi;
+struct type *builtin_type_v2si;
+struct type *builtin_type_ptr;
+struct type *builtin_type_CORE_ADDR;
+struct type *builtin_type_bfd_vma;
 
 int opaque_type_resolution = 1;
 
@@ -633,6 +641,44 @@ create_set_type (result_type, domain_type)
   return (result_type);
 }
 
+
+/* Construct and return a type of the form:
+       struct NAME { ELT_TYPE ELT_NAME[N]; }
+   We use these types for SIMD registers.  For example, the type of
+   the SSE registers on the late x86-family processors is:
+       struct __builtin_v4sf { float f[4]; }
+   built by the function call:
+       init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4)
+   The type returned is a permanent type, allocated using malloc; it
+   doesn't live in any objfile's obstack.  */
+static struct type *
+init_simd_type (char *name,
+               struct type *elt_type,
+               char *elt_name,
+               int n)
+{
+  struct type *t;
+  struct field *f;
+
+  /* Build the field structure.  */
+  f = xmalloc (sizeof (*f));
+  memset (f, 0, sizeof (*f));
+  f->loc.bitpos = 0;
+  f->type = create_array_type (0, elt_type,
+                              create_range_type (0, builtin_type_int,
+                                                 0, n-1));
+  f->name = elt_name;
+
+  /* Build a struct type with that field.  */
+  t = init_type (TYPE_CODE_STRUCT, n * TYPE_LENGTH (elt_type), 0, 0, 0);
+  t->nfields = 1;
+  t->fields = f;
+  t->tag_name = name;
+
+  return t;
+}
+
+
 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. 
    A MEMBER is a wierd thing -- it amounts to a typed offset into
    a struct, e.g. "an int at offset 8".  A MEMBER TYPE doesn't
@@ -1616,6 +1662,20 @@ can_dereference (t)
      && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID);
 }
 
+int
+is_integral_type (t)
+     struct type *t;
+{
+  CHECK_TYPEDEF (t);
+  return
+    ((t != NULL)
+     && ((TYPE_CODE (t) == TYPE_CODE_INT)
+        || (TYPE_CODE (t) == TYPE_CODE_ENUM)
+        || (TYPE_CODE (t) == TYPE_CODE_CHAR)
+        || (TYPE_CODE (t) == TYPE_CODE_RANGE)
+        || (TYPE_CODE (t) == TYPE_CODE_BOOL)));
+}
+
 /* Chill varying string and arrays are represented as follows:
 
    struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data};
@@ -1980,9 +2040,7 @@ int
 count_virtual_fns (dclass)
      struct type *dclass;
 {
-  int base;                    /* index for base classes */
   int fn, oi;                  /* function and overloaded instance indices */
-
   int vfuncs;                  /* count to return */
 
   /* recurse on bases that can share virtual table */
@@ -2471,7 +2529,7 @@ dump_fn_fieldlists (type, spaces)
   struct fn_field *f;
 
   printfi_filtered (spaces, "fn_fieldlists ");
-  gdb_print_address (TYPE_FN_FIELDLISTS (type), gdb_stdout);
+  gdb_print_host_address (TYPE_FN_FIELDLISTS (type), gdb_stdout);
   printf_filtered ("\n");
   for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++)
     {
@@ -2479,8 +2537,8 @@ dump_fn_fieldlists (type, spaces)
       printfi_filtered (spaces + 2, "[%d] name '%s' (",
                        method_idx,
                        TYPE_FN_FIELDLIST_NAME (type, method_idx));
-      gdb_print_address (TYPE_FN_FIELDLIST_NAME (type, method_idx),
-                        gdb_stdout);
+      gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx),
+                             gdb_stdout);
       printf_filtered (") length %d\n",
                       TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
       for (overload_idx = 0;
@@ -2490,24 +2548,24 @@ dump_fn_fieldlists (type, spaces)
          printfi_filtered (spaces + 4, "[%d] physname '%s' (",
                            overload_idx,
                            TYPE_FN_FIELD_PHYSNAME (f, overload_idx));
-         gdb_print_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
-                            gdb_stdout);
+         gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
+                                 gdb_stdout);
          printf_filtered (")\n");
          printfi_filtered (spaces + 8, "type ");
-         gdb_print_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout);
+         gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout);
          printf_filtered ("\n");
 
          recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx),
                               spaces + 8 + 2);
 
          printfi_filtered (spaces + 8, "args ");
-         gdb_print_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout);
+         gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout);
          printf_filtered ("\n");
 
          print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces);
          printfi_filtered (spaces + 8, "fcontext ");
-         gdb_print_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
-                            gdb_stdout);
+         gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
+                                 gdb_stdout);
          printf_filtered ("\n");
 
          printfi_filtered (spaces + 8, "is_const %d\n",
@@ -2541,7 +2599,7 @@ print_cplus_stuff (type, spaces)
     {
       printfi_filtered (spaces, "virtual_field_bits (%d bits at *",
                        TYPE_N_BASECLASSES (type));
-      gdb_print_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout);
+      gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout);
       printf_filtered (")");
 
       print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
@@ -2554,7 +2612,7 @@ print_cplus_stuff (type, spaces)
        {
          printfi_filtered (spaces, "private_field_bits (%d bits at *",
                            TYPE_NFIELDS (type));
-         gdb_print_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout);
+         gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout);
          printf_filtered (")");
          print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
                            TYPE_NFIELDS (type));
@@ -2564,7 +2622,7 @@ print_cplus_stuff (type, spaces)
        {
          printfi_filtered (spaces, "protected_field_bits (%d bits at *",
                            TYPE_NFIELDS (type));
-         gdb_print_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout);
+         gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout);
          printf_filtered (")");
          print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
                            TYPE_NFIELDS (type));
@@ -2603,7 +2661,7 @@ recursive_dump_type (type, spaces)
          if (type == first_dont_print[i])
            {
              printfi_filtered (spaces, "type node ");
-             gdb_print_address (type, gdb_stdout);
+             gdb_print_host_address (type, gdb_stdout);
              printf_filtered (" <same as already seen type>\n");
              return;
            }
@@ -2613,17 +2671,17 @@ recursive_dump_type (type, spaces)
     }
 
   printfi_filtered (spaces, "type node ");
-  gdb_print_address (type, gdb_stdout);
+  gdb_print_host_address (type, gdb_stdout);
   printf_filtered ("\n");
   printfi_filtered (spaces, "name '%s' (",
                    TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>");
-  gdb_print_address (TYPE_NAME (type), gdb_stdout);
+  gdb_print_host_address (TYPE_NAME (type), gdb_stdout);
   printf_filtered (")\n");
   if (TYPE_TAG_NAME (type) != NULL)
     {
       printfi_filtered (spaces, "tagname '%s' (",
                        TYPE_TAG_NAME (type));
-      gdb_print_address (TYPE_TAG_NAME (type), gdb_stdout);
+      gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout);
       printf_filtered (")\n");
     }
   printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type));
@@ -2696,20 +2754,20 @@ recursive_dump_type (type, spaces)
   puts_filtered ("\n");
   printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
   printfi_filtered (spaces, "objfile ");
-  gdb_print_address (TYPE_OBJFILE (type), gdb_stdout);
+  gdb_print_host_address (TYPE_OBJFILE (type), gdb_stdout);
   printf_filtered ("\n");
   printfi_filtered (spaces, "target_type ");
-  gdb_print_address (TYPE_TARGET_TYPE (type), gdb_stdout);
+  gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout);
   printf_filtered ("\n");
   if (TYPE_TARGET_TYPE (type) != NULL)
     {
       recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
     }
   printfi_filtered (spaces, "pointer_type ");
-  gdb_print_address (TYPE_POINTER_TYPE (type), gdb_stdout);
+  gdb_print_host_address (TYPE_POINTER_TYPE (type), gdb_stdout);
   printf_filtered ("\n");
   printfi_filtered (spaces, "reference_type ");
-  gdb_print_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
+  gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
   printf_filtered ("\n");
   printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type));
   if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED)
@@ -2722,7 +2780,7 @@ recursive_dump_type (type, spaces)
     }
   puts_filtered ("\n");
   printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type));
-  gdb_print_address (TYPE_FIELDS (type), gdb_stdout);
+  gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout);
   puts_filtered ("\n");
   for (idx = 0; idx < TYPE_NFIELDS (type); idx++)
     {
@@ -2730,12 +2788,12 @@ recursive_dump_type (type, spaces)
                        "[%d] bitpos %d bitsize %d type ",
                        idx, TYPE_FIELD_BITPOS (type, idx),
                        TYPE_FIELD_BITSIZE (type, idx));
-      gdb_print_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
+      gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
       printf_filtered (" name '%s' (",
                       TYPE_FIELD_NAME (type, idx) != NULL
                       ? TYPE_FIELD_NAME (type, idx)
                       : "<NULL>");
-      gdb_print_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
+      gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
       printf_filtered (")\n");
       if (TYPE_FIELD_TYPE (type, idx) != NULL)
        {
@@ -2743,7 +2801,7 @@ recursive_dump_type (type, spaces)
        }
     }
   printfi_filtered (spaces, "vptr_basetype ");
-  gdb_print_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
+  gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
   puts_filtered ("\n");
   if (TYPE_VPTR_BASETYPE (type) != NULL)
     {
@@ -2755,14 +2813,14 @@ recursive_dump_type (type, spaces)
     case TYPE_CODE_METHOD:
     case TYPE_CODE_FUNC:
       printfi_filtered (spaces, "arg_types ");
-      gdb_print_address (TYPE_ARG_TYPES (type), gdb_stdout);
+      gdb_print_host_address (TYPE_ARG_TYPES (type), gdb_stdout);
       puts_filtered ("\n");
       print_arg_types (TYPE_ARG_TYPES (type), spaces);
       break;
 
     case TYPE_CODE_STRUCT:
       printfi_filtered (spaces, "cplus_stuff ");
-      gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
+      gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
       puts_filtered ("\n");
       print_cplus_stuff (type, spaces);
       break;
@@ -2772,7 +2830,7 @@ recursive_dump_type (type, spaces)
          the value.  Pick cplus_struct_type, even though we know it isn't
          any particular one. */
       printfi_filtered (spaces, "type_specific ");
-      gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
+      gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
       if (TYPE_CPLUS_SPECIFIC (type) != NULL)
        {
          printf_filtered (" (unknown data form)");
@@ -2913,6 +2971,35 @@ build_gdbtypes ()
      &showlist);
   opaque_type_resolution = 1;
 
+
+  /* Build SIMD types.  */
+  builtin_type_v4sf
+    = init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4);
+  builtin_type_v4si
+    = init_simd_type ("__builtin_v4si", builtin_type_int32, "f", 4);
+  builtin_type_v8qi
+    = init_simd_type ("__builtin_v8qi", builtin_type_int8, "f", 8);
+  builtin_type_v4hi
+    = init_simd_type ("__builtin_v4hi", builtin_type_int16, "f", 4);
+  builtin_type_v2si
+    = init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2);
+
+  /* Pointer/Address types. */
+  /* NOTE: At present there is no way of differentiating between at
+     target address and the target C language pointer type type even
+     though the two can be different (cf d10v) */
+  builtin_type_ptr =
+    init_type (TYPE_CODE_INT, TARGET_PTR_BIT / 8,
+              TYPE_FLAG_UNSIGNED,
+              "__ptr", (struct objfile *) NULL);
+  builtin_type_CORE_ADDR =
+    init_type (TYPE_CODE_INT, TARGET_PTR_BIT / 8,
+              TYPE_FLAG_UNSIGNED,
+              "__CORE_ADDR", (struct objfile *) NULL);
+  builtin_type_bfd_vma =
+    init_type (TYPE_CODE_INT, TARGET_BFD_VMA_BIT / 8,
+              TYPE_FLAG_UNSIGNED,
+              "__bfd_vma", (struct objfile *) NULL);
 }
 
 
@@ -2951,5 +3038,13 @@ _initialize_gdbtypes ()
   register_gdbarch_swap (&builtin_type_uint32, sizeof (struct type *), NULL);
   register_gdbarch_swap (&builtin_type_int64, sizeof (struct type *), NULL);
   register_gdbarch_swap (&builtin_type_uint64, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v4sf, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v4si, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v8qi, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v4hi, sizeof (struct type *), NULL);
+  register_gdbarch_swap (&builtin_type_v2si, sizeof (struct type *), NULL);
+  REGISTER_GDBARCH_SWAP (builtin_type_ptr);
+  REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
+  REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma);
   register_gdbarch_swap (NULL, 0, build_gdbtypes);
 }
This page took 0.027947 seconds and 4 git commands to generate.