Re: GCC backend development

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

 



Radu Hobincu <radu.hobincu@xxxxxxxxxx> writes:

> I'm trying to write a GCC backend for a custom RISC machine and
> suddenly I seems to have a problem while compiling some C++ classes.
> After changing some code from all the implementation in the header
> file to declaration of the class in the header file and implementation
> in the .cpp file, the compiler started asking me for a
> STATIC_CHAIN_REGNUM. I'm a bit unfamiliar with this concept and google
> didn't really help (altho I found out there's a band called Static
> Chain...) so I was wondering if there are some links/ docs that
> explain what this does.
>
> Anyway, after declaring the macro and adding/ fixing some rtx
> templates in order to load a label into a register, now, when
> compiling the cpp file, I get some strange calls to some functions
> I've never seen before: __gxx_personality_sj0, _Unwind_SjLj_Resume,
> _Unwind_SjLj_Unregister. I'm pretty sure these are functions defined
> somewhere in libstdc++ but I have no idea what they do and I don't
> know why they suddenly appeared now, after I split the code in
> header/implementation.
>
> At the same time, some asm inlines which worked fine before started
> givimg me "error: âasmâ operand requires impossible reload", but
> however still work, as in they generate valid asm inline code.
>
> So, to summarize:
>    1. what exactly is a static chain?

First I'll say that you neglected to see which version of gcc you are
using.

The static chain is used by a nested function to refer to variables
defined in the enclosing function.  I don't know what you mean when you
say that the compiler started asking you for a STATIC_CHAIN_REGNUM.
Normally if a backend does not define STATIC_CHAIN_REGNUM, and you write
code using a nested function, the compiler will give the error "nested
functions not supported on this target".  You should of course only see
that error if you write code that uses nested functions.  Nested
functions are a C extension.  I don't know of any way that you can
trigger this error in C++ code.

>    2. why is that after splitting the code, calls to stdlibc++
> suddenly appear, and is there a way to keep them from appearing?

The functions you mention are used for exception handling.  I would
guess that when all the code is in the header file gcc was able to
determine that no exceptions could occur, but when the definitions were
moved out of the header file some exceptions became possible.  If you
want to write C++ code you need to either provide the functions which
handle exceptions or you need to always compile with -fno-exceptions.

>    3. is the asm error a fatal error or can I live with it/ fix it?

An "impossible reload" error is indeed an error and can not be ignored.
gcc will try to carry on by simply deleting the erroneous instruction,
so your program will not work as expected.

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