[PATCH] Rename gdbarch_tdep template function to gdbarch_tdep_cast for g++ 4.8

Mark Wielaard mark@klomp.org
Sat Jul 23 00:02:28 GMT 2022


commit 08106042d "gdb: move the type cast into gdbarch_tdep" created
a template function with the same name as a struct gdbarch_tdep. This
confused g++ 4.8 believing the struct gdbarch_tdep was an incomplete
type. Fix this by renaming the template function to gdbarch_tdep_cast.
---
 gdb/aarch64-fbsd-nat.c     |   4 +-
 gdb/aarch64-fbsd-tdep.c    |   6 +-
 gdb/aarch64-linux-nat.c    |  20 +++---
 gdb/aarch64-linux-tdep.c   |  10 +--
 gdb/aarch64-newlib-tdep.c  |   2 +-
 gdb/aarch64-tdep.c         |  48 +++++++-------
 gdb/aix-thread.c           |  28 ++++----
 gdb/alpha-linux-tdep.c     |   2 +-
 gdb/alpha-netbsd-tdep.c    |   2 +-
 gdb/alpha-obsd-tdep.c      |   2 +-
 gdb/alpha-tdep.c           |  14 ++--
 gdb/amd64-darwin-tdep.c    |   2 +-
 gdb/amd64-fbsd-nat.c       |   4 +-
 gdb/amd64-fbsd-tdep.c      |   4 +-
 gdb/amd64-linux-tdep.c     |   8 +--
 gdb/amd64-netbsd-tdep.c    |   2 +-
 gdb/amd64-obsd-tdep.c      |   2 +-
 gdb/amd64-sol2-tdep.c      |   2 +-
 gdb/amd64-tdep.c           |  34 +++++-----
 gdb/amd64-windows-tdep.c   |   2 +-
 gdb/arc-linux-tdep.c       |   4 +-
 gdb/arc-newlib-tdep.c      |   2 +-
 gdb/arc-tdep.c             |   8 +--
 gdb/arm-fbsd-nat.c         |   4 +-
 gdb/arm-fbsd-tdep.c        |   6 +-
 gdb/arm-linux-nat.c        |   8 +--
 gdb/arm-linux-tdep.c       |   4 +-
 gdb/arm-netbsd-nat.c       |   8 +--
 gdb/arm-netbsd-tdep.c      |   4 +-
 gdb/arm-none-tdep.c        |   2 +-
 gdb/arm-obsd-tdep.c        |   2 +-
 gdb/arm-tdep.c             | 110 +++++++++++++++----------------
 gdb/arm-wince-tdep.c       |   2 +-
 gdb/avr-tdep.c             |  12 ++--
 gdb/bfin-tdep.c            |   4 +-
 gdb/cris-linux-tdep.c      |   2 +-
 gdb/cris-tdep.c            |  18 ++---
 gdb/csky-tdep.c            |   8 +--
 gdb/frv-tdep.c             |   4 +-
 gdb/ft32-tdep.c            |   2 +-
 gdb/gdbarch.h              |   2 +-
 gdb/hppa-bsd-tdep.c        |   2 +-
 gdb/hppa-linux-tdep.c      |   4 +-
 gdb/hppa-tdep.c            |  12 ++--
 gdb/i386-bsd-tdep.c        |   2 +-
 gdb/i386-darwin-tdep.c     |   4 +-
 gdb/i386-fbsd-tdep.c       |   4 +-
 gdb/i386-gnu-tdep.c        |   2 +-
 gdb/i386-go32-tdep.c       |   2 +-
 gdb/i386-linux-tdep.c      |   4 +-
 gdb/i386-netbsd-tdep.c     |   4 +-
 gdb/i386-nto-tdep.c        |   6 +-
 gdb/i386-obsd-tdep.c       |   2 +-
 gdb/i386-sol2-tdep.c       |   2 +-
 gdb/i386-tdep.c            |  98 +++++++++++++--------------
 gdb/i386-windows-tdep.c    |   2 +-
 gdb/i387-tdep.c            |  20 +++---
 gdb/ia64-linux-tdep.c      |   2 +-
 gdb/ia64-tdep.c            |  12 ++--
 gdb/loongarch-linux-tdep.c |   2 +-
 gdb/loongarch-tdep.c       |   4 +-
 gdb/m32c-tdep.c            |  58 ++++++++--------
 gdb/m68hc11-tdep.c         |  12 ++--
 gdb/m68k-bsd-tdep.c        |   2 +-
 gdb/m68k-linux-tdep.c      |   2 +-
 gdb/m68k-tdep.c            |  38 +++++------
 gdb/mep-tdep.c             |   6 +-
 gdb/mips-linux-tdep.c      |   4 +-
 gdb/mips-tdep.c            |  50 +++++++-------
 gdb/mn10300-tdep.c         |   2 +-
 gdb/mn10300-tdep.h         |   2 +-
 gdb/msp430-tdep.c          |  12 ++--
 gdb/nds32-tdep.c           |  20 +++---
 gdb/nios2-linux-tdep.c     |   2 +-
 gdb/nios2-tdep.c           |   4 +-
 gdb/or1k-tdep.c            |   8 +--
 gdb/ppc-fbsd-nat.c         |   4 +-
 gdb/ppc-fbsd-tdep.c        |   8 +--
 gdb/ppc-linux-nat.c        |  22 +++----
 gdb/ppc-linux-tdep.c       |  18 ++---
 gdb/ppc-netbsd-nat.c       |   6 +-
 gdb/ppc-netbsd-tdep.c      |   2 +-
 gdb/ppc-obsd-nat.c         |   4 +-
 gdb/ppc-obsd-tdep.c        |   2 +-
 gdb/ppc-sysv-tdep.c        |  22 +++----
 gdb/ppc64-tdep.c           |   2 +-
 gdb/riscv-linux-tdep.c     |   2 +-
 gdb/riscv-tdep.c           |  26 ++++----
 gdb/rl78-tdep.c            |   8 +--
 gdb/rs6000-aix-nat.c       |   6 +-
 gdb/rs6000-aix-tdep.c      |  16 ++---
 gdb/rs6000-lynx178-tdep.c  |   4 +-
 gdb/rs6000-tdep.c          | 132 ++++++++++++++++++-------------------
 gdb/rx-tdep.c              |   2 +-
 gdb/s390-linux-tdep.c      |  20 +++---
 gdb/s390-tdep.c            |  42 ++++++------
 gdb/sh-linux-tdep.c        |   2 +-
 gdb/sh-netbsd-tdep.c       |   2 +-
 gdb/sh-tdep.c              |   8 +--
 gdb/sparc-linux-tdep.c     |   4 +-
 gdb/sparc-netbsd-tdep.c    |   2 +-
 gdb/sparc-sol2-tdep.c      |   2 +-
 gdb/sparc-tdep.c           |  14 ++--
 gdb/sparc64-fbsd-tdep.c    |   2 +-
 gdb/sparc64-linux-tdep.c   |   4 +-
 gdb/sparc64-netbsd-tdep.c  |   2 +-
 gdb/sparc64-obsd-tdep.c    |   2 +-
 gdb/sparc64-sol2-tdep.c    |   2 +-
 gdb/sparc64-tdep.c         |  10 +--
 gdb/tic6x-linux-tdep.c     |   6 +-
 gdb/tic6x-tdep.c           |   6 +-
 gdb/v850-tdep.c            |   6 +-
 gdb/windows-nat.c          |   2 +-
 gdb/xtensa-linux-nat.c     |   4 +-
 gdb/xtensa-linux-tdep.c    |   2 +-
 gdb/xtensa-tdep.c          |  54 +++++++--------
 gdb/z80-tdep.c             |   8 +--
 117 files changed, 659 insertions(+), 659 deletions(-)

diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c
index 708ddc40d58..43dfb97ff52 100644
--- a/gdb/aarch64-fbsd-nat.c
+++ b/gdb/aarch64-fbsd-nat.c
@@ -90,7 +90,7 @@ aarch64_fbsd_nat_target::fetch_registers (struct regcache *regcache,
 				    &aarch64_fbsd_fpregset);
 
   gdbarch *gdbarch = regcache->arch ();
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   if (tdep->has_tls ())
     {
       const struct regcache_map_entry aarch64_fbsd_tls_regmap[] =
@@ -123,7 +123,7 @@ aarch64_fbsd_nat_target::store_registers (struct regcache *regcache,
 				    PT_SETFPREGS, &aarch64_fbsd_fpregset);
 
   gdbarch *gdbarch = regcache->arch ();
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   if (tdep->has_tls ())
     {
       const struct regcache_map_entry aarch64_fbsd_tls_regmap[] =
diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c
index 4a6b4115234..0cbb40149b2 100644
--- a/gdb/aarch64-fbsd-tdep.c
+++ b/gdb/aarch64-fbsd-tdep.c
@@ -143,7 +143,7 @@ aarch64_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					   void *cb_data,
 					   const struct regcache *regcache)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   cb (".reg", AARCH64_FBSD_SIZEOF_GREGSET, AARCH64_FBSD_SIZEOF_GREGSET,
       &aarch64_fbsd_gregset, NULL, cb_data);
@@ -190,7 +190,7 @@ static CORE_ADDR
 aarch64_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 				       CORE_ADDR lm_addr, CORE_ADDR offset)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   struct regcache *regcache;
 
   regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
