Patch: redo of new insns for pa2.0

Jerry Quinn jquinn@nortelnetworks.com
Fri Jul 30 12:12:00 GMT 1999


This is a redo of a patch I sent in a few weeks ago.  It redoes the
instructions and adds test cases.

This patch adds several pa2.0 instructions to gas.  It adds popbts, 64 bit
versions of bb and new syntax for bvb variant, havg, hshladd, hshradd, shrpd,
and shrpw.

ChangeLog entry:

Fri Jul 30 14:52:21 EDT 1999  Jerry Quinn <jquinn@nortelnetworks.com>

    * include/opcode/hppa.h (pa_opcodes):  Add popbts, new forms of bb, havg,
    hshladd, hshradd, shrpd, and shrpw instructions.  Update arg comments.
    * gas/config/tc-hppa.c (pa_ip):  Add cases for '.', '~'. '$'. and '!'
    * opcodes/hppa-dis.c (print_insn_hppa):  Likewise.
    * gas/testsuite/gas/hppa/basic/basic.exp (do_branch2,do_media): New.
    * gas/testsuite/gas/hppa/basic/branch2.s:  New.
    * gas/testsuite/gas/hppa/basic/media.s:  New.

*** pa-prev/include/opcode/hppa.h	Thu Jul 29 17:26:27 1999
--- gas-src/include/opcode/hppa.h	Fri Jul 30 14:27:31 1999
***************
*** 70,78 ****
  
     In the args field, the following characters are unused:
  
! 	' !"#$%&   *+- ./          :;< > @'
! 	'            M       U     [\]  '
! 	'a  d                      {|}~'
  
     Here are all the characters:
  
--- 70,78 ----
  
     In the args field, the following characters are unused:
  
! 	'  "# %&   *+-  /          :;< > @'
! 	'  C        LM       U   YZ[\]  '
! 	'a  d       l              {|} '
  
     Here are all the characters:
  
***************
*** 88,96 ****
     5    5 bit immediate at 15.
     s    2 bit space specifier at 17.
     S    3 bit space specifier at 18.
-    c    indexed load completer.
-    C    short load and store completer.
-    Y	Store Bytes Short completer
     V    5 bit immediate value at 31
     i    11 bit immediate value at 31
     j    14 bit immediate value at 31
--- 88,93 ----
***************
*** 145,158 ****
  
  Also these:
  
     p    5 bit shift count at 26 (to support the SHD instruction) encoded as
          31-p
     P    5 bit bit position at 26
     T    5 bit field length at 31 (encoded as 32-T)
     A    13 bit immediate at 18 (to support the BREAK instruction)
     ^	like b, but describes a control register
!    Z    System Control Completer (to support LPA, LHA, etc.)
     D    26 bit immediate at 31 (to support the DIAG instruction)
  
     f    3 bit Special Function Unit identifier at 25
     O    20 bit Special Function Unit operation split between 15 bits at 20
--- 142,158 ----
  
  Also these:
  
+    .    2 bit shift amount at 25
     p    5 bit shift count at 26 (to support the SHD instruction) encoded as
          31-p
+    ~    6 bit shift count at 20,22:26 encoded as 63-~.
     P    5 bit bit position at 26
     T    5 bit field length at 31 (encoded as 32-T)
     A    13 bit immediate at 18 (to support the BREAK instruction)
     ^	like b, but describes a control register
!    !    sar (cr11) register
     D    26 bit immediate at 31 (to support the DIAG instruction)
+    $    9 bit immediate at 28 (to support POPBTS)
  
     f    3 bit Special Function Unit identifier at 25
     O    20 bit Special Function Unit operation split between 15 bits at 20
***************
*** 170,177 ****
  	(for 0xe format FP instructions)
     G    Destination Floating Point Operand Format Completer encoded 2 bits at 18
  
