Subject: changes for gcc-2.6.2, target ns32k
To: Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
From: Matthias Pfaller <leo@marco.de>
List: port-pc532
Date: 11/23/1994 10:14:12
Hi Richard,

here comes a bunch of changes to gcc-2.6.2 for ns32k.

	Matthias

Wed Nov 23 10:12:54 1994  Ian Dall  (dall@hfrd.dsto.gov.au)

	* config/ns32k/{ns32k.c,ns32k.h}: Add -mhimem option to
	support linking kernels etc above the 0x20000000 boundary.

	* config/ns32k/{netbsd.h,pc532.h, ns32k.c}: Interpretation of
	BASE_REG_NEEDED was wrong. It should be used to indicate
	broken assemblers which can't do absolute addressing.

Sun Nov 20 11:55:58 MET 1994  Matthias Pfaller (leo@marco.de)

	* configure (ns32k-pc532-netbsd): No need for fixincludes
	and libgcc1.
	* ns32k/ns32k.h (CONST_COSTS): Range -0x3fff to 0x4000 was
	wrong. Correct range is -0x1fff to 0x2000.
	* ns32k/ns32k.md (everywhere): Range -0x3fff to 0x4000 was
	wrong. Correct range is -0x1fffffff to 0x20000000. Constants
	not in this range have to be loaded with movd. Try to
	shortcircuit with TARGET_32532 as early as possible.
	(movsi): Use movd to load unknown symbol values to allow
	addresses greater then 0x20000000 (but for -fpic addr has to
	be used).
	* ns32k/ns32k.c (print_operand): Removed dead code.
	* ns32k/pc532.h (TARGET_DEFAULT): Forbid usage of bitfield
	instructions.

--- 1.1	1994/11/17 07:04:25
+++ netbsd.h	1994/11/17 22:47:03
@@ -63,10 +63,6 @@
 
 #define MOVD_FLOAT_OK
 
-/* Every address needs to use a base reg.  */
-
-#define BASE_REG_NEEDED
-
 /* Names to predefine in the preprocessor for this target machine.  */
 
 #undef CPP_PREDEFINES
--- 1.1	1994/11/17 07:04:14
+++ ns32k.c	1994/11/17 21:55:56
@@ -451,21 +451,7 @@
   else if (GET_CODE (x) == MEM)
     {
       rtx tmp = XEXP (x, 0);
-#if ! (defined (PC_RELATIVE) || defined (NO_ABSOLUTE_PREFIX_IF_SYMBOLIC))
-      if (GET_CODE (tmp) != CONST_INT)
-	{
-	  char *out = XSTR (tmp, 0);
-	  if (out[0] == '*')
-	    {
-	      PUT_ABSOLUTE_PREFIX (file);
-	      fprintf (file, "%s", &out[1]);
-	    }
-	  else
-	    ASM_OUTPUT_LABELREF (file, out);
-	}
-      else
-#endif
-	output_address (XEXP (x, 0));
+      output_address (XEXP (x, 0));
     }
   else if (GET_CODE (x) == CONST_DOUBLE && GET_MODE (x) != VOIDmode)
     {
@@ -615,7 +601,7 @@
 	      rtx sym, off, tmp1;
 	      tmp1 = XEXP (tmp,0);
 	      if (GET_CODE (tmp1)  != PLUS)
-	abort ();
+		abort ();
 
 	      sym = XEXP (tmp1,0);
 	      if (GET_CODE (sym) != SYMBOL_REF)
@@ -670,7 +656,7 @@
 
   if (base
 #ifndef INDEX_RATHER_THAN_BASE
-      && flag_pic 
+      && (flag_pic || TARGET_HIMEM)
       && GET_CODE (base) != SYMBOL_REF 
       && GET_CODE (offset) != CONST_INT
 #else
@@ -684,15 +670,15 @@
     }
 
   /* now, offset, base and indexexp are set */
+#ifndef BASE_REG_NEEDED
   if (! base)
     {
 #if defined (PC_RELATIVE) || defined (NO_ABSOLUTE_PREFIX_IF_SYMBOLIC)
       if (GET_CODE (offset) == CONST_INT)
-/*      if (! (GET_CODE (offset) == LABEL_REF
-	     || GET_CODE (offset) == SYMBOL_REF)) */
 #endif
 	PUT_ABSOLUTE_PREFIX (file);
     }
+#endif
 
   output_addr_const (file, offset);
   if (base) /* base can be (REG ...) or (MEM ...) */
@@ -711,8 +697,8 @@
 	fprintf (file, "(%s)", reg_names[REGNO (base)]);
 	break;
       case SYMBOL_REF:
-	  if (! flag_pic)
-	    abort ();
+	if (! flag_pic)
+	  abort ();
 
         fprintf (file, "(");
 	output_addr_const (file, base);
@@ -766,45 +752,26 @@
 	output_addr_const (file, offset);
 	if (base)
 	  fprintf (file, "(%s)", reg_names[REGNO (base)]);
-#ifdef BASE_REG_NEEDED
 	else if (TARGET_SB)
 	  fprintf (file, "(sb)");
 	else
 	  abort ();
-#endif
 	fprintf (file, ")");
 	break;
-
       default:
 	abort ();
       }
 #ifdef PC_RELATIVE
