This is the mail archive of the mailing list for the GCC 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: Modifying ARM code generator for elimination of 8bit writes - need help

On 20 July 2006 16:25, Ian Lance Taylor wrote:

> "Dave Korn" <> writes:
>>   Is there any generic advice available as to when and why one should use
>> emit_insn (gen_rtx_SET (....)) as opposed to emit_move_insn (...)?
> It depends on where you are in the compiler.  You can only use
> gen_rtx_SET if you know that the resulting insn will be recognized.  I
> think it is usually cleaner to use gen_INSNNAME, but in some cases
> that is inconvenient because there are different possible insns
> involved (depending on processor type, etc.).

  Ah, so simple register/memory/constant moves with valid addressing modes are
(in general, on most cpus) going to be ok, but out-of-range constants,
complicated mem or subreg expressions, or complex (non-folded/non-foldable)
compound operands would make it barf IIUYC.

> emit_move_insn should be used to move values around.  The middle end
> only calls gen_rtx_SET if it is going to then call recog to make sure
> the result is valid.
>>   (There are other similar pairs of functions with seemingly overlapping
>> functionality that I find equally confusing.  For instance, I *think* that
>> you should only use gen_rtx_REG when you want to create a new pseudo, and
>> that in the general case of wanting an rtx that refers to an existing
>> pseudo or a hard reg you're supposed to use gen_reg_rtx which takes care
>> of sharing and everything for you... but I haven't seen any solid
>> documentation that backs up my hypothesis.)
> You should normally use gen_reg_rtx to create a new pseudo-register.
> gen_rtx_REG is normally used to create a reference to a hard register.

  Ah, I got it 100% the wrong way around!  I'm afraid I wrote the question off
the top of my head without doing my homework first.

> Using gen_rtx_REG to refer to an existing pseudo-register will
> normally do the wrong thing.  If there is any code which does that, it
> needs a very hard look.

  I'm not saying that there is any; I'm afraid I wrote the question off the
top of my head without checking I'd got the two the right way round.

  Thanks to you and R. for your explanations; it's not too complicated to get
to grips with, but it's one of those things that falls under the category of
unwritten knowledge that you only pick up by (sometimes bitter) experience.

Can't think of a witty .sigline today....

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