This is the mail archive of the binutils@sourceware.org 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]

[PATCH] New ia64 @slotcount pseudo func


Submitted for comment as per previous discussions.

--Douglas Rupp
AdaCore


	* gas/config/tc-ia64.c (PSEUDO_FUNC_EXPR): New pseudo_func type. 
	(@slotcount): New pseudo func of type EXPR.
	(ia64_parse_name): Implement @slotcount.

--- gas/config/tc-ia64.c	2009-10-06 22:13:53.000000000 -0700
+++ gas/config/tc-ia64.c	2009-10-28 11:31:41.300435760 -0800
@@ -545,7 +545,8 @@ static struct
 	PSEUDO_FUNC_RELOC,
 	PSEUDO_FUNC_CONST,
 	PSEUDO_FUNC_REG,
-	PSEUDO_FUNC_FLOAT
+	PSEUDO_FUNC_FLOAT,
+	PSEUDO_FUNC_EXPR
       }
     type;
     union
@@ -576,6 +577,9 @@ pseudo_func[] =
     { NULL, 0, { 0 } },	/* placeholder for FUNC_LT_TP_RELATIVE */
     { "iplt",	PSEUDO_FUNC_RELOC, { 0 } },
 
+    /* expression pseudo functions:  */
+    { "slotcount", PSEUDO_FUNC_EXPR, { 0 } },
+
     /* mbtype4 constants:  */
     { "alt",	PSEUDO_FUNC_CONST, { 0xa } },
     { "brcst",	PSEUDO_FUNC_CONST, { 0x0 } },
@@ -7779,6 +7783,72 @@ ia64_parse_name (char *name, expressionS
 	  *nextcharP = *input_line_pointer;
 	  break;
 
+	case PSEUDO_FUNC_EXPR:
+	  end = input_line_pointer;
+	  if (*nextcharP != '(')
+	    {
+	      as_bad (_("Expected '('"));
+	      break;
+	    }
+	  /* Skip '('.  */
+	  ++input_line_pointer;
+
+	  /* The only expression pseudo func at this time is @slotcount
+	     which takes an expression guaranteed to look like (beg-end),
+	     there beg and end are addresses, and figure out how many
+	     Itanium instruction slots separate the addresses.  The value
+	     is needed for a couple of VMS debugger attributes relating to
+	     prologue and epilogue size.  */
+
+	  if (strcmp (pseudo_func[idx].name, "slotcount") == 0)
+	    {
+	      char *name;
+	      char c;
+	      symbolS *symbolPend, *symbolPbeg;
+	      int end, beg, val;
+
+	      name = input_line_pointer;
+	      c = get_symbol_end ();
+	      symbolPend = symbol_find_or_make (name);
+
+	      ++input_line_pointer;
+	      name = input_line_pointer;
+	      c = get_symbol_end ();
+	      symbolPbeg = symbol_find_or_make (name);
+
+	      /* Calculate the number of instruction slots between the two
+		 labels.  They are guaranteed to be in the same (.text)
+		 section.  */
+	      end = S_GET_VALUE (symbolPend);
+	      beg = S_GET_VALUE (symbolPbeg);
+
+	      val = (((end & -16) - (beg & -16)) / 16 * 3)
+		    + (end & 15)
+		    - (beg & 15);
+
+	      e->X_op = O_constant;
+	      e->X_add_number = val;
+
+	      /* Put the ')' back for later error checking.  */
+	      *input_line_pointer = ')';
+	    }
+	  else
+            {
+	      /* Do something by default which is not unexpected.  */
+	      expression (e);
+	    }
+
+	  if (*input_line_pointer != ')')
+	    {
+	      as_bad (_("Missing ')'"));
+	      goto done1;
+	    }
+	  /* Skip ')'.  */
+	  ++input_line_pointer;
+	done1:
+	  *nextcharP = *input_line_pointer;
+	  break;
+
 	case PSEUDO_FUNC_CONST:
 	  e->X_op = O_constant;
 	  e->X_add_number = pseudo_func[idx].u.ival;

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