-  else if (GET_CODE (offset) == LABEL_REF
-	   || GET_CODE (offset) == SYMBOL_REF
-	   || GET_CODE (offset) == CONST
-	   || GET_CODE (offset) == PLUS)
+  else if (GET_CODE (offset) != CONST_INT)
     fprintf (file, "(pc)");
-#endif
 #ifdef BASE_REG_NEEDED
-  else 
-    {
-      /* Abs. addresses don't need a base (I think). */
-      if (GET_CODE (offset) != CONST_INT
-#ifndef PC_RELATIVE
-	  && GET_CODE (offset) != LABEL_REF
-	  && GET_CODE (offset) != SYMBOL_REF
-	  && GET_CODE (offset) != CONST
-	  && GET_CODE (offset) != PLUS
-#endif
-         )
-        {
-	  if (TARGET_SB)
-	    fprintf (file, "(sb)");
-	  else
-	    abort ();
-        }
-    }
+  else if (TARGET_SB)
+    fprintf (file, "(sb)");
+  else
+    abort ();
 #endif
+#endif /* PC_RELATIVE */
+
   /* now print index if we have one */
   if (indexexp)
     {
--- 1.1	1994/11/17 07:04:14
+++ ns32k.h	1994/11/17 22:45:47
@@ -81,6 +81,7 @@
 
 /* Ok to use the static base register (and presume it's 0) */
 #define TARGET_SB    ((target_flags & 32) == 0)
+#define TARGET_HIMEM (target_flags & 128)
 
 /* Compile using bitfield insns.  */
 #define TARGET_BITFIELD ((target_flags & 64) == 0)
@@ -106,6 +107,8 @@
     { "nosb", 32},				\
     { "bitfield", -64},				\
     { "nobitfield", 64},			\
+    { "himem", 128},				\
+    { "nohimem", -128},				\
     { "", TARGET_DEFAULT}}
 /* TARGET_DEFAULT is defined in encore.h, pc532.h, etc.  */
 
@@ -114,7 +117,7 @@
 
 #define OVERRIDE_OPTIONS		\
 {					\
-  if (flag_pic) target_flags |= 32;	\
+  if (flag_pic || TARGET_HIMEM) target_flags |= 32;	\
 }
 
 
@@ -910,7 +913,7 @@
    || (GET_CODE (X) == PLUS						\
        && GET_CODE (XEXP (X, 0)) == REG					\
        && REG_OK_FOR_BASE_P (XEXP (X, 0))				\
-       && (flag_pic ? 							\
+       && ((flag_pic || TARGET_HIMEM) ? 				\
 	     CONSTANT_ADDRESS_NO_LABEL_P (XEXP (X, 1))	 		\
 	   :								\
 	     CONSTANT_ADDRESS_P (XEXP (X, 1))) 				\
@@ -1142,7 +1145,7 @@
 #define CONST_COSTS(RTX,CODE,OUTER_CODE) \
   case CONST_INT:						\
     if (INTVAL (RTX) <= 7 && INTVAL (RTX) >= -8) return 0;	\
-    if (INTVAL (RTX) < 0x4000 && INTVAL (RTX) >= -0x4000)	\
+    if (INTVAL (RTX) < 0x2000 && INTVAL (RTX) >= -0x2000)	\
       return 1;							\
   case CONST:							\
   case LABEL_REF:						\
--- 1.1	1994/11/17 07:04:14
+++ ns32k.md	1994/11/17 22:48:51
@@ -318,6 +318,8 @@
   ""
   "*
 {
+  extern int flag_pic;						\
+
   if (FP_REG_P (operands[0]))
     {
       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 8)
@@ -344,16 +346,25 @@
 	{
 	  if (i <= 7 && i >= -8)
 	    return \"movqd %1,%0\";
-	  if (i < 0x4000 && i >= -0x4000)
+	  if (i <= 0x1fffffff && i >= -0x20000000)
 #if defined (GNX_V3) || defined (UTEK_ASM)
 	    return \"addr %c1,%0\";
 #else
 	    return \"addr @%c1,%0\";
 #endif
+	  return \"movd %$%1,%0\";
 	}
       else
         return output_move_dconst(i, \"%$%1,%0\");
     }
+  else if (GET_CODE (operands[1]) == CONST && ! flag_pic)
+    {
+	/* Must contain symbols so we don`t know how big it is. In
+	 * that case addr might lead to overflow. For PIC symbolic
+	 * address loads always have to be done with addr.
+	 */
+	return \"movd %$%1,%0\";
+    }
   else if (GET_CODE (operands[1]) == REG)
     {
       if (REGNO (operands[1]) < 16)
@@ -867,8 +878,8 @@
 
       if (i <= 7 && i >= -8)
 	return \"addqd %2,%0\";
-      else if (GET_CODE (operands[0]) == REG
-	       && i < 0x4000 && i >= -0x4000 && ! TARGET_32532)
+      else if (! TARGET_32532 && GET_CODE (operands[0]) == REG
+	       && i <= 0x1fffffff && i >= -0x20000000)
 	return \"addr %c2(%0),%0\";
     }
   return \"addd %2,%0\";
@@ -953,8 +964,8 @@
   "GET_CODE (operands[0]) == CONST_INT"
   "*
 {
-  if (GET_CODE(operands[0]) == CONST_INT && INTVAL(operands[0]) < 64
-      && INTVAL(operands[0]) > -64 && ! TARGET_32532)
+  if (! TARGET_32532 && GET_CODE(operands[0]) == CONST_INT 
+      && INTVAL(operands[0]) < 64 && INTVAL(operands[0]) > -64)
     return \"adjspb %$%0\";
   return \"adjspd %$%0\";
 }")
@@ -1443,7 +1454,7 @@
     {
       if (INTVAL (operands[2]) == 1)
 	return \"addw %0,%0\";
-      else if (INTVAL (operands[2]) == 2 && !TARGET_32532)
+      else if (! TARGET_32532 && INTVAL (operands[2]) == 2)
 	return \"addw %0,%0\;addw %0,%0\";
     }
   if (TARGET_32532)
@@ -1462,7 +1473,7 @@
     {
       if (INTVAL (operands[2]) == 1)
 	return \"addb %0,%0\";
-      else if (INTVAL (operands[2]) == 2 && !TARGET_32532)
+      else if (! TARGET_32532 && INTVAL (operands[2]) == 2)
 	return \"addb %0,%0\;addb %0,%0\";
     }
   if (TARGET_32532)
--- pc532.h	Tue Feb 22 14:10:23 1994
+++ /var/tmp/ns32k/pc532.h	Tue Sep 13 00:22:08 1994
@@ -23,9 +23,9 @@
 #include "ns32k/ns32k.h"
 
 /* Compile for the floating point unit & 32532 by default;
-   also presume SB is zero */
+   also presume SB is zero and no bitfield instructions */
 
-#define TARGET_DEFAULT 25
+#define TARGET_DEFAULT (1 + 24 + 64)
 
 /* Write DBX debugging info for gdb to read */
 
@@ -70,7 +70,3 @@
 /* movd insns may have floating point constant operands.  */
 
 #define MOVD_FLOAT_OK
-
-/* Every address needs to use a base reg.  */
-
-#define BASE_REG_NEEDED
--- configure.orig	Wed Nov 16 22:47:29 1994
+++ configure	Sat Nov 19 00:59:22 1994
@@ -1728,6 +1728,10 @@
 	ns32k-pc532-netbsd*)
 		tm_file=ns32k/netbsd.h
 		xm_file=ns32k/xm-netbsd.h
+		tmake_file=t-libc-ok
+		# On NetBSD, the headers are already okay.
+		fixincludes=Makefile.in
+		xmake_file=x-netbsd
 		;;
 	pyramid-*-*)
 		cpu_type=pyr