This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newbie questions about relaxation in binutils port


On Wed, 22 Aug 2007, Tomas Svensson wrote:
> I'm in the process of porting binutils to a new target CPU, and have
> some questions to ask regarding relaxation, that I have been unable to
> find clear answers to in the documentation and mailing list archives.
> Also, the source code of different ports seem to say very different
> things.
>
> What is the difference in purpose between
> md_estimate_size_before_relax

Initialize the estimate, to smallest possible (which might be
final for e.g. immediate constants as opposed to pc-relative
expressions).

> and md_relax_frag?

Update the estimate.

> Also, what is the actual interpretation of the frag_var and
> frag_variant functions?

*shrug* they both build a frag.  About the difference, I've
forgot.  I usually look at the code when that happens. :)  ...
nothing pops up besides the "OVE: This variant of frag_var
assumes that space for the tail has been allocated by caller".
No, I don't know who this OVE is.

> I am looking to implement a mechanism that can choose which one of two
> instructions (of different length) to output depending on the size of
> the immediate value, and I believe that putting the correct opcode
> into the frag is best done in md_convert_frag. Should I do anything
> about the frag length here, too?

Not besides fragP->fr_fix.

> Say that the original opcode has length 2, and I have created a frag
> with frag_var using max_chars=2 and var=2. On realizing that the
> immediate won't fit, I want to change it into an instruction with an
> opcode of length 4. In md_convert_frag, do I need to call frag_more?

No.  You do the updates in md_relax_frag; update
fragP->fr_subtype.  You're supposed to allocate max size in the
variant part of your frag; no need to call frag_more anywhere
after you initially parse insns and build the insn chain.

> Do I need to change fragP->fr_fix or fr_var?

In md_convert_frag, set fr_fix.

> If any of this is obvious from some documentation that I've
> overlooked, please point me to it!

You mentioned you've already looked at different ports, so I
don't know what, except of course gas/doc/internals.texi and the
code that calls those functions.  I looked at the CRIS port,
which I believe is correct, while composing this reply.

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]