public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [Patch] New ia64 @slotcount pseudo func (for VMS)
@ 2010-02-10 13:24 Tristan Gingold
  2010-02-12 11:42 ` Nick Clifton
  0 siblings, 1 reply; 6+ messages in thread
From: Tristan Gingold @ 2010-02-10 13:24 UTC (permalink / raw)
  To: binutils; +Cc: Douglas B Rupp

Hi,

with Doug we finally wrote this patch to implement @slotcount pseudo function for ia64 VMS.  This pseudo
is available only on VMS to avoid pseudo namespace pollution.

There is also a testcase.

No regressions for ia64 linux.

Tristan.

gas/
2010-02-10  Tristan Gingold  <gingold@adacore.com>
	    Douglas B Rupp  <rupp@gnat.com>

	* config/tc-ia64.c (enum reloc_func): Add FUNC_SLOTCOUNT_RELOC.
	(DUMMY_RELOC_IA64_SLOTCOUNT): Added.
	(pseudo_func): Add an entry for slotcount.
	(md_begin): Initialize slotcount pseudo symbol.
	(ia64_parse_name): Handle @slotcount parameter.
	(ia64_gen_real_reloc_type): Handle slotcount.
	(md_apply_fix): Ditto.

gas/testsuite
2010-02-10  Tristan Gingold  <gingold@adacore.com>

	* gas/ia64/slotcount.s, gas/ia64/slotcount.s: New test.
	* gas/ia64/ia64.exp: Add slotcount test (vms only).

diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index e4563a7..73e31aa 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -103,6 +103,9 @@ enum reloc_func
     FUNC_LT_DTP_RELATIVE,
     FUNC_LT_TP_RELATIVE,
     FUNC_IPLT_RELOC,
+#ifdef TE_VMS
+    FUNC_SLOTCOUNT_RELOC,
+#endif
   };
 
 enum reg_symbol
@@ -163,6 +166,11 @@ struct label_fix
   bfd_boolean dw2_mark_labels;
 };
 
+#ifdef TE_VMS
+/* An internally used relocation.  */
+#define DUMMY_RELOC_IA64_SLOTCOUNT	(BFD_RELOC_UNUSED + 1)
+#endif
+
 /* This is the endianness of the current section.  */
 extern int target_big_endian;
 
@@ -575,6 +583,9 @@ pseudo_func[] =
     { NULL, 0, { 0 } },	/* placeholder for FUNC_LT_DTP_RELATIVE */
     { NULL, 0, { 0 } },	/* placeholder for FUNC_LT_TP_RELATIVE */
     { "iplt",	PSEUDO_FUNC_RELOC, { 0 } },
+#ifdef TE_VMS
+    { "slotcount", PSEUDO_FUNC_RELOC, { 0 } },
+#endif
 
     /* mbtype4 constants:  */
     { "alt",	PSEUDO_FUNC_CONST, { 0xa } },
@@ -7158,6 +7169,12 @@ md_begin (void)
     symbol_new (".<iplt>", undefined_section, FUNC_IPLT_RELOC,
 		&zero_address_frag);
 
+#ifdef TE_VMS
+  pseudo_func[FUNC_SLOTCOUNT_RELOC].u.sym =
+    symbol_new (".<slotcount>", undefined_section, FUNC_SLOTCOUNT_RELOC,
+		&zero_address_frag);
+#endif
+
  if (md.tune != itanium1)
    {
      /* Convert MFI NOPs bundles into MMI NOPs bundles.  */
@@ -7744,6 +7761,15 @@ ia64_parse_name (char *name, expressionS *e, char *nextcharP)
 	    }
 	  /* Skip ')'.  */
 	  ++input_line_pointer;
+#ifdef TE_VMS
+          if (idx == FUNC_SLOTCOUNT_RELOC)
+            {
+              /* @slotcount can accept any expression.  Canonicalize.  */
+              e->X_add_symbol = make_expr_symbol (e);
+              e->X_op = O_symbol;
+              e->X_add_number = 0;
+            }
+#endif
 	  if (e->X_op != O_symbol)
 	    {
 	      if (e->X_op != O_pseudo_fixup)
@@ -11109,6 +11135,11 @@ ia64_gen_real_reloc_type (struct symbol *sym, bfd_reloc_code_real_type r_type)
 	}
       break;
 
+#ifdef TE_VMS
+    case FUNC_SLOTCOUNT_RELOC:
+      return DUMMY_RELOC_IA64_SLOTCOUNT;
+#endif
+
     default:
       abort ();
     }
@@ -11278,12 +11309,48 @@ md_apply_fix (fixS *fix, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 	  S_SET_THREAD_LOCAL (fix->fx_addsy);
 	  break;
 
+#ifdef TE_VMS
+        case DUMMY_RELOC_IA64_SLOTCOUNT:
+	  as_bad_where (fix->fx_file, fix->fx_line,
+			_("cannot resolve @slotcount parameter"));
+	  fix->fx_done = 1;
+	  return;
+#endif
+
 	default:
 	  break;
 	}
     }
   else if (fix->tc_fix_data.opnd == IA64_OPND_NIL)
     {
+#ifdef TE_VMS
+      if (fix->fx_r_type == DUMMY_RELOC_IA64_SLOTCOUNT)
+        {
+          /* For @slotcount, convert an addresses difference to a slots
+             difference.  */
+          valueT v;
+
+          v = (value >> 4) * 3;
+          switch (value & 0x0f)
+            {
+            case 0:
+            case 1:
+            case 2:
+              v += value & 0x0f;
+              break;
+            case 0x0f:
+              v += 2;
+              break;
+            case 0x0e:
+              v += 1;
+              break;
+            default:
+              as_bad (_("invalid @slotcount value"));
+            }
+          value = v;
+        }
+#endif
+
       if (fix->tc_fix_data.bigendian)
 	number_to_chars_bigendian (fixpos, value, fix->fx_size);
       else
diff --git a/gas/testsuite/gas/ia64/ia64.exp b/gas/testsuite/gas/ia64/ia64.exp
index 3dfd10b..221b8d4 100644
--- a/gas/testsuite/gas/ia64/ia64.exp
+++ b/gas/testsuite/gas/ia64/ia64.exp
@@ -89,4 +89,9 @@ if [istarget "ia64-*"] then {
     run_dump_test "operand-or"
     run_list_test "hint.b-err" ""
     run_list_test "hint.b-warn" "-mhint.b=warning"
+
+    if [istarget "ia64-*-*vms*"] then {
+	run_dump_test "slotcount"
+    }
+
 }
diff --git a/gas/testsuite/gas/ia64/slotcount.d b/gas/testsuite/gas/ia64/slotcount.d
new file mode 100644
index 0000000..3548266
--- /dev/null
+++ b/gas/testsuite/gas/ia64/slotcount.d
@@ -0,0 +1,10 @@
+#objdump: -s -j .slot_test
+#name: ia64 slotcount
+
+.*: +file format .*
+
+Contents of section .slot_test:
+ 0000 04000000 01000000 02000000 03000000  ................
+ 0010 04000000 05000000 06000000 07000000  ................
+ 0020 08000000 02000000 06000000 03000000  ................
+ 0030 02000000                             ....            
diff --git a/gas/testsuite/gas/ia64/slotcount.s b/gas/testsuite/gas/ia64/slotcount.s
new file mode 100644
index 0000000..bdbc318
--- /dev/null
+++ b/gas/testsuite/gas/ia64/slotcount.s
@@ -0,0 +1,51 @@
+	.section	.slot_test0,"",@progbits
+	data4.ua	@slotcount(.L1-.L0)
+
+	.text
+	.align 16
+foo:
+[.L0:]
+	mov r2 = r12
+[.L1:]
+	mov r8 = r14
+[.L2:]
+	;;
+	mov r12 = r2
+[.L3:]
+        {
+        .mii
+        nop 0
+[.L4:]
+        nop 0
+[.L5:]
+        nop 0
+        }
+        {
+[.L6:]
+        nop 0
+[.L7:]
+        nop 0
+[.L8:]
+	br.ret.sptk.many b0
+	;;
+        }
+
+	.section	.slot_test,"",@progbits
+//     	data4.ua	@slotcount(.Lundef)
+
+	data4.ua	@slotcount(17)
+
+	data4.ua	@slotcount(.L1-.L0) // 1
+	data4.ua	@slotcount(.L2-.L0) // 2
+	data4.ua	@slotcount(.L3-.L0) // 3
+	data4.ua	@slotcount(.L4-.L0) // 4
+	data4.ua	@slotcount(.L5-.L0) // 5
+	data4.ua	@slotcount(.L6-.L0) // 6
+	data4.ua	@slotcount(.L7-.L0) // 7
+	data4.ua	@slotcount(.L8-.L0) // 8
+
+        data4.ua	@slotcount(.L3-.L1) // 2
+        data4.ua	@slotcount(.L8-.L2) // 6
+        data4.ua	@slotcount(.L4-.L1) // 3
+        data4.ua	@slotcount(.L4-.L2) // 2
+//     	data4.ua	@slotcount(.L2-.Lundef)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] New ia64 @slotcount pseudo func (for VMS)
  2010-02-10 13:24 [Patch] New ia64 @slotcount pseudo func (for VMS) Tristan Gingold
@ 2010-02-12 11:42 ` Nick Clifton
  2010-02-12 13:44   ` Tristan Gingold
  2010-02-12 14:01   ` Tristan Gingold
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Clifton @ 2010-02-12 11:42 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils, Douglas B Rupp

