This is the mail archive of the gcc-help@gcc.gnu.org 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: Question on .md file


Savithri Venkatachalapathy <snvpathy@yahoo.com> writes:

Your questions are all answered by the gcc internals manual.  Check
there first.

> 1.In the .md file I noticed that there are certain
> instructions defined as: define_insn "aaa_internal1",
> "aaa_internal2a" etc..
> What does this actually mean? What does "internal"
> suggest?

The only names which matters are the standard names used to generate
RTL instructions.  These are defined here:
    http://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html#Standard%20Names

Other insn names are used only as comments.  A name like aaa_internal
might mean that aaa is a standard name represented by a define_expand,
and that aaa_internal is a particular implementation for a particular
CPU class.  Or it might mean something else entirely.

> 2. I have 4 brach instructions:
>  BNE (Branch on Not Equal)
>  BEQ (Branch on EQual)
>  BEQZ(Branch on EQual to Zero)
>  BNEZ(Branch on Not Equal to Zero)
> 
> I have defined the first 2 instructions as define_insn
> "bne" and define_insn "beq".
> But I am not sure which name I should use for the last
> 2 instructions. 

The name doesn't matter as such, because gcc will never generate beqz
or bnez.  It may generate a comparison instruction against a constant
zero followed by a bne or beq.  Exactly how you should handle this
depends upon your CPU and how it handles comparisons and branches.
Look at other similar MD files.

> 3. Also I noticed in arm.md, sh.md, that the branch
> instructions have define_expand and not define_insn.
> Why is that?

Well, for the ARM it's because the branch instruction wants to pick up
the comparison information saved by cmpsi define_expand.  For example,
when gcc wants to generate a branch when two operands are equal, it
will call cmpsi and then beq.  On the ARM cmpsi will save the
operands.  The beq will pick up the operands, generate the compare (in
arm_gen_compare_reg()), and generate a branch insn.  At assembler
generation time, if the branch hasn't been optimized into something
else, it will be recognized by arm_cond_branch which will generate the
actual branch.

Ian


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