This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Patch] New ia64 @slotcount pseudo func (for VMS)
- From: Tristan Gingold <gingold at adacore dot com>
- To: binutils at sourceware dot org
- Cc: Douglas B Rupp <rupp at gnat dot com>
- Date: Wed, 10 Feb 2010 14:24:22 +0100
- Subject: [Patch] New ia64 @slotcount pseudo func (for VMS)
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)