diff mbox series

[committed,OG10] amdgcn: DWARF address spaces

Message ID ba486dca-3f0d-77f8-4c8e-c8a16a723bb6@codesourcery.com
State New
Headers show
Series [committed,OG10] amdgcn: DWARF address spaces | expand

Commit Message

Andrew Stubbs Jan. 15, 2021, 12:12 p.m. UTC
This patch implements DWARF address spaces for pointers to LDS, etc., on 
AMD GCN.

The address space mappings are defined by AMD in their DWARF proposals, 
and the LLVM implementation.

ROCGDB does not actually support this feature yet, I don't believe, but 
will do so soonish.

Committed to devel/omp/gcc-10. Queued for mainline.

Andrew
diff mbox series

Patch

amdgcn: DWARF address spaces

Map GCN address spaces to the proposed DWARF address spaces defined by AMD.

gcc/ChangeLog:

	* config/gcn/gcn.c: Include dwarf2.h.
	(gcn_addr_space_debug): New function.
	(TARGET_ADDR_SPACE_DEBUG): New hook.

diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c
index 1cb92714f24..f0e4636c06a 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -51,6 +51,7 @@ 
 #include "intl.h"
 #include "rtl-iter.h"
 #include "gimple.h"
+#include "dwarf2.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -1502,6 +1503,31 @@  gcn_addr_space_convert (rtx op, tree from_type, tree to_type)
     gcc_unreachable ();
 }
 
+/* Implement TARGET_ADDR_SPACE_DEBUG.
+
+   Return the dwarf address space class for each hardware address space.  */
+
+static int
+gcn_addr_space_debug (addr_space_t as)
+{
+  switch (as)
+    {
+      case ADDR_SPACE_DEFAULT:
+      case ADDR_SPACE_FLAT:
+      case ADDR_SPACE_GLOBAL:
+      case ADDR_SPACE_SCALAR_FLAT:
+      case ADDR_SPACE_FLAT_SCRATCH:
+	return DW_ADDR_none;
+      case ADDR_SPACE_LDS:
+	return 3;      // DW_ADDR_LLVM_group
+      case ADDR_SPACE_SCRATCH:
+	return 4;      // DW_ADDR_LLVM_private
+      case ADDR_SPACE_GDS:
+	return 0x8000; // DW_ADDR_AMDGPU_region
+    }
+  gcc_unreachable ();
+}
+
 
 /* Implement REGNO_MODE_CODE_OK_FOR_BASE_P via gcn.h
    
@@ -6366,6 +6392,8 @@  gcn_dwarf_register_span (rtx rtl)
 
 #undef  TARGET_ADDR_SPACE_ADDRESS_MODE
 #define TARGET_ADDR_SPACE_ADDRESS_MODE gcn_addr_space_address_mode
+#undef  TARGET_ADDR_SPACE_DEBUG
+#define TARGET_ADDR_SPACE_DEBUG gcn_addr_space_debug
 #undef  TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P
 #define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P \
   gcn_addr_space_legitimate_address_p