Re: Segmentation fault when compiling GCC with new RTL pass

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 3, 2012 at 12:00 PM, Tomasz Jankowski <tomcioj@xxxxxxxxx> wrote:
>
> Yes, this was the reason, I was using rtx with patten instead of valid
> insn. After reading more source code I found, that I have to use
> make_insn_raw() to create insn from patter.

Note that most callers use emit_insn and friends, not make_insn_raw.

> When reading source code of RTL passes I saw two ways of browsing
> insn. In one way basic blocks are used, in the way we have something
> like:
>
>     FOR_EACH_BB(bb)
>     {
>         FOR_BB_INSNS(bb, insn)
>         {
>              // do something with insn
>         }
>     }
>
> and in the second way we access insns using "get_insns()" function
> from rtl.h and just handle it in regular "for" loop. What's the
> difference between these two solutions? When using basic blocks we
> browse source code as function by function. But when we use
> "get_insns()" we simple go trough all insns in current compilation
> unit, right?

get_insns() returns all the insns in the current function or in the
current insn sequence (see push_to_sequence).  In new code if you want
to look at all the insns in the current function you should always use
the first way--loop over the basic blocks and loop over the insns in
the block.

> What's the difference between "emit_insn_...()" and "add_insn_...()"
> functions? From RTL pass point of view, they seem to work in the same
> way.

emit_insn takes an general rtx and emits it as an insn.  add_insn only
takes an insn.  In particular, emit_insn calls add_insn.


> In OpenRISC assigning 32 bit constant to register is handled by
> "define_expand". What I want to do is to call my instruction after
> constant is copied to register. For such assignment in C:
>
>     int AAAA = 12345678;
>
> I get such dump after RTL expand:
>
>     (insn 5 4 6 3 simple_test.c:3 (set (reg:SI 43)
>             (const_int 12320768 [0xbc0000])) -1 (nil))
>
> Then my new pass is executed and I get ("rto" is my custom instruction
> and it take single register):
>
>     (insn 5 4 19 3 simple_test.c:3 (set (reg:SI 43)
>             (const_int 12320768 [0xbc0000])) -1 (nil))
>     (insn 19 5 6 3 (rto:SI (reg:SI 43)) -1 (nil))
>
> At this point everything is ok, but in final assembler output, here
> this assignment is expanded with "define_expand" I get:
>
>     l.movhi     r3,hi(12320768)  # move immediate M
>     l.rto       r3
>     l.ori       r3,r3,24910
>
> instead of:
>
>     l.movhi     r3,hi(12320768)  # move immediate M
>     l.ori       r3,r3,24910
>     l.rto       r3
>
> I don't know why mu instruction call gets "injected" in the previous
> define_expand output.

I think you are misunderstanding something.  define_expand is called
when GIMPLE is converted to RTL.  It is also called during reload, and
at other times when general instructions are generated.  In
particular, define_expand is not used to convert one insn to another
(define_split does that) and define_expand is not used when generating
assembler code.

I don't know what rto:SI means and I don't know what you are trying to
do.  If I were trying to insert an insn at a particular point I would
not define a new RTL code, I would use UNSPEC_VOLATILE.

> Last thing - should I send my questions on gcc-help or other mailing list?

For these kinds of questions, gcc-help is good.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux