This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] New ia64 @slotcount pseudo func (2nd try)
- From: Douglas B Rupp <rupp at gnat dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: Nick Clifton <nickc at redhat dot com>, binutils at sourceware dot org, Richard Henderson <rth at redhat dot com>
- Date: Thu, 29 Oct 2009 00:08:20 -0700
- Subject: [PATCH] New ia64 @slotcount pseudo func (2nd try)
- References: <4AE8A868.5060908@gnat.com> <20091029011452.GJ8111@bubble.grove.modra.org>
I tried to address all your concerns, but I didn't understand the
comment about checking for a comma.
Second try submitted for review
--Douglas Rupp
AdaCore
2009-10-29 Douglas B Rupp <rupp@gnat.com>
* 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 22:35:06.244566607 -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,58 @@ ia64_parse_name (char *name, expressionS
*nextcharP = *input_line_pointer;
break;
+ case PSEUDO_FUNC_EXPR:
+ 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. */
+
+ {
+ 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++ = c;
+
+ name = input_line_pointer;
+ c = get_symbol_end ();
+ symbolPbeg = symbol_find_or_make (name);
+ *input_line_pointer = c;
+
+ /* 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;
+ }
+
+ if (*input_line_pointer != ')')
+ as_bad (_("Missing ')'"));
+
+ *nextcharP = *++input_line_pointer;
+ break;
+
case PSEUDO_FUNC_CONST:
e->X_op = O_constant;
e->X_add_number = pseudo_func[idx].u.ival;