Add hook for modifying debug info for address spaces
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 9 Nov 2015 09:19:19 +0000 (09:19 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 9 Nov 2015 09:19:19 +0000 (09:19 +0000)
        * dwarf2out.c (modified_type_die): Pass the address space number
        through TARGET_ADDR_SPACE_DEBUG to produce the dwarf address class.
        * target.def (TARGET_ADDR_SPACE_DEBUG): New.
        * targhooks.c (default_addr_space_debug): New.
        * targhooks.h (default_addr_space_debug): Declare.
        * doc/tm.texi.in (TARGET_ADDR_SPACE_DEBUG): Mark it.
        * doc/tm.texi: Rebuild.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230000 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/dwarf2out.c
gcc/target.def
gcc/targhooks.c
gcc/targhooks.h

index 858f9b8..9a91cf8 100644 (file)
@@ -1,5 +1,13 @@
 2015-11-09  Richard Henderson  <rth@redhat.com>
 
+       * dwarf2out.c (modified_type_die): Pass the address space number
+       through TARGET_ADDR_SPACE_DEBUG to produce the dwarf address class.
+       * target.def (TARGET_ADDR_SPACE_DEBUG): New.
+       * targhooks.c (default_addr_space_debug): New.
+       * targhooks.h (default_addr_space_debug): Declare.
+       * doc/tm.texi.in (TARGET_ADDR_SPACE_DEBUG): Mark it.
+       * doc/tm.texi: Rebuild.
+
        * gimple.c (check_loadstore): Return false when 0 is a valid address.
        * fold-const.c (const_unop) [ADDR_SPACE_CONVERT_EXPR]: Do not fold
        null when 0 is valid in the source address space.
index 56cf60d..5609a98 100644 (file)
@@ -10379,6 +10379,11 @@ guaranteed that one of the two address spaces is a subset of the other,
 as determined by the @code{TARGET_ADDR_SPACE_SUBSET_P} target hook.
 @end deftypefn
 
+@deftypefn {Target Hook} int TARGET_ADDR_SPACE_DEBUG (addr_space_t @var{as})
+Define this to define how the address space is encoded in dwarf.
+The result is the value to be used with @code{DW_AT_address_class}.
+@end deftypefn
+
 @node Misc
 @section Miscellaneous Parameters
 @cindex parameters, miscellaneous
index 40abf76..96ca063 100644 (file)
@@ -7459,6 +7459,8 @@ c_register_addr_space ("__ea", ADDR_SPACE_EA);
 
 @hook TARGET_ADDR_SPACE_CONVERT
 
+@hook TARGET_ADDR_SPACE_DEBUG
+
 @node Misc
 @section Miscellaneous Parameters
 @cindex parameters, miscellaneous
index 6d02fe7..f184750 100644 (file)
@@ -10899,29 +10899,39 @@ modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
            mod_type_die = d;
          }
     }
-  else if (code == POINTER_TYPE)
+  else if (code == POINTER_TYPE || code == REFERENCE_TYPE)
     {
-      mod_type_die = new_die (DW_TAG_pointer_type, mod_scope, type);
-      add_AT_unsigned (mod_type_die, DW_AT_byte_size,
-                      simple_type_size_in_bits (type) / BITS_PER_UNIT);
-      item_type = TREE_TYPE (type);
-      if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (item_type)))
-       add_AT_unsigned (mod_type_die, DW_AT_address_class,
-                        TYPE_ADDR_SPACE (item_type));
-    }
-  else if (code == REFERENCE_TYPE)
-    {
-      if (TYPE_REF_IS_RVALUE (type) && dwarf_version >= 4)
-       mod_type_die = new_die (DW_TAG_rvalue_reference_type, mod_scope,
-                               type);
-      else
-       mod_type_die = new_die (DW_TAG_reference_type, mod_scope, type);
+      dwarf_tag tag = DW_TAG_pointer_type;
+      if (code == REFERENCE_TYPE)
+       {
+         if (TYPE_REF_IS_RVALUE (type) && dwarf_version >= 4)
+           tag = DW_TAG_rvalue_reference_type;
+         else
+           tag = DW_TAG_reference_type;
+       }
+      mod_type_die = new_die (tag, mod_scope, type);
+
       add_AT_unsigned (mod_type_die, DW_AT_byte_size,
                       simple_type_size_in_bits (type) / BITS_PER_UNIT);
       item_type = TREE_TYPE (type);
-      if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (item_type)))
-       add_AT_unsigned (mod_type_die, DW_AT_address_class,
-                        TYPE_ADDR_SPACE (item_type));
+
+      addr_space_t as = TYPE_ADDR_SPACE (item_type);
+      if (!ADDR_SPACE_GENERIC_P (as))
+       {
+         int action = targetm.addr_space.debug (as);
+         if (action >= 0)
+           {
+             /* Positive values indicate an address_class.  */
+             add_AT_unsigned (mod_type_die, DW_AT_address_class, action);
+           }
+         else
+           {
+             /* Negative values indicate an (inverted) segment base reg.  */
+             dw_loc_descr_ref d
+               = one_reg_loc_descriptor (~action, VAR_INIT_STATUS_INITIALIZED);
+             add_AT_loc (mod_type_die, DW_AT_segment, d);
+           }
+       }
     }
   else if (code == INTEGER_TYPE
           && TREE_TYPE (type) != NULL_TREE
index fc52798..0f7d3e5 100644 (file)
@@ -3244,6 +3244,14 @@ as determined by the @code{TARGET_ADDR_SPACE_SUBSET_P} target hook.",
  rtx, (rtx op, tree from_type, tree to_type),
  default_addr_space_convert)
 
+/* Function to encode an address space into dwarf.  */
+DEFHOOK
+(debug,
+ "Define this to define how the address space is encoded in dwarf.\n\
+The result is the value to be used with @code{DW_AT_address_class}.",
+ int, (addr_space_t as),
+ default_addr_space_debug)
+
 HOOK_VECTOR_END (addr_space)
 
 #undef HOOK_PREFIX
index d9108a6..c810525 100644 (file)
@@ -1277,6 +1277,14 @@ default_addr_space_zero_address_valid (addr_space_t as ATTRIBUTE_UNUSED)
   return false;
 }
 
+/* The default hook for debugging the address space is to return the
+   address space number to indicate DW_AT_address_class.  */
+int
+default_addr_space_debug (addr_space_t as)
+{
+  return as;
+}
+
 /* The default hook for TARGET_ADDR_SPACE_CONVERT. This hook should never be
    called for targets with only a generic address space.  */
 
index d93d4d7..8747f95 100644 (file)
@@ -178,6 +178,7 @@ extern rtx default_addr_space_legitimize_address (rtx, rtx, machine_mode,
                                                  addr_space_t);
 extern bool default_addr_space_subset_p (addr_space_t, addr_space_t);
 extern bool default_addr_space_zero_address_valid (addr_space_t);
+extern int default_addr_space_debug (addr_space_t);
 extern rtx default_addr_space_convert (rtx, tree, tree);
 extern unsigned int default_case_values_threshold (void);
 extern bool default_have_conditional_execution (void);