This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
Re: Possible reloc patch (2/2)
- To: Doug Evans <dje at transmeta dot com>
- Subject: Re: Possible reloc patch (2/2)
- From: Richard Sandiford <rsandifo at cygnus dot com>
- Date: Wed, 24 Jan 2001 12:49:03 +0000 (GMT)
- Cc: <cgen at sources dot redhat dot com>
On Wed, 24 Jan 2001, Richard Sandiford wrote:
> > In general you don't to add conditional compilation if there's
> > another solution.
>
> Would it be OK to add an attribute to define-operand which selects
> this behaviour?
Or, how about this? Not that I'm flailing around here or anything.
Please apply if you're happy with it, otherwise I'll leave things be.
Richard
--
For cgen docs.
2001-01-24 Richard Sandiford <r.sandiford@redhat.com>
* doc/porting.texi (CGEN_RELOC_IS_OPERAND_RELATIVE): New macro.
Index: ./cgen/doc/porting.texi
===================================================================
RCS file: /cvs/src/src/cgen/doc/porting.texi,v
retrieving revision 1.2
diff -c -p -d -r1.2 porting.texi
*** ./cgen/doc/porting.texi 2000/11/01 21:35:13 1.2
--- ./cgen/doc/porting.texi 2001/01/24 12:40:07
*************** they should be used unless it's not poss
*** 579,584 ****
--- 579,593 ----
@item @code{#define tc_gen_reloc gas_cgen_tc_gen_reloc}
if you're able to use it.
@end itemize
+
+ @item @code{CGEN_RELOC_IS_OPERAND_RELATIVE (@var{reloc})}
+
+ If defined, this macro tells @code{gas_cgen_md_apply_fix3} where to position
+ a reloc with code @var{reloc}. If the expression is true, the reloc will
+ point to the start of the operand it applies to; if false, it will point to
+ the start of the containing instruction. The latter behaviour is the
+ default one if the macro is not defined.
+
@end itemize
@item @code{md_begin} should contain the following (plus anything else you
--
For gas
2001-01-24 Richard Sandiford <r.sandiford@redhat.com>
* cgen.c (CGEN_RELOC_IS_OPERAND_RELATIVE): New macro, provide
default value.
(gas_cgen_md_apply_fix3): Use new macro.
Index: ./gas/cgen.c
===================================================================
RCS file: /cvs/src/src/gas/cgen.c,v
retrieving revision 1.8
diff -c -p -d -r1.8 cgen.c
*** ./gas/cgen.c 2001/01/12 23:34:43 1.8
--- ./gas/cgen.c 2001/01/24 12:39:32
*************** Foundation, 59 Temple Place - Suite 330,
*** 28,33 ****
--- 28,37 ----
#include "cgen.h"
#include "dwarf2dbg.h"
+ #ifndef CGEN_RELOC_IS_OPERAND_RELATIVE
+ #define CGEN_RELOC_IS_OPERAND_RELATIVE(RELOC) 0
+ #endif
+
/* Opcode table descriptor, must be set by md_begin. */
CGEN_CPU_DESC gas_cgen_cpu_desc;
*************** gas_cgen_md_apply_fix3 (fixP, valueP, se
*** 590,595 ****
--- 594,608 ----
reloc_type = md_cgen_lookup_reloc (insn, operand, fixP);
if (reloc_type != BFD_RELOC_NONE)
{
+ if (CGEN_RELOC_IS_OPERAND_RELATIVE (reloc_type))
+ {
+ const CGEN_IFLD *field;
+
+ field = cgen_ifield_lookup_by_num (gas_cgen_cpu_desc,
+ operand->ifield);
+ fixP->fx_where += field->word_offset / 8;
+ fixP->fx_size = field->length / 8;
+ }
fixP->fx_r_type = reloc_type;
}
else