Hi Tristan,

> with Doug we finally wrote this patch to implement @slotcount pseudo function for ia64 VMS.  This pseudo
> is available only on VMS to avoid pseudo namespace pollution.

I think that this really ought to have some documentation written for it 
in gas/doc/c-ia64.texi...

> gas/
> 2010-02-10  Tristan Gingold<gingold@adacore.com>
> 	Douglas B Rupp<rupp@gnat.com>
>
> 	* config/tc-ia64.c (enum reloc_func): Add FUNC_SLOTCOUNT_RELOC.
> 	(DUMMY_RELOC_IA64_SLOTCOUNT): Added.
> 	(pseudo_func): Add an entry for slotcount.
> 	(md_begin): Initialize slotcount pseudo symbol.
> 	(ia64_parse_name): Handle @slotcount parameter.
> 	(ia64_gen_real_reloc_type): Handle slotcount.
> 	(md_apply_fix): Ditto.
>
> gas/testsuite
> 2010-02-10  Tristan Gingold<gingold@adacore.com>
>
> 	* gas/ia64/slotcount.s, gas/ia64/slotcount.s: New test.
> 	* gas/ia64/ia64.exp: Add slotcount test (vms only).

Approved - please apply - but please do consider adding some 
documentation as well.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] New ia64 @slotcount pseudo func (for VMS)
  2010-02-12 11:42 ` Nick Clifton
@ 2010-02-12 13:44   ` Tristan Gingold
  2010-02-12 14:01   ` Tristan Gingold
  1 sibling, 0 replies; 6+ messages in thread
From: Tristan Gingold @ 2010-02-12 13:44 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Douglas B Rupp


On Feb 12, 2010, at 12:41 PM, Nick Clifton wrote:

> Hi Tristan,
> 
>> with Doug we finally wrote this patch to implement @slotcount pseudo function for ia64 VMS.  This pseudo
>> is available only on VMS to avoid pseudo namespace pollution.
> 
> I think that this really ought to have some documentation written for it in gas/doc/c-ia64.texi...

Ok, will write it before committing.

Thanks,
Tristan.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] New ia64 @slotcount pseudo func (for VMS)
  2010-02-12 11:42 ` Nick Clifton
  2010-02-12 13:44   ` Tristan Gingold
@ 2010-02-12 14:01   ` Tristan Gingold
  2010-02-12 14:10     ` Nick Clifton
  1 sibling, 1 reply; 6+ messages in thread
From: Tristan Gingold @ 2010-02-12 14:01 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Douglas B Rupp


On Feb 12, 2010, at 12:41 PM, Nick Clifton wrote:

> Hi Tristan,
> 
>> with Doug we finally wrote this patch to implement @slotcount pseudo function for ia64 VMS.  This pseudo
>> is available only on VMS to avoid pseudo namespace pollution.
> 
> I think that this really ought to have some documentation written for it in gas/doc/c-ia64.texi...

What about this ?
(checked with make info).

Tristan.

gas/
2010-02-12  Tristan Gingold  <gingold@adacore.com>

	* doc/c-ia64.texi (IA-64-Relocs): Document @slotcount.

diff --git a/gas/doc/c-ia64.texi b/gas/doc/c-ia64.texi
index 6b0f3a9..f684171 100644
--- a/gas/doc/c-ia64.texi
+++ b/gas/doc/c-ia64.texi
@@ -120,7 +120,7 @@ Reference Guide.
 * IA-64-Chars::                Special Characters
 * IA-64-Regs::                 Register Names
 * IA-64-Bits::                 Bit Names
-@c * IA-64-Relocs::               Relocations		// to be written
 @node IA-64-Chars
@@ -170,6 +170,21 @@ the @samp{ssm}/@samp{sum} and @samp{rsm}/@samp{rum}
 instructions, but they can be used anywhere else where an integer
 constant is expected.
 
+@node IA-64-Relocs
+@subsection Relocations
+@cindex IA-64 relocations
+
+In addition to the standard IA-64 relocations, the following relocations are
+implemented by @code{@value{AS}}:
+
+@table @code
+@item @@slotcount(@var{V})
+Convert the address offset @var{V} into a slot count.  This pseudo
+function is available only on VMS.  The expression @var{V} must be
+known at assembly time: it can't reference undefined symbols or symbols in
+different sections.
+@end table
+
 @node IA-64 Opcodes
 @section Opcodes
 For detailed information on the IA-64 machine instruction set, see the

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] New ia64 @slotcount pseudo func (for VMS)
  2010-02-12 14:01   ` Tristan Gingold
