From e86d5cf30f28a748b17a42ecc9a2ad4119ef8c3d Mon Sep 17 00:00:00 2001
From: David Edelsohn <dje.gcc@gmail.com>
Date: Wed, 21 Feb 1996 05:50:03 +0000
Subject: [PATCH] 	* config/tc-sparc.c (parse_keyword_arg): Accept
 leadling '%'. 	(sparc_ip): Accept %asr[1..31] for v8 and %asr[%16..31] for
 v9. 	Recognize [uU] format args as sparclet cpregs.

---
 gas/config/tc-sparc.c | 42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)

diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c
index 0cac1fef48c..d06d3b3870f 100644
--- a/gas/config/tc-sparc.c
+++ b/gas/config/tc-sparc.c
@@ -760,7 +760,7 @@ BSR (val, amount)
 }
 
 /* Parse an argument that can be expressed as a keyword.
-   (eg: #StoreStore).
+   (eg: #StoreStore or %ccfr).
    The result is a boolean indicating success.
    If successful, INPUT_POINTER is updated.  */
 
@@ -774,7 +774,7 @@ parse_keyword_arg (lookup_fn, input_pointerP, valueP)
   char c, *p, *q;
 
   p = *input_pointerP;
-  for (q = p + (*p == '#'); isalpha (*q) || *q == '_'; ++q)
+  for (q = p + (*p == '#' || *p == '%'); isalpha (*q) || *q == '_'; ++q)
     continue;
   c = *q;
   *q = 0;
@@ -1008,11 +1008,22 @@ sparc_ip (str)
 			  ++s;
 			}
 
-		      if (num < 16 || 31 < num)
+		      if (current_architecture >= SPARC_OPCODE_ARCH_V9)
 			{
-			  error_message = ": asr number must be between 15 and 31";
-			  goto error;
-			}	/* out of range */
+			  if (num < 16 || 31 < num)
+			    {
+			      error_message = ": asr number must be between 16 and 31";
+			      goto error;
+			    }
+			}
+		      else
+			{
+			  if (num < 1 || 31 < num)
+			    {
+			      error_message = ": asr number must be between 1 and 31";
+			      goto error;
+			    }
+			}
 
 		      opcode |= (*args == 'M' ? RS1 (num) : RD (num));
 		      continue;
@@ -1021,9 +1032,8 @@ sparc_ip (str)
 		    {
 		      error_message = ": expecting %asrN";
 		      goto error;
-		    }		/* if %asr followed by a number. */
-
-		}		/* if %asr */
+		    }
+		} /* if %asr */
 	      break;
 
 	    case 'I':
@@ -1744,6 +1754,20 @@ sparc_ip (str)
 	      s += 2;
 	      continue;
 
+	    case 'u':
+	    case 'U':
+	      {
+		/* Parse a sparclet cpreg.  */
+		int cpreg;
+		if (! parse_keyword_arg (sparc_encode_sparclet_cpreg, &s, &cpreg))
+		  {
+		    error_message = ": invalid cpreg name";
+		    goto error;
+		  }
+		opcode |= (*args == 'U' ? RS1 (cpreg) : RD (cpreg));
+		continue;
+	      }
+
 	    default:
 	      as_fatal ("failed sanity check.");
 	    }			/* switch on arg code */