This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
[Fwd: Re: New Sanyo Stormy16 relocations]
- From: Andrew MacLeod <amacleod at redhat dot com>
- To: cgen at sources dot redhat dot com
- Date: 16 Dec 2002 14:57:29 -0500
- Subject: [Fwd: Re: New Sanyo Stormy16 relocations]
I forgot to send this to cgen for approval of the cgen compnents as
well.
Here's a copy of the patch. Are these cgen changes OK? Sanyo has been
using them for some time now. We're basically adding a couple of simple
relocations.
Andrew
> >
> > 2002-12-13 Andrew MacLeod <amacleod@redhat.com>
> >
> >
> >
> > bfd/ChangeLog
> > * elf32-xstormy16.c (xstormy16_elf_howto): Add R_XSTORMY16_LO16
> > and R_XSTORMY16_HI16) howto entries.
> > (xstormy16_reloc_map): Map R_XSTORMY16_{LO,HI}16 to BFD_RELOC_{LO,HI}16.
> > (xstormy16_info_to_howto_rela): Use R_XSTORMY16_GNU_VTINHERIT to
> > determine the start of the second reloc table.
> >
> > cgen/ChangeLog
> > * cpu/xstormy16.cpu (imm16): Call handler immediate16.
> > * cpu/xstormy16.opc (parse_small_immediate): Return on '@'.
> > (parse_immediate16): Handle immediate16 values, which now include
> > @hi(label) and @lo(label)
> >
> > gas/ChangeLog
> > * config/tc-xstormy16.c (md_cgen_lookup_reloc): If a relocation
> > has already been set up, use it.
> >
> > include/ChangeLog
> > * elf/xstormy16.h (START_RELOC_NUMBERS) Add relocation numbers
> > for R_XSTORMY16_LO16 and R_XSTORMY16_HI16.
> >
> > opcodes/ChangeLog
> > * opcodes/xstormy16-asm.c: Regenerate.
> >
> > sid/component/cgen-cpu/xstormy16/ChangeLog
> > * xstormy16-cpu.h: Regenerate.
> > * xstormy16-decode.cxx: Regenerate.
> > * xstormy16-decode.h: Regenerate.
> > * xstormy16-desc.h: Regenerate.
> > * xstormy16-sem.cxx: Regenerate.
> > * xstormy16-write.cxx: Regenerate.
> >
> >
> > Index: cgen/cpu/xstormy16.cpu
> > ===================================================================
> > RCS file: /cvs/src/src/cgen/cpu/xstormy16.cpu,v
> > retrieving revision 1.4
> > diff -c -p -r1.4 xstormy16.cpu
> > *** cgen/cpu/xstormy16.cpu 25 Nov 2002 21:14:16 -0000 1.4
> > --- cgen/cpu/xstormy16.cpu 4 Dec 2002 23:03:17 -0000
> > ***************
> > *** 268,274 ****
> > (dnop imm12 "12 bit signed immediate" () h-sint f-imm12)
> >
> > (dnf f-imm16 "16 bit" (SIGN-OPT) 16 16)
> > ! (dnop imm16 "16 bit immediate" () h-uint f-imm16)
> >
> > (dnf f-lmem8 "8 bit unsigned low memory" (ABS-ADDR) 8 8)
> > (define-operand
> > --- 268,281 ----
> > (dnop imm12 "12 bit signed immediate" () h-sint f-imm12)
> >
> > (dnf f-imm16 "16 bit" (SIGN-OPT) 16 16)
> > ! (define-operand
> > ! (name imm16)
> > ! (comment "16 bit immediate")
> > ! (attrs)
> > ! (type h-uint)
> > ! (index f-imm16)
> > ! (handlers (parse "immediate16"))
> > ! )
> >
> > (dnf f-lmem8 "8 bit unsigned low memory" (ABS-ADDR) 8 8)
> > (define-operand
> > Index: cgen/cpu/xstormy16.opc
> > ===================================================================
> > RCS file: /cvs/src/src/cgen/cpu/xstormy16.opc,v
> > retrieving revision 1.2
> > diff -c -p -r1.2 xstormy16.opc
> > *** cgen/cpu/xstormy16.opc 2 Dec 2002 21:53:53 -0000 1.2
> > --- cgen/cpu/xstormy16.opc 4 Dec 2002 23:03:17 -0000
> > *************** parse_small_immediate (cd, strp, opindex
> > *** 91,96 ****
> > --- 91,99 ----
> > enum cgen_parse_operand_result result;
> > const char *errmsg;
> >
> > + if (**strp == '@')
> > + return _("No relocation for small immediate");
> > +
> > errmsg = (* cd->parse_operand_fn)
> > (cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
> > &result, &value);
> > *************** parse_small_immediate (cd, strp, opindex
> > *** 103,107 ****
> > --- 106,158 ----
> >
> > *valuep = value;
> > return NULL;
> > + }
> > +
> > + /* Literal scan be either a normal literal, a @hi() or @lo relocation. */
> > +
> > + static const char *
> > + parse_immediate16 (cd, strp, opindex, valuep)
> > + CGEN_CPU_DESC cd;
> > + const char **strp;
> > + int opindex;
> > + unsigned long *valuep;
> > + {
> > + const char *errmsg;
> > + enum cgen_parse_operand_result result;
> > + bfd_reloc_code_real_type code = BFD_RELOC_NONE;
> > + bfd_vma value;
> > +
> > + if (strncmp (*strp, "@hi(", 4) == 0)
> > + {
> > + *strp += 4;
> > + code = BFD_RELOC_HI16;
> > + }
> > + else
> > + if (strncmp (*strp, "@lo(", 4) == 0)
> > + {
> > + *strp += 4;
> > + code = BFD_RELOC_LO16;
> > + }
> > +
> > + if (code == BFD_RELOC_NONE)
> > + errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
> > + else
> > + {
> > + errmsg = cgen_parse_address (cd, strp, opindex, code, &result, &value);
> > + if ((errmsg == NULL) &&
> > + (result != CGEN_PARSE_OPERAND_RESULT_QUEUED))
> > + errmsg = _("Operand is not a symbol");
> > +
> > + *valuep = value;
> > + if ((code == BFD_RELOC_HI16 || code == BFD_RELOC_LO16)
> > + && **strp == ')')
> > + *strp += 1;
> > + else
> > + {
> > + errmsg = _("Syntax error: No trailing ')'");
> > + return errmsg;
> > + }
> > + }
> > + return errmsg;
> > }
> > /* -- */
> > Index: include/elf/xstormy16.h
> > ===================================================================
> > RCS file: /cvs/src/src/include/elf/xstormy16.h,v
> > retrieving revision 1.1
> > diff -c -p -r1.1 xstormy16.h
> > *** include/elf/xstormy16.h 8 Dec 2001 03:46:03 -0000 1.1
> > --- include/elf/xstormy16.h 4 Dec 2002 23:03:17 -0000
> > *************** START_RELOC_NUMBERS (elf_xstormy16_reloc
> > *** 37,42 ****
> > --- 37,45 ----
> > RELOC_NUMBER (R_XSTORMY16_24, 8)
> > RELOC_NUMBER (R_XSTORMY16_FPTR16, 9)
> >
> > + RELOC_NUMBER (R_XSTORMY16_LO16, 10)
> > + RELOC_NUMBER (R_XSTORMY16_HI16, 11)
> > +
> > RELOC_NUMBER (R_XSTORMY16_GNU_VTINHERIT, 128)
> > RELOC_NUMBER (R_XSTORMY16_GNU_VTENTRY, 129)
> > END_RELOC_NUMBERS (R_XSTORMY16_max)
> > Index: bfd/elf32-xstormy16.c
> > ===================================================================
> > RCS file: /cvs/src/src/bfd/elf32-xstormy16.c,v
> > retrieving revision 1.13
> > diff -c -p -r1.13 elf32-xstormy16.c
> > *** bfd/elf32-xstormy16.c 30 Nov 2002 08:39:38 -0000 1.13
> > --- bfd/elf32-xstormy16.c 4 Dec 2002 23:03:18 -0000
> > *************** static reloc_howto_type xstormy16_elf_ho
> > *** 208,213 ****
> > --- 208,243 ----
> > 0, /* src_mask */
> > 0xffffffff, /* dst_mask */
> > FALSE), /* pcrel_offset */
> > +
> > + /* Low order 16 bit value of a high memory address. */
> > + HOWTO (R_XSTORMY16_LO16, /* type */
> > + 0, /* rightshift */
> > + 1, /* size (0 = byte, 1 = short, 2 = long) */
> > + 16, /* bitsize */
> > + FALSE, /* pc_relative */
> > + 0, /* bitpos */
> > + complain_overflow_dont, /* complain_on_overflow */
> > + bfd_elf_generic_reloc, /* special_function */
> > + "R_XSTORMY16_LO16", /* name */
> > + FALSE, /* partial_inplace */
> > + 0, /* src_mask */
> > + 0xffff, /* dst_mask */
> > + FALSE), /* pcrel_offset */
> > +
> > + /* High order 16 bit value of a high memory address. */
> > + HOWTO (R_XSTORMY16_HI16, /* type */
> > + 16, /* rightshift */
> > + 1, /* size (0 = byte, 1 = short, 2 = long) */
> > + 16, /* bitsize */
> > + FALSE, /* pc_relative */
> > + 0, /* bitpos */
> > + complain_overflow_dont, /* complain_on_overflow */
> > + bfd_elf_generic_reloc, /* special_function */
> > + "R_XSTORMY16_HI16", /* name */
> > + FALSE, /* partial_inplace */
> > + 0, /* src_mask */
> > + 0xffff, /* dst_mask */
> > + FALSE), /* pcrel_offset */
> > };
> >
> > static reloc_howto_type xstormy16_elf_howto_table2 [] =
> > *************** static const reloc_map xstormy16_reloc_m
> > *** 265,270 ****
> > --- 295,302 ----
> > { BFD_RELOC_XSTORMY16_REL_12, R_XSTORMY16_REL_12, xstormy16_elf_howto_table },
> > { BFD_RELOC_XSTORMY16_24, R_XSTORMY16_24, xstormy16_elf_howto_table },
> > { BFD_RELOC_XSTORMY16_FPTR16, R_XSTORMY16_FPTR16, xstormy16_elf_howto_table },
> > + { BFD_RELOC_LO16, R_XSTORMY16_LO16, xstormy16_elf_howto_table },
> > + { BFD_RELOC_HI16, R_XSTORMY16_HI16, xstormy16_elf_howto_table },
> > { BFD_RELOC_VTABLE_INHERIT, R_XSTORMY16_GNU_VTINHERIT, xstormy16_elf_howto_table2 },
> > { BFD_RELOC_VTABLE_ENTRY, R_XSTORMY16_GNU_VTENTRY, xstormy16_elf_howto_table2 },
> > };
> > *************** xstormy16_info_to_howto_rela (abfd, cach
> > *** 300,306 ****
> > {
> > unsigned int r_type = ELF32_R_TYPE (dst->r_info);
> >
> > ! if (r_type <= (unsigned int) R_XSTORMY16_FPTR16)
> > cache_ptr->howto = &xstormy16_elf_howto_table [r_type];
> > else if (r_type - R_XSTORMY16_GNU_VTINHERIT
> > <= (unsigned int) R_XSTORMY16_GNU_VTENTRY)
> > --- 332,338 ----
> > {
> > unsigned int r_type = ELF32_R_TYPE (dst->r_info);
> >
> > ! if (r_type <= (unsigned int) R_XSTORMY16_HI16)
> > cache_ptr->howto = &xstormy16_elf_howto_table [r_type];
> > else if (r_type - R_XSTORMY16_GNU_VTINHERIT
> > <= (unsigned int) R_XSTORMY16_GNU_VTENTRY)
> > Index: gas/config/tc-xstormy16.c
> > ===================================================================
> > RCS file: /cvs/src/src/gas/config/tc-xstormy16.c,v
> > retrieving revision 1.5
> > diff -c -p -r1.5 tc-xstormy16.c
> > *** gas/config/tc-xstormy16.c 30 Nov 2002 08:39:44 -0000 1.5
> > --- gas/config/tc-xstormy16.c 4 Dec 2002 23:03:18 -0000
> > *************** md_cgen_lookup_reloc (insn, operand, fix
> > *** 340,346 ****
> > --- 340,349 ----
> > return fixP->fx_pcrel ? BFD_RELOC_8_PCREL : BFD_RELOC_8;
> >
> > case XSTORMY16_OPERAND_IMM16:
> > + /* This might have been processed at parse time. */
> > fixP->fx_where += 2;
> > + if (fixP->fx_cgen.opinfo && fixP->fx_cgen.opinfo != BFD_RELOC_NONE)
> > + return fixP->fx_cgen.opinfo;
> > return fixP->fx_pcrel ? BFD_RELOC_16_PCREL : BFD_RELOC_16;
> >
> > case XSTORMY16_OPERAND_ABS24:
> >