@@ -213,7 +213,7 @@ aarch64_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 static void
 aarch64_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   /* Generic FreeBSD support.  */
   fbsd_init_abi (info, gdbarch);
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index a457fcd48ad..3de7d407149 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -359,7 +359,7 @@ static void
 fetch_pauth_masks_from_thread (struct regcache *regcache)
 {
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (regcache->arch ());
   int ret;
   struct iovec iovec;
   uint64_t pauth_regset[2] = {0, 0};
@@ -385,7 +385,7 @@ static void
 fetch_mteregs_from_thread (struct regcache *regcache)
 {
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (regcache->arch ());
   int regno = tdep->mte_reg_base;
 
   gdb_assert (regno != -1);
@@ -410,7 +410,7 @@ static void
 store_mteregs_to_thread (struct regcache *regcache)
 {
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (regcache->arch ());
   int regno = tdep->mte_reg_base;
 
   gdb_assert (regno != -1);
@@ -439,7 +439,7 @@ static void
 fetch_tlsregs_from_thread (struct regcache *regcache)
 {
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (regcache->arch ());
   int regno = tdep->tls_regnum;
 
   gdb_assert (regno != -1);
@@ -464,7 +464,7 @@ static void
 store_tlsregs_to_thread (struct regcache *regcache)
 {
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (regcache->arch ());
   int regno = tdep->tls_regnum;
 
   gdb_assert (regno != -1);
@@ -493,7 +493,7 @@ static void
 aarch64_fetch_registers (struct regcache *regcache, int regno)
 {
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (regcache->arch ());
 
   if (regno == -1)
     {
@@ -543,7 +543,7 @@ static void
 aarch32_fetch_registers (struct regcache *regcache, int regno)
 {
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (regcache->arch ());
 
   if (regno == -1)
     {
@@ -579,7 +579,7 @@ static void
 aarch64_store_registers (struct regcache *regcache, int regno)
 {
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (regcache->arch ());
 
   if (regno == -1)
     {
@@ -619,7 +619,7 @@ static void
 aarch32_store_registers (struct regcache *regcache, int regno)
 {
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (regcache->arch ());
 
   if (regno == -1)
     {
@@ -893,7 +893,7 @@ aarch64_linux_nat_target::thread_architecture (ptid_t ptid)
 
   /* Only return it if the current vector length matches the one in the tdep.  */
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (inf->gdbarch);
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (inf->gdbarch);
   uint64_t vq = aarch64_sve_get_vq (ptid.lwp ());
   if (vq == tdep->vq)
     return inf->gdbarch;
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 15773c75da8..ed9e3b1e2bc 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -289,7 +289,7 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self,
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
   CORE_ADDR sigcontext_addr = (sp + AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET
 			       + AARCH64_UCONTEXT_SIGCONTEXT_OFFSET );
@@ -643,7 +643,7 @@ aarch64_linux_collect_sve_regset (const struct regset *regset,
   gdb_byte *header = (gdb_byte *) buf;
   struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   uint64_t vq = tdep->vq;
 
   gdb_assert (buf != NULL);
@@ -679,7 +679,7 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					    void *cb_data,
 					    const struct regcache *regcache)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   cb (".reg", AARCH64_LINUX_SIZEOF_GREGSET, AARCH64_LINUX_SIZEOF_GREGSET,
       &aarch64_linux_gregset, NULL, cb_data);
@@ -1748,7 +1748,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
 				  struct ui_out *uiout,
 				  enum gdb_signal siggnal)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (!tdep->has_mte () || siggnal != GDB_SIGNAL_SEGV)
     return;
@@ -1970,7 +1970,7 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 								    NULL };
   static const char *const stap_register_indirection_suffixes[] = { "]",
 								    NULL };
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   tdep->lowest_pc = 0x8000;
 
diff --git a/gdb/aarch64-newlib-tdep.c b/gdb/aarch64-newlib-tdep.c
index c9236b17801..1be7dd86041 100644
--- a/gdb/aarch64-newlib-tdep.c
+++ b/gdb/aarch64-newlib-tdep.c
@@ -29,7 +29,7 @@
 static void
 aarch64_newlib_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   /* Jump buffer - support for longjmp.
      Offset of original PC in jump buffer (in registers).  */
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 8670197a888..03fe79c1190 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -502,7 +502,7 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch,
       else if (inst.opcode->iclass == ic_system)
 	{
 	  aarch64_gdbarch_tdep *tdep
-	    = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+	    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 	  int ra_state_val = 0;
 
 	  if (insn == 0xd503233f /* paciasp.  */
@@ -640,7 +640,7 @@ aarch64_analyze_prologue_test (void)
   struct aarch64_prologue_cache cache;
   cache.saved_regs = trad_frame_alloc_saved_regs (gdbarch);
 
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   /* Test the simple prologue in which frame pointer is used.  */
   {
@@ -1076,7 +1076,7 @@ aarch64_prologue_frame_unwind_stop_reason (struct frame_info *this_frame,
 
   /* Halt the backtrace at "_start".  */
   gdbarch *arch = get_frame_arch (this_frame);
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (arch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (arch);
   if (cache->prev_pc <= tdep->lowest_pc)
     return UNWIND_OUTERMOST;
 
@@ -1120,7 +1120,7 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
       CORE_ADDR lr;
       struct gdbarch *gdbarch = get_frame_arch (this_frame);
       aarch64_gdbarch_tdep *tdep
-	= gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+	= gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
       lr = frame_unwind_register_unsigned (this_frame, AARCH64_LR_REGNUM);
 
@@ -1289,7 +1289,7 @@ aarch64_dwarf2_prev_register (struct frame_info *this_frame,
 			      void **this_cache, int regnum)
 {
   gdbarch *arch = get_frame_arch (this_frame);
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (arch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (arch);
   CORE_ADDR lr;
 
   switch (regnum)
@@ -1315,7 +1315,7 @@ aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			       struct dwarf2_frame_state_reg *reg,
 			       struct frame_info *this_frame)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   switch (regnum)
     {
@@ -1355,7 +1355,7 @@ static bool
 aarch64_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op,
 				     struct dwarf2_frame_state *fs)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   struct dwarf2_frame_state_reg *ra_state;
 
   if (op == DW_CFA_AARCH64_negate_ra_state)
@@ -1996,7 +1996,7 @@ aarch64_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
 static struct type *
 aarch64_vnq_type (struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (tdep->vnq_type == NULL)
     {
@@ -2023,7 +2023,7 @@ aarch64_vnq_type (struct gdbarch *gdbarch)
 static struct type *
 aarch64_vnd_type (struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (tdep->vnd_type == NULL)
     {
@@ -2053,7 +2053,7 @@ aarch64_vnd_type (struct gdbarch *gdbarch)
 static struct type *
 aarch64_vns_type (struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (tdep->vns_type == NULL)
     {
@@ -2083,7 +2083,7 @@ aarch64_vns_type (struct gdbarch *gdbarch)
 static struct type *
 aarch64_vnh_type (struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (tdep->vnh_type == NULL)
     {
@@ -2116,7 +2116,7 @@ aarch64_vnh_type (struct gdbarch *gdbarch)
 static struct type *
 aarch64_vnb_type (struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (tdep->vnb_type == NULL)
     {
@@ -2143,7 +2143,7 @@ aarch64_vnb_type (struct gdbarch *gdbarch)
 static struct type *
 aarch64_vnv_type (struct gdbarch *gdbarch)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (tdep->vnv_type == NULL)
     {
@@ -2214,7 +2214,7 @@ aarch64_vnv_type (struct gdbarch *gdbarch)
 static int
 aarch64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (reg >= AARCH64_DWARF_X0 && reg <= AARCH64_DWARF_X0 + 30)
     return AARCH64_X0_REGNUM + reg - AARCH64_DWARF_X0;
@@ -2518,7 +2518,7 @@ aarch64_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
   CORE_ADDR jb_addr;
   gdb_byte buf[X_REGISTER_SIZE];
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   jb_addr = get_frame_register_unsigned (frame, AARCH64_X0_REGNUM);
@@ -2549,7 +2549,7 @@ aarch64_gen_return_address (struct gdbarch *gdbarch,
 static const char *
 aarch64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   static const char *const q_name[] =
     {
@@ -2663,7 +2663,7 @@ aarch64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 static struct type *
 aarch64_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   int p_regnum = regnum - gdbarch_num_regs (gdbarch);
 
@@ -2700,7 +2700,7 @@ static int
 aarch64_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 				    const struct reggroup *group)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   int p_regnum = regnum - gdbarch_num_regs (gdbarch);
 
@@ -2754,7 +2754,7 @@ static struct value *
 aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache,
 			   int regnum)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   struct value *result_value = allocate_value (register_type (gdbarch, regnum));
 
   VALUE_LVAL (result_value) = lval_register;
@@ -2824,7 +2824,7 @@ static void
 aarch64_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache,
 		      int regnum, const gdb_byte *buf)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
   regnum -= gdbarch_num_regs (gdbarch);
 
   if (regnum >= AARCH64_Q0_REGNUM && regnum < AARCH64_Q0_REGNUM + 32)
@@ -3377,7 +3377,7 @@ aarch64_get_tdesc_vq (const struct target_desc *tdesc)
 static int
 aarch64_cannot_store_register (struct gdbarch *gdbarch, int regnum)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (!tdep->has_pauth ())
     return 0;
@@ -3444,7 +3444,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
     {
       aarch64_gdbarch_tdep *tdep
-	= gdbarch_tdep<aarch64_gdbarch_tdep> (best_arch->gdbarch);
+	= gdbarch_tdep_cast<aarch64_gdbarch_tdep> (best_arch->gdbarch);
       if (tdep && tdep->vq == vq)
 	return best_arch->gdbarch;
     }
@@ -3693,7 +3693,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 aarch64_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+  aarch64_gdbarch_tdep *tdep = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (gdbarch);
 
   if (tdep == NULL)
     return;
@@ -3915,7 +3915,7 @@ aarch64_record_branch_except_sys (aarch64_insn_decode_record *aarch64_insn_r)
 {
 
   aarch64_gdbarch_tdep *tdep
-    = gdbarch_tdep<aarch64_gdbarch_tdep> (aarch64_insn_r->gdbarch);
+    = gdbarch_tdep_cast<aarch64_gdbarch_tdep> (aarch64_insn_r->gdbarch);
   uint8_t insn_bits24_27, insn_bits28_31, insn_bits22_23;
   uint32_t record_buf[4];
 
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 4c9195a7f12..f49d721bd1f 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1111,7 +1111,7 @@ static void
 supply_gprs64 (struct regcache *regcache, uint64_t *vals)
 {
   ppc_gdbarch_tdep *tdep
-    = gdbarch_tdep<ppc_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<ppc_gdbarch_tdep> (regcache->arch ());
   int regno;
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
@@ -1133,7 +1133,7 @@ static void
 supply_fprs (struct regcache *regcache, double *vals)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int regno;
 
   /* This function should never be called on architectures without
@@ -1151,7 +1151,7 @@ supply_fprs (struct regcache *regcache, double *vals)
 static int
 special_register_p (struct gdbarch *gdbarch, int regno)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   return regno == gdbarch_pc_regnum (gdbarch)
       || regno == tdep->ppc_ps_regnum
@@ -1174,7 +1174,7 @@ supply_sprs64 (struct regcache *regcache,
 	       uint32_t fpscr)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   regcache->raw_supply (gdbarch_pc_regnum (gdbarch), (char *) &iar);
   regcache->raw_supply (tdep->ppc_ps_regnum, (char *) &msr);
@@ -1196,7 +1196,7 @@ supply_sprs32 (struct regcache *regcache,
 	       uint32_t fpscr)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   regcache->raw_supply (gdbarch_pc_regnum (gdbarch), (char *) &iar);
   regcache->raw_supply (tdep->ppc_ps_regnum, (char *) &msr);
@@ -1219,7 +1219,7 @@ static void
 fetch_regs_user_thread (struct regcache *regcache, pthdb_pthread_t pdtid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int status, i;
   pthdb_context_t ctx;
 
@@ -1274,7 +1274,7 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
 			  pthdb_tid_t tid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   uint64_t gprs64[ppc_num_gprs];
   uint32_t gprs32[ppc_num_gprs];
   double fprs[ppc_num_fprs];
@@ -1377,7 +1377,7 @@ static void
 fill_gprs64 (const struct regcache *regcache, uint64_t *vals)
 {
   ppc_gdbarch_tdep *tdep
-    = gdbarch_tdep<ppc_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<ppc_gdbarch_tdep> (regcache->arch ());
   int regno;
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
@@ -1390,7 +1390,7 @@ static void
 fill_gprs32 (const struct regcache *regcache, uint32_t *vals)
 {
   ppc_gdbarch_tdep *tdep
-    = gdbarch_tdep<ppc_gdbarch_tdep> (regcache->arch ());
+    = gdbarch_tdep_cast<ppc_gdbarch_tdep> (regcache->arch ());
   int regno;
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
@@ -1404,7 +1404,7 @@ static void
 fill_fprs (const struct regcache *regcache, double *vals)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int regno;
 
   /* This function should never be called on architectures without
@@ -1428,7 +1428,7 @@ fill_sprs64 (const struct regcache *regcache,
 	     uint32_t *fpscr)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* Verify that the size of the size of the IAR buffer is the
      same as the raw size of the PC (in the register cache).  If
@@ -1462,7 +1462,7 @@ fill_sprs32 (const struct regcache *regcache,
 	     uint32_t *fpscr)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* Verify that the size of the size of the IAR buffer is the
      same as the raw size of the PC (in the register cache).  If
@@ -1499,7 +1499,7 @@ static void
 store_regs_user_thread (const struct regcache *regcache, pthdb_pthread_t pdtid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int status, i;
   pthdb_context_t ctx;
   uint32_t int32;
@@ -1589,7 +1589,7 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
 			  pthdb_tid_t tid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   uint64_t gprs64[ppc_num_gprs];
   uint32_t gprs32[ppc_num_gprs];
   double fprs[ppc_num_fprs];
diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c
index c103aafc1ff..eaae46f03f0 100644
--- a/gdb/alpha-linux-tdep.c
+++ b/gdb/alpha-linux-tdep.c
@@ -362,7 +362,7 @@ alpha_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* Hook into the MDEBUG frame unwinder.  */
   alpha_mdebug_init_abi (info, gdbarch);
 
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
   tdep->dynamic_sigtramp_offset = alpha_linux_sigtramp_offset;
   tdep->sigcontext_addr = alpha_linux_sigcontext_addr;
   tdep->pc_in_sigtramp = alpha_linux_pc_in_sigtramp;
diff --git a/gdb/alpha-netbsd-tdep.c b/gdb/alpha-netbsd-tdep.c
index 72d7019377f..3beb9908c2f 100644
--- a/gdb/alpha-netbsd-tdep.c
+++ b/gdb/alpha-netbsd-tdep.c
@@ -250,7 +250,7 @@ static void
 alphanbsd_init_abi (struct gdbarch_info info,
 		    struct gdbarch *gdbarch)
 {
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
 
   /* Hook into the DWARF CFI frame unwinder.  */
   alpha_dwarf2_init_abi (info, gdbarch);
diff --git a/gdb/alpha-obsd-tdep.c b/gdb/alpha-obsd-tdep.c
index c0d672c3f72..58ecbffea4e 100644
--- a/gdb/alpha-obsd-tdep.c
+++ b/gdb/alpha-obsd-tdep.c
@@ -97,7 +97,7 @@ alphaobsd_sigcontext_addr (struct frame_info *this_frame)
 static void
 alphaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
 
   /* Hook into the DWARF CFI frame unwinder.  */
   alpha_dwarf2_init_abi (info, gdbarch);
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 44efc8e4bbb..3c2adac43e3 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -615,7 +615,7 @@ alpha_return_value (struct gdbarch *gdbarch, struct value *function,
 		    gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   enum type_code code = type->code ();
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
 
   if ((code == TYPE_CODE_STRUCT
        || code == TYPE_CODE_UNION
@@ -851,7 +851,7 @@ static int
 alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR jb_addr;
   gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
@@ -891,7 +891,7 @@ alpha_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
   *this_prologue_cache = info;
 
   gdbarch *arch = get_frame_arch (this_frame);
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (arch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (arch);
   info->sigcontext_addr = tdep->sigcontext_addr (this_frame);
 
   return info;
@@ -904,7 +904,7 @@ static CORE_ADDR
 alpha_sigtramp_register_address (struct gdbarch *gdbarch,
 				 CORE_ADDR sigcontext_addr, int regnum)
 { 
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
 
   if (regnum >= 0 && regnum < 32)
     return sigcontext_addr + tdep->sc_regs_offset + regnum * 8;
@@ -925,7 +925,7 @@ alpha_sigtramp_frame_this_id (struct frame_info *this_frame,
 			      struct frame_id *this_id)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
   struct alpha_sigtramp_unwind_cache *info
     = alpha_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache);
   CORE_ADDR stack_addr, code_addr;
@@ -1000,7 +1000,7 @@ alpha_sigtramp_frame_sniffer (const struct frame_unwind *self,
 
   /* We shouldn't even bother to try if the OSABI didn't register a
      sigcontext_addr handler or pc_in_sigtramp handler.  */
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
   if (tdep->sigcontext_addr == NULL)
     return 0;
 
@@ -1041,7 +1041,7 @@ static int heuristic_fence_post = 0;
 static CORE_ADDR
 alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  alpha_gdbarch_tdep *tdep = gdbarch_tdep<alpha_gdbarch_tdep> (gdbarch);
+  alpha_gdbarch_tdep *tdep = gdbarch_tdep_cast<alpha_gdbarch_tdep> (gdbarch);
   CORE_ADDR last_non_nop = pc;
   CORE_ADDR fence = pc - heuristic_fence_post;
   CORE_ADDR orig_pc = pc;
diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c
index 7fc35536bc6..a6aa052d75b 100644
--- a/gdb/amd64-darwin-tdep.c
+++ b/gdb/amd64-darwin-tdep.c
@@ -97,7 +97,7 @@ amd64_darwin_sigcontext_addr (struct frame_info *this_frame)
 static void
 x86_darwin_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   amd64_init_abi (info, gdbarch,
 		  amd64_target_description (X86_XSTATE_SSE_MASK, true));
diff --git a/gdb/amd64-fbsd-nat.c b/gdb/amd64-fbsd-nat.c
index 7023a182e78..43228bd7835 100644
--- a/gdb/amd64-fbsd-nat.c
+++ b/gdb/amd64-fbsd-nat.c
@@ -102,7 +102,7 @@ amd64_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = regcache->arch ();
 #if defined(PT_GETFSBASE) || defined(PT_GETGSBASE)
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 #endif
   pid_t pid = get_ptrace_pid (regcache->ptid ());
   const struct regset *gregset = find_gregset (gdbarch);
@@ -174,7 +174,7 @@ amd64_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = regcache->arch ();
 #if defined(PT_GETFSBASE) || defined(PT_GETGSBASE)
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 #endif
   pid_t pid = get_ptrace_pid (regcache->ptid ());
   const struct regset *gregset = find_gregset (gdbarch);
diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
index 8e40283d838..45e1b5aafce 100644
--- a/gdb/amd64-fbsd-tdep.c
+++ b/gdb/amd64-fbsd-tdep.c
@@ -262,7 +262,7 @@ amd64fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					void *cb_data,
 					const struct regcache *regcache)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   cb (".reg", AMD64_FBSD_SIZEOF_GREGSET, AMD64_FBSD_SIZEOF_GREGSET,
       &amd64_fbsd_gregset, NULL, cb_data);
@@ -299,7 +299,7 @@ amd64fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 static void
 amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* Generic FreeBSD support. */
   fbsd_init_abi (info, gdbarch);
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 35703a36785..561d9584a70 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1659,7 +1659,7 @@ amd64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					  void *cb_data,
 					  const struct regcache *regcache)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   cb (".reg", 27 * 8, 27 * 8, &i386_gregset, NULL, cb_data);
   cb (".reg2", 512, 512, &amd64_fpregset, NULL, cb_data);
@@ -1796,7 +1796,7 @@ static void
 amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch,
 			    int num_disp_step_buffers)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, num_disp_step_buffers);
 
@@ -1849,7 +1849,7 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch,
 static void
 amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   const struct tdesc_feature *feature;
   int valid_p;
@@ -2063,7 +2063,7 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static void
 amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   const struct tdesc_feature *feature;
   int valid_p;
diff --git a/gdb/amd64-netbsd-tdep.c b/gdb/amd64-netbsd-tdep.c
index 59d723caa55..4c80649a5c1 100644
--- a/gdb/amd64-netbsd-tdep.c
+++ b/gdb/amd64-netbsd-tdep.c
@@ -97,7 +97,7 @@ int amd64nbsd_r_reg_offset[] =
 static void
 amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* Initialize general-purpose register set details first.  */
   tdep->gregset_reg_offset = amd64nbsd_r_reg_offset;
diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c
index f0bc7c474a6..97baa18e76f 100644
--- a/gdb/amd64-obsd-tdep.c
+++ b/gdb/amd64-obsd-tdep.c
@@ -420,7 +420,7 @@ static const struct frame_unwind amd64obsd_trapframe_unwind =
 static void
 amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   amd64_init_abi (info, gdbarch,
 		  amd64_target_description (X86_XSTATE_SSE_MASK, true));
diff --git a/gdb/amd64-sol2-tdep.c b/gdb/amd64-sol2-tdep.c
index ce96eb045ec..4a7eb6f4539 100644
--- a/gdb/amd64-sol2-tdep.c
+++ b/gdb/amd64-sol2-tdep.c
@@ -80,7 +80,7 @@ amd64_sol2_mcontext_addr (struct frame_info *this_frame)
 static void
 amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset;
   tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset);
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 0563b32a54b..806fe4a6af5 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -247,7 +247,7 @@ static const int amd64_dwarf_regmap_len =
 static int
 amd64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int ymm0_regnum = tdep->ymm0_regnum;
   int regnum = -1;
 
@@ -331,7 +331,7 @@ static const char * const amd64_dword_names[] =
 static const char *
 amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   if (i386_byte_regnum_p (gdbarch, regnum))
     return amd64_byte_names[regnum - tdep->al_regnum];
   else if (i386_zmm_regnum_p (gdbarch, regnum))
@@ -353,7 +353,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
 				  readable_regcache *regcache,
 				  int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   value *result_value = allocate_value (register_type (gdbarch, regnum));
   VALUE_LVAL (result_value) = lval_register;
@@ -413,7 +413,7 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch,
 			     struct regcache *regcache,
 			     int regnum, const gdb_byte *buf)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (i386_byte_regnum_p (gdbarch, regnum))
     {
@@ -465,7 +465,7 @@ static int
 amd64_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 				  struct agent_expr *ax, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (i386_byte_regnum_p (gdbarch, regnum))
     {
@@ -2749,7 +2749,7 @@ static struct amd64_frame_cache *
 amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct amd64_frame_cache *cache;
   CORE_ADDR addr;
@@ -2832,7 +2832,7 @@ amd64_sigtramp_frame_sniffer (const struct frame_unwind *self,
 			      void **this_cache)
 {
   gdbarch *arch = get_frame_arch (this_frame);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
 
   /* We shouldn't even bother if we don't have a sigcontext_addr
      handler.  */
@@ -3032,7 +3032,7 @@ amd64_supply_fpregset (const struct regset *regset, struct regcache *regcache,
 		       int regnum, const void *fpregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   gdb_assert (len >= tdep->sizeof_fpregset);
   amd64_supply_fxsave (regcache, regnum, fpregs);
@@ -3049,7 +3049,7 @@ amd64_collect_fpregset (const struct regset *regset,
 			int regnum, void *fpregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   gdb_assert (len >= tdep->sizeof_fpregset);
   amd64_collect_fxsave (regcache, regnum, fpregs);
@@ -3073,7 +3073,7 @@ amd64_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
   gdb_byte buf[8];
   CORE_ADDR jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int jb_pc_offset = tdep->jb_pc_offset;
   int len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr);
 
@@ -3117,7 +3117,7 @@ void
 amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
 		const target_desc *default_tdesc)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   const struct target_desc *tdesc = info.target_desc;
   static const char *const stap_integer_prefixes[] = { "$", NULL };
   static const char *const stap_register_prefixes[] = { "%", NULL };
@@ -3296,7 +3296,7 @@ amd64_none_init_abi (gdbarch_info info, gdbarch *arch)
 static struct type *
 amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   switch (regnum - tdep->eax_regnum)
     {
@@ -3314,7 +3314,7 @@ void
 amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
 		    const target_desc *default_tdesc)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   amd64_init_abi (info, gdbarch, default_tdesc);
 
@@ -3384,7 +3384,7 @@ amd64_supply_fxsave (struct regcache *regcache, int regnum,
 		     const void *fxsave)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   i387_supply_fxsave (regcache, regnum, fxsave);
 
@@ -3407,7 +3407,7 @@ amd64_supply_xsave (struct regcache *regcache, int regnum,
 		    const void *xsave)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   i387_supply_xsave (regcache, regnum, xsave);
 
@@ -3442,7 +3442,7 @@ amd64_collect_fxsave (const struct regcache *regcache, int regnum,
 		      void *fxsave)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   gdb_byte *regs = (gdb_byte *) fxsave;
 
   i387_collect_fxsave (regcache, regnum, fxsave);
@@ -3463,7 +3463,7 @@ amd64_collect_xsave (const struct regcache *regcache, int regnum,
 		     void *xsave, int gcore)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   gdb_byte *regs = (gdb_byte *) xsave;
 
   i387_collect_xsave (regcache, regnum, xsave, gcore);
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index a9aef0bab88..9018328102a 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -1277,7 +1277,7 @@ amd64_windows_auto_wide_charset (void)
 static void
 amd64_windows_init_abi_common (gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* The dwarf2 unwinder (appended very early by i386_gdbarch_init) is
      preferred over the SEH one.  The reasons are:
diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index d72bdaf24ac..2cb8c3958ae 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -411,7 +411,7 @@ static std::vector<CORE_ADDR>
 arc_linux_software_single_step (struct regcache *regcache)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
+  arc_gdbarch_tdep *tdep = gdbarch_tdep_cast<arc_gdbarch_tdep> (gdbarch);
   struct gdb_non_printing_memory_disassembler dis (gdbarch);
 
   /* Read current instruction.  */
@@ -694,7 +694,7 @@ arc_linux_core_read_description (struct gdbarch *gdbarch,
 static void
 arc_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
+  arc_gdbarch_tdep *tdep = gdbarch_tdep_cast<arc_gdbarch_tdep> (gdbarch);
 
   arc_linux_debug_printf ("GNU/Linux OS/ABI initialization.");
 
diff --git a/gdb/arc-newlib-tdep.c b/gdb/arc-newlib-tdep.c
index 2499dff43ec..ece10c6cd94 100644
--- a/gdb/arc-newlib-tdep.c
+++ b/gdb/arc-newlib-tdep.c
@@ -36,7 +36,7 @@ arc_newlib_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   arc_newlib_debug_printf ("Initialization.");
 
-  arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
+  arc_gdbarch_tdep *tdep = gdbarch_tdep_cast<arc_gdbarch_tdep> (gdbarch);
 
   /* Offset of original PC in longjmp jump buffer (in registers).  Value of PC
      offset can be found in newlib/libc/machine/arc/setjmp.S.  */
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 11e0551266e..fdc836048e4 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -1002,7 +1002,7 @@ arc_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
   arc_debug_printf ("called");
 
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
+  arc_gdbarch_tdep *tdep = gdbarch_tdep_cast<arc_gdbarch_tdep> (gdbarch);
   int pc_offset = tdep->jb_pc * ARC_REGISTER_SIZE;
   gdb_byte buf[ARC_REGISTER_SIZE];
   CORE_ADDR jb_addr = get_frame_register_unsigned (frame, ARC_FIRST_ARG_REGNUM);
@@ -1810,7 +1810,7 @@ arc_make_sigtramp_frame_cache (struct frame_info *this_frame)
   arc_debug_printf ("called");
 
   gdbarch *arch = get_frame_arch (this_frame);
-  arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (arch);
+  arc_gdbarch_tdep *tdep = gdbarch_tdep_cast<arc_gdbarch_tdep> (arch);
 
   /* Allocate new frame cache instance and space for saved register info.  */
   struct arc_frame_cache *cache = FRAME_OBSTACK_ZALLOC (struct arc_frame_cache);
@@ -1887,7 +1887,7 @@ arc_sigtramp_frame_sniffer (const struct frame_unwind *self,
   arc_debug_printf ("called");
 
   gdbarch *arch = get_frame_arch (this_frame);
-  arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (arch);
+  arc_gdbarch_tdep *tdep = gdbarch_tdep_cast<arc_gdbarch_tdep> (arch);
 
   /* If we have a sigcontext_addr handler, then just return 1 (same as the
      "default_frame_sniffer ()").  */
@@ -2414,7 +2414,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 arc_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  arc_gdbarch_tdep *tdep = gdbarch_tdep<arc_gdbarch_tdep> (gdbarch);
+  arc_gdbarch_tdep *tdep = gdbarch_tdep_cast<arc_gdbarch_tdep> (gdbarch);
 
   gdb_printf (file, "arc_dump_tdep: jb_pc = %i\n", tdep->jb_pc);
 
diff --git a/gdb/arm-fbsd-nat.c b/gdb/arm-fbsd-nat.c
index b161b7ed908..10013650105 100644
--- a/gdb/arm-fbsd-nat.c
+++ b/gdb/arm-fbsd-nat.c
@@ -55,7 +55,7 @@ arm_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum)
 #endif
 #ifdef PT_GETREGSET
   gdbarch *gdbarch = regcache->arch ();
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->tls_regnum > 0)
     {
@@ -90,7 +90,7 @@ arm_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
 #endif
 #ifdef PT_GETREGSET
   gdbarch *gdbarch = regcache->arch ();
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->tls_regnum > 0)
     {
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index 61c8f0cecad..2139eebb9f9 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -159,7 +159,7 @@ arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				       void *cb_data,
 				       const struct regcache *regcache)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   cb (".reg", ARM_FBSD_SIZEOF_GREGSET, ARM_FBSD_SIZEOF_GREGSET,
       &arm_fbsd_gregset, NULL, cb_data);
@@ -233,7 +233,7 @@ static CORE_ADDR
 arm_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 				   CORE_ADDR lm_addr, CORE_ADDR offset)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   struct regcache *regcache;
 
   regcache = get_thread_arch_regcache (current_inferior ()->process_target (),
@@ -256,7 +256,7 @@ arm_fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 static void
 arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Generic FreeBSD support.  */
   fbsd_init_abi (info, gdbarch);
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 0188c78fe7a..de0189e5f62 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -339,7 +339,7 @@ fetch_vfp_regs (struct regcache *regcache)
   gdb_byte regbuf[ARM_VFP3_REGS_SIZE];
   int ret, tid;
   struct gdbarch *gdbarch = regcache->arch ();
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Get the thread id for the ptrace call.  */
   tid = regcache->ptid ().lwp ();
@@ -368,7 +368,7 @@ store_vfp_regs (const struct regcache *regcache)
   gdb_byte regbuf[ARM_VFP3_REGS_SIZE];
   int ret, tid;
   struct gdbarch *gdbarch = regcache->arch ();
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Get the thread id for the ptrace call.  */
   tid = regcache->ptid ().lwp ();
@@ -413,7 +413,7 @@ void
 arm_linux_nat_target::fetch_registers (struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (-1 == regno)
     {
@@ -450,7 +450,7 @@ void
 arm_linux_nat_target::store_registers (struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (-1 == regno)
     {
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 1feb69fe6dd..be9aa384202 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -712,7 +712,7 @@ arm_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					void *cb_data,
 					const struct regcache *regcache)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   cb (".reg", ARM_LINUX_SIZEOF_GREGSET, ARM_LINUX_SIZEOF_GREGSET,
       &arm_linux_gregset, NULL, cb_data);
@@ -1716,7 +1716,7 @@ arm_linux_init_abi (struct gdbarch_info info,
 								    NULL };
   static const char *const stap_register_indirection_suffixes[] = { "]",
 								    NULL };
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 1);
 
diff --git a/gdb/arm-netbsd-nat.c b/gdb/arm-netbsd-nat.c
index 251159154c9..62cae277749 100644
--- a/gdb/arm-netbsd-nat.c
+++ b/gdb/arm-netbsd-nat.c
@@ -50,7 +50,7 @@ static arm_netbsd_nat_target the_arm_netbsd_nat_target;
 static void
 arm_supply_vfpregset (struct regcache *regcache, struct fpreg *fpregset)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (regcache->arch ());
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (regcache->arch ());
   if (tdep->vfp_register_count == 0)
     return;
 
@@ -97,7 +97,7 @@ fetch_fp_register (struct regcache *regcache, int regno)
       return;
     }
 
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (regcache->arch ());
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (regcache->arch ());
   if (regno == ARM_FPSCR_REGNUM && tdep->vfp_register_count != 0)
     regcache->raw_supply (ARM_FPSCR_REGNUM, (char *) &vfp.vfp_fpscr);
   else if (regno >= ARM_D0_REGNUM
@@ -279,7 +279,7 @@ store_fp_register (const struct regcache *regcache, int regno)
       return;
     }
 
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (regcache->arch ());
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (regcache->arch ());
   if (regno == ARM_FPSCR_REGNUM && tdep->vfp_register_count != 0)
     regcache->raw_collect (ARM_FPSCR_REGNUM, (char *) &vfp.vfp_fpscr);
   else if (regno >= ARM_D0_REGNUM
@@ -301,7 +301,7 @@ store_fp_register (const struct regcache *regcache, int regno)
 static void
 store_fp_regs (const struct regcache *regcache)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (regcache->arch ());
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (regcache->arch ());
   int lwp = regcache->ptid ().lwp ();
   if (tdep->vfp_register_count == 0)
     return;
diff --git a/gdb/arm-netbsd-tdep.c b/gdb/arm-netbsd-tdep.c
index aa4d15df4c6..de429b728b5 100644
--- a/gdb/arm-netbsd-tdep.c
+++ b/gdb/arm-netbsd-tdep.c
@@ -111,7 +111,7 @@ static void
 arm_netbsd_init_abi_common (struct gdbarch_info info,
 			    struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   tdep->lowest_pc = 0x8000;
   switch (info.byte_order)
@@ -148,7 +148,7 @@ static void
 arm_netbsd_elf_init_abi (struct gdbarch_info info,
 			 struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   arm_netbsd_init_abi_common (info, gdbarch);
 
diff --git a/gdb/arm-none-tdep.c b/gdb/arm-none-tdep.c
index 0d5eb04826e..53845e15701 100644
--- a/gdb/arm-none-tdep.c
+++ b/gdb/arm-none-tdep.c
@@ -177,7 +177,7 @@ arm_none_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				       void *cb_data,
 				       const struct regcache *regcache)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   cb (".reg", ARM_NONE_SIZEOF_GREGSET, ARM_NONE_SIZEOF_GREGSET,
       &arm_none_gregset, nullptr, cb_data);
diff --git a/gdb/arm-obsd-tdep.c b/gdb/arm-obsd-tdep.c
index 634c76b7561..93a6dcde173 100644
--- a/gdb/arm-obsd-tdep.c
+++ b/gdb/arm-obsd-tdep.c
@@ -76,7 +76,7 @@ static void
 armobsd_init_abi (struct gdbarch_info info,
 		  struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->fp_model == ARM_FLOAT_AUTO)
     tdep->fp_model = ARM_FLOAT_SOFT_VFP;
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index d3b4fce98a3..c75cbf5da00 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -355,7 +355,7 @@ static void
 arm_cache_init (struct arm_prologue_cache *cache, struct frame_info *frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   arm_cache_init (cache, gdbarch);
   cache->sp = get_frame_register_unsigned (frame, ARM_SP_REGNUM);
@@ -553,7 +553,7 @@ bool arm_unwind_secure_frames = true;
 int
 arm_psr_thumb_bit (struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->is_m)
     return XPSR_T;
@@ -665,7 +665,7 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr)
   struct bound_minimal_symbol sym;
   char type;
   arm_displaced_step_copy_insn_closure *dsc = nullptr;
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (gdbarch_displaced_step_copy_insn_closure_by_addr_p (gdbarch))
     dsc = ((arm_displaced_step_copy_insn_closure * )
@@ -769,7 +769,7 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr)
 static int
 arm_m_addr_is_magic (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   if (tdep->have_sec_ext)
     {
       switch ((addr & 0xff000000))
@@ -811,7 +811,7 @@ arm_m_addr_is_magic (struct gdbarch *gdbarch, CORE_ADDR addr)
 static CORE_ADDR
 arm_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR val)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* On M-profile devices, do not strip the low bit from EXC_RETURN
      (the magic exception return address).  */
@@ -939,7 +939,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
 			CORE_ADDR start, CORE_ADDR limit,
 			struct arm_prologue_cache *cache)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
   int i;
@@ -1879,7 +1879,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
   CORE_ADDR offset, current_pc;
   pv_t regs[ARM_FPS_REGNUM];
   CORE_ADDR unrecognized_pc = 0;
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Search the prologue looking for instructions that set up the
      frame pointer, adjust the stack pointer, and save registers.
@@ -2127,7 +2127,7 @@ arm_scan_prologue (struct frame_info *this_frame,
   CORE_ADDR prologue_start, prologue_end;
   CORE_ADDR prev_pc = get_frame_pc (this_frame);
   CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Assume there is no frame until proven otherwise.  */
   cache->framereg = ARM_SP_REGNUM;
@@ -2232,7 +2232,7 @@ arm_make_prologue_cache (struct frame_info *this_frame)
     return cache;
 
   arm_gdbarch_tdep *tdep =
-    gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
 
   prev_sp = unwound_fp + cache->framesize;
   arm_cache_set_active_sp_value (cache, tdep, prev_sp);
@@ -2263,7 +2263,7 @@ arm_prologue_unwind_stop_reason (struct frame_info *this_frame,
   /* This is meant to halt the backtrace at "_start".  */
   pc = get_frame_pc (this_frame);
   gdbarch *arch = get_frame_arch (this_frame);
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (arch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (arch);
   if (pc <= tdep->lowest_pc)
     return UNWIND_OUTERMOST;
 
@@ -2291,7 +2291,7 @@ arm_prologue_this_id (struct frame_info *this_frame,
   cache = (struct arm_prologue_cache *) *this_cache;
 
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
 
   /* Use function start address as part of the frame ID.  If we cannot
      identify the start address (due to missing symbol information),
@@ -2318,7 +2318,7 @@ arm_prologue_prev_register (struct frame_info *this_frame,
     *this_cache = arm_make_prologue_cache (this_frame);
   cache = (struct arm_prologue_cache *) *this_cache;
 
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* If this frame has signed the return address, mark it as so.  */
   if (tdep->have_pacbti && cache->ra_signed_state.has_value ()
@@ -2986,7 +2986,7 @@ arm_exidx_fill_cache (struct frame_info *this_frame, gdb_byte *entry)
 
   /* We already got the previous SP.  */
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   arm_cache_set_active_sp_value (cache, tdep, vsp);
 
   return cache;
@@ -3111,7 +3111,7 @@ arm_make_epilogue_frame_cache (struct frame_info *this_frame)
 
   /* Since we are in epilogue, the SP has been restored.  */
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   arm_cache_set_active_sp_value (cache, tdep,
 				 get_frame_register_unsigned (this_frame,
 							      ARM_SP_REGNUM));
@@ -3150,7 +3150,7 @@ arm_epilogue_frame_this_id (struct frame_info *this_frame,
     func = pc;
 
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   *this_id = frame_id_build (arm_cache_get_prev_sp_value (cache, tdep), pc);
 }
 
@@ -3274,7 +3274,7 @@ arm_make_stub_cache (struct frame_info *this_frame)
   arm_cache_init (cache, this_frame);
 
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   arm_cache_set_active_sp_value (cache, tdep,
 				 get_frame_register_unsigned (this_frame,
 							      ARM_SP_REGNUM));
@@ -3296,7 +3296,7 @@ arm_stub_this_id (struct frame_info *this_frame,
   cache = (struct arm_prologue_cache *) *this_cache;
 
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   *this_id = frame_id_build (arm_cache_get_prev_sp_value (cache, tdep),
 			     get_frame_pc (this_frame));
 }
@@ -3344,7 +3344,7 @@ static struct arm_prologue_cache *
 arm_m_exception_cache (struct frame_info *this_frame)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct arm_prologue_cache *cache;
   CORE_ADDR lr;
@@ -3655,7 +3655,7 @@ arm_m_exception_this_id (struct frame_info *this_frame,
 
   /* Our frame ID for a stub frame is the current SP and LR.  */
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   *this_id = frame_id_build (arm_cache_get_prev_sp_value (cache, tdep),
 			     get_frame_pc (this_frame));
 }
@@ -3677,7 +3677,7 @@ arm_m_exception_prev_register (struct frame_info *this_frame,
 
   /* The value was already reconstructed into PREV_SP.  */
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   if (prev_regnum == ARM_SP_REGNUM)
     return frame_unwind_got_constant (this_frame, prev_regnum,
 				      arm_cache_get_prev_sp_value (cache, tdep));
@@ -3765,7 +3765,7 @@ arm_normal_frame_base (struct frame_info *this_frame, void **this_cache)
   cache = (struct arm_prologue_cache *) *this_cache;
 
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (get_frame_arch (this_frame));
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (get_frame_arch (this_frame));
   return arm_cache_get_prev_sp_value (cache, tdep) - cache->framesize;
 }
 
@@ -3781,7 +3781,7 @@ arm_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache,
 			  int regnum)
 {
   struct gdbarch * gdbarch = get_frame_arch (this_frame);
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   CORE_ADDR lr;
   ULONGEST cpsr;
 
@@ -4305,7 +4305,7 @@ arm_vfp_call_candidate (struct type *t, enum arm_vfp_cprc_base_type *base_type,
 static int
 arm_vfp_abi_for_function (struct gdbarch *gdbarch, struct type *func_type)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Variadic functions always use the base ABI.  Assume that functions
      without debug info are not variadic.  */
@@ -4339,7 +4339,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int use_vfp_abi;
   struct type *ftype;
   unsigned vfp_regs_free = (1 << 16) - 1;
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Determine the type of this function and whether the VFP ABI
      applies.  */
@@ -4611,7 +4611,7 @@ arm_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 static struct type *
 arm_ext_type (struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (!tdep->arm_ext_type)
     tdep->arm_ext_type
@@ -4624,7 +4624,7 @@ arm_ext_type (struct gdbarch *gdbarch)
 static struct type *
 arm_neon_double_type (struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->neon_double_type == NULL)
     {
@@ -4663,7 +4663,7 @@ arm_neon_double_type (struct gdbarch *gdbarch)
 static struct type *
 arm_neon_quad_type (struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->neon_quad_type == NULL)
     {
@@ -4701,7 +4701,7 @@ arm_neon_quad_type (struct gdbarch *gdbarch)
 static bool
 is_q_pseudo (struct gdbarch *gdbarch, int regnum)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* Q pseudo registers are available for both NEON (Q0~Q15) and
      MVE (Q0~Q7) features.  */
@@ -4722,7 +4722,7 @@ is_q_pseudo (struct gdbarch *gdbarch, int regnum)
 static bool
 is_s_pseudo (struct gdbarch *gdbarch, int regnum)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->have_s_pseudos
       && regnum >= tdep->s_pseudo_base
@@ -4741,7 +4741,7 @@ is_s_pseudo (struct gdbarch *gdbarch, int regnum)
 static bool
 is_mve_pseudo (struct gdbarch *gdbarch, int regnum)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->have_mve
       && regnum >= tdep->mve_pseudo_base
@@ -4760,7 +4760,7 @@ is_mve_pseudo (struct gdbarch *gdbarch, int regnum)
 static bool
 is_pacbti_pseudo (struct gdbarch *gdbarch, int regnum)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->have_pacbti
       && regnum >= tdep->pacbti_pseudo_base
@@ -4776,7 +4776,7 @@ is_pacbti_pseudo (struct gdbarch *gdbarch, int regnum)
 static struct type *
 arm_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (is_s_pseudo (gdbarch, regnum))
     return builtin_type (gdbarch)->builtin_float;
@@ -4855,7 +4855,7 @@ arm_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
   /* PACBTI register containing the Pointer Authentication Code.  */
   if (reg == ARM_DWARF_RA_AUTH_CODE)
     {
-      arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+      arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
       if (tdep->have_pacbti)
 	return tdep->pacbti_pseudo_base;
@@ -5001,7 +5001,7 @@ arm_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
   int buf_len;
   enum bfd_endian order = gdbarch_byte_order_for_code (gdbarch);
   int i, any, last_it, last_it_count;
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* If we are using BKPT breakpoints, none of this is necessary.  */
   if (tdep->thumb2_breakpoint == NULL)
@@ -8309,7 +8309,7 @@ arm_displaced_init_closure (struct gdbarch *gdbarch, CORE_ADDR from,
 			    CORE_ADDR to,
 			    arm_displaced_step_copy_insn_closure *dsc)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   unsigned int i, len, offset;
   enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
   int size = dsc->is_thumb? 2 : 4;
@@ -8472,7 +8472,7 @@ static const gdb_byte arm_default_thumb_be_breakpoint[] = THUMB_BE_BREAKPOINT;
 static int
 arm_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
 
   if (arm_pc_is_thumb (gdbarch, *pcptr))
@@ -8507,7 +8507,7 @@ arm_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 static const gdb_byte *
 arm_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   switch (kind)
     {
@@ -8579,7 +8579,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
 {
   struct gdbarch *gdbarch = regs->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (TYPE_CODE_FLT == type->code ())
     {
@@ -8690,7 +8690,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
       return (TYPE_LENGTH (type) > 16);
     }
 
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   if (tdep->arm_abi != ARM_ABI_APCS)
     {
       /* The AAPCS says all aggregates not larger than a word are returned
@@ -8796,7 +8796,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
   if (type->code () == TYPE_CODE_FLT)
     {
       gdb_byte buf[ARM_FP_REGISTER_SIZE];
-      arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+      arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
       switch (tdep->fp_model)
 	{
@@ -8885,7 +8885,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function,
 		  struct type *valtype, struct regcache *regcache,
 		  gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   struct type *func_type = function ? value_type (function) : NULL;
   enum arm_vfp_cprc_base_type vfp_base_type;
   int vfp_base_count;
@@ -8977,7 +8977,7 @@ static int
 arm_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR jb_addr;
   gdb_byte buf[ARM_INT_REGISTER_SIZE];
@@ -9170,7 +9170,7 @@ show_fp_model (struct ui_file *file, int from_tty,
       && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm)
     {
       arm_gdbarch_tdep *tdep
-	= gdbarch_tdep<arm_gdbarch_tdep> (target_gdbarch ());
+	= gdbarch_tdep_cast<arm_gdbarch_tdep> (target_gdbarch ());
 
       gdb_printf (file, _("\
 The current ARM floating point model is \"auto\" (currently \"%s\").\n"),
@@ -9210,7 +9210,7 @@ arm_show_abi (struct ui_file *file, int from_tty,
       && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm)
     {
       arm_gdbarch_tdep *tdep
-	= gdbarch_tdep<arm_gdbarch_tdep> (target_gdbarch ());
+	= gdbarch_tdep_cast<arm_gdbarch_tdep> (target_gdbarch ());
 
       gdb_printf (file, _("\
 The current ARM ABI is \"auto\" (currently \"%s\").\n"),
@@ -9289,7 +9289,7 @@ show_disassembly_style_sfunc (struct ui_file *file, int from_tty,
 static const char *
 arm_register_name (struct gdbarch *gdbarch, int i)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (is_s_pseudo (gdbarch, i))
     {
@@ -9460,7 +9460,7 @@ static enum register_status
 arm_mve_pseudo_read (struct gdbarch *gdbarch, readable_regcache *regcache,
 		     int regnum, gdb_byte *buf)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* P0 is the first 16 bits of VPR.  */
   return regcache->raw_read_part (tdep->mve_vpr_regnum, 0, 2, buf);
@@ -9474,7 +9474,7 @@ arm_pseudo_read (struct gdbarch *gdbarch, readable_regcache *regcache,
   char name_buf[4];
   gdb_byte reg_buf[8];
   int offset, double_regnum;
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   gdb_assert (regnum >= num_regs);
 
@@ -9546,7 +9546,7 @@ static void
 arm_mve_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache,
 		      int regnum, const gdb_byte *buf)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   /* P0 is the first 16 bits of VPR.  */
   regcache->raw_write_part (tdep->mve_vpr_regnum, 0, 2, buf);
@@ -9560,7 +9560,7 @@ arm_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache,
   char name_buf[4];
   gdb_byte reg_buf[8];
   int offset, double_regnum;
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   gdb_assert (regnum >= num_regs);
 
@@ -9648,7 +9648,7 @@ arm_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 static void
 arm_register_g_packet_guesses (struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->is_m)
     {
@@ -9691,7 +9691,7 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch)
 static int
 arm_code_of_frame_writable (struct gdbarch *gdbarch, struct frame_info *frame)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep->is_m && get_frame_type (frame) == SIGTRAMP_FRAME)
     {
@@ -10250,7 +10250,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
     {
       arm_gdbarch_tdep *tdep
-	= gdbarch_tdep<arm_gdbarch_tdep> (best_arch->gdbarch);
+	= gdbarch_tdep_cast<arm_gdbarch_tdep> (best_arch->gdbarch);
 
       if (arm_abi != ARM_ABI_AUTO && arm_abi != tdep->arm_abi)
 	continue;
@@ -10570,7 +10570,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 arm_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   if (tdep == NULL)
     return;
@@ -12779,7 +12779,7 @@ arm_record_coproc_data_proc (arm_insn_decode_record *arm_insn_r)
 {
   uint32_t op, op1_ebit, coproc, bits_24_25;
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep> (arm_insn_r->gdbarch);
+    = gdbarch_tdep_cast<arm_gdbarch_tdep> (arm_insn_r->gdbarch);
   struct regcache *reg_cache = arm_insn_r->regcache;
 
   arm_insn_r->opcode = bits (arm_insn_r->arm_insn, 24, 27);
@@ -13267,7 +13267,7 @@ static int
 thumb_record_ldm_stm_swi (arm_insn_decode_record *thumb_insn_r)
 {
   arm_gdbarch_tdep *tdep
-    = gdbarch_tdep<arm_gdbarch_tdep>  (thumb_insn_r->gdbarch);
+    = gdbarch_tdep_cast<arm_gdbarch_tdep>  (thumb_insn_r->gdbarch);
   struct regcache *reg_cache = thumb_insn_r->regcache;
 
   uint32_t ret = 0; /* function return value: -1:record failure ;  0:success  */
diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
index 5063b308809..fbe1ede4a45 100644
--- a/gdb/arm-wince-tdep.c
+++ b/gdb/arm-wince-tdep.c
@@ -115,7 +115,7 @@ arm_wince_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 static void
 arm_wince_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
+  arm_gdbarch_tdep *tdep = gdbarch_tdep_cast<arm_gdbarch_tdep> (gdbarch);
 
   windows_init_abi (info, gdbarch);
 
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 4722f7ee748..e4f51867bac 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -232,7 +232,7 @@ avr_register_type (struct gdbarch *gdbarch, int reg_nr)
   if (reg_nr == AVR_PC_REGNUM)
     return builtin_type (gdbarch)->builtin_uint32;
 
-  avr_gdbarch_tdep *tdep = gdbarch_tdep<avr_gdbarch_tdep> (gdbarch);
+  avr_gdbarch_tdep *tdep = gdbarch_tdep_cast<avr_gdbarch_tdep> (gdbarch);
   if (reg_nr == AVR_PSEUDO_PC_REGNUM)
     return tdep->pc_type;
 
@@ -750,7 +750,7 @@ avr_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end,
   gdb_assert (vpc < AVR_MAX_PROLOGUE_SIZE);
 
   /* Handle static small stack allocation using rcall or push.  */
-  avr_gdbarch_tdep *tdep = gdbarch_tdep<avr_gdbarch_tdep> (gdbarch);
+  avr_gdbarch_tdep *tdep = gdbarch_tdep_cast<avr_gdbarch_tdep> (gdbarch);
   while (scan_stage == 1 && vpc < len)
     {
       insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
@@ -1053,7 +1053,7 @@ avr_frame_unwind_cache (struct frame_info *this_frame,
 
   /* The previous frame's SP needed to be computed.  Save the computed
      value.  */
-  avr_gdbarch_tdep *tdep = gdbarch_tdep<avr_gdbarch_tdep> (gdbarch);
+  avr_gdbarch_tdep *tdep = gdbarch_tdep_cast<avr_gdbarch_tdep> (gdbarch);
   info->saved_regs[AVR_SP_REGNUM].set_value (info->prev_sp
 					     - 1 + tdep->call_length);
 
@@ -1135,7 +1135,7 @@ avr_frame_prev_register (struct frame_info *this_frame,
 	  int i;
 	  gdb_byte buf[3];
 	  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-	  avr_gdbarch_tdep *tdep = gdbarch_tdep<avr_gdbarch_tdep> (gdbarch);
+	  avr_gdbarch_tdep *tdep = gdbarch_tdep_cast<avr_gdbarch_tdep> (gdbarch);
 
 	  read_memory (info->saved_regs[AVR_PC_REGNUM].addr (),
 		       buf, tdep->call_length);
@@ -1277,7 +1277,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 {
   int i;
   gdb_byte buf[3];
-  avr_gdbarch_tdep *tdep = gdbarch_tdep<avr_gdbarch_tdep> (gdbarch);
+  avr_gdbarch_tdep *tdep = gdbarch_tdep_cast<avr_gdbarch_tdep> (gdbarch);
   int call_length = tdep->call_length;
   CORE_ADDR return_pc = avr_convert_iaddr_to_raw (bp_addr);
   int regnum = AVR_ARGN_REGNUM;
@@ -1461,7 +1461,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
     {
       avr_gdbarch_tdep *tdep
-	= gdbarch_tdep<avr_gdbarch_tdep> (best_arch->gdbarch);
+	= gdbarch_tdep_cast<avr_gdbarch_tdep> (best_arch->gdbarch);
 
       if (tdep->call_length == call_length)
 	return best_arch->gdbarch;
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index f232e22c37c..175f2424574 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -766,7 +766,7 @@ bfin_frame_align (struct gdbarch *gdbarch, CORE_ADDR address)
 enum bfin_abi
 bfin_abi (struct gdbarch *gdbarch)
 {
-  bfin_gdbarch_tdep *tdep = gdbarch_tdep<bfin_gdbarch_tdep> (gdbarch);
+  bfin_gdbarch_tdep *tdep = gdbarch_tdep_cast<bfin_gdbarch_tdep> (gdbarch);
   return tdep->bfin_abi;
 }
 
@@ -792,7 +792,7 @@ bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       bfin_gdbarch_tdep *tdep
-	= gdbarch_tdep<bfin_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<bfin_gdbarch_tdep> (arches->gdbarch);
 
       if (tdep->bfin_abi != abi)
 	continue;
diff --git a/gdb/cris-linux-tdep.c b/gdb/cris-linux-tdep.c
index b3ed7450e99..5da68cbe6a5 100644
--- a/gdb/cris-linux-tdep.c
+++ b/gdb/cris-linux-tdep.c
@@ -33,7 +33,7 @@
 static void
 cris_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 73110d97f2f..8b5a92efe0d 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -313,7 +313,7 @@ cris_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
 				  void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct cris_unwind_cache *info;
   CORE_ADDR addr;
@@ -450,7 +450,7 @@ static int
 crisv32_single_step_through_delay (struct gdbarch *gdbarch,
 				   struct frame_info *this_frame)
 {
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   ULONGEST erp;
   int ret = 0;
 
@@ -696,7 +696,7 @@ cris_frame_unwind_cache (struct frame_info *this_frame,
 			 void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   struct cris_unwind_cache *info;
 
   if ((*this_prologue_cache))
@@ -1334,7 +1334,7 @@ crisv32_scan_prologue (CORE_ADDR pc, struct frame_info *this_frame,
 static CORE_ADDR
 cris_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   CORE_ADDR func_addr, func_end;
   struct symtab_and_line sal;
   CORE_ADDR pc_after_prologue;
@@ -1369,7 +1369,7 @@ cris_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 static const gdb_byte *
 cris_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   static unsigned char break8_insn[] = {0x38, 0xe9};
   static unsigned char break15_insn[] = {0x3f, 0xe9};
 
@@ -1388,7 +1388,7 @@ static int
 cris_spec_reg_applicable (struct gdbarch *gdbarch,
 			  struct cris_spec_reg spec_reg)
 {
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   unsigned int version = tdep->cris_version;
   
   switch (spec_reg.applicable_version)
@@ -3767,7 +3767,7 @@ cris_supply_gregset (const struct regset *regset, struct regcache *regcache,
 		     int regnum, const void *gregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   int i;
   const cris_elf_greg_t *regp = static_cast<const cris_elf_greg_t *>(gregs);
 
@@ -3861,7 +3861,7 @@ Makes GDB use the NRP register instead of the ERP register in certain cases."),
 static void
 cris_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  cris_gdbarch_tdep *tdep = gdbarch_tdep<cris_gdbarch_tdep> (gdbarch);
+  cris_gdbarch_tdep *tdep = gdbarch_tdep_cast<cris_gdbarch_tdep> (gdbarch);
   if (tdep != NULL)
     {
       gdb_printf (file, "cris_dump_tdep: tdep->cris_version = %i\n",
@@ -3941,7 +3941,7 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       cris_gdbarch_tdep *tdep
-	= gdbarch_tdep<cris_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<cris_gdbarch_tdep> (arches->gdbarch);
 
       if (tdep->cris_version == usr_cmd_cris_version
 	  && tdep->cris_mode == usr_cmd_cris_mode
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index 01d4a0f28cb..a29652e1cf0 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -2684,7 +2684,7 @@ csky_pseudo_register_name (struct gdbarch *gdbarch, int regno)
 {
   int num_regs = gdbarch_num_regs (gdbarch);
   csky_gdbarch_tdep *tdep
-    = gdbarch_tdep<csky_gdbarch_tdep> (gdbarch);
+    = gdbarch_tdep_cast<csky_gdbarch_tdep> (gdbarch);
 
   regno -= num_regs;
 
@@ -2732,7 +2732,7 @@ csky_pseudo_register_read (struct gdbarch *gdbarch,
 {
   int num_regs = gdbarch_num_regs (gdbarch);
   csky_gdbarch_tdep *tdep
-    = gdbarch_tdep<csky_gdbarch_tdep> (gdbarch);
+    = gdbarch_tdep_cast<csky_gdbarch_tdep> (gdbarch);
 
   regnum -= num_regs;
 
@@ -2784,7 +2784,7 @@ csky_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 {
   int num_regs = gdbarch_num_regs (gdbarch);
   csky_gdbarch_tdep *tdep
-    = gdbarch_tdep<csky_gdbarch_tdep> (gdbarch);
+    = gdbarch_tdep_cast<csky_gdbarch_tdep> (gdbarch);
 
   regnum -= num_regs;
 
@@ -2912,7 +2912,7 @@ csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       csky_gdbarch_tdep *tdep
-	= gdbarch_tdep<csky_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<csky_gdbarch_tdep> (arches->gdbarch);
       if (fpu_abi != tdep->fpu_abi)
         continue;
       if (vdsp_version != tdep->vdsp_version)
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 34f437764a9..ddd3e7181ef 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -93,7 +93,7 @@ struct frv_gdbarch_tdep : gdbarch_tdep
 enum frv_abi
 frv_abi (struct gdbarch *gdbarch)
 {
-  frv_gdbarch_tdep *tdep = gdbarch_tdep<frv_gdbarch_tdep> (gdbarch);
+  frv_gdbarch_tdep *tdep = gdbarch_tdep_cast<frv_gdbarch_tdep> (gdbarch);
   return tdep->frv_abi;
 }
 
@@ -275,7 +275,7 @@ frv_register_name (struct gdbarch *gdbarch, int reg)
   if (reg >= frv_num_regs + frv_num_pseudo_regs)
     return "?toolarge?";
 
-  frv_gdbarch_tdep *tdep = gdbarch_tdep<frv_gdbarch_tdep> (gdbarch);
+  frv_gdbarch_tdep *tdep = gdbarch_tdep_cast<frv_gdbarch_tdep> (gdbarch);
   return tdep->register_names[reg];
 }
 
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 024ca47ce4d..8949806ba0c 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -110,7 +110,7 @@ ft32_register_type (struct gdbarch *gdbarch, int reg_nr)
 {
   if (reg_nr == FT32_PC_REGNUM)
     {
-      ft32_gdbarch_tdep *tdep = gdbarch_tdep<ft32_gdbarch_tdep> (gdbarch);
+      ft32_gdbarch_tdep *tdep = gdbarch_tdep_cast<ft32_gdbarch_tdep> (gdbarch);
       return tdep->pc_type;
     }
   else if (reg_nr == FT32_SP_REGNUM || reg_nr == FT32_FP_REGNUM)
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 16c73915c64..16dc0cfc0ec 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -162,7 +162,7 @@ extern struct gdbarch_tdep *gdbarch_tdep_1 (struct gdbarch *gdbarch);
 
 template<typename TDepType>
 static inline TDepType *
-gdbarch_tdep (struct gdbarch *gdbarch)
+gdbarch_tdep_cast (struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep_1 (gdbarch);
   return gdb::checked_static_cast<TDepType *> (tdep);
diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c
index c405511529d..104182fae1a 100644
--- a/gdb/hppa-bsd-tdep.c
+++ b/gdb/hppa-bsd-tdep.c
@@ -118,7 +118,7 @@ hppabsd_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 void
 hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+  hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
 
   /* OpenBSD and NetBSD have a 64-bit 'long double'.  */
   set_gdbarch_long_double_bit (gdbarch, 64);
diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
index f17d2ae6b02..82bcda34a04 100644
--- a/gdb/hppa-linux-tdep.c
+++ b/gdb/hppa-linux-tdep.c
@@ -476,7 +476,7 @@ hppa_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					 void *cb_data,
 					 const struct regcache *regcache)
 {
-  hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+  hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
 
   cb (".reg", 80 * tdep->bytes_per_address, 80 * tdep->bytes_per_address,
       &hppa_linux_regset, NULL, cb_data);
@@ -486,7 +486,7 @@ hppa_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 static void
 hppa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+  hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 9f93a945a6a..a5029bc3fe4 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -247,7 +247,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table,
   if (size > 0)
     {
       struct gdbarch *gdbarch = objfile->arch ();
-      hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+      hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
       unsigned long tmp;
       unsigned i;
       char *buf = (char *) alloca (size);
@@ -718,7 +718,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   /* Global pointer (r19) of the function we are trying to call.  */
   CORE_ADDR gp;
 
-  hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+  hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
 
   for (write_pass = 0; write_pass < 2; write_pass++)
     {
@@ -955,7 +955,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			function_call_return_method return_method,
 			CORE_ADDR struct_addr)
 {
-  hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+  hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i, offset = 0;
   CORE_ADDR gp;
@@ -2241,7 +2241,7 @@ hppa_frame_cache (struct frame_info *this_frame, void **this_cache)
   }
 
   {
-    hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+    hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
 
     if (tdep->unwind_adjust_stub)
       tdep->unwind_adjust_stub (this_frame, cache->base, cache->saved_regs);
@@ -2471,7 +2471,7 @@ hppa_stub_unwind_sniffer (const struct frame_unwind *self,
 {
   CORE_ADDR pc = get_frame_address_in_block (this_frame);
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+  hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
 
   if (pc == 0
       || (tdep->in_solib_call_trampoline != NULL
@@ -3147,7 +3147,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 hppa_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  hppa_gdbarch_tdep *tdep = gdbarch_tdep<hppa_gdbarch_tdep> (gdbarch);
+  hppa_gdbarch_tdep *tdep = gdbarch_tdep_cast<hppa_gdbarch_tdep> (gdbarch);
 
   gdb_printf (file, "bytes_per_address = %d\n", 
 	      tdep->bytes_per_address);
diff --git a/gdb/i386-bsd-tdep.c b/gdb/i386-bsd-tdep.c
index dbbd3c786c3..e2c9ac0042b 100644
--- a/gdb/i386-bsd-tdep.c
+++ b/gdb/i386-bsd-tdep.c
@@ -74,7 +74,7 @@ int i386bsd_sc_reg_offset[] =
 void
 i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   tdep->jb_pc_offset = 0;
 
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index 2a9198aceb3..8cbe1a90826 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -156,7 +156,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			     function_call_return_method return_method,
 			     CORE_ADDR struct_addr)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   int i;
@@ -248,7 +248,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 static void
 i386_darwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* We support the SSE registers.  */
   tdep->num_xmm_regs = I386_NUM_XREGS - 1;
diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c
index b7a524db68c..9d8d7c1615a 100644
--- a/gdb/i386-fbsd-tdep.c
+++ b/gdb/i386-fbsd-tdep.c
@@ -325,7 +325,7 @@ i386fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				       void *cb_data,
 				       const struct regcache *regcache)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   cb (".reg", I386_FBSD_SIZEOF_GREGSET, I386_FBSD_SIZEOF_GREGSET,
       &i386_fbsd_gregset, NULL, cb_data);
@@ -365,7 +365,7 @@ i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 static void
 i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* Generic FreeBSD support. */
   fbsd_init_abi (info, gdbarch);
diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c
index 3d97fe36a85..97a512975be 100644
--- a/gdb/i386-gnu-tdep.c
+++ b/gdb/i386-gnu-tdep.c
@@ -173,7 +173,7 @@ static int i386gnu_gregset_reg_offset[] =
 static void
 i386gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* GNU uses ELF.  */
   i386_elf_init_abi (info, gdbarch);
diff --git a/gdb/i386-go32-tdep.c b/gdb/i386-go32-tdep.c
index 0c0c08e3579..9d591158be6 100644
--- a/gdb/i386-go32-tdep.c
+++ b/gdb/i386-go32-tdep.c
@@ -26,7 +26,7 @@
 static void
 i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* DJGPP doesn't have any special frames for signal handlers.  */
   tdep->sigtramp_p = NULL;
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 6033104230f..0764b8d9bd9 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -763,7 +763,7 @@ i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					 void *cb_data,
 					 const struct regcache *regcache)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   cb (".reg", 68, 68, &i386_gregset, NULL, cb_data);
 
@@ -825,7 +825,7 @@ i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch,
 static void
 i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   const struct target_desc *tdesc = info.target_desc;
   struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   const struct tdesc_feature *feature;
diff --git a/gdb/i386-netbsd-tdep.c b/gdb/i386-netbsd-tdep.c
index a9ebc3dd827..f0aa7f4837e 100644
--- a/gdb/i386-netbsd-tdep.c
+++ b/gdb/i386-netbsd-tdep.c
@@ -372,7 +372,7 @@ i386nbsd_sigtramp_cache_init (const struct tramp_frame *self,
 static void 
 i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* Obviously NetBSD is BSD-based.  */
   i386bsd_init_abi (info, gdbarch);
@@ -407,7 +407,7 @@ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static void
 i386nbsdelf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* It's still NetBSD.  */
   i386nbsd_init_abi (info, gdbarch);
diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
index 259867f262b..731f9d326b0 100644
--- a/gdb/i386-nto-tdep.c
+++ b/gdb/i386-nto-tdep.c
@@ -77,7 +77,7 @@ static void
 i386nto_supply_gregset (struct regcache *regcache, char *gpregs)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   gdb_assert (tdep->gregset_reg_offset == i386nto_gregset_reg_offset);
   i386_gregset.supply_regset (&i386_gregset, regcache, -1,
@@ -126,7 +126,7 @@ static int
 i386nto_register_area (struct gdbarch *gdbarch,
 		       int regno, int regset, unsigned *off)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   *off = 0;
   if (regset == NTO_REG_GENERAL)
@@ -315,7 +315,7 @@ init_i386nto_ops (void)
 static void
 i386nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   static struct target_so_ops nto_svr4_so_ops;
 
   /* Deal with our strange signals.  */
diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c
index 798094509c6..e0bd677d866 100644
--- a/gdb/i386-obsd-tdep.c
+++ b/gdb/i386-obsd-tdep.c
@@ -407,7 +407,7 @@ static const struct frame_unwind i386obsd_trapframe_unwind = {
 static void 
 i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* Obviously OpenBSD is BSD-based.  */
   i386bsd_init_abi (info, gdbarch);
diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c
index 5ee108d3578..a5c7ccf74a3 100644
--- a/gdb/i386-sol2-tdep.c
+++ b/gdb/i386-sol2-tdep.c
@@ -65,7 +65,7 @@ i386_sol2_mcontext_addr (struct frame_info *this_frame)
 static void
 i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* Solaris is SVR4-based.  */
   i386_svr4_init_abi (info, gdbarch);
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index d500f6998c5..f940f60ac21 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -169,7 +169,7 @@ const int num_lower_zmm_regs = 16;
 static int
 i386_mmx_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int mm0_regnum = tdep->mm0_regnum;
 
   if (mm0_regnum < 0)
@@ -184,7 +184,7 @@ i386_mmx_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_byte_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   regnum -= tdep->al_regnum;
   return regnum >= 0 && regnum < tdep->num_byte_regs;
@@ -195,7 +195,7 @@ i386_byte_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_word_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   regnum -= tdep->ax_regnum;
   return regnum >= 0 && regnum < tdep->num_word_regs;
@@ -206,7 +206,7 @@ i386_word_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_dword_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int eax_regnum = tdep->eax_regnum;
 
   if (eax_regnum < 0)
@@ -221,7 +221,7 @@ i386_dword_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int zmm0h_regnum = tdep->zmm0h_regnum;
 
   if (zmm0h_regnum < 0)
@@ -234,7 +234,7 @@ i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int zmm0_regnum = tdep->zmm0_regnum;
 
   if (zmm0_regnum < 0)
@@ -247,7 +247,7 @@ i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_k_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int k0_regnum = tdep->k0_regnum;
 
   if (k0_regnum < 0)
@@ -260,7 +260,7 @@ i386_k_regnum_p (struct gdbarch *gdbarch, int regnum)
 static int
 i386_ymmh_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int ymm0h_regnum = tdep->ymm0h_regnum;
 
   if (ymm0h_regnum < 0)
@@ -275,7 +275,7 @@ i386_ymmh_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int ymm0_regnum = tdep->ymm0_regnum;
 
   if (ymm0_regnum < 0)
@@ -288,7 +288,7 @@ i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum)
 static int
 i386_ymmh_avx512_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int ymm16h_regnum = tdep->ymm16h_regnum;
 
   if (ymm16h_regnum < 0)
@@ -301,7 +301,7 @@ i386_ymmh_avx512_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_ymm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int ymm16_regnum = tdep->ymm16_regnum;
 
   if (ymm16_regnum < 0)
@@ -316,7 +316,7 @@ i386_ymm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_bnd_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int bnd0_regnum = tdep->bnd0_regnum;
 
   if (bnd0_regnum < 0)
@@ -331,7 +331,7 @@ i386_bnd_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int num_xmm_regs = I387_NUM_XMM_REGS (tdep);
 
   if (num_xmm_regs == 0)
@@ -346,7 +346,7 @@ i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_xmm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int num_xmm_avx512_regs = I387_NUM_XMM_AVX512_REGS (tdep);
 
   if (num_xmm_avx512_regs == 0)
@@ -359,7 +359,7 @@ i386_xmm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum)
 static int
 i386_mxcsr_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (I387_NUM_XMM_REGS (tdep) == 0)
     return 0;
@@ -372,7 +372,7 @@ i386_mxcsr_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_fp_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (I387_ST0_REGNUM (tdep) < 0)
     return 0;
@@ -384,7 +384,7 @@ i386_fp_regnum_p (struct gdbarch *gdbarch, int regnum)
 int
 i386_fpc_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (I387_ST0_REGNUM (tdep) < 0)
     return 0;
@@ -398,7 +398,7 @@ i386_fpc_regnum_p (struct gdbarch *gdbarch, int regnum)
 static int
 i386_bndr_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
    if (I387_BND0R_REGNUM (tdep) < 0)
      return 0;
@@ -412,7 +412,7 @@ i386_bndr_regnum_p (struct gdbarch *gdbarch, int regnum)
 static int
 i386_mpx_ctrl_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
    if (I387_BNDCFGU_REGNUM (tdep) < 0)
      return 0;
@@ -426,7 +426,7 @@ i386_mpx_ctrl_regnum_p (struct gdbarch *gdbarch, int regnum)
 bool
 i386_pkru_regnum_p (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int pkru_regnum = tdep->pkru_regnum;
 
   if (pkru_regnum < 0)
@@ -462,7 +462,7 @@ i386_register_name (struct gdbarch *gdbarch, int regnum)
 const char *
 i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   if (i386_bnd_regnum_p (gdbarch, regnum))
     return i386_bnd_names[regnum - tdep->bnd0_regnum];
   if (i386_mmx_regnum_p (gdbarch, regnum))
@@ -485,7 +485,7 @@ i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 static int
 i386_dbx_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* This implements what GCC calls the "default" register map
      (dbx_register_map[]).  */
@@ -532,7 +532,7 @@ i386_dbx_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 static int
 i386_svr4_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* This implements the GCC register map that tries to be compatible
      with the SVR4 C compiler for DWARF (svr4_dbx_register_map[]).  */
@@ -2434,7 +2434,7 @@ static struct i386_frame_cache *
 i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct i386_frame_cache *cache;
   CORE_ADDR addr;
@@ -2524,7 +2524,7 @@ i386_sigtramp_frame_sniffer (const struct frame_unwind *self,
 			     void **this_prologue_cache)
 {
   gdbarch *arch = get_frame_arch (this_frame);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
 
   /* We shouldn't even bother if we don't have a sigcontext_addr
      handler.  */
@@ -2611,7 +2611,7 @@ i386_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
   CORE_ADDR sp, jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int jb_pc_offset = tdep->jb_pc_offset;
 
   /* If JB_PC_OFFSET is -1, we have no way to find out where the
@@ -2860,7 +2860,7 @@ static void
 i386_extract_return_value (struct gdbarch *gdbarch, struct type *type,
 			   struct regcache *regcache, gdb_byte *valbuf)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int len = TYPE_LENGTH (type);
   gdb_byte buf[I386_MAX_REGISTER_SIZE];
 
@@ -2918,7 +2918,7 @@ static void
 i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
 			 struct regcache *regcache, const gdb_byte *valbuf)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int len = TYPE_LENGTH (type);
 
   if (type->code () == TYPE_CODE_FLT)
@@ -2997,7 +2997,7 @@ static const char *struct_convention = default_struct_convention;
 static int
 i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   enum type_code code = type->code ();
   int len = TYPE_LENGTH (type);
 
@@ -3099,7 +3099,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
 struct type *
 i387_ext_type (struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (!tdep->i387_ext_type)
     {
@@ -3117,7 +3117,7 @@ i387_ext_type (struct gdbarch *gdbarch)
 static struct type *
 i386_bnd_type (struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
 
   if (!tdep->i386_bnd_type)
@@ -3153,7 +3153,7 @@ i386_bnd_type (struct gdbarch *gdbarch)
 static struct type *
 i386_zmm_type (struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (!tdep->i386_zmm_type)
     {
@@ -3212,7 +3212,7 @@ i386_zmm_type (struct gdbarch *gdbarch)
 static struct type *
 i386_ymm_type (struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (!tdep->i386_ymm_type)
     {
@@ -3269,7 +3269,7 @@ i386_ymm_type (struct gdbarch *gdbarch)
 static struct type *
 i386_mmx_type (struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (!tdep->i386_mmx_type)
     {
@@ -3346,7 +3346,7 @@ static int
 i386_mmx_regnum_to_fp_regnum (readable_regcache *regcache, int regnum)
 {
   gdbarch *arch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
   int mmxreg, fpreg;
   ULONGEST fstat;
   int tos;
@@ -3387,7 +3387,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch,
     }
   else
     {
-      i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+      i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
       if (i386_bnd_regnum_p (gdbarch, regnum))
 	{
 	  regnum -= tdep->bnd0_regnum;
@@ -3577,7 +3577,7 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
     }
   else
     {
-      i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+      i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
       if (i386_bnd_regnum_p (gdbarch, regnum))
 	{
@@ -3685,7 +3685,7 @@ int
 i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 				 struct agent_expr *ax, int regnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (i386_mmx_regnum_p (gdbarch, regnum))
     {
@@ -3902,7 +3902,7 @@ i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
 		     int regnum, const void *gregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   const gdb_byte *regs = (const gdb_byte *) gregs;
   int i;
 
@@ -3927,7 +3927,7 @@ i386_collect_gregset (const struct regset *regset,
 		      int regnum, void *gregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   gdb_byte *regs = (gdb_byte *) gregs;
   int i;
 
@@ -3950,7 +3950,7 @@ i386_supply_fpregset (const struct regset *regset, struct regcache *regcache,
 		      int regnum, const void *fpregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (len == I387_SIZEOF_FXSAVE)
     {
@@ -3973,7 +3973,7 @@ i386_collect_fpregset (const struct regset *regset,
 		       int regnum, void *fpregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (len == I387_SIZEOF_FXSAVE)
     {
@@ -4005,7 +4005,7 @@ i386_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				   void *cb_data,
 				   const struct regcache *regcache)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, &i386_gregset, NULL,
       cb_data);
@@ -4510,7 +4510,7 @@ i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 void
 i386_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* System V Release 4 uses ELF.  */
   i386_elf_init_abi (info, gdbarch);
@@ -4552,7 +4552,7 @@ int
 i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 			  const struct reggroup *group)
 {
-  const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  const i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int fp_regnum_p, mmx_regnum_p, xmm_regnum_p, mxcsr_regnum_p,
       ymm_regnum_p, ymmh_regnum_p, ymm_avx512_regnum_p, ymmh_avx512_regnum_p,
       bndr_regnum_p, bnd_regnum_p, zmm_regnum_p, zmmh_regnum_p,
@@ -4997,7 +4997,7 @@ static int i386_record_floats (struct gdbarch *gdbarch,
 			       struct i386_record_s *ir,
 			       uint32_t iregnum)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   int i;
 
   /* Oza: Because of floating point insn push/pop of fpu stack is going to
@@ -5068,7 +5068,7 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   ULONGEST addr;
   gdb_byte buf[I386_MAX_REGISTER_SIZE];
   struct i386_record_s ir;
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   uint8_t rex_w = -1;
   uint8_t rex_r = 0;
 
@@ -8839,7 +8839,7 @@ i386_mpx_bd_base (void)
 
   rcache = get_current_regcache ();
   gdbarch *arch = rcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
 
   regstatus = regcache_raw_read_unsigned (rcache, tdep->bndcfgu_regnum, &ret);
 
@@ -8853,7 +8853,7 @@ int
 i386_mpx_enabled (void)
 {
   gdbarch *arch = get_current_arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
   const struct target_desc *tdesc = tdep->tdesc;
 
   return (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx") != NULL);
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
index 9eec6e28109..5a560fa628b 100644
--- a/gdb/i386-windows-tdep.c
+++ b/gdb/i386-windows-tdep.c
@@ -136,7 +136,7 @@ i386_windows_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 static void
 i386_windows_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   set_gdbarch_skip_trampoline_code (gdbarch, i386_windows_skip_trampoline_code);
 
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 42ed4eebc2c..cb06306c704 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -204,7 +204,7 @@ void
 i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 		       struct frame_info *frame, const char *args)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   ULONGEST fctrl;
   int fctrl_p;
   ULONGEST fstat;
@@ -440,7 +440,7 @@ void
 i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const gdb_byte *regs = (const gdb_byte *) fsave;
   int i;
@@ -495,7 +495,7 @@ void
 i387_collect_fsave (const struct regcache *regcache, int regnum, void *fsave)
 {
   gdbarch *arch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
   gdb_byte *regs = (gdb_byte *) fsave;
   int i;
 
@@ -589,7 +589,7 @@ void
 i387_supply_fxsave (struct regcache *regcache, int regnum, const void *fxsave)
 {
   gdbarch *arch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
   const gdb_byte *regs = (const gdb_byte *) fxsave;
   int i;
 
@@ -673,7 +673,7 @@ void
 i387_collect_fxsave (const struct regcache *regcache, int regnum, void *fxsave)
 {
   gdbarch *arch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (arch);
   gdb_byte *regs = (gdb_byte *) fxsave;
   int i;
 
@@ -906,7 +906,7 @@ i387_xsave_get_clear_bv (struct gdbarch *gdbarch, const void *xsave)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   const gdb_byte *regs = (const gdb_byte *) xsave;
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   /* Get `xstat_bv'.  The supported bits in `xstat_bv' are 8 bytes.  */
   ULONGEST xstate_bv = extract_unsigned_integer (XSAVE_XSTATE_BV_ADDR (regs),
@@ -926,7 +926,7 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
 {
   struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   const gdb_byte *regs = (const gdb_byte *) xsave;
   int i;
   /* In 64-bit mode the split between "low" and "high" ZMM registers is at
@@ -1349,7 +1349,7 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
 {
   struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   gdb_byte *p, *regs = (gdb_byte *) xsave;
   gdb_byte raw[I386_MAX_REGISTER_SIZE];
   ULONGEST initial_xstate_bv, clear_bv, xstate_bv = 0;
@@ -1934,7 +1934,7 @@ i387_tag (const gdb_byte *raw)
 void
 i387_return_value (struct gdbarch *gdbarch, struct regcache *regcache)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
   ULONGEST fstat;
 
   /* Set the top of the floating-point register stack to 7.  The
@@ -1957,7 +1957,7 @@ i387_return_value (struct gdbarch *gdbarch, struct regcache *regcache)
 void
 i387_reset_bnd_regs (struct gdbarch *gdbarch, struct regcache *regcache)
 {
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   if (I387_BND0R_REGNUM (tdep) > 0)
     {
diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c
index 508d4e6f7c6..be87fa8d711 100644
--- a/gdb/ia64-linux-tdep.c
+++ b/gdb/ia64-linux-tdep.c
@@ -216,7 +216,7 @@ ia64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 static void
 ia64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
+  ia64_gdbarch_tdep *tdep = gdbarch_tdep_cast<ia64_gdbarch_tdep> (gdbarch);
   static const char *const stap_register_prefixes[] = { "r", NULL };
   static const char *const stap_register_indirection_prefixes[] = { "[",
 								    NULL };
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index b7c1c0decae..30f09b37ddb 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -310,7 +310,7 @@ static const struct floatformat *floatformats_ia64_ext[2] =
 static struct type *
 ia64_ext_type (struct gdbarch *gdbarch)
 {
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
+  ia64_gdbarch_tdep *tdep = gdbarch_tdep_cast<ia64_gdbarch_tdep> (gdbarch);
 
   if (!tdep->ia64_ext_type)
     tdep->ia64_ext_type
@@ -2177,7 +2177,7 @@ ia64_sigtramp_frame_init_saved_regs (struct frame_info *this_frame,
 				     struct ia64_frame_cache *cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
+  ia64_gdbarch_tdep *tdep = gdbarch_tdep_cast<ia64_gdbarch_tdep> (gdbarch);
 
   if (tdep->sigcontext_register_address)
     {
@@ -2336,7 +2336,7 @@ ia64_sigtramp_frame_sniffer (const struct frame_unwind *self,
 			     void **this_cache)
 {
   gdbarch *arch = get_frame_arch (this_frame);
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (arch);
+  ia64_gdbarch_tdep *tdep = gdbarch_tdep_cast<ia64_gdbarch_tdep> (arch);
   if (tdep->pc_in_sigtramp)
     {
       CORE_ADDR pc = get_frame_pc (this_frame);
@@ -2485,7 +2485,7 @@ ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val,
   unw_word_t bsp, sof, cfm, psr, ip;
   struct frame_info *this_frame = (struct frame_info *) arg;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
+  ia64_gdbarch_tdep *tdep = gdbarch_tdep_cast<ia64_gdbarch_tdep> (gdbarch);
   
   /* We never call any libunwind routines that need to write registers.  */
   gdb_assert (!write);
@@ -3485,7 +3485,7 @@ ia64_find_global_pointer_from_dynamic_section (struct gdbarch *gdbarch,
 static CORE_ADDR
 ia64_find_global_pointer (struct gdbarch *gdbarch, CORE_ADDR faddr)
 {
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
+  ia64_gdbarch_tdep *tdep = gdbarch_tdep_cast<ia64_gdbarch_tdep> (gdbarch);
   CORE_ADDR addr = 0;
 
   if (tdep->find_global_pointer_from_solib)
@@ -3680,7 +3680,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      function_call_return_method return_method,
 		      CORE_ADDR struct_addr)
 {
-  ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
+  ia64_gdbarch_tdep *tdep = gdbarch_tdep_cast<ia64_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int argno;
   struct value *arg;
diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c
index 3a81ff31972..0ad208ebdb2 100644
--- a/gdb/loongarch-linux-tdep.c
+++ b/gdb/loongarch-linux-tdep.c
@@ -255,7 +255,7 @@ loongarch_linux_syscall_next_pc (struct frame_info *frame)
 static void
 loongarch_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  loongarch_gdbarch_tdep *tdep = gdbarch_tdep<loongarch_gdbarch_tdep> (gdbarch);
+  loongarch_gdbarch_tdep *tdep = gdbarch_tdep_cast<loongarch_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
index 5711e6f05d7..88e31c26da7 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -225,7 +225,7 @@ static CORE_ADDR
 loongarch_next_pc (struct regcache *regcache, CORE_ADDR cur_pc)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  loongarch_gdbarch_tdep *tdep = gdbarch_tdep<loongarch_gdbarch_tdep> (gdbarch);
+  loongarch_gdbarch_tdep *tdep = gdbarch_tdep_cast<loongarch_gdbarch_tdep> (gdbarch);
   insn_t insn = loongarch_fetch_instruction (cur_pc);
   size_t insn_len = loongarch_insn_length (insn);
   CORE_ADDR next_pc = cur_pc + insn_len;
@@ -1237,7 +1237,7 @@ loongarch_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 	 we are looking for.  If it doesn't then we can't reuse this
 	 gdbarch.  */
       loongarch_gdbarch_tdep *candidate_tdep
-	= gdbarch_tdep<loongarch_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<loongarch_gdbarch_tdep> (arches->gdbarch);
 
       if (candidate_tdep->abi_features != abi_features)
 	continue;
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 37456d16cb3..41ba294e865 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -142,7 +142,7 @@ struct m32c_gdbarch_tdep : gdbarch_tdep
 static void
 make_types (struct gdbarch *arch)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   unsigned long mach = gdbarch_bfd_arch_info (arch)->mach;
   int data_addr_reg_bits, code_addr_reg_bits;
   char type_name[50];
@@ -215,7 +215,7 @@ make_types (struct gdbarch *arch)
 static const char *
 m32c_register_name (struct gdbarch *gdbarch, int num)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   return tdep->regs[num].name;
 }
 
@@ -223,7 +223,7 @@ m32c_register_name (struct gdbarch *gdbarch, int num)
 static struct type *
 m32c_register_type (struct gdbarch *arch, int reg_nr)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   return tdep->regs[reg_nr].type;
 }
 
@@ -231,7 +231,7 @@ m32c_register_type (struct gdbarch *arch, int reg_nr)
 static int
 m32c_register_sim_regno (struct gdbarch *gdbarch, int reg_nr)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   return tdep->regs[reg_nr].sim_num;
 }
 
@@ -239,7 +239,7 @@ m32c_register_sim_regno (struct gdbarch *gdbarch, int reg_nr)
 static int
 m32c_debug_info_reg_to_regnum (struct gdbarch *gdbarch, int reg_nr)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   if (0 <= reg_nr && reg_nr <= M32C_MAX_DWARF_REGNUM
       && tdep->dwarf_regs[reg_nr])
     return tdep->dwarf_regs[reg_nr]->num;
@@ -254,7 +254,7 @@ static int
 m32c_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 			  const struct reggroup *group)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   struct m32c_reg *reg = &tdep->regs[regnum];
 
   /* The anonymous raw registers aren't in any groups.  */
@@ -330,7 +330,7 @@ static int
 m32c_read_flg (readable_regcache *cache)
 {
   gdbarch *arch = cache->arch ();
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   ULONGEST flg;
 
   cache->raw_read (tdep->flg->num, &flg);
@@ -530,7 +530,7 @@ static enum register_status
 m32c_r3r2r1r0_read (struct m32c_reg *reg, readable_regcache *cache, gdb_byte *buf)
 {
   gdbarch *arch = reg->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   int len = TYPE_LENGTH (tdep->r0->type);
   enum register_status status;
 
@@ -567,7 +567,7 @@ m32c_r3r2r1r0_write (struct m32c_reg *reg, struct regcache *cache,
 		     const gdb_byte *buf)
 {
   gdbarch *arch = reg->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   int len = TYPE_LENGTH (tdep->r0->type);
 
   if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
@@ -595,7 +595,7 @@ m32c_pseudo_register_read (struct gdbarch *arch,
 			   int cookednum,
 			   gdb_byte *buf)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   struct m32c_reg *reg;
 
   gdb_assert (0 <= cookednum && cookednum < tdep->num_regs);
@@ -613,7 +613,7 @@ m32c_pseudo_register_write (struct gdbarch *arch,
 			    int cookednum,
 			    const gdb_byte *buf)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   struct m32c_reg *reg;
 
   gdb_assert (0 <= cookednum && cookednum < tdep->num_regs);
@@ -638,7 +638,7 @@ add_reg (struct gdbarch *arch,
 	 struct m32c_reg *ry,
 	 int n)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   struct m32c_reg *r = &tdep->regs[tdep->num_regs];
 
   gdb_assert (tdep->num_regs < M32C_MAX_NUM_REGS);
@@ -678,7 +678,7 @@ set_dwarf_regnum (struct m32c_reg *reg, int num)
 
   /* Update the DWARF->reg mapping.  */
   gdbarch *arch = reg->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   tdep->dwarf_regs[num] = reg;
 }
 
@@ -800,7 +800,7 @@ mark_save_restore (struct m32c_reg *reg)
 static void
 make_regs (struct gdbarch *arch)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   int mach = gdbarch_bfd_arch_info (arch)->mach;
   int num_raw_regs;
   int num_cooked_regs;
@@ -1349,7 +1349,7 @@ m32c_pv_enter (struct m32c_pv_state *state, int size)
     return 1;
 
   gdbarch *arch = state->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   if (m32c_pv_push (state, state->fb, tdep->push_addr_bytes))
     return 1;
 
@@ -1379,7 +1379,7 @@ static int
 m32c_pv_pushm (struct m32c_pv_state *state, int src)
 {
   gdbarch *arch = state->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   /* The bits in SRC indicating which registers to save are:
      r0 r1 r2 r3 a0 a1 sb fb */
@@ -1400,7 +1400,7 @@ static int
 m32c_is_1st_arg_reg (struct m32c_pv_state *state, pv_t value)
 {
   gdbarch *arch = state->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   return (value.kind == pvk_register
 	  && (gdbarch_bfd_arch_info (state->arch)->mach == bfd_mach_m16c
@@ -1415,7 +1415,7 @@ static int
 m32c_is_arg_reg (struct m32c_pv_state *state, pv_t value)
 {
   gdbarch *arch = state->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   return (value.kind == pvk_register
 	  && (gdbarch_bfd_arch_info (state->arch)->mach == bfd_mach_m16c
@@ -1440,7 +1440,7 @@ m32c_is_arg_spill (struct m32c_pv_state *st,
 		   pv_t value)
 {
   gdbarch *arch = st->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   return (m32c_is_arg_reg (st, value)
 	  && loc.kind == srcdest_mem
@@ -1464,7 +1464,7 @@ m32c_is_struct_return (struct m32c_pv_state *st,
 		       pv_t value)
 {
   gdbarch *arch = st->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   return (m32c_is_1st_arg_reg (st, value)
 	  && !st->stack->find_reg (st->arch, value.reg, 0)
@@ -1482,7 +1482,7 @@ static int
 m32c_pushm_is_reg_save (struct m32c_pv_state *st, int src)
 {
   gdbarch *arch = st->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   /* The bits in SRC indicating which registers to save are:
      r0 r1 r2 r3 a0 a1 sb fb */
@@ -1510,7 +1510,7 @@ check_for_saved (void *prologue_untyped, pv_t addr, CORE_ADDR size, pv_t value)
 {
   struct m32c_prologue *prologue = (struct m32c_prologue *) prologue_untyped;
   struct gdbarch *arch = prologue->arch;
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   /* Is this the unchanged value of some register being saved on the
      stack?  */
@@ -1550,7 +1550,7 @@ m32c_analyze_prologue (struct gdbarch *arch,
 		       CORE_ADDR start, CORE_ADDR limit,
 		       struct m32c_prologue *prologue)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   unsigned long mach = gdbarch_bfd_arch_info (arch)->mach;
   CORE_ADDR after_last_frame_related_insn;
   struct m32c_pv_state st;
@@ -1881,7 +1881,7 @@ m32c_frame_base (struct frame_info *this_frame,
   struct m32c_prologue *p
     = m32c_analyze_frame_prologue (this_frame, this_prologue_cache);
   gdbarch *arch = get_frame_arch (this_frame);
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
 
   /* In functions that use alloca, the distance between the stack
      pointer and the frame base varies dynamically, so we can't use
@@ -1932,7 +1932,7 @@ m32c_prev_register (struct frame_info *this_frame,
 		    void **this_prologue_cache, int regnum)
 {
   gdbarch *arch = get_frame_arch (this_frame);
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (arch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (arch);
   struct m32c_prologue *p
     = m32c_analyze_frame_prologue (this_frame, this_prologue_cache);
   CORE_ADDR frame_base = m32c_frame_base (this_frame, this_prologue_cache);
@@ -2015,7 +2015,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      function_call_return_method return_method,
 		      CORE_ADDR struct_addr)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned long mach = gdbarch_bfd_arch_info (gdbarch)->mach;
   CORE_ADDR cfa;
@@ -2178,7 +2178,7 @@ m32c_return_value (struct gdbarch *gdbarch,
 		   gdb_byte *readbuf,
 		   const gdb_byte *writebuf)
 {
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum return_value_convention conv;
   ULONGEST valtype_len = TYPE_LENGTH (valtype);
@@ -2309,7 +2309,7 @@ static CORE_ADDR
 m32c_skip_trampoline_code (struct frame_info *frame, CORE_ADDR stop_pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* It would be nicer to simply look up the addresses of known
@@ -2555,7 +2555,7 @@ m32c_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc,
   struct m32c_prologue p;
 
   struct regcache *regcache = get_current_regcache ();
-  m32c_gdbarch_tdep *tdep = gdbarch_tdep<m32c_gdbarch_tdep> (gdbarch);
+  m32c_gdbarch_tdep *tdep = gdbarch_tdep_cast<m32c_gdbarch_tdep> (gdbarch);
   
   if (!find_pc_partial_function (pc, &name, &func_addr, &func_end))
     internal_error (__FILE__, __LINE__,
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 9eb18b937be..48d88926018 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -146,14 +146,14 @@ struct m68gc11_gdbarch_tdep : gdbarch_tdep
 static int
 stack_correction (gdbarch *arch)
 {
-  m68gc11_gdbarch_tdep *tdep = gdbarch_tdep<m68gc11_gdbarch_tdep> (arch);
+  m68gc11_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68gc11_gdbarch_tdep> (arch);
   return tdep->stack_correction;
 }
 
 static int
 use_page_register (gdbarch *arch)
 {
-  m68gc11_gdbarch_tdep *tdep = gdbarch_tdep<m68gc11_gdbarch_tdep> (arch);
+  m68gc11_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68gc11_gdbarch_tdep> (arch);
   return tdep->stack_correction;
 }
 
@@ -642,7 +642,7 @@ m68hc11_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
       return pc;
     }
 
-  m68gc11_gdbarch_tdep *tdep = gdbarch_tdep<m68gc11_gdbarch_tdep> (gdbarch);
+  m68gc11_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68gc11_gdbarch_tdep> (gdbarch);
   seq_table = tdep->prologue;
   
   /* The 68hc11 stack is as follows:
@@ -1020,7 +1020,7 @@ m68hc11_print_register (struct gdbarch *gdbarch, struct ui_file *file,
   else
     {
       m68gc11_gdbarch_tdep *tdep
-	= gdbarch_tdep<m68gc11_gdbarch_tdep> (gdbarch);
+	= gdbarch_tdep_cast<m68gc11_gdbarch_tdep> (gdbarch);
 
       if (regno == HARD_PC_REGNUM && tdep->use_page_register)
 	{
@@ -1125,7 +1125,7 @@ m68hc11_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
       gdb_printf (file, " Y=");
       m68hc11_print_register (gdbarch, file, frame, HARD_Y_REGNUM);
   
-      m68gc11_gdbarch_tdep *tdep = gdbarch_tdep<m68gc11_gdbarch_tdep> (gdbarch);
+      m68gc11_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68gc11_gdbarch_tdep> (gdbarch);
 
       if (tdep->use_page_register)
 	{
@@ -1417,7 +1417,7 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       m68gc11_gdbarch_tdep *tdep
-	= gdbarch_tdep<m68gc11_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<m68gc11_gdbarch_tdep> (arches->gdbarch);
 
       if (tdep->elf_flags != elf_flags)
 	continue;
diff --git a/gdb/m68k-bsd-tdep.c b/gdb/m68k-bsd-tdep.c
index 2614c223f8e..6223613457c 100644
--- a/gdb/m68k-bsd-tdep.c
+++ b/gdb/m68k-bsd-tdep.c
@@ -133,7 +133,7 @@ m68kbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 static void
 m68kbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   tdep->jb_pc = 5;
   tdep->jb_elt_size = 4;
diff --git a/gdb/m68k-linux-tdep.c b/gdb/m68k-linux-tdep.c
index 28401d3ecc6..4ecd80c3001 100644
--- a/gdb/m68k-linux-tdep.c
+++ b/gdb/m68k-linux-tdep.c
@@ -384,7 +384,7 @@ m68k_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 static void
 m68k_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 9e59f5904c3..e2b42d86933 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -70,7 +70,7 @@ typedef BP_MANIPULATION (m68k_break_insn) m68k_breakpoint;
 static struct type *
 m68k_ps_type (struct gdbarch *gdbarch)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (!tdep->m68k_ps_type)
     {
@@ -99,7 +99,7 @@ m68k_ps_type (struct gdbarch *gdbarch)
 static struct type *
 m68881_ext_type (struct gdbarch *gdbarch)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (!tdep->m68881_ext_type)
     tdep->m68881_ext_type
@@ -120,7 +120,7 @@ m68881_ext_type (struct gdbarch *gdbarch)
 static struct type *
 m68k_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep->fpregs_present)
     {
@@ -171,7 +171,7 @@ static const char * const m68k_register_names[] = {
 static const char *
 m68k_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (regnum < 0 || regnum >= ARRAY_SIZE (m68k_register_names))
     internal_error (__FILE__, __LINE__,
@@ -191,7 +191,7 @@ static int
 m68k_convert_register_p (struct gdbarch *gdbarch,
 			 int regnum, struct type *type)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (!tdep->fpregs_present)
     return 0;
@@ -300,7 +300,7 @@ m68k_extract_return_value (struct type *type, struct regcache *regcache,
   if (type->code () == TYPE_CODE_PTR && len == 4)
     {
       struct gdbarch *gdbarch = regcache->arch ();
-      m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+      m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
       regcache->raw_read (tdep->pointer_result_regnum, valbuf);
     }
   else if (len <= 4)
@@ -325,7 +325,7 @@ m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
 {
   gdb_byte buf[M68K_MAX_REGISTER_SIZE];
   struct gdbarch *gdbarch = regcache->arch ();
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep->float_return && type->code () == TYPE_CODE_FLT)
     {
@@ -348,7 +348,7 @@ m68k_store_return_value (struct type *type, struct regcache *regcache,
   if (type->code () == TYPE_CODE_PTR && len == 4)
     {
       struct gdbarch *gdbarch = regcache->arch ();
-      m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+      m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
       regcache->raw_write (tdep->pointer_result_regnum, valbuf);
       /* gdb historically also set D0 in the SVR4 case.  */
       if (tdep->pointer_result_regnum != M68K_D0_REGNUM)
@@ -371,7 +371,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
 			      const gdb_byte *valbuf)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep->float_return && type->code () == TYPE_CODE_FLT)
     {
@@ -391,7 +391,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
 static int
 m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
   enum type_code code = type->code ();
   int len = TYPE_LENGTH (type);
 
@@ -469,7 +469,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
 			gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   enum type_code code = type->code ();
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   /* Aggregates with a single member are always returned like their
      sole element.  */
@@ -541,7 +541,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      function_call_return_method return_method,
 		      CORE_ADDR struct_addr)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[4];
   int i;
@@ -596,7 +596,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 static int
 m68k_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int num)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (num < 8)
     /* d0..7 */
@@ -766,7 +766,7 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
 			     struct m68k_frame_cache *cache)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (cache->locals >= 0)
     {
@@ -1058,7 +1058,7 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
   gdb_byte *buf;
   CORE_ADDR sp, jb_addr;
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   if (tdep->jb_pc < 0)
@@ -1104,7 +1104,7 @@ m68k_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
 void
 m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   /* SVR4 uses a different calling convention.  */
   set_gdbarch_return_value (gdbarch, m68k_svr4_return_value);
@@ -1122,7 +1122,7 @@ m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 static void
 m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   m68k_svr4_init_abi (info, gdbarch);
   tdep->pointer_result_regnum = M68K_D0_REGNUM;
@@ -1237,7 +1237,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
     {
       m68k_gdbarch_tdep *tdep
-	= gdbarch_tdep<m68k_gdbarch_tdep> (best_arch->gdbarch);
+	= gdbarch_tdep_cast<m68k_gdbarch_tdep> (best_arch->gdbarch);
 
       if (flavour != tdep->flavour)
 	continue;
@@ -1339,7 +1339,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
+  m68k_gdbarch_tdep *tdep = gdbarch_tdep_cast<m68k_gdbarch_tdep> (gdbarch);
 
   if (tdep == NULL)
     return;
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index d5ba78c6df9..1e6a77af9a8 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -260,7 +260,7 @@ me_module_register_set (CONFIG_ATTR me_module,
        specifically excluding the generic coprocessor register sets.  */
 
   mep_gdbarch_tdep *tdep
-    = gdbarch_tdep<mep_gdbarch_tdep> (target_gdbarch ());
+    = gdbarch_tdep_cast<mep_gdbarch_tdep> (target_gdbarch ());
   CGEN_CPU_DESC desc = tdep->cpu_desc;
   const CGEN_HW_ENTRY *hw;
 
@@ -856,7 +856,7 @@ current_me_module (void)
   else
     {
       mep_gdbarch_tdep *tdep
-	= gdbarch_tdep<mep_gdbarch_tdep> (target_gdbarch ());
+	= gdbarch_tdep_cast<mep_gdbarch_tdep> (target_gdbarch ());
       return tdep->me_module;
     }
 }
@@ -2391,7 +2391,7 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       mep_gdbarch_tdep *tdep
-	= gdbarch_tdep<mep_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<mep_gdbarch_tdep> (arches->gdbarch);
 
       if (tdep->me_module == me_module)
 	return arches->gdbarch;
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index ca313a28279..b2297f0ab35 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -1317,7 +1317,7 @@ mips_linux_get_syscall_number (struct gdbarch *gdbarch,
 			       thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int regsize = register_size (gdbarch, MIPS_V0_REGNUM);
   /* The content of a register */
@@ -1527,7 +1527,7 @@ static void
 mips_linux_init_abi (struct gdbarch_info info,
 		     struct gdbarch *gdbarch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   enum mips_abi abi = mips_abi (gdbarch);
   struct tdesc_arch_data *tdesc_data = info.tdesc_data;
 
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 98270268584..1fc1a9109f4 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -227,7 +227,7 @@ static const char mips_disassembler_options_n64[] = "gpr-names=64";
 const struct mips_regnum *
 mips_regnum (struct gdbarch *gdbarch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   return tdep->regnum;
 }
 
@@ -252,7 +252,7 @@ mips_float_register_p (struct gdbarch *gdbarch, int regnum)
 static bool
 mips_eabi (gdbarch *arch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (arch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (arch);
   return (tdep->mips_abi == MIPS_ABI_EABI32 \
 	  || tdep->mips_abi == MIPS_ABI_EABI64);
 }
@@ -260,21 +260,21 @@ mips_eabi (gdbarch *arch)
 static int
 mips_last_fp_arg_regnum (gdbarch *arch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (arch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (arch);
   return tdep->mips_last_fp_arg_regnum;
 }
 
 static int
 mips_last_arg_regnum (gdbarch *arch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (arch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (arch);
   return tdep->mips_last_arg_regnum;
 }
 
 static enum mips_fpu_type
 mips_get_fpu_type (gdbarch *arch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (arch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (arch);
   return tdep->mips_fpu_type;
 }
 
@@ -282,14 +282,14 @@ mips_get_fpu_type (gdbarch *arch)
 enum mips_abi
 mips_abi (struct gdbarch *gdbarch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   return tdep->mips_abi;
 }
 
 int
 mips_isa_regsize (struct gdbarch *gdbarch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
   /* If we know how big the registers are, use that size.  */
   if (tdep->register_size_valid_p)
@@ -335,7 +335,7 @@ mips_abi_regsize (struct gdbarch *gdbarch)
 static int
 is_mips16_isa (struct gdbarch *gdbarch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   return tdep->mips_isa == ISA_MIPS16;
 }
 
@@ -344,7 +344,7 @@ is_mips16_isa (struct gdbarch *gdbarch)
 static int
 is_micromips_isa (struct gdbarch *gdbarch)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   return tdep->mips_isa == ISA_MICROMIPS;
 }
 
@@ -636,7 +636,7 @@ static const char * const mips_linux_reg_names[NUM_MIPS_PROCESSOR_REGS] = {
 static const char *
 mips_register_name (struct gdbarch *gdbarch, int regno)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   /* GPR names for all ABIs other than n32/n64.  */
   static const char *mips_gpr_names[] = {
     "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
@@ -777,7 +777,7 @@ mips_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
   else if (register_size (gdbarch, rawnum) >
 	   register_size (gdbarch, cookednum))
     {
-      mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+      mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
       if (tdep->mips64_transfers_32bit_regs_p)
 	return regcache->raw_read_part (rawnum, 0, 4, buf);
@@ -810,7 +810,7 @@ mips_pseudo_register_write (struct gdbarch *gdbarch,
   else if (register_size (gdbarch, rawnum) >
 	   register_size (gdbarch, cookednum))
     {
-      mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+      mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
       if (tdep->mips64_transfers_32bit_regs_p)
 	regcache->raw_write_part (rawnum, 0, 4, buf);
@@ -855,7 +855,7 @@ mips_ax_pseudo_register_push_stack (struct gdbarch *gdbarch,
       if (register_size (gdbarch, rawnum) > register_size (gdbarch, reg))
 	{
 	  mips_gdbarch_tdep *tdep
-	    = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+	    = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
 	  if (!tdep->mips64_transfers_32bit_regs_p
 	      || gdbarch_byte_order (gdbarch) != BFD_ENDIAN_BIG)
@@ -1059,7 +1059,7 @@ mips_register_type (struct gdbarch *gdbarch, int regnum)
   else
     {
       int rawnum = regnum - gdbarch_num_regs (gdbarch);
-      mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+      mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
       /* The cooked or ABI registers.  These are sized according to
 	 the ABI (with a few complications).  */
@@ -1191,7 +1191,7 @@ show_mask_address (struct ui_file *file, int from_tty,
       else
 	{
 	  mips_gdbarch_tdep *tdep
-	    = gdbarch_tdep<mips_gdbarch_tdep> (target_gdbarch ());
+	    = gdbarch_tdep_cast<mips_gdbarch_tdep> (target_gdbarch ());
 
 	  if (mips_mask_address_p (tdep))
 	    additional_text = _(" (currently \"on\")");
@@ -1727,7 +1727,7 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc)
 	    case 12:            /* SYSCALL */
 	      {
 		mips_gdbarch_tdep *tdep
-		  = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+		  = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
 		if (tdep->syscall_next_pc != NULL)
 		  pc = tdep->syscall_next_pc (get_current_frame ());
@@ -1938,7 +1938,7 @@ micromips_next_pc (struct regcache *regcache, CORE_ADDR pc)
 		case 0x22d: /* SYSCALL:  000000 1000101101 111100 */
 		  {
 		    mips_gdbarch_tdep *tdep
-		      = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+		      = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
 		    if (tdep->syscall_next_pc != NULL)
 		      pc = tdep->syscall_next_pc (get_current_frame ());
@@ -3901,7 +3901,7 @@ mips_stub_frame_base_sniffer (struct frame_info *this_frame)
 static CORE_ADDR
 mips_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
   if (mips_mask_address_p (tdep) && (((ULONGEST) addr) >> 32 == 0xffffffffUL))
     /* This hack is a work-around for existing boards using PMON, the
@@ -4804,7 +4804,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function,
 			struct type *type, struct regcache *regcache,
 			gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   int fp_return_type = 0;
   int offset, regnum, xfer;
 
@@ -5195,7 +5195,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
 			  struct type *type, struct regcache *regcache,
 			  gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
 
   /* From MIPSpro N32 ABI Handbook, Document Number: 007-2816-004
 
@@ -5704,7 +5704,7 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function,
 {
   CORE_ADDR func_addr = function ? find_function_addr (function, NULL) : 0;
   int mips16 = mips_pc_is_mips16 (gdbarch, func_addr);
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   enum mips_fval_reg fval_reg;
 
   fval_reg = readbuf ? mips16 ? mips_fval_gpr : mips_fval_fpr : mips_fval_both;
@@ -8101,7 +8101,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   else if (arches != NULL)
     {
       mips_gdbarch_tdep *tdep
-	= gdbarch_tdep<mips_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<mips_gdbarch_tdep> (arches->gdbarch);
       elf_flags = tdep->elf_flags;
     }
   else
@@ -8142,7 +8142,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   if (found_abi == MIPS_ABI_UNKNOWN && info.abfd == NULL && arches != NULL)
     {
       mips_gdbarch_tdep *tdep
-	= gdbarch_tdep<mips_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<mips_gdbarch_tdep> (arches->gdbarch);
       found_abi = tdep->found_abi;
     }
 
@@ -8459,7 +8459,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       mips_gdbarch_tdep *tdep
-	= gdbarch_tdep<mips_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<mips_gdbarch_tdep> (arches->gdbarch);
 
       /* MIPS needs to be pedantic about which ABI and the compressed
 	 ISA variation the object is using.  */
@@ -8917,7 +8917,7 @@ mips_fpu_type_str (enum mips_fpu_type fpu_type)
 static void
 mips_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  mips_gdbarch_tdep *tdep = gdbarch_tdep<mips_gdbarch_tdep> (gdbarch);
+  mips_gdbarch_tdep *tdep = gdbarch_tdep_cast<mips_gdbarch_tdep> (gdbarch);
   if (tdep != NULL)
     {
       int ef_mips_arch;
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 22511d894d4..817aba8a278 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -1412,7 +1412,7 @@ mn10300_gdbarch_init (struct gdbarch_info info,
 static void
 mn10300_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  mn10300_gdbarch_tdep *tdep = gdbarch_tdep<mn10300_gdbarch_tdep> (gdbarch);
+  mn10300_gdbarch_tdep *tdep = gdbarch_tdep_cast<mn10300_gdbarch_tdep> (gdbarch);
   gdb_printf (file, "mn10300_dump_tdep: am33_mode = %d\n",
 	      tdep->am33_mode);
 }
diff --git a/gdb/mn10300-tdep.h b/gdb/mn10300-tdep.h
index 87b861ead90..3e1a4873150 100644
--- a/gdb/mn10300-tdep.h
+++ b/gdb/mn10300-tdep.h
@@ -84,7 +84,7 @@ struct mn10300_gdbarch_tdep : gdbarch_tdep
 static inline int
 get_am33_mode (gdbarch *arch)
 {
-  mn10300_gdbarch_tdep *tdep = gdbarch_tdep<mn10300_gdbarch_tdep> (arch);
+  mn10300_gdbarch_tdep *tdep = gdbarch_tdep_cast<mn10300_gdbarch_tdep> (arch);
   return tdep->am33_mode;
 }
 
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index 4ae8b3d5626..4334485db8b 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -341,7 +341,7 @@ msp430_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc,
   int rn;
   pv_t reg[MSP430_NUM_TOTAL_REGS];
   CORE_ADDR after_last_frame_setup_insn = start_pc;
-  msp430_gdbarch_tdep *tdep = gdbarch_tdep<msp430_gdbarch_tdep> (gdbarch);
+  msp430_gdbarch_tdep *tdep = gdbarch_tdep_cast<msp430_gdbarch_tdep> (gdbarch);
   int code_model = tdep->code_model;
   int sz;
 
@@ -570,7 +570,7 @@ msp430_return_value (struct gdbarch *gdbarch,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   LONGEST valtype_len = TYPE_LENGTH (valtype);
-  msp430_gdbarch_tdep *tdep = gdbarch_tdep<msp430_gdbarch_tdep> (gdbarch);
+  msp430_gdbarch_tdep *tdep = gdbarch_tdep_cast<msp430_gdbarch_tdep> (gdbarch);
   int code_model = tdep->code_model;
 
   if (TYPE_LENGTH (valtype) > 8
@@ -651,7 +651,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int write_pass;
   int sp_off = 0;
   CORE_ADDR cfa;
-  msp430_gdbarch_tdep *tdep = gdbarch_tdep<msp430_gdbarch_tdep> (gdbarch);
+  msp430_gdbarch_tdep *tdep = gdbarch_tdep_cast<msp430_gdbarch_tdep> (gdbarch);
   int code_model = tdep->code_model;
 
   struct type *func_type = value_type (function);
@@ -814,7 +814,7 @@ msp430_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 
   stub_name = bms.minsym->linkage_name ();
 
-  msp430_gdbarch_tdep *tdep = gdbarch_tdep<msp430_gdbarch_tdep> (gdbarch);
+  msp430_gdbarch_tdep *tdep = gdbarch_tdep_cast<msp430_gdbarch_tdep> (gdbarch);
   if (tdep->code_model == MSP_SMALL_CODE_MODEL
       && msp430_in_return_stub (gdbarch, pc, stub_name))
     {
@@ -877,7 +877,7 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 	  if (ca && gdbarch_bfd_arch_info (ca)->arch == bfd_arch_msp430)
 	    {
 	      msp430_gdbarch_tdep *ca_tdep
-		= gdbarch_tdep<msp430_gdbarch_tdep> (ca);
+		= gdbarch_tdep_cast<msp430_gdbarch_tdep> (ca);
 
 	      elf_flags = ca_tdep->elf_flags;
 	      isa = ca_tdep->isa;
@@ -904,7 +904,7 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       msp430_gdbarch_tdep *candidate_tdep
-	= gdbarch_tdep<msp430_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<msp430_gdbarch_tdep> (arches->gdbarch);
 
       if (candidate_tdep->elf_flags != elf_flags
 	  || candidate_tdep->isa != isa
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index 11bfd2d1f54..0c10ea202e8 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -289,7 +289,7 @@ typedef BP_MANIPULATION (nds32_break_insn) nds32_breakpoint;
 static int
 nds32_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int num)
 {
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   const int FSR = 38;
   const int FDR = FSR + 32;
 
@@ -432,7 +432,7 @@ nds32_pseudo_register_read (struct gdbarch *gdbarch,
 			    readable_regcache *regcache, int regnum,
 			    gdb_byte *buf)
 {
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   gdb_byte reg_buf[8];
   int offset, fdr_regnum;
   enum register_status status;
@@ -471,7 +471,7 @@ nds32_pseudo_register_write (struct gdbarch *gdbarch,
 			     struct regcache *regcache, int regnum,
 			     const gdb_byte *buf)
 {
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   gdb_byte reg_buf[8];
   int offset, fdr_regnum;
 
@@ -608,7 +608,7 @@ static CORE_ADDR
 nds32_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
 			CORE_ADDR limit_pc, struct nds32_frame_cache *cache)
 {
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi);
   /* Current scanning status.  */
   int in_prologue_bb = 0;
@@ -1169,7 +1169,7 @@ static int
 nds32_analyze_epilogue (struct gdbarch *gdbarch, CORE_ADDR pc,
 			struct nds32_frame_cache *cache)
 {
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi);
   CORE_ADDR limit_pc;
   uint32_t insn, insn_len;
@@ -1220,7 +1220,7 @@ nds32_analyze_epilogue (struct gdbarch *gdbarch, CORE_ADDR pc,
 static int
 nds32_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi);
   int insn_type = INSN_NORMAL;
   int ret_found = 0;
@@ -1424,7 +1424,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int i;
   ULONGEST regval;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   struct type *func_type = value_type (function);
   int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi);
   int abi_split = nds32_abi_split (tdep->elf_abi);
@@ -1652,7 +1652,7 @@ nds32_extract_return_value (struct gdbarch *gdbarch, struct type *type,
 			    struct regcache *regcache, gdb_byte *valbuf)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi);
   int calling_use_fpr;
   int len;
@@ -1742,7 +1742,7 @@ nds32_store_return_value (struct gdbarch *gdbarch, struct type *type,
 			  struct regcache *regcache, const gdb_byte *valbuf)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
+  nds32_gdbarch_tdep *tdep = gdbarch_tdep_cast<nds32_gdbarch_tdep> (gdbarch);
   int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi);
   int calling_use_fpr;
   int len;
@@ -1965,7 +1965,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info))
     {
       nds32_gdbarch_tdep *idep
-	= gdbarch_tdep<nds32_gdbarch_tdep> (best_arch->gdbarch);
+	= gdbarch_tdep_cast<nds32_gdbarch_tdep> (best_arch->gdbarch);
 
       if (idep->elf_abi != elf_abi)
 	continue;
diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c
index da69638b20b..415a950a1bb 100644
--- a/gdb/nios2-linux-tdep.c
+++ b/gdb/nios2-linux-tdep.c
@@ -217,7 +217,7 @@ nios2_linux_is_kernel_helper (CORE_ADDR pc)
 static void
 nios2_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  nios2_gdbarch_tdep *tdep = gdbarch_tdep<nios2_gdbarch_tdep> (gdbarch);
+  nios2_gdbarch_tdep *tdep = gdbarch_tdep_cast<nios2_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c
index 0bad229b44a..e612c810b8d 100644
--- a/gdb/nios2-tdep.c
+++ b/gdb/nios2-tdep.c
@@ -2098,7 +2098,7 @@ static CORE_ADDR
 nios2_get_next_pc (struct regcache *regcache, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  nios2_gdbarch_tdep *tdep = gdbarch_tdep<nios2_gdbarch_tdep> (gdbarch);
+  nios2_gdbarch_tdep *tdep = gdbarch_tdep_cast<nios2_gdbarch_tdep> (gdbarch);
   unsigned long mach = gdbarch_bfd_arch_info (gdbarch)->mach;
   unsigned int insn;
   const struct nios2_opcode *op = nios2_fetch_insn (gdbarch, pc, &insn);
@@ -2221,7 +2221,7 @@ static int
 nios2_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  nios2_gdbarch_tdep *tdep = gdbarch_tdep<nios2_gdbarch_tdep> (gdbarch);
+  nios2_gdbarch_tdep *tdep = gdbarch_tdep_cast<nios2_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR jb_addr = get_frame_register_unsigned (frame, NIOS2_R4_REGNUM);
   gdb_byte buf[4];
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index 4699b755d42..e40da6560c2 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -248,7 +248,7 @@ or1k_return_value (struct gdbarch *gdbarch, struct value *functype,
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum type_code rv_type = valtype->code ();
   unsigned int rv_size = TYPE_LENGTH (valtype);
-  or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
+  or1k_gdbarch_tdep *tdep = gdbarch_tdep_cast<or1k_gdbarch_tdep> (gdbarch);
   int bpw = tdep->bytes_per_word;
 
   /* Deal with struct/union as addresses.  If an array won't fit in a
@@ -353,7 +353,7 @@ or1k_delay_slot_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   const CGEN_INSN *insn;
   CGEN_FIELDS tmp_fields;
-  or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
+  or1k_gdbarch_tdep *tdep = gdbarch_tdep_cast<or1k_gdbarch_tdep> (gdbarch);
 
   insn = cgen_lookup_insn (tdep->gdb_cgen_cpu_desc,
 			   NULL,
@@ -635,7 +635,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   int heap_offset = 0;
   CORE_ADDR heap_sp = sp - 128;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
+  or1k_gdbarch_tdep *tdep = gdbarch_tdep_cast<or1k_gdbarch_tdep> (gdbarch);
   int bpa = tdep->bytes_per_address;
   int bpw = tdep->bytes_per_word;
   struct type *func_type = value_type (function);
@@ -1273,7 +1273,7 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 or1k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
+  or1k_gdbarch_tdep *tdep = gdbarch_tdep_cast<or1k_gdbarch_tdep> (gdbarch);
 
   if (NULL == tdep)
     return; /* Nothing to report */
diff --git a/gdb/ppc-fbsd-nat.c b/gdb/ppc-fbsd-nat.c
index d0a5778e2d3..af0fda43a5a 100644
--- a/gdb/ppc-fbsd-nat.c
+++ b/gdb/ppc-fbsd-nat.c
@@ -100,7 +100,7 @@ fill_fpregset (const struct regcache *regcache,
 static int
 getfpregs_supplies (struct gdbarch *gdbarch, int regno)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating
 	 point registers.  Traditionally, GDB's register set has still
@@ -185,7 +185,7 @@ static int
 ppcfbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int i, regnum;
 
   /* The stack pointer shouldn't be zero.  */
diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c
index f5b482921a7..56854f4cf7a 100644
--- a/gdb/ppc-fbsd-tdep.c
+++ b/gdb/ppc-fbsd-tdep.c
@@ -126,7 +126,7 @@ ppcfbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				      void *cb_data,
 				      const struct regcache *regcache)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (tdep->wordsize == 4)
     cb (".reg", 148, 148, &ppc32_fbsd_gregset, NULL, cb_data);
@@ -200,7 +200,7 @@ static struct trad_frame_cache *
 ppcfbsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   struct trad_frame_cache *cache;
   CORE_ADDR addr, base, func;
   gdb_byte buf[PPC_INSN_SIZE];
@@ -287,7 +287,7 @@ static CORE_ADDR
 ppcfbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 				  CORE_ADDR lm_addr, CORE_ADDR offset)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   struct regcache *regcache;
   int tp_offset, tp_regnum;
 
@@ -319,7 +319,7 @@ ppcfbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
 static void
 ppcfbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* Generic FreeBSD support. */
   fbsd_init_abi (info, gdbarch);
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index de4158c411a..d3bce1c4372 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -649,7 +649,7 @@ static int
 ppc_register_u_addr (struct gdbarch *gdbarch, int regno)
 {
   int u_addr = -1;
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
      interface, and not the wordsize of the program's ABI.  */
   int wordsize = sizeof (long);
@@ -802,7 +802,7 @@ static void
 fetch_spe_register (struct regcache *regcache, int tid, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   struct gdb_evrregset_t evrregs;
 
   gdb_assert (sizeof (evrregs.evr[0])
@@ -911,7 +911,7 @@ static void
 fetch_register (struct regcache *regcache, int tid, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   /* This isn't really an address.  But ptrace thinks of it as one.  */
   CORE_ADDR regaddr = ppc_register_u_addr (gdbarch, regno);
   int bytes_transferred;
@@ -1156,7 +1156,7 @@ static void
 fetch_gp_regs (struct regcache *regcache, int tid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int i;
 
   if (have_ptrace_getsetregs)
@@ -1208,7 +1208,7 @@ static void
 fetch_fp_regs (struct regcache *regcache, int tid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int i;
 
   if (have_ptrace_getsetfpregs)
@@ -1226,7 +1226,7 @@ static void
 fetch_ppc_registers (struct regcache *regcache, int tid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   fetch_gp_regs (regcache, tid);
   if (tdep->ppc_fp0_regnum >= 0)
@@ -1425,7 +1425,7 @@ static void
 store_spe_register (const struct regcache *regcache, int tid, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   struct gdb_evrregset_t evrregs;
 
   gdb_assert (sizeof (evrregs.evr[0])
@@ -1477,7 +1477,7 @@ static void
 store_register (const struct regcache *regcache, int tid, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   /* This isn't really an address.  But ptrace thinks of it as one.  */
   CORE_ADDR regaddr = ppc_register_u_addr (gdbarch, regno);
   int i;
@@ -1718,7 +1718,7 @@ static void
 store_gp_regs (const struct regcache *regcache, int tid, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int i;
 
   if (have_ptrace_getsetregs)
@@ -1780,7 +1780,7 @@ static void
 store_fp_regs (const struct regcache *regcache, int tid, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int i;
 
   if (have_ptrace_getsetfpregs)
@@ -1798,7 +1798,7 @@ static void
 store_ppc_registers (const struct regcache *regcache, int tid)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
  
   store_gp_regs (regcache, tid, -1);
   if (tdep->ppc_fp0_regnum >= 0)
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index beef4bd393c..8a368feb6b0 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -332,7 +332,7 @@ ppc_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
   unsigned int insnbuf[POWERPC32_PLT_CHECK_LEN];
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR target = 0;
   int scan_limit, i;
@@ -898,7 +898,7 @@ ppc_linux_vsxregset (void)
 const struct regset *
 ppc_linux_cgprregset (struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (tdep->wordsize == 4)
     {
@@ -938,7 +938,7 @@ ppc_linux_collect_core_cpgrregset (const struct regset *regset,
 				   int regnum, void *buf, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   const struct regset *cgprregset = ppc_linux_cgprregset (gdbarch);
 
@@ -985,7 +985,7 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					void *cb_data,
 					const struct regcache *regcache)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int have_altivec = tdep->ppc_vr0_regnum != -1;
   int have_vsx = tdep->ppc_vsr0_upper_regnum != -1;
   int have_ppr = tdep->ppc_ppr_regnum != -1;
@@ -1170,7 +1170,7 @@ ppc_linux_sigtramp_cache (struct frame_info *this_frame,
   CORE_ADDR fpregs;
   int i;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   base = get_frame_register_unsigned (this_frame,
@@ -1341,7 +1341,7 @@ ppc_linux_get_syscall_number (struct gdbarch *gdbarch,
 			      thread_info *thread)
 {
   struct regcache *regcache = get_thread_regcache (thread);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* Make sure we're in a 32- or 64-bit machine */
@@ -1419,7 +1419,7 @@ static int
 ppc_linux_syscall_record (struct regcache *regcache)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   ULONGEST scnum;
   enum gdb_syscall syscall_gdb;
   int ret;
@@ -1509,7 +1509,7 @@ ppc_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache,
   const int SIGNAL_FRAMESIZE = 128;
   const int sizeof_rt_sigframe = 1440 * 2 + 8 * 2 + 4 * 6 + 8 + 8 + 128 + 512;
   ULONGEST sp;
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int i;
 
   for (i = 3; i <= 12; i++)
@@ -2044,7 +2044,7 @@ static void
 ppc_linux_init_abi (struct gdbarch_info info,
 		    struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   struct tdesc_arch_data *tdesc_data = info.tdesc_data;
   static const char *const stap_integer_prefixes[] = { "i", NULL };
   static const char *const stap_register_indirection_prefixes[] = { "(",
diff --git a/gdb/ppc-netbsd-nat.c b/gdb/ppc-netbsd-nat.c
index 91f18fbb83f..fa1df0bc265 100644
--- a/gdb/ppc-netbsd-nat.c
+++ b/gdb/ppc-netbsd-nat.c
@@ -52,7 +52,7 @@ static ppc_nbsd_nat_target the_ppc_nbsd_nat_target;
 static int
 getregs_supplies (struct gdbarch *gdbarch, int regnum)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   return ((regnum >= tdep->ppc_gp0_regnum
 	   && regnum < tdep->ppc_gp0_regnum + ppc_num_gprs)
@@ -68,7 +68,7 @@ getregs_supplies (struct gdbarch *gdbarch, int regnum)
 static int
 getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating
      point registers.  Traditionally, GDB's register set has still
@@ -159,7 +159,7 @@ ppcnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
   struct switchframe sf;
   struct callframe cf;
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int i;
 
   /* The stack pointer shouldn't be zero.  */
diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c
index d8dc494979a..2ff0aef4d33 100644
--- a/gdb/ppc-netbsd-tdep.c
+++ b/gdb/ppc-netbsd-tdep.c
@@ -102,7 +102,7 @@ ppcnbsd_sigtramp_cache_init (const struct tramp_frame *self,
 			     CORE_ADDR func)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   CORE_ADDR addr, base;
   int i;
 
diff --git a/gdb/ppc-obsd-nat.c b/gdb/ppc-obsd-nat.c
index e480f19dc73..176d4245585 100644
--- a/gdb/ppc-obsd-nat.c
+++ b/gdb/ppc-obsd-nat.c
@@ -54,7 +54,7 @@ static ppc_obsd_nat_target the_ppc_obsd_nat_target;
 static int
 getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* FIXME: jimb/2004-05-05: Some PPC variants don't have floating
      point registers.  Traditionally, GDB's register set has still
@@ -154,7 +154,7 @@ static int
 ppcobsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   struct switchframe sf;
   struct callframe cf;
   int i, regnum;
diff --git a/gdb/ppc-obsd-tdep.c b/gdb/ppc-obsd-tdep.c
index 90fb5e3a399..39138b5d387 100644
--- a/gdb/ppc-obsd-tdep.c
+++ b/gdb/ppc-obsd-tdep.c
@@ -161,7 +161,7 @@ static struct trad_frame_cache *
 ppcobsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct trad_frame_cache *cache;
   CORE_ADDR addr, base, func;
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index 1fe81b95f6c..b0e08adeb64 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -65,7 +65,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			      function_call_return_method return_method,
 			      CORE_ADDR struct_addr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function));
   ULONGEST saved_sp;
@@ -602,7 +602,7 @@ get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype,
 				struct regcache *regcache, gdb_byte *readbuf,
 				const gdb_byte *writebuf)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   gdb_assert (valtype->code () == TYPE_CODE_DECFLOAT);
 
@@ -680,7 +680,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type,
 			  gdb_byte *readbuf, const gdb_byte *writebuf,
 			  int broken_gcc)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int opencl_abi = func_type? ppc_sysv_use_opencl_abi (func_type) : 0;
 
@@ -1267,7 +1267,7 @@ ppc64_sysv_abi_push_val (struct gdbarch *gdbarch,
 			 const bfd_byte *val, int len, int align,
 			 struct ppc64_sysv_argpos *argpos)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int offset = 0;
 
   /* Enforce alignment of stack location, if requested.  */
@@ -1317,7 +1317,7 @@ static void
 ppc64_sysv_abi_push_integer (struct gdbarch *gdbarch, ULONGEST val,
 			     struct ppc64_sysv_argpos *argpos)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte buf[PPC_MAX_REGISTER_SIZE];
 
@@ -1335,7 +1335,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch,
 			  struct type *type, const bfd_byte *val,
 			  struct ppc64_sysv_argpos *argpos)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   if (tdep->soft_float)
     return;
 
@@ -1420,7 +1420,7 @@ static void
 ppc64_sysv_abi_push_vreg (struct gdbarch *gdbarch, const bfd_byte *val,
 			  struct ppc64_sysv_argpos *argpos)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (argpos->regcache && argpos->vreg <= 13)
     argpos->regcache->cooked_write (tdep->ppc_vr0_regnum + argpos->vreg, val);
@@ -1436,7 +1436,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch,
 			   struct type *type, const bfd_byte *val,
 			   struct ppc64_sysv_argpos *argpos)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (type->code () == TYPE_CODE_FLT
       && TYPE_LENGTH (type) == 16
@@ -1589,7 +1589,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch,
 				CORE_ADDR struct_addr)
 {
   CORE_ADDR func_addr = find_function_addr (function, NULL);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function));
   ULONGEST back_chain;
@@ -1783,7 +1783,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
 				  struct regcache *regcache, gdb_byte *readbuf,
 				  const gdb_byte *writebuf, int index)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* Integers live in GPRs starting at r3.  */
   if ((valtype->code () == TYPE_CODE_INT
@@ -1972,7 +1972,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
 			     struct type *valtype, struct regcache *regcache,
 			     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   struct type *func_type = function ? value_type (function) : NULL;
   int opencl_abi = func_type? ppc_sysv_use_opencl_abi (func_type) : 0;
   struct type *eltype;
diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c
index 0437ca7e3f3..2f7f1a97b1c 100644
--- a/gdb/ppc64-tdep.c
+++ b/gdb/ppc64-tdep.c
@@ -89,7 +89,7 @@ ppc64_plt_entry_point (struct frame_info *frame, CORE_ADDR plt_off)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   CORE_ADDR tocp;
 
   if (execution_direction == EXEC_REVERSE)
diff --git a/gdb/riscv-linux-tdep.c b/gdb/riscv-linux-tdep.c
index 5bda2e5c824..4e5902fdd95 100644
--- a/gdb/riscv-linux-tdep.c
+++ b/gdb/riscv-linux-tdep.c
@@ -179,7 +179,7 @@ riscv_linux_syscall_next_pc (struct frame_info *frame)
 static void
 riscv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 2d41be96b20..c713724a5bb 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -733,7 +733,7 @@ show_riscv_debug_variable (struct ui_file *file, int from_tty,
 int
 riscv_isa_xlen (struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   return tdep->isa_features.xlen;
 }
 
@@ -742,7 +742,7 @@ riscv_isa_xlen (struct gdbarch *gdbarch)
 int
 riscv_abi_xlen (struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   return tdep->abi_features.xlen;
 }
 
@@ -751,7 +751,7 @@ riscv_abi_xlen (struct gdbarch *gdbarch)
 int
 riscv_isa_flen (struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   return tdep->isa_features.flen;
 }
 
@@ -760,7 +760,7 @@ riscv_isa_flen (struct gdbarch *gdbarch)
 int
 riscv_abi_flen (struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   return tdep->abi_features.flen;
 }
 
@@ -769,7 +769,7 @@ riscv_abi_flen (struct gdbarch *gdbarch)
 bool
 riscv_abi_embedded (struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   return tdep->abi_features.embedded;
 }
 
@@ -786,7 +786,7 @@ riscv_has_fp_regs (struct gdbarch *gdbarch)
 static bool
 riscv_has_fp_abi (struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   return tdep->abi_features.flen > 0;
 }
 
@@ -910,7 +910,7 @@ riscv_register_name (struct gdbarch *gdbarch, int regnum)
      will show up in 'info register all'.  Unless, we identify the
      duplicate copies of these registers (in riscv_tdesc_unknown_reg) and
      then hide the registers here by giving them no name.  */
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   if (tdep->duplicate_fflags_regnum == regnum)
     return NULL;
   if (tdep->duplicate_frm_regnum == regnum)
@@ -938,7 +938,7 @@ riscv_register_name (struct gdbarch *gdbarch, int regnum)
 static struct type *
 riscv_fpreg_d_type (struct gdbarch *gdbarch)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
 
   if (tdep->riscv_fpreg_d_type == nullptr)
     {
@@ -1260,7 +1260,7 @@ riscv_is_regnum_a_named_csr (int regnum)
 static bool
 riscv_is_unknown_csr (struct gdbarch *gdbarch, int regnum)
 {
-  riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+  riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   return (regnum >= tdep->unknown_csrs_first_regnum
 	  && regnum < (tdep->unknown_csrs_first_regnum
 		       + tdep->unknown_csrs_count));
@@ -3600,7 +3600,7 @@ riscv_tdesc_unknown_reg (struct gdbarch *gdbarch, tdesc_feature *feature,
      record their register numbers here.  */
   if (strcmp (tdesc_feature_name (feature), riscv_freg_feature.name ()) == 0)
     {
-      riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+      riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
       int *regnum_ptr = nullptr;
 
       if (strcmp (reg_name, "fflags") == 0)
@@ -3631,7 +3631,7 @@ riscv_tdesc_unknown_reg (struct gdbarch *gdbarch, tdesc_feature *feature,
      about register groups in riscv_register_reggroup_p.  */
   if (strcmp (tdesc_feature_name (feature), riscv_csr_feature.name ()) == 0)
     {
-      riscv_gdbarch_tdep *tdep = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+      riscv_gdbarch_tdep *tdep = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
       if (tdep->unknown_csrs_first_regnum == -1)
 	tdep->unknown_csrs_first_regnum = possible_regnum;
       gdb_assert (tdep->unknown_csrs_first_regnum
@@ -3733,7 +3733,7 @@ riscv_gdbarch_init (struct gdbarch_info info,
 	 we are looking for.  If it doesn't then we can't reuse this
 	 gdbarch.  */
       riscv_gdbarch_tdep *other_tdep
-	= gdbarch_tdep<riscv_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<riscv_gdbarch_tdep> (arches->gdbarch);
 
       if (other_tdep->isa_features != features
 	  || other_tdep->abi_features != abi_features)
@@ -3858,7 +3858,7 @@ riscv_next_pc (struct regcache *regcache, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   const riscv_gdbarch_tdep *tdep
-    = gdbarch_tdep<riscv_gdbarch_tdep> (gdbarch);
+    = gdbarch_tdep_cast<riscv_gdbarch_tdep> (gdbarch);
   struct riscv_insn insn;
   CORE_ADDR next_pc;
 
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 2462e7a191d..b6c66a34125 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -267,7 +267,7 @@ struct rl78_prologue
 static struct type *
 rl78_psw_type (struct gdbarch *gdbarch)
 {
-  rl78_gdbarch_tdep *tdep = gdbarch_tdep<rl78_gdbarch_tdep> (gdbarch);
+  rl78_gdbarch_tdep *tdep = gdbarch_tdep_cast<rl78_gdbarch_tdep> (gdbarch);
 
   if (tdep->rl78_psw_type == NULL)
     {
@@ -291,7 +291,7 @@ rl78_psw_type (struct gdbarch *gdbarch)
 static struct type *
 rl78_register_type (struct gdbarch *gdbarch, int reg_nr)
 {
-  rl78_gdbarch_tdep *tdep = gdbarch_tdep<rl78_gdbarch_tdep> (gdbarch);
+  rl78_gdbarch_tdep *tdep = gdbarch_tdep_cast<rl78_gdbarch_tdep> (gdbarch);
 
   if (reg_nr == RL78_PC_REGNUM)
     return tdep->rl78_code_pointer;
@@ -1248,7 +1248,7 @@ rl78_return_value (struct gdbarch *gdbarch,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST valtype_len = TYPE_LENGTH (valtype);
-  rl78_gdbarch_tdep *tdep = gdbarch_tdep<rl78_gdbarch_tdep> (gdbarch);
+  rl78_gdbarch_tdep *tdep = gdbarch_tdep_cast<rl78_gdbarch_tdep> (gdbarch);
   int is_g10 = tdep->elf_flags & E_FLAG_RL78_G10;
 
   if (valtype_len > 8)
@@ -1394,7 +1394,7 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       rl78_gdbarch_tdep *tdep
-	= gdbarch_tdep<rl78_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<rl78_gdbarch_tdep> (arches->gdbarch);
 
       if (tdep->elf_flags != elf_flags)
 	continue;
diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c
index cb141427696..8d6d79d78d0 100644
--- a/gdb/rs6000-aix-nat.c
+++ b/gdb/rs6000-aix-nat.c
@@ -115,7 +115,7 @@ static rs6000_nat_target the_rs6000_nat_target;
 static int
 regmap (struct gdbarch *gdbarch, int regno, int *isfloat)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   *isfloat = 0;
   if (tdep->ppc_gp0_regnum <= regno
@@ -317,7 +317,7 @@ rs6000_nat_target::fetch_registers (struct regcache *regcache, int regno)
 
   else
     {
-      ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+      ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
       /* Read 32 general purpose registers.  */
       for (regno = tdep->ppc_gp0_regnum;
@@ -359,7 +359,7 @@ rs6000_nat_target::store_registers (struct regcache *regcache, int regno)
 
   else
     {
-      ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+      ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
       /* Write general purpose registers first.  */
       for (regno = tdep->ppc_gp0_regnum;
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index 41384993c26..0770e450157 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -75,7 +75,7 @@ aix_sighandle_frame_cache (struct frame_info *this_frame,
   LONGEST backchain;
   CORE_ADDR base, base_orig, func;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct trad_frame_cache *this_trad_cache;
 
@@ -261,7 +261,7 @@ rs6000_aix_iterate_over_regset_sections (struct gdbarch *gdbarch,
 					 void *cb_data,
 					 const struct regcache *regcache)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   if (tdep->wordsize == 4)
     cb (".reg", 592, 592, &rs6000_aix32_regset, NULL, cb_data);
   else
@@ -292,7 +292,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			function_call_return_method return_method,
 			CORE_ADDR struct_addr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int ii;
   int len = 0;
@@ -522,7 +522,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function,
 		     struct type *valtype, struct regcache *regcache,
 		     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* The calling convention this function implements assumes the
@@ -660,7 +660,7 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 				   CORE_ADDR addr,
 				   struct target_ops *targ)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct obj_section *s;
 
@@ -704,7 +704,7 @@ branch_dest (struct regcache *regcache, int opcode, int instr,
 	     CORE_ADDR pc, CORE_ADDR safety)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR dest;
   int immediate;
@@ -972,7 +972,7 @@ static struct ld_info
 rs6000_aix_extract_ld_info (struct gdbarch *gdbarch,
 			    const gdb_byte *ldi_buf)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
   const struct ld_info_desc desc
@@ -1131,7 +1131,7 @@ rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
 static void
 rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* RS6000/AIX does not support PT_STEP.  Has to be simulated.  */
   set_gdbarch_software_single_step (gdbarch, rs6000_software_single_step);
diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c
index dc13dd3fa73..a1ecac632e0 100644
--- a/gdb/rs6000-lynx178-tdep.c
+++ b/gdb/rs6000-lynx178-tdep.c
@@ -36,7 +36,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch,
 				function_call_return_method return_method,
 				CORE_ADDR struct_addr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int ii;
   int len = 0;
@@ -265,7 +265,7 @@ rs6000_lynx178_return_value (struct gdbarch *gdbarch, struct value *function,
 			     struct type *valtype, struct regcache *regcache,
 			     gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   /* The calling convention this function implements assumes the
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 640459f1c28..ad706689343 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -201,7 +201,7 @@ struct rs6000_framedata
 int
 vsx_register_p (struct gdbarch *gdbarch, int regno)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   if (tdep->ppc_vsr0_regnum < 0)
     return 0;
   else
@@ -213,7 +213,7 @@ vsx_register_p (struct gdbarch *gdbarch, int regno)
 int
 altivec_register_p (struct gdbarch *gdbarch, int regno)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   if (tdep->ppc_vr0_regnum < 0 || tdep->ppc_vrsave_regnum < 0)
     return 0;
   else
@@ -225,7 +225,7 @@ altivec_register_p (struct gdbarch *gdbarch, int regno)
 int
 spe_register_p (struct gdbarch *gdbarch, int regno)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   
   /* Is it a reference to EV0 -- EV31, and do we have those?  */
   if (IS_SPE_PSEUDOREG (tdep, regno))
@@ -257,7 +257,7 @@ spe_register_p (struct gdbarch *gdbarch, int regno)
 int
 ppc_floating_point_unit_p (struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   return (tdep->ppc_fp0_regnum >= 0
 	  && tdep->ppc_fpscr_regnum >= 0);
@@ -268,7 +268,7 @@ ppc_floating_point_unit_p (struct gdbarch *gdbarch)
 int
 ppc_altivec_support_p (struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   return (tdep->ppc_vr0_regnum >= 0
 	  && tdep->ppc_vrsave_regnum >= 0);
@@ -297,7 +297,7 @@ set_sim_regno (int *table, int gdb_regno, int sim_regno)
 static void
 init_sim_regno_table (struct gdbarch *arch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (arch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (arch);
   int total_regs = gdbarch_num_regs (arch);
   int *sim_regno = GDBARCH_OBSTACK_CALLOC (arch, total_regs, int);
   int i;
@@ -391,7 +391,7 @@ init_sim_regno_table (struct gdbarch *arch)
 static int
 rs6000_register_sim_regno (struct gdbarch *gdbarch, int reg)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int sim_regno;
 
   if (tdep->sim_regno == NULL)
@@ -522,7 +522,7 @@ ppc_supply_gregset (const struct regset *regset, struct regcache *regcache,
 		    int regnum, const void *gregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   const struct ppc_reg_offsets *offsets
     = (const struct ppc_reg_offsets *) regset->regmap;
   size_t offset;
@@ -578,7 +578,7 @@ ppc_supply_fpregset (const struct regset *regset, struct regcache *regcache,
   if (!ppc_floating_point_unit_p (gdbarch))
     return;
 
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   offsets = (const struct ppc_reg_offsets *) regset->regmap;
   if (regnum == -1)
     {
@@ -611,7 +611,7 @@ ppc_collect_gregset (const struct regset *regset,
 		     int regnum, void *gregs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   const struct ppc_reg_offsets *offsets
     = (const struct ppc_reg_offsets *) regset->regmap;
   size_t offset;
@@ -668,7 +668,7 @@ ppc_collect_fpregset (const struct regset *regset,
   if (!ppc_floating_point_unit_p (gdbarch))
     return;
 
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   offsets = (const struct ppc_reg_offsets *) regset->regmap;
   if (regnum == -1)
     {
@@ -746,7 +746,7 @@ static int
 rs6000_in_function_epilogue_frame_p (struct frame_info *curfrm,
 				     struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   bfd_byte insn_buf[PPC_INSN_SIZE];
   CORE_ADDR scan_pc, func_start, func_end, epilogue_start, epilogue_end;
@@ -1042,7 +1042,7 @@ ppc_displaced_step_fixup (struct gdbarch *gdbarch,
       if (insn & 0x1)
 	{
 	  /* Link register needs to be set to the next instruction's PC.  */
-	  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+	  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 	  regcache_cooked_write_unsigned (regs,
 					  tdep->ppc_lr_regnum,
 					  from + PPC_INSN_SIZE);
@@ -1590,7 +1590,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
   int num_skip_non_prologue_insns = 0;
   int r0_contains_arg = 0;
   const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
   memset (fdata, 0, sizeof (struct rs6000_framedata));
@@ -2310,7 +2310,7 @@ static CORE_ADDR
 rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned int ii, op;
   int rel;
@@ -2368,7 +2368,7 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 static struct type *
 rs6000_builtin_type_vec64 (struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (!tdep->ppc_builtin_type_vec64)
     {
@@ -2413,7 +2413,7 @@ rs6000_builtin_type_vec64 (struct gdbarch *gdbarch)
 static struct type *
 rs6000_builtin_type_vec128 (struct gdbarch *gdbarch)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (!tdep->ppc_builtin_type_vec128)
     {
@@ -2467,7 +2467,7 @@ rs6000_builtin_type_vec128 (struct gdbarch *gdbarch)
 static const char *
 rs6000_register_name (struct gdbarch *gdbarch, int regno)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* The upper half "registers" have names in the XML description,
      but we present only the low GPRs and the full 64-bit registers
@@ -2605,7 +2605,7 @@ rs6000_register_name (struct gdbarch *gdbarch, int regno)
 static struct type *
 rs6000_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* These are the e500 pseudo-registers.  */
   if (IS_SPE_PSEUDOREG (tdep, regnum))
@@ -2644,7 +2644,7 @@ static int
 rs6000_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 				   const struct reggroup *group)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (IS_V_ALIAS_PSEUDOREG (tdep, regnum))
     return 0;
@@ -2659,7 +2659,7 @@ static int
 rs6000_convert_register_p (struct gdbarch *gdbarch, int regnum,
 			   struct type *type)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   return (tdep->ppc_fp0_regnum >= 0
 	  && regnum >= tdep->ppc_fp0_regnum
@@ -2744,7 +2744,7 @@ e500_move_ev_register (move_ev_register_func move,
 		       struct regcache *regcache, int ev_reg, void *buffer)
 {
   struct gdbarch *arch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (arch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (arch);
   int reg_index;
   gdb_byte *byte_buffer = (gdb_byte *) buffer;
   enum register_status status;
@@ -2785,7 +2785,7 @@ e500_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
 			   int ev_reg, gdb_byte *buffer)
 {
   struct gdbarch *arch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index;
   enum register_status status;
 
@@ -2826,7 +2826,7 @@ static enum register_status
 dfp_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
 			   int reg_nr, gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, fp0;
   enum register_status status;
 
@@ -2866,7 +2866,7 @@ static void
 dfp_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int reg_nr, const gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, fp0;
 
   if (IS_DFP_PSEUDOREG (tdep, reg_nr))
@@ -2903,7 +2903,7 @@ v_alias_pseudo_register_read (struct gdbarch *gdbarch,
 			      readable_regcache *regcache, int reg_nr,
 			      gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   gdb_assert (IS_V_ALIAS_PSEUDOREG (tdep, reg_nr));
 
   return regcache->raw_read (tdep->ppc_vr0_regnum
@@ -2918,7 +2918,7 @@ v_alias_pseudo_register_write (struct gdbarch *gdbarch,
 			       struct regcache *regcache,
 			       int reg_nr, const gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   gdb_assert (IS_V_ALIAS_PSEUDOREG (tdep, reg_nr));
 
   regcache->raw_write (tdep->ppc_vr0_regnum
@@ -2930,7 +2930,7 @@ static enum register_status
 vsx_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
 			   int reg_nr, gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, vr0, fp0, vsr0_upper;
   enum register_status status;
 
@@ -2978,7 +2978,7 @@ static void
 vsx_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int reg_nr, const gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, vr0, fp0, vsr0_upper;
 
   if (IS_VSX_PSEUDOREG (tdep, reg_nr))
@@ -3020,7 +3020,7 @@ static enum register_status
 efp_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
 			   int reg_nr, gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, vr0;
 
   if (IS_EFP_PSEUDOREG (tdep, reg_nr))
@@ -3049,7 +3049,7 @@ static void
 efp_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int reg_nr, const gdb_byte *buffer)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, vr0;
   int offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 0 : 8;
 
@@ -3085,7 +3085,7 @@ rs6000_pseudo_register_read (struct gdbarch *gdbarch,
 			     int reg_nr, gdb_byte *buffer)
 {
   struct gdbarch *regcache_arch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   gdb_assert (regcache_arch == gdbarch);
 
@@ -3116,7 +3116,7 @@ rs6000_pseudo_register_write (struct gdbarch *gdbarch,
 			      int reg_nr, const gdb_byte *buffer)
 {
   struct gdbarch *regcache_arch = regcache->arch ();
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   gdb_assert (regcache_arch == gdbarch);
 
@@ -3147,7 +3147,7 @@ static void
 dfp_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 				struct agent_expr *ax, int reg_nr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, fp0;
 
   if (IS_DFP_PSEUDOREG (tdep, reg_nr))
@@ -3174,7 +3174,7 @@ static void
 v_alias_pseudo_register_collect (struct gdbarch *gdbarch,
 				 struct agent_expr *ax, int reg_nr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   gdb_assert (IS_V_ALIAS_PSEUDOREG (tdep, reg_nr));
 
   ax_reg_mask (ax, tdep->ppc_vr0_regnum
@@ -3188,7 +3188,7 @@ static void
 vsx_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 				struct agent_expr *ax, int reg_nr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, vr0, fp0, vsr0_upper;
 
   if (IS_VSX_PSEUDOREG (tdep, reg_nr))
@@ -3226,7 +3226,7 @@ static void
 efp_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 				struct agent_expr *ax, int reg_nr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int reg_index, vr0;
 
   if (IS_EFP_PSEUDOREG (tdep, reg_nr))
@@ -3249,7 +3249,7 @@ static int
 rs6000_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 				   struct agent_expr *ax, int reg_nr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   if (IS_SPE_PSEUDOREG (tdep, reg_nr))
     {
       int reg_index = reg_nr - tdep->ppc_ev0_regnum;
@@ -3289,7 +3289,7 @@ rs6000_gen_return_address (struct gdbarch *gdbarch,
 			   struct agent_expr *ax, struct axs_value *value,
 			   CORE_ADDR scope)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   value->type = register_type (gdbarch, tdep->ppc_lr_regnum);
   value->kind = axs_lvalue_register;
   value->u.reg = tdep->ppc_lr_regnum;
@@ -3300,7 +3300,7 @@ rs6000_gen_return_address (struct gdbarch *gdbarch,
 static int
 rs6000_stab_reg_to_regnum (struct gdbarch *gdbarch, int num)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (0 <= num && num <= 31)
     return tdep->ppc_gp0_regnum + num;
@@ -3342,7 +3342,7 @@ rs6000_stab_reg_to_regnum (struct gdbarch *gdbarch, int num)
 static int
 rs6000_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int num)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (0 <= num && num <= 31)
     return tdep->ppc_gp0_regnum + num;
@@ -3561,7 +3561,7 @@ rs6000_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct rs6000_frame_cache *cache;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct rs6000_framedata fdata;
   int wordsize = tdep->wordsize;
@@ -3797,7 +3797,7 @@ rs6000_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct rs6000_frame_cache *cache;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (*this_cache)
     return (struct rs6000_frame_cache *) *this_cache;
@@ -3918,7 +3918,7 @@ ppc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
 			    struct dwarf2_frame_state_reg *reg,
 			    struct frame_info *this_frame)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   /* PPC32 and PPC64 ABI's are the same regarding volatile and
      non-volatile registers.  We will use the same code for both.  */
@@ -4229,7 +4229,7 @@ static int
 ppc_process_record_op4 (struct gdbarch *gdbarch, struct regcache *regcache,
 			CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int ext = PPC_FIELD (insn, 21, 11);
   int vra = PPC_FIELD (insn, 11, 5);
 
@@ -4771,7 +4771,7 @@ static int
 ppc_process_record_op6 (struct gdbarch *gdbarch, struct regcache *regcache,
 			CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int subtype = PPC_FIELD (insn, 28, 4);
   CORE_ADDR ea = 0;
 
@@ -4799,7 +4799,7 @@ static int
 ppc_process_record_op19 (struct gdbarch *gdbarch, struct regcache *regcache,
 			   CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int ext = PPC_EXTOP (insn);
 
   switch (ext & 0x01f)
@@ -4855,7 +4855,7 @@ ppc_process_record_op31_177 (struct gdbarch *gdbarch,
 {
   int RA_opcode = PPC_RA(insn);
   int as = PPC_FIELD (insn, 6, 3);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   switch (RA_opcode)
     {
@@ -4875,7 +4875,7 @@ static int
 ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache,
 			   CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int ext = PPC_EXTOP (insn);
   int tmp, nr, nb = 0, i;
   CORE_ADDR at_dcsz, ea = 0;
@@ -5536,7 +5536,7 @@ static int
 ppc_process_record_op59 (struct gdbarch *gdbarch, struct regcache *regcache,
 			 CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int ext = PPC_EXTOP (insn);
   int at = PPC_FIELD (insn, 6, 3);
 
@@ -5701,7 +5701,7 @@ ppc_process_record_op60_XX2 (struct gdbarch *gdbarch,
 			     struct regcache *regcache,
 			     CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int RA_opcode = PPC_RA(insn);
 
   switch (RA_opcode)
@@ -5742,7 +5742,7 @@ static int
 ppc_process_record_op60 (struct gdbarch *gdbarch, struct regcache *regcache,
 			   CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int ext = PPC_EXTOP (insn);
 
   switch (ext >> 2)
@@ -6097,7 +6097,7 @@ static int
 ppc_process_record_op61 (struct gdbarch *gdbarch, struct regcache *regcache,
 			   CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   ULONGEST ea = 0;
   int size;
 
@@ -6156,7 +6156,7 @@ static int
 ppc_process_record_op63 (struct gdbarch *gdbarch, struct regcache *regcache,
 			   CORE_ADDR addr, uint32_t insn)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int ext = PPC_EXTOP (insn);
   int tmp;
 
@@ -6453,7 +6453,7 @@ ppc_process_record_prefix_op42 (struct gdbarch *gdbarch,
 				struct regcache *regcache,
 				uint32_t insn_prefix, uint32_t insn_suffix)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int type = PPC_FIELD (insn_prefix, 6, 2);
   int ST1 = PPC_FIELD (insn_prefix, 8, 1);
 
@@ -6489,7 +6489,7 @@ ppc_process_record_prefix_op59_XX3 (struct gdbarch *gdbarch,
   int type = PPC_FIELD (insn_prefix, 6, 2);
   int ST4 = PPC_FIELD (insn_prefix, 8, 4);
   int at = PPC_FIELD (insn_suffix, 6, 3);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (type == 3)
     {
@@ -6603,7 +6603,7 @@ ppc_process_record_prefix_store (struct gdbarch *gdbarch,
 				 CORE_ADDR addr, uint32_t insn_prefix,
 				 uint32_t insn_suffix)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   ULONGEST iaddr = 0;
   int size;
   int R = PPC_BIT (insn_prefix, 11);
@@ -6659,7 +6659,7 @@ ppc_process_record_prefix_op32 (struct gdbarch *gdbarch,
   int type = PPC_FIELD (insn_prefix, 6, 2);
   int ST1 = PPC_FIELD (insn_prefix, 8, 1);
   int ST4 = PPC_FIELD (insn_prefix, 8, 4);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (type == 1)
     {
@@ -6713,7 +6713,7 @@ ppc_process_record_prefix_op33 (struct gdbarch *gdbarch,
 {
   int type = PPC_FIELD (insn_prefix, 6, 2);
   int ST4 = PPC_FIELD (insn_prefix, 8, 4);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (type == 1)
     {
@@ -6751,7 +6751,7 @@ ppc_process_record_prefix_op34 (struct gdbarch *gdbarch,
   int type = PPC_FIELD (insn_prefix, 6, 2);
   int ST1 = PPC_FIELD (insn_prefix, 8, 1);
   int ST4 = PPC_FIELD (insn_prefix, 8, 4);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (type == 1)
     {
@@ -6797,7 +6797,7 @@ ppc_process_record_prefix_store_vsx_ds_form (struct gdbarch *gdbarch,
 					     uint32_t insn_prefix,
 					     uint32_t insn_suffix)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   ULONGEST ea = 0;
   int size;
   int R = PPC_BIT (insn_prefix, 11);
@@ -6850,7 +6850,7 @@ ppc_process_record_prefix_vsx_d_form (struct gdbarch *gdbarch,
 				      uint32_t insn_prefix,
 				      uint32_t insn_suffix)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   ULONGEST ea = 0;
   int size;
   int R = PPC_BIT (insn_prefix, 11);
@@ -6907,7 +6907,7 @@ ppc_process_prefix_instruction (int insn_prefix, int insn_suffix,
 {
   int type = PPC_FIELD (insn_prefix, 6, 2);
   int ST1 = PPC_FIELD (insn_prefix, 8, 1);
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   int op6;
 
   /* D-form has uses a 5-bit opcode in the instruction suffix */
@@ -7086,7 +7086,7 @@ int
 ppc_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
 		      CORE_ADDR addr)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   uint32_t insn, insn_suffix;
   int op6, tmp, i;
@@ -8150,7 +8150,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 	 meaningful, because 64-bit CPUs can run in 32-bit mode.  So, perform
 	 separate word size check.  */
       ppc_gdbarch_tdep *tdep
-	= gdbarch_tdep<ppc_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<ppc_gdbarch_tdep> (arches->gdbarch);
       if (tdep && tdep->elf_abi != elf_abi)
 	continue;
       if (tdep && tdep->soft_float != soft_float)
@@ -8452,7 +8452,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 rs6000_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
+  ppc_gdbarch_tdep *tdep = gdbarch_tdep_cast<ppc_gdbarch_tdep> (gdbarch);
 
   if (tdep == NULL)
     return;
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index c67d4057195..4fd0717d788 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -964,7 +964,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       rx_gdbarch_tdep *tdep
-	= gdbarch_tdep<rx_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<rx_gdbarch_tdep> (arches->gdbarch);
 
       if (tdep->elf_flags != elf_flags)
 	continue;
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 05bf03973fc..6ff45e40c5b 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -79,7 +79,7 @@ static void
 s390_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc);
 
@@ -269,7 +269,7 @@ s390_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				   void *cb_data,
 				   const struct regcache *regcache)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   const int gregset_size = (tdep->abi == ABI_LINUX_S390 ?
 			    s390_sizeof_gregset : s390x_sizeof_gregset);
 
@@ -390,7 +390,7 @@ s390_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
 				  void **this_prologue_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct s390_sigtramp_unwind_cache *info;
@@ -561,7 +561,7 @@ s390_linux_get_syscall_number (struct gdbarch *gdbarch,
 			       thread_info *thread)
 {
   struct regcache *regs = get_thread_regcache (thread);
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST pc;
   ULONGEST svc_number = -1;
@@ -594,7 +594,7 @@ static int
 s390_all_but_pc_registers_record (struct regcache *regcache)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   int i;
 
   for (i = 0; i < 16; i++)
@@ -804,7 +804,7 @@ static int
 s390_linux_syscall_record (struct regcache *regcache, LONGEST syscall_native)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   int ret;
   enum gdb_syscall syscall_gdb;
 
@@ -855,7 +855,7 @@ static int
 s390_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache,
 			  enum gdb_signal signal)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   /* There are two kinds of signal frames on s390. rt_sigframe is always
      the larger one, so don't even bother with sigframe.  */
   const int sizeof_rt_sigframe = (tdep->abi == ABI_LINUX_ZSERIES ?
@@ -1119,7 +1119,7 @@ s390_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
 static void
 s390_linux_init_abi_any (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   tdep->s390_syscall_record = s390_linux_syscall_record;
 
@@ -1154,7 +1154,7 @@ s390_linux_init_abi_any (struct gdbarch_info info, struct gdbarch *gdbarch)
 static void
 s390_linux_init_abi_31 (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   tdep->abi = ABI_LINUX_S390;
 
@@ -1170,7 +1170,7 @@ s390_linux_init_abi_31 (struct gdbarch_info info, struct gdbarch *gdbarch)
 static void
 s390_linux_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   tdep->abi = ABI_LINUX_ZSERIES;
 
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 2aeb3a14637..856908bb8f5 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1045,7 +1045,7 @@ s390_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 static int
 s390_register_call_saved (struct gdbarch *gdbarch, int regnum)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   switch (tdep->abi)
     {
@@ -1076,7 +1076,7 @@ s390_guess_tracepoint_registers (struct gdbarch *gdbarch,
 				 struct regcache *regcache,
 				 CORE_ADDR addr)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   int sz = register_size (gdbarch, S390_PSWA_REGNUM);
   gdb_byte *reg = (gdb_byte *) alloca (sz);
   ULONGEST pswm, pswa;
@@ -1172,7 +1172,7 @@ enum { s390_dwarf_reg_r0l = ARRAY_SIZE (s390_dwarf_regmap) - 16 };
 static int
 s390_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   int gdb_reg = -1;
 
   /* In a 32-on-64 debug scenario, debug info refers to the full
@@ -1231,7 +1231,7 @@ static struct value *
 s390_value_from_register (struct gdbarch *gdbarch, struct type *type,
 			  int regnum, struct frame_id frame_id)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   struct value *value = default_value_from_register (gdbarch, type,
 						     regnum, frame_id);
   check_typedef (type);
@@ -1250,7 +1250,7 @@ s390_value_from_register (struct gdbarch *gdbarch, struct type *type,
 static const char *
 s390_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   if (regnum == tdep->pc_regnum)
     return "pc";
@@ -1284,7 +1284,7 @@ s390_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
 static struct type *
 s390_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   if (regnum == tdep->pc_regnum)
     return builtin_type (gdbarch)->builtin_func_ptr;
@@ -1308,7 +1308,7 @@ static enum register_status
 s390_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache,
 			   int regnum, gdb_byte *buf)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int regsize = register_size (gdbarch, regnum);
   ULONGEST val;
@@ -1383,7 +1383,7 @@ static void
 s390_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
 			    int regnum, const gdb_byte *buf)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int regsize = register_size (gdbarch, regnum);
   ULONGEST val, psw;
@@ -1442,7 +1442,7 @@ static int
 s390_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 				 const struct reggroup *group)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 
   /* We usually save/restore the whole PSW, which includes PC and CC.
      However, some older gdbservers may not support saving/restoring
@@ -1470,7 +1470,7 @@ static int
 s390_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 				 struct agent_expr *ax, int regnum)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   if (regnum == tdep->pc_regnum)
     {
       ax_reg_mask (ax, S390_PSWA_REGNUM);
@@ -1504,7 +1504,7 @@ static int
 s390_ax_pseudo_register_push_stack (struct gdbarch *gdbarch,
 				    struct agent_expr *ax, int regnum)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   if (regnum == tdep->pc_regnum)
     {
       ax_reg (ax, S390_PSWA_REGNUM);
@@ -1905,7 +1905,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		      function_call_return_method return_method,
 		      CORE_ADDR struct_addr)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   int word_size = gdbarch_ptr_bit (gdbarch) / 8;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   int i;
@@ -2084,7 +2084,7 @@ s390_return_value (struct gdbarch *gdbarch, struct value *function,
       break;
     case TYPE_CODE_ARRAY:
       {
-	s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+	s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
 	rvc = (tdep->vector_abi == S390_VECTOR_ABI_128
 	       && TYPE_LENGTH (type) <= 16 && type->is_vector ())
 	  ? RETURN_VALUE_REGISTER_CONVENTION
@@ -2168,7 +2168,7 @@ s390_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 static CORE_ADDR
 s390_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   ULONGEST pc;
   pc = frame_unwind_register_unsigned (next_frame, tdep->pc_regnum);
   return gdbarch_addr_bits_remove (gdbarch, pc);
@@ -2190,7 +2190,7 @@ static struct value *
 s390_unwind_pseudo_register (struct frame_info *this_frame, int regnum)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   struct type *type = register_type (gdbarch, regnum);
 
   /* Unwind PC via PSW address.  */
@@ -2775,7 +2775,7 @@ static CORE_ADDR
 s390_record_address_mask (struct gdbarch *gdbarch, struct regcache *regcache,
 			  CORE_ADDR val)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   ULONGEST pswm, pswa;
   int am;
   if (tdep->abi == ABI_LINUX_S390)
@@ -2842,7 +2842,7 @@ s390_record_calc_disp_vsce (struct gdbarch *gdbarch, struct regcache *regcache,
 			    uint8_t vx, uint8_t el, uint8_t es, uint16_t bd,
 			    int8_t dh, CORE_ADDR *res)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST x;
   gdb_byte buf[16];
@@ -2885,7 +2885,7 @@ static int s390_popcnt (unsigned int x) {
 static int
 s390_record_gpr_g (struct gdbarch *gdbarch, struct regcache *regcache, int i)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i))
     return -1;
   if (tdep->abi == ABI_LINUX_S390)
@@ -2899,7 +2899,7 @@ s390_record_gpr_g (struct gdbarch *gdbarch, struct regcache *regcache, int i)
 static int
 s390_record_gpr_h (struct gdbarch *gdbarch, struct regcache *regcache, int i)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   if (tdep->abi == ABI_LINUX_S390)
     {
       if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i))
@@ -2939,7 +2939,7 @@ static int
 s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
 		     CORE_ADDR addr)
 {
-  s390_gdbarch_tdep *tdep = gdbarch_tdep<s390_gdbarch_tdep> (gdbarch);
+  s390_gdbarch_tdep *tdep = gdbarch_tdep_cast<s390_gdbarch_tdep> (gdbarch);
   uint16_t insn[3] = {0};
   /* Instruction as bytes.  */
   uint8_t ibyte[6];
@@ -7178,7 +7178,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       s390_gdbarch_tdep *tmp
-	= gdbarch_tdep<s390_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<s390_gdbarch_tdep> (arches->gdbarch);
 
       if (!tmp)
 	continue;
diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c
index f146f023add..3e9c3c3027b 100644
--- a/gdb/sh-linux-tdep.c
+++ b/gdb/sh-linux-tdep.c
@@ -195,7 +195,7 @@ sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
 					     svr4_fetch_objfile_link_map);
 
-  sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
+  sh_gdbarch_tdep *tdep = gdbarch_tdep_cast<sh_gdbarch_tdep> (gdbarch);
 
   /* Remember regset characteristics.  The sizes should match
      elf_gregset_t and elf_fpregset_t from Linux.  */
diff --git a/gdb/sh-netbsd-tdep.c b/gdb/sh-netbsd-tdep.c
index 49760337c4b..a051736fc71 100644
--- a/gdb/sh-netbsd-tdep.c
+++ b/gdb/sh-netbsd-tdep.c
@@ -63,7 +63,7 @@ static void
 shnbsd_init_abi (struct gdbarch_info info,
 		  struct gdbarch *gdbarch)
 {
-  sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
+  sh_gdbarch_tdep *tdep = gdbarch_tdep_cast<sh_gdbarch_tdep> (gdbarch);
   nbsd_init_abi (info, gdbarch);
 
   tdep->core_gregmap = (struct sh_corefile_regmap *)regmap;
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 062df860c81..b4161764bb5 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1554,7 +1554,7 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 static struct type *
 sh_littlebyte_bigword_type (struct gdbarch *gdbarch)
 {
-  sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
+  sh_gdbarch_tdep *tdep = gdbarch_tdep_cast<sh_gdbarch_tdep> (gdbarch);
 
   if (tdep->sh_littlebyte_bigword_type == NULL)
     tdep->sh_littlebyte_bigword_type
@@ -2146,7 +2146,7 @@ sh_corefile_supply_regset (const struct regset *regset,
 			   int regnum, const void *regs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
+  sh_gdbarch_tdep *tdep = gdbarch_tdep_cast<sh_gdbarch_tdep> (gdbarch);
   const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset
 					     ? tdep->core_gregmap
 					     : tdep->core_fpregmap);
@@ -2172,7 +2172,7 @@ sh_corefile_collect_regset (const struct regset *regset,
 			    int regnum, void *regs, size_t len)
 {
   struct gdbarch *gdbarch = regcache->arch ();
-  sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
+  sh_gdbarch_tdep *tdep = gdbarch_tdep_cast<sh_gdbarch_tdep> (gdbarch);
   const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset
 					     ? tdep->core_gregmap
 					     : tdep->core_fpregmap);
@@ -2210,7 +2210,7 @@ sh_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				 void *cb_data,
 				 const struct regcache *regcache)
 {
-  sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
+  sh_gdbarch_tdep *tdep = gdbarch_tdep_cast<sh_gdbarch_tdep> (gdbarch);
 
   if (tdep->core_gregmap != NULL)
     cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset,
diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c
index 66481ea7b8a..068c8a64af5 100644
--- a/gdb/sparc-linux-tdep.c
+++ b/gdb/sparc-linux-tdep.c
@@ -254,7 +254,7 @@ static void
 sparc_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
   gdbarch *arch = regcache->arch ();
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (arch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (arch);
   ULONGEST psr;
 
   regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc);
@@ -421,7 +421,7 @@ static const struct regset sparc32_linux_fpregset =
 static void
 sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/sparc-netbsd-tdep.c b/gdb/sparc-netbsd-tdep.c
index 57c178511fa..62a207ea924 100644
--- a/gdb/sparc-netbsd-tdep.c
+++ b/gdb/sparc-netbsd-tdep.c
@@ -295,7 +295,7 @@ static const struct regset sparc32nbsd_fpregset =
 void
 sparc32nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   nbsd_init_abi (info, gdbarch);
 
diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c
index a92e95ce71b..e35a190e630 100644
--- a/gdb/sparc-sol2-tdep.c
+++ b/gdb/sparc-sol2-tdep.c
@@ -196,7 +196,7 @@ static const struct frame_unwind sparc32_sol2_sigtramp_frame_unwind =
 static void
 sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   tdep->gregset = &sparc32_sol2_gregset;
   tdep->sizeof_gregset = 152;
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 397f5489550..65051bdb2aa 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -425,7 +425,7 @@ sparc32_register_name (struct gdbarch *gdbarch, int regnum)
 static struct type *
 sparc_psr_type (struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   if (!tdep->sparc_psr_type)
     {
@@ -447,7 +447,7 @@ sparc_psr_type (struct gdbarch *gdbarch)
 static struct type *
 sparc_fsr_type (struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   if (!tdep->sparc_fsr_type)
     {
@@ -988,7 +988,7 @@ CORE_ADDR
 sparc_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
 			CORE_ADDR current_pc, struct sparc_frame_cache *cache)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
   unsigned long insn;
   int offset = 0;
   int dest = -1;
@@ -1680,7 +1680,7 @@ sparc_analyze_control_transfer (struct regcache *regcache,
 
       /* Trap instruction (TRAP).  */
       gdbarch *arch = regcache->arch ();
-      sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (arch);
+      sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (arch);
       return tdep->step_trap (frame, insn);
     }
 
@@ -1731,7 +1731,7 @@ static std::vector<CORE_ADDR>
 sparc_software_single_step (struct regcache *regcache)
 {
   struct gdbarch *arch = regcache->arch ();
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (arch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (arch);
   CORE_ADDR npc, nnpc;
 
   CORE_ADDR pc, orig_npc;
@@ -1761,7 +1761,7 @@ static void
 sparc_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
   gdbarch *arch = regcache->arch ();
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (arch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (arch);
 
   regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc);
   regcache_cooked_write_unsigned (regcache, tdep->npc_regnum, pc + 4);
@@ -1776,7 +1776,7 @@ sparc_iterate_over_regset_sections (struct gdbarch *gdbarch,
 				    void *cb_data,
 				    const struct regcache *regcache)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, tdep->gregset, NULL,
       cb_data);
diff --git a/gdb/sparc64-fbsd-tdep.c b/gdb/sparc64-fbsd-tdep.c
index 76c682fd521..d9cfffb14c2 100644
--- a/gdb/sparc64-fbsd-tdep.c
+++ b/gdb/sparc64-fbsd-tdep.c
@@ -222,7 +222,7 @@ static const struct regset sparc64fbsd_fpregset =
 static void
 sparc64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   /* Generic FreeBSD support. */
   fbsd_init_abi (info, gdbarch);
diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index f5940cfcdee..63c39475d95 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -262,7 +262,7 @@ static void
 sparc64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
   gdbarch *arch = regcache->arch ();
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (arch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (arch);
   ULONGEST state;
 
   regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc);
@@ -364,7 +364,7 @@ static const struct regset sparc64_linux_fpregset =
 static void
 sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/sparc64-netbsd-tdep.c b/gdb/sparc64-netbsd-tdep.c
index db368118f23..e2c7238de3b 100644
--- a/gdb/sparc64-netbsd-tdep.c
+++ b/gdb/sparc64-netbsd-tdep.c
@@ -248,7 +248,7 @@ static const struct regset sparc64nbsd_fpregset =
 static void
 sparc64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   nbsd_init_abi (info, gdbarch);
 
diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c
index d6470a51b65..5e0a33b6dc4 100644
--- a/gdb/sparc64-obsd-tdep.c
+++ b/gdb/sparc64-obsd-tdep.c
@@ -423,7 +423,7 @@ static const struct regset sparc64obsd_fpregset =
 static void
 sparc64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   tdep->gregset = &sparc64obsd_gregset;
   tdep->sizeof_gregset = 288;
diff --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c
index e656c359efa..4f90a044e8c 100644
--- a/gdb/sparc64-sol2-tdep.c
+++ b/gdb/sparc64-sol2-tdep.c
@@ -199,7 +199,7 @@ static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind =
 static void
 sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   tdep->gregset = &sparc64_sol2_gregset;
   tdep->sizeof_gregset = 304;
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 5ca5f2dca8c..45777f6494b 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -648,7 +648,7 @@ sparc64_structure_or_union_p (const struct type *type)
 static struct type *
 sparc64_pstate_type (struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   if (!tdep->sparc64_pstate_type)
     {
@@ -675,7 +675,7 @@ sparc64_pstate_type (struct gdbarch *gdbarch)
 static struct type *
 sparc64_ccr_type (struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   if (tdep->sparc64_ccr_type == NULL)
     {
@@ -700,7 +700,7 @@ sparc64_ccr_type (struct gdbarch *gdbarch)
 static struct type *
 sparc64_fsr_type (struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   if (!tdep->sparc64_fsr_type)
     {
@@ -733,7 +733,7 @@ sparc64_fsr_type (struct gdbarch *gdbarch)
 static struct type *
 sparc64_fprs_type (struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   if (!tdep->sparc64_fprs_type)
     {
@@ -1806,7 +1806,7 @@ sparc64_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
 void
 sparc64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  sparc_gdbarch_tdep *tdep = gdbarch_tdep<sparc_gdbarch_tdep> (gdbarch);
+  sparc_gdbarch_tdep *tdep = gdbarch_tdep_cast<sparc_gdbarch_tdep> (gdbarch);
 
   tdep->pc_regnum = SPARC64_PC_REGNUM;
   tdep->npc_regnum = SPARC64_NPC_REGNUM;
diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c
index b2422d1ccc0..dc862f2ca83 100644
--- a/gdb/tic6x-linux-tdep.c
+++ b/gdb/tic6x-linux-tdep.c
@@ -45,7 +45,7 @@ static const gdb_byte tic6x_bkpt_bnop_le[] = { 0x22, 0xa1, 0x00, 0x00 };
 static unsigned int
 tic6x_register_sigcontext_offset (unsigned int regnum, struct gdbarch *gdbarch)
 {
-  tic6x_gdbarch_tdep *tdep = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
+  tic6x_gdbarch_tdep *tdep = gdbarch_tdep_cast<tic6x_gdbarch_tdep> (gdbarch);
 
   if (regnum == TIC6X_A4_REGNUM || regnum == TIC6X_A4_REGNUM + 2
       || regnum == TIC6X_A4_REGNUM + 4)
@@ -92,7 +92,7 @@ tic6x_linux_rt_sigreturn_init (const struct tramp_frame *self,
 		    + TIC6X_SIGINFO_SIZE
 		    + 4 + 4 /* uc_flags and *uc_link in struct ucontext.  */
 		    + TIC6X_STACK_T_SIZE);
-  tic6x_gdbarch_tdep *tdep = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
+  tic6x_gdbarch_tdep *tdep = gdbarch_tdep_cast<tic6x_gdbarch_tdep> (gdbarch);
   unsigned int reg_offset;
   unsigned int i;
 
@@ -165,7 +165,7 @@ extern struct target_so_ops dsbt_so_ops;
 static void
 tic6x_uclinux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  tic6x_gdbarch_tdep *tdep = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
+  tic6x_gdbarch_tdep *tdep = gdbarch_tdep_cast<tic6x_gdbarch_tdep> (gdbarch);
 
   linux_init_abi (info, gdbarch, 0);
 
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index b7efcf18576..e0554417e0b 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -325,7 +325,7 @@ tic6x_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 static const gdb_byte *
 tic6x_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
 {
-  tic6x_gdbarch_tdep *tdep = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
+  tic6x_gdbarch_tdep *tdep = gdbarch_tdep_cast<tic6x_gdbarch_tdep> (gdbarch);
 
   *size = kind;
 
@@ -599,7 +599,7 @@ tic6x_get_next_pc (struct regcache *regcache, CORE_ADDR pc)
       if (inst == TIC6X_INST_SWE)
 	{
 	  tic6x_gdbarch_tdep *tdep
-	    = gdbarch_tdep<tic6x_gdbarch_tdep> (gdbarch);
+	    = gdbarch_tdep_cast<tic6x_gdbarch_tdep> (gdbarch);
 
 	  if (tdep->syscall_next_pc != NULL)
 	    return tdep->syscall_next_pc (get_current_frame ());
@@ -1217,7 +1217,7 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       tic6x_gdbarch_tdep *tdep
-	= gdbarch_tdep<tic6x_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<tic6x_gdbarch_tdep> (arches->gdbarch);
 
       if (has_gp != tdep->has_gp)
 	continue;
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 4de5faa6a47..67e8e350470 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -511,7 +511,7 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type)
 {
   int i;
   struct type *fld_type, *tgt_type;
-  v850_gdbarch_tdep *tdep = gdbarch_tdep<v850_gdbarch_tdep> (gdbarch);
+  v850_gdbarch_tdep *tdep = gdbarch_tdep_cast<v850_gdbarch_tdep> (gdbarch);
 
   if (tdep->abi == V850_ABI_RH850)
     {
@@ -1023,7 +1023,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
   int argnum;
   int arg_space = 0;
   int stack_offset;
-  v850_gdbarch_tdep *tdep = gdbarch_tdep<v850_gdbarch_tdep> (gdbarch);
+  v850_gdbarch_tdep *tdep = gdbarch_tdep_cast<v850_gdbarch_tdep> (gdbarch);
 
   if (tdep->abi == V850_ABI_RH850)
     stack_offset = 0;
@@ -1374,7 +1374,7 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        arches = gdbarch_list_lookup_by_info (arches->next, &info))
     {
       v850_gdbarch_tdep *tdep
-	= gdbarch_tdep<v850_gdbarch_tdep> (arches->gdbarch);
+	= gdbarch_tdep_cast<v850_gdbarch_tdep> (arches->gdbarch);
 
       if (tdep->e_flags != e_flags || tdep->e_machine != e_machine)
 	continue;
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 43a2c112db5..830144fa2c4 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -486,7 +486,7 @@ windows_fetch_one_register (struct regcache *regcache,
 
   char *context_offset = context_ptr + windows_process.mappings[r];
   struct gdbarch *gdbarch = regcache->arch ();
-  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep_cast<i386_gdbarch_tdep> (gdbarch);
 
   gdb_assert (!gdbarch_read_pc_p (gdbarch));
   gdb_assert (gdbarch_pc_regnum (gdbarch) >= 0);
diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
index d005c9d8f78..9e9e9081406 100644
--- a/gdb/xtensa-linux-nat.c
+++ b/gdb/xtensa-linux-nat.c
@@ -62,7 +62,7 @@ fill_gregset (const struct regcache *regcache,
   int i;
   xtensa_elf_gregset_t *regs = (xtensa_elf_gregset_t *) gregsetp;
   struct gdbarch *gdbarch = regcache->arch ();
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
     regcache->raw_collect (gdbarch_pc_regnum (gdbarch), &regs->pc);
@@ -124,7 +124,7 @@ supply_gregset_reg (struct regcache *regcache,
   xtensa_elf_gregset_t *regs = (xtensa_elf_gregset_t *) gregsetp;
 
   struct gdbarch *gdbarch = regcache->arch ();
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
     regcache->raw_supply (gdbarch_pc_regnum (gdbarch), &regs->pc);
diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c
index 600b59b8894..9602dccc0b0 100644
--- a/gdb/xtensa-linux-tdep.c
+++ b/gdb/xtensa-linux-tdep.c
@@ -99,7 +99,7 @@ xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
 static void
 xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   if (tdep->num_nopriv_regs < tdep->num_regs)
     {
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index f881870e244..ce990958d6d 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -116,7 +116,7 @@ static unsigned int xtensa_debug_level = 0;
 static int
 windowing_enabled (struct gdbarch *gdbarch, unsigned int ps)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   /* If we know CALL0 ABI is set explicitly,  say it is Call0.  */
   if (tdep->call_abi == CallAbiCall0Only)
@@ -130,7 +130,7 @@ windowing_enabled (struct gdbarch *gdbarch, unsigned int ps)
 static int
 arreg_number (struct gdbarch *gdbarch, int a_regnum, ULONGEST wb)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   int arreg;
 
   arreg = a_regnum - tdep->a0_base;
@@ -145,7 +145,7 @@ arreg_number (struct gdbarch *gdbarch, int a_regnum, ULONGEST wb)
 static int
 areg_number (struct gdbarch *gdbarch, int ar_regnum, unsigned int wb)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   int areg;
 
   areg = ar_regnum - tdep->ar_base;
@@ -226,7 +226,7 @@ static int
 xtensa_find_register_by_name (struct gdbarch *gdbarch, const char *name)
 {
   int i;
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++)
     if (strcasecmp (tdep->regmap[i].name, name) == 0)
@@ -239,7 +239,7 @@ xtensa_find_register_by_name (struct gdbarch *gdbarch, const char *name)
 static const char *
 xtensa_register_name (struct gdbarch *gdbarch, int regnum)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   /* Return the name stored in the register map.  */
   if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch))
@@ -254,7 +254,7 @@ xtensa_register_name (struct gdbarch *gdbarch, int regnum)
 static struct type *
 xtensa_register_type (struct gdbarch *gdbarch, int regnum)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   /* Return signed integer for ARx and Ax registers.  */
   if ((regnum >= tdep->ar_base
@@ -339,7 +339,7 @@ static int
 xtensa_reg_to_regnum (struct gdbarch *gdbarch, int regnum)
 {
   int i;
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   if (regnum >= 0 && regnum < 16)
     return tdep->a0_base + regnum;
@@ -542,7 +542,7 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch,
 {
   DEBUGTRACE ("xtensa_pseudo_register_read (... regnum = %d (%s) ...)\n",
 	      regnum, xtensa_register_name (gdbarch, regnum));
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   /* Read aliases a0..a15, if this is a Windowed ABI.  */
   if (tdep->isa_use_windowed_registers
@@ -634,7 +634,7 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch,
 {
   DEBUGTRACE ("xtensa_pseudo_register_write (... regnum = %d (%s) ...)\n",
 	      regnum, xtensa_register_name (gdbarch, regnum));
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   /* Renumber register, if aliases a0..a15 on Windowed ABI.  */
   if (tdep->isa_use_windowed_registers
@@ -767,7 +767,7 @@ xtensa_register_reggroup_p (struct gdbarch *gdbarch,
 			    int regnum,
 			    const struct reggroup *group)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   xtensa_register_t* reg = &tdep->regmap[regnum];
   xtensa_register_type_t type = reg->type;
   xtensa_register_group_t rg = reg->group;
@@ -821,7 +821,7 @@ xtensa_supply_gregset (const struct regset *regset,
 {
   const xtensa_elf_gregset_t *regs = (const xtensa_elf_gregset_t *) gregs;
   struct gdbarch *gdbarch = rc->arch ();
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   int i;
 
   DEBUGTRACE ("xtensa_supply_gregset (..., regnum==%d, ...)\n", regnum);
@@ -1050,7 +1050,7 @@ static struct frame_id
 xtensa_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
 {
   CORE_ADDR pc, fp;
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   /* THIS-FRAME is a dummy frame.  Return a frame ID of that frame.  */
 
@@ -1105,7 +1105,7 @@ xtensa_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR current_pc)
 {
 #define RETURN_FP goto done
 
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   unsigned int fp_regnum = tdep->a0_base + 1;
   CORE_ADDR start_addr;
   xtensa_isa isa;
@@ -1255,7 +1255,7 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache)
   if (windowed)
     {
       LONGEST op1;
-      xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+      xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
       /* Get WINDOWBASE, WINDOWSTART, and PS registers.  */
       wb = get_frame_register_unsigned (this_frame, 
@@ -1417,7 +1417,7 @@ xtensa_frame_prev_register (struct frame_info *this_frame,
   struct xtensa_frame_cache *cache;
   ULONGEST saved_reg = 0;
   int done = 1;
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   if (*this_cache == NULL)
     *this_cache = xtensa_frame_cache (this_frame, this_cache);
@@ -1546,7 +1546,7 @@ xtensa_extract_return_value (struct type *type,
 
   gdb_assert(len > 0);
 
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   if (tdep->call_abi != CallAbiCall0Only)
     {
       /* First, we have to find the caller window in the register file.  */
@@ -1602,7 +1602,7 @@ xtensa_store_return_value (struct type *type,
 
   DEBUGTRACE ("xtensa_store_return_value (...)\n");
 
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   if (tdep->call_abi != CallAbiCall0Only)
     {
       regcache_raw_read_unsigned 
@@ -1686,7 +1686,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
 			CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   int size, onstack_size;
   gdb_byte *buf = (gdb_byte *) alloca (16);
   CORE_ADDR ra, ps;
@@ -1935,7 +1935,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
 static int
 xtensa_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   if (tdep->isa_use_density_instructions)
     return 2;
@@ -2182,7 +2182,7 @@ call0_track_op (struct gdbarch *gdbarch, xtensa_c0reg_t dst[], xtensa_c0reg_t sr
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   unsigned litbase, litaddr, litval;
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   switch (opclass)
     {
@@ -2557,7 +2557,7 @@ call0_frame_cache (struct frame_info *this_frame,
   CORE_ADDR body_pc=UINT_MAX;	/* PC, where prologue analysis stopped.  */
   CORE_ADDR sp, fp, ra;
   int fp_regnum = C0_SP, c0_hasfp = 0, c0_frmsz = 0, prev_sp = 0, to_stk;
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
  
   sp = get_frame_register_unsigned
     (this_frame, tdep->a0_base + 1);
@@ -2710,7 +2710,7 @@ static int a11_was_saved;
 static void
 execute_l32e (struct gdbarch *gdbarch, int at, int as, int offset, CORE_ADDR wb)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   int atreg = arreg_number (gdbarch, tdep->a0_base + at, wb);
   int asreg = arreg_number (gdbarch, tdep->a0_base + as, wb);
   CORE_ADDR addr = xtensa_read_register (asreg) + offset;
@@ -2740,7 +2740,7 @@ execute_l32e (struct gdbarch *gdbarch, int at, int as, int offset, CORE_ADDR wb)
 static void
 execute_s32e (struct gdbarch *gdbarch, int at, int as, int offset, CORE_ADDR wb)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   int atreg = arreg_number (gdbarch, tdep->a0_base + at, wb);
   int asreg = arreg_number (gdbarch, tdep->a0_base + as, wb);
   CORE_ADDR addr = xtensa_read_register (asreg) + offset;
@@ -2774,7 +2774,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb)
   xtensa_opcode opc;
   int insn_num = 0;
   void (*func) (struct gdbarch *, int, int, int, CORE_ADDR);
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   uint32_t at, as, offset;
 
@@ -2905,7 +2905,7 @@ xtensa_window_interrupt_frame_cache (struct frame_info *this_frame,
   CORE_ADDR ps, wb, ws, ra;
   int epc1_regnum, i, regnum;
   xtensa_exception_handler_t eh_type;
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
 
   /* Read PS, WB, and WS from the hardware. Note that PS register
      must be present, if Windowed ABI is supported.  */
@@ -3019,7 +3019,7 @@ xtensa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 
       CORE_ADDR end_func;
 
-      xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+      xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
       if ((tdep->call_abi == CallAbiCall0Only)
 	  && call0_ret (start_pc, prologue_sal.end))
 	return start_pc;
@@ -3041,7 +3041,7 @@ xtensa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 static void
 xtensa_verify_config (struct gdbarch *gdbarch)
 {
-  xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
+  xtensa_gdbarch_tdep *tdep = gdbarch_tdep_cast<xtensa_gdbarch_tdep> (gdbarch);
   string_file log;
 
   /* Verify that we got a reasonable number of AREGS.  */
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index 6a11883e7b4..d7f4625fbf3 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -308,7 +308,7 @@ z80_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end,
 		   struct z80_unwind_cache *info)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  z80_gdbarch_tdep *tdep = gdbarch_tdep<z80_gdbarch_tdep> (gdbarch);
+  z80_gdbarch_tdep *tdep = gdbarch_tdep_cast<z80_gdbarch_tdep> (gdbarch);
   int addr_len = tdep->addr_length;
   gdb_byte prologue[32]; /* max prologue is 24 bytes: __interrupt with local array */
   int pos = 0;
@@ -564,7 +564,7 @@ z80_frame_unwind_cache (struct frame_info *this_frame,
   gdb_byte buf[sizeof(void*)];
   struct z80_unwind_cache *info;
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
-  z80_gdbarch_tdep *tdep = gdbarch_tdep<z80_gdbarch_tdep> (gdbarch);
+  z80_gdbarch_tdep *tdep = gdbarch_tdep_cast<z80_gdbarch_tdep> (gdbarch);
   int addr_len = tdep->addr_length;
 
   if (*this_prologue_cache)
@@ -697,7 +697,7 @@ z80_frame_prev_register (struct frame_info *this_frame,
 	  ULONGEST pc;
 	  gdb_byte buf[3];
 	  struct gdbarch *gdbarch = get_frame_arch (this_frame);
-	  z80_gdbarch_tdep *tdep = gdbarch_tdep<z80_gdbarch_tdep> (gdbarch);
+	  z80_gdbarch_tdep *tdep = gdbarch_tdep_cast<z80_gdbarch_tdep> (gdbarch);
 	  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
 
 	  read_memory (info->saved_regs[Z80_PC_REGNUM].addr (),
@@ -750,7 +750,7 @@ z80_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
   else /* kind is non-RST address, use CALL instead, but it is dungerous */
     {
-      z80_gdbarch_tdep *tdep = gdbarch_tdep<z80_gdbarch_tdep> (gdbarch);
+      z80_gdbarch_tdep *tdep = gdbarch_tdep_cast<z80_gdbarch_tdep> (gdbarch);
       gdb_byte *p = break_insn;
       *p++ = 0xcd;
       *p++ = (kind >> 0) & 0xff;
-- 
2.30.2



More information about the Gdb-patches mailing list