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]
Other format: [Raw text]

RE: Is this a gas bug?


Gan, George wrotes:
>
> Occasionally, I wrote an instruction: "mov.i ar.unat=r2".
> After I assembled it with gas and objdump it, I got almost the same instruction.
> However, as the IA64 SDM,1:24 says, ar.unat can't be accessed by I unit.
> Why gas don't raise a warning this time? I think "mov.i ar.unat=.." is more 
> dangerous than accessing memory immediately after an instruction that modify
> region register.
>

Yes, I think it is also a bug of gas. Gas does not check if application register is accessed by the right execution unit. This patch (partially) fixes it.

With this patch there are two unexpected failures in gas ia64 testsuite.

FAIL: ia64 opc-m
FAIL: ia64 tls

The first case failed on the following instructions:

{ .mii; alloc r4 = ar.pfs, 2, 10, 16, 16;; }

The second case failed on the same instruction:

alloc r36 = ar.pfs, 0, 5, 3, 0

Gas puts these two alloc instruction into M-unit type slot without noting that ar.pfs can only be accessed by I-unit. I have no time to fix this now. I will try to fix it if nobody submit patch for it in about two weeks.

Another improvement to this patch is to improve the error report in this patch. Instead of reporting application register number, we can report its synonym. Some other code modification is need to accomplish this, e.g. ar[] array and the code to add synonyms for application registers into hash table, to enable lookup register name by its number.


Jie Zhang

2004-05-24  Jie Zhang  <jiez@citiz.net>

	* config/tc-ia64.c (emit_one_bundle): Check if the
	application register is accessed by the right execution
	unit.

Index: tc-ia64.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ia64.c,v
retrieving revision 1.109
diff -c -3 -p -r1.109 tc-ia64.c
*** tc-ia64.c	6 May 2004 22:32:44 -0000	1.109
--- tc-ia64.c	23 May 2004 16:46:02 -0000
*************** emit_one_bundle ()
*** 6388,6393 ****
--- 6388,6425 ----
  	  continue;		/* try next slot */
  	}
  
+       /* Make sure that application register is accessed by the
+ 	 right execution unit. */
+       for (j = 0; j < NELEMS (idesc->operands); j++)
+ 	{
+ 	  expressionS *e;
+ 
+ 	  if (idesc->operands[j] == IA64_OPND_NIL)
+ 	    break;
+ 
+ 	  e = & md.slot[curr].opnd[j];
+ 
+ 	  /* If application register is accessed by the wrong
+ 	     execution unit, we report an error. */
+ 	  if (e->X_op == O_register
+ 	      && e->X_add_number > REG_AR
+ 	      && e->X_add_number <= REG_AR + 128)
+ 	    {
+ 	      if (ar_is_in_integer_unit (e->X_add_number)
+ 	  	  && insn_unit != IA64_UNIT_I)
+ 		as_bad_where (md.slot[curr].src_file,
+ 			      md.slot[curr].src_line,
+ 			      "appliction register %d can only be accessed by I-unit",
+ 			      (int)(e->X_add_number - REG_AR));
+ 	      else if (!ar_is_in_integer_unit (e->X_add_number)
+ 		       && insn_unit != IA64_UNIT_M)
+ 		as_bad_where (md.slot[curr].src_file,
+ 			      md.slot[curr].src_line,
+ 			      "appliction register %d can only be accessed by M-unit",
+ 			      (int)(e->X_add_number - REG_AR));
+ 	    }
+ 	}
+ 
        {
  	bfd_vma addr;
  

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