-    s    2 bit space specifier at 17.
-    b    register field at 10.
     r	5 bit immediate value at 31 (for the break instruction)
  	(very similar to V above, except the value is unsigned instead of
  	low_sign_ext)
--- 170,175 ----
***************
*** 306,314 ****
--- 304,316 ----
  { "addbf",	0xa8000000, 0xfc000000, "?dnx,b,w", pa10},
  { "addibt",	0xa4000000, 0xfc000000, "?dn5,b,w", pa10},
  { "addibf",	0xac000000, 0xfc000000, "?dn5,b,w", pa10},
+ { "bb",		0xc0006000, 0xffe06000, "?Bnx,!,w", pa20, FLAG_STRICT}, 
+ { "bb",		0xc0004000, 0xffe06000, "?bnx,!,w", pa10, FLAG_STRICT}, 
+ { "bb",		0xc4006000, 0xfc006000, "?Bnx,Q,w", pa20, FLAG_STRICT}, 
  { "bb",		0xc4004000, 0xfc004000, "?bnx,Q,w", pa10}, 
  { "bvb",	0xc0004000, 0xffe04000, "?bnx,w", pa10},
  { "clrbts",	0xe8004005, 0xffffffff, "", pa20, FLAG_STRICT},
+ { "popbts",	0xe8004005, 0xfffff007, "$", pa20, FLAG_STRICT},
  { "pushnom",	0xe8004001, 0xffffffff, "", pa20, FLAG_STRICT},
  { "pushbts",	0xe8004001, 0xffe0ffff, "x", pa20, FLAG_STRICT},
  
***************
*** 361,368 ****
--- 363,381 ----
  { "sh3addl",    0x08000ac0, 0xfc000fe0, "?ax,b,t", pa10},
  { "sh3addo",    0x08000ec0, 0xfc000fe0, "?ax,b,t", pa10},
  
+ /* Subword Operation Instructions */
+ 
+ { "havg",       0x080002c0, 0xfc00ffe0, "x,b,t", pa20, FLAG_STRICT},
+ { "hshladd",    0x08000700, 0xfc00ff20, "x,.,b,t", pa20, FLAG_STRICT},
+ { "hshradd",    0x08000500, 0xfc00ff20, "x,.,b,t", pa20, FLAG_STRICT},
+ 
+ 
  /* Extract and Deposit Instructions */
  
+ { "shrpd",      0xd0000200, 0xfc001fe0, "?Xx,b,!,t", pa20, FLAG_STRICT},
+ { "shrpd",      0xd0000400, 0xfc001400, "?Xx,b,~,t", pa20, FLAG_STRICT},
+ { "shrpw",      0xd0000000, 0xfc001fe0, "?xx,b,!,t", pa10, FLAG_STRICT},
+ { "shrpw",      0xd0000800, 0xfc001c00, "?xx,b,p,t", pa10, FLAG_STRICT},
  { "vshd",       0xd0000000, 0xfc001fe0, "?xx,b,t", pa10},
  { "shd",        0xd0000800, 0xfc001c00, "?xx,b,p,t", pa10},
  { "vextru",     0xd0001000, 0xfc001fe0, "?xb,T,x", pa10},
*** pa-prev/gas/config/tc-hppa.c	Thu Jul 29 17:26:24 1999
--- gas-src/gas/config/tc-hppa.c	Fri Jul 30 14:23:50 1999
***************
*** 1564,1569 ****
--- 1564,1588 ----
  	      CHECK_FIELD (num, 31, 0, 0);
  	      INSERT_FIELD_AND_CONTINUE (opcode, num, 21);
  
+ 	    /* Handle %sar or %cr11.  No bits get set, we just verify that it
+ 	       is there.  */
+ 	    case '!':
+ 	      /* Skip whitespace before register.  */
+ 	      while (*s == ' ' || *s == '\t')
+ 		s = s + 1;
+ 
+ 	      if (!strncasecmp(s, "%sar", 4))
+ 	        {
+ 		  s += 4;
+ 		  continue;
+ 		}
+ 	      else if (!strncasecmp(s, "%cr11", 5))
+ 	        {
+ 		  s += 5;
+ 		  continue;
+ 		}
+ 	      break;
+ 
  	    /* Handle a 5 bit register field at 15.  */
  	    case 'x':
  	      num = pa_parse_number (&s, 0);
***************
*** 2439,2444 ****
--- 2458,2470 ----
  		  continue;
  		}
  
+ 	    /* Handle a 2 bit shift count at 25.  */
+ 	    case '.':
+ 	      num = pa_get_absolute_expression (&the_insn, &s);
+ 	      s = expr_end;
+ 	      CHECK_FIELD (num, 3, 1, 0);
+ 	      INSERT_FIELD_AND_CONTINUE (opcode, num, 6);
+ 
  	    /* Handle a 5 bit shift count at 26.  */
  	    case 'p':
  	      num = pa_get_absolute_expression (&the_insn, &s);
***************
*** 2446,2451 ****
--- 2472,2486 ----
  	      CHECK_FIELD (num, 31, 0, 0);
  	      INSERT_FIELD_AND_CONTINUE (opcode, 31 - num, 5);
  
+ 	    /* Handle a 6 bit shift count at 20,22:26.  */
+ 	    case '~':
+ 	      num = pa_get_absolute_expression (&the_insn, &s);
+ 	      s = expr_end;
+ 	      CHECK_FIELD (num, 63, 0, 0);
+ 	      num = 63 - num;
+ 	      opcode |= (num & 0x20) << 6;
+ 	      INSERT_FIELD_AND_CONTINUE (opcode, num & 0x1f, 5);
+ 
  	    /* Handle a 5 bit bit position at 26.  */
  	    case 'P':
  	      num = pa_get_absolute_expression (&the_insn, &s);
***************
*** 2463,2468 ****
--- 2498,2510 ----
  	      CHECK_FIELD (num, 31, 0, 0);
  	      INSERT_FIELD_AND_CONTINUE (opcode, num, 21);
  
+ 	    /* Handle a 9 bit immediate at 28.  */
+ 	    case '$':
+ 	      num = pa_get_absolute_expression (&the_insn, &s);
+ 	      s = expr_end;
+ 	      CHECK_FIELD (num, 511, 1, 0);
+ 	      INSERT_FIELD_AND_CONTINUE (opcode, num, 3);
+   
  	    /* Handle a 13 bit immediate at 18.  */
  	    case 'A':
  	      num = pa_get_absolute_expression (&the_insn, &s);
*** pa-prev/opcodes/hppa-dis.c	Thu Jul 29 17:26:29 1999
--- gas-src/opcodes/hppa-dis.c	Fri Jul 30 14:25:23 1999
***************
*** 625,634 ****
--- 625,646 ----
  		     of address.  */
  		  fput_const (extract_17 (insn), info);
  		  break;
+ 		case '.':
+ 		  (*info->fprintf_func) (info->stream, "%d",
+ 				    GET_FIELD (insn, 24, 25));
+ 		  break;
  		case 'p':
  		  (*info->fprintf_func) (info->stream, "%d",
  				    31 - GET_FIELD (insn, 22, 26));
  		  break;
+ 		case '~':
+ 		  {
+ 		    int num;
+ 		    num = GET_FIELD (insn, 20, 20) << 5;
+ 		    num |= GET_FIELD (insn, 22, 26);
+ 		    (*info->fprintf_func) (info->stream, "%d", 63 - num);
+ 		    break;
+ 		  }
  		case 'P':
  		  (*info->fprintf_func) (info->stream, "%d",
  				    GET_FIELD (insn, 22, 26));
***************
*** 636,641 ****
--- 648,656 ----
  		case 'T':
  		  (*info->fprintf_func) (info->stream, "%d",
  				    32 - GET_FIELD (insn, 27, 31));
+ 		  break;
+ 		case '$':
+ 		  fput_const (GET_FIELD (insn, 20, 28), info);
  		  break;
  		case 'A':
  		  fput_const (GET_FIELD (insn, 6, 18), info);
*** pa-prev/gas/testsuite/gas/hppa/basic/basic.exp	Fri Jul 30 11:13:27 1999
--- gas-src/gas/testsuite/gas/hppa/basic/basic.exp	Fri Jul 30 15:06:24 1999
***************
*** 359,364 ****
--- 359,410 ----
      if [expr $x==183] then { pass $testname } else { fail $testname }
  }
  
+ proc do_branch2 {} {
+     set testname "branch2.s: branch tests"
+     set x 0
+ 
+     gas_start "branch2.s" "-al"
+ 
+     # Check the assembled instruction against a table built by the HP assembler
+     # Any differences should be checked by hand -- with the number of problems
+     # I've seen in the HP assembler I don't completely trust it.
+     #
+     # Instead of having a variable for each match string just increment the
+     # total number of matches seen.  That's simpler when testing large numbers
+     # of instructions (as these tests to).
+     while 1 {
+ 	expect {
+ 	    -re "^ +\[0-9\]+ 0000 C0045FF5\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0004 C004DFED\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0008 C0045FE7\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 000c C004DFDF\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0010 C0047FD5\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0014 C004FFCD\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0018 C0047FC7\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 001c C004FFBF\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0020 C4A47FB5\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0024 C4A4FFAD\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0028 C4A47FA7\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 002c C4A4FF9F\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0030 E8004005\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0034 E800400D\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0038 E8004F9D\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 003c E8004001\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0040 E8044001\[^\n\]*\n"	{ set x [expr $x+1] }
+ 	    -re "\[^\n\]*\n"				{ }
+ 	    timeout				{ perror "timeout\n"; break }
+ 	    eof					{ break }
+ 	}
+     }
+ 
+     # This was intended to do any cleanup necessary.  It kinda looks like it
+     # isn't needed, but just in case, please keep it in for now.
+     gas_finish
+ 
+     # Did we find what we were looking for?  If not, flunk it.
+     if [expr $x==17] then { pass $testname } else { fail $testname }
+ }
+ 
  proc do_add {} {
      set testname "add.s: add tests"
      set x 0
***************
*** 2025,2030 ****
--- 2071,2112 ----
      if [expr $x==96] then { pass $testname } else { fail $testname }
  }
  
+ proc do_media {} {
+     set testname "media.s: purge tests"
+     set x 0
+ 
+     gas_start "media.s" "-al"
+ 
+     # Check the assembled instruction against a table built by the HP assembler
+     # Any differences should be checked by hand -- with the number of problems
+     # I've seen in the HP assembler I don't completely trust it.
+     #
+     # Instead of having a variable for each match string just increment the
+     # total number of matches seen.  That's simpler when testing large numbers
+     # of instructions (as these tests to).
+     while 1 {
+ 	expect {
+ 	    -re "^ +\[0-9\]+ 0000 096702CC\[^\n]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0004 0967074C\[^\n]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0008 0967078C\[^\n]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 000c 096707CC\[^\n]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0010 0967054C\[^\n]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0014 0967058C\[^\n]*\n"	{ set x [expr $x+1] }
+ 	    -re "^ +\[0-9\]+ 0014 096705CC\[^\n]*\n"	{ set x [expr $x+1] }
+ 	    -re "\[^\n\]*\n"				{ }
+ 	    timeout				{ perror "timeout\n"; break }
+ 	    eof					{ break }
+ 	}
+     }
+ 
+     # This was intended to do any cleanup necessary.  It kinda looks like it
+     # isn't needed, but just in case, please keep it in for now.
+     gas_finish
+ 
+     # Did we find what we were looking for?  If not, flunk it.
+     if [expr $x==18] then { pass $testname } else { fail $testname }
+ }
+ 
  proc do_special {} {
      set testname "special.s: special tests"
      set x 0
***************
*** 2272,2277 ****
--- 2354,2360 ----
      do_imem
      do_immed
      do_branch
+     do_branch2
      do_add
      do_sh1add
      do_sh2add
***************
*** 2292,2299 ****
--- 2375,2384 ----
      do_fp_misc
      do_fmem
      do_fp_comp
+     do_fp_comp2
      do_fp_conv
      do_fp_fcmp
+     do_media
      do_special
      do_spop
      do_copr
*** pa-prev/gas/testsuite/gas/hppa/basic/branch2.s	Wed Dec 31 19:00:00 1969
--- gas-src/gas/testsuite/gas/hppa/basic/branch2.s	Fri Jul 30 14:38:09 1999
***************
*** 0 ****
--- 1,41 ----
+ 	.LEVEL 2.0
+ 	.SPACE $PRIVATE$
+ 	.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31
+ 	.SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82
+ 	.SPACE $TEXT$
+ 	.SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44
+ 	.SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY
+ 
+ 	.SPACE $TEXT$
+ 	.SUBSPA $CODE$
+ 
+ 	.align 4
+ ; More branching instructions than you ever knew what to do with.
+ ; PA 2.0 versions and new syntax.
+ 
+ ;
+ ; We could/should test some of the corner cases for register and 
+ ; immediate fields.  We should also check the assorted field
+ ; selectors to make sure they're handled correctly.
+ 
+ bb_tests:	
+ 	bb,< %r4,%sar,bb_tests
+ 	bb,>= %r4,%sar,bb_tests
+ 	bb,<,n %r4,%cr11,bb_tests
+ 	bb,>=,n %r4,%cr11,bb_tests
+ 	bb,*< %r4,%sar,bb_tests
+ 	bb,*>= %r4,%sar,bb_tests
+ 	bb,*<,n %r4,%cr11,bb_tests
+ 	bb,*>=,n %r4,%cr11,bb_tests
+ 	bb,*< %r4,5,bb_tests
+ 	bb,*>= %r4,5,bb_tests
+ 	bb,*<,n %r4,5,bb_tests
+ 	bb,*>=,n %r4,5,bb_tests
+ 	
+ branch_stack:	
+ 	clrbts
+ 	popbts 1
+ 	popbts 499
+ 	pushnom
+ 	pushbts %r4
+ 
*** pa-prev/gas/testsuite/gas/hppa/basic/media.s	Wed Dec 31 19:00:00 1969
--- gas-src/gas/testsuite/gas/hppa/basic/media.s	Fri Jul 30 15:01:39 1999
***************
*** 0 ****
--- 1,25 ----
+ 	.LEVEL 2.0
+ 	.SPACE $PRIVATE$
+ 	.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31
+ 	.SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82
+ 	.SPACE $TEXT$
+ 	.SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44
+ 	.SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY
+ 
+ 	.SPACE $TEXT$
+ 	.SUBSPA $CODE$
+ 
+ 	.align 4
+ ; PA2.0 multimedia (halfword) instruction tests
+ ;
+ ; We could/should test some of the corner cases for register and 
+ ; immediate fields.  We should also check the assorted field
+ ; selectors to make sure they're handled correctly.
+ 
+ 	havg %r7,%r11,%r12
+ 	hshladd %r7,1,%r11,%r12
+ 	hshladd %r7,2,%r11,%r12
+ 	hshladd %r7,3,%r11,%r12
+ 	hshradd %r7,1,%r11,%r12
+ 	hshradd %r7,2,%r11,%r12
+ 	hshradd %r7,3,%r11,%r12

-- 
Jerry Quinn                             Tel: (514) 761-8737
jquinn@nortelnetworks.com               Fax: (514) 761-8505
Speech Recognition Research



More information about the Binutils mailing list