This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Code cleanup in tc-mips.c


Hi All,

this patch does some code cleanup and fixes the still unused parsing
of %gp_rel.


Thiemo


2001-08-21  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/gas/ChangeLog
	* tc_mips.h (MAX_GPREL_OFFSET): Change it to the maximum allowed
	value, not the word beyond maximum.
	* tc_mips.c (macro_build_lui): Code cleanup.
	(macro): Reflect change to MAX_GPREL_OFFSET.
	(mips_ip): Check explicitly against S_EX_NONE.
	(my_get_SmallExpression): parse for %gp_rel, not %gprel.
	(md_apply_fix): Code cleanup.


diff -BurpNX /bigdisk/src/binutils-exclude src-orig/gas/config/tc-mips.h src/gas/config/tc-mips.h
--- src-orig/gas/config/tc-mips.h	Sat Aug 18 21:47:23 2001
+++ src/gas/config/tc-mips.h	Sat Aug 18 22:42:17 2001
@@ -47,7 +47,7 @@ struct expressionS;
 
 /* Maximum symbol offset that can be encoded in a BFD_RELOC_MIPS_GPREL
    relocation: */
-#define MAX_GPREL_OFFSET (0x7FF4)
+#define MAX_GPREL_OFFSET (0x7FF0)
 
 #define md_relax_frag(segment, fragp, stretch) mips_relax_frag(fragp, stretch)
 extern int mips_relax_frag PARAMS ((struct frag *, long));
diff -BurpNX /bigdisk/src/binutils-exclude src-orig/gas/config/tc-mips.c src/gas/config/tc-mips.c
--- src-orig/gas/config/tc-mips.c	Sat Aug 18 21:47:23 2001
+++ src/gas/config/tc-mips.c	Tue Aug 21 18:21:49 2001
@@ -2861,10 +2927,8 @@ macro_build_lui (place, counter, ep, reg
   if (high_expr.X_op == O_constant)
     {
       /* we can compute the instruction now without a relocation entry */
-      if (high_expr.X_add_number & 0x8000)
-	high_expr.X_add_number += 0x10000;
-      high_expr.X_add_number =
-	((unsigned long) high_expr.X_add_number >> 16) & 0xffff;
+      high_expr.X_add_number = ((high_expr.X_add_number + 0x8000)
+				>> 16) & 0xffff;
       r = BFD_RELOC_UNUSED;
     }
   else
@@ -4963,6 +5148,6 @@ macro (ip)
 	  if (breg == 0)
 	    {
-	      if ((valueT) offset_expr.X_add_number >= MAX_GPREL_OFFSET
+	      if ((valueT) offset_expr.X_add_number > MAX_GPREL_OFFSET
 		  || nopic_need_relax (offset_expr.X_add_symbol, 1))
 		p = NULL;
 	      else
@@ -4991,7 +5257,7 @@ macro (ip)
 	    }
 	  else
 	    {
-	      if ((valueT) offset_expr.X_add_number >= MAX_GPREL_OFFSET
+	      if ((valueT) offset_expr.X_add_number > MAX_GPREL_OFFSET
 		  || nopic_need_relax (offset_expr.X_add_symbol, 1))
 		p = NULL;
 	      else
@@ -5486,7 +5752,7 @@ macro (ip)
 	     If there is a base register, we add it to $at after the
 	     lui instruction.  If there is a constant, we always use
 	     the last case.  */
-	  if ((valueT) offset_expr.X_add_number >= MAX_GPREL_OFFSET
+	  if ((valueT) offset_expr.X_add_number > MAX_GPREL_OFFSET
 	      || nopic_need_relax (offset_expr.X_add_symbol, 1))
 	    {
 	      p = NULL;
@@ -7790,7 +8060,7 @@ mips_ip (str, ip)
 	    case 'u':		/* upper 16 bits */
 	      c = my_getSmallExpression (&imm_expr, s);
 	      imm_reloc = BFD_RELOC_LO16;
-	      if (c)
+	      if (c != S_EX_NONE)
 		{
 		  if (c != S_EX_LO)
 		    {
@@ -8661,13 +8931,14 @@ my_getSmallExpression (ep, str)
   else if (str[0] == '%'
 	   && tolower(str[1]) == 'g'
 	   && tolower(str[2]) == 'p'
-	   && tolower(str[3]) == 'r'
-	   && tolower(str[4]) == 'e'
-	   && tolower(str[5]) == 'l'
-	   && str[6] == '(')
+	   && tolower(str[3]) == '_'
+	   && tolower(str[4]) == 'r'
+	   && tolower(str[5]) == 'e'
+	   && tolower(str[6]) == 'l'
+	   && str[7] == '(')
     {
       c = S_EX_GPREL;
-      str += sizeof ("%gprel(") - 2;
+      str += sizeof ("%gp_rel(") - 2;
     }
   else if (str[0] == '%'
 	   && tolower(str[1]) == 'n'
@@ -9703,9 +9995,7 @@ md_apply_fix (fixP, valueP)
 	  value += (fixP->fx_next->fx_frag->fr_address
 		    + fixP->fx_next->fx_where);
 	}
-      if (value & 0x8000)
-	value += 0x10000;
-      value >>= 16;
+      value = ((value + 0x8000) >> 16) & 0xffff;
       buf = (unsigned char *) fixP->fx_frag->fr_literal + fixP->fx_where;
       if (target_big_endian)
 	buf += 2;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]