@ 2010-02-12 14:10     ` Nick Clifton
  2010-02-12 14:35       ` Tristan Gingold
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Clifton @ 2010-02-12 14:10 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils, Douglas B Rupp

Hi Tristan,

> What about this ?

Great - thanks for writing this.

> gas/
> 2010-02-12  Tristan Gingold<gingold@adacore.com>
>
> 	* doc/c-ia64.texi (IA-64-Relocs): Document @slotcount.

Approved - please apply.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Patch] New ia64 @slotcount pseudo func (for VMS)
  2010-02-12 14:10     ` Nick Clifton
@ 2010-02-12 14:35       ` Tristan Gingold
  0 siblings, 0 replies; 6+ messages in thread
From: Tristan Gingold @ 2010-02-12 14:35 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Douglas B Rupp


On Feb 12, 2010, at 3:09 PM, Nick Clifton wrote:

> Hi Tristan,
> 
>> What about this ?
> 
> Great - thanks for writing this.
> 
>> gas/
>> 2010-02-12  Tristan Gingold<gingold@adacore.com>
>> 
>> 	* doc/c-ia64.texi (IA-64-Relocs): Document @slotcount.
> 
> Approved - please apply.

Thanks.  The whole patch set has been committed.

Tristan.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-12 14:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 13:24 [Patch] New ia64 @slotcount pseudo func (for VMS) Tristan Gingold
2010-02-12 11:42 ` Nick Clifton
2010-02-12 13:44   ` Tristan Gingold
2010-02-12 14:01   ` Tristan Gingold
2010-02-12 14:10     ` Nick Clifton
2010-02-12 14:35       ` Tristan Gingold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).