tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] modern c++ compiler written in C (food for thought)


From: Jared Maddox
Subject: Re: [Tinycc-devel] modern c++ compiler written in C (food for thought)
Date: Sat, 31 Oct 2015 12:38:37 -0500

> Date: Wed, 28 Oct 2015 07:11:47 +0100
> From: Basile Starynkevitch <address@hidden>
> To: address@hidden
> Subject: Re: [Tinycc-devel] modern c++ compiler written in C (food for
>         thought)
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> On 10/28/2015 05:14 AM, Sergey Korshunoff wrote:
>> Hi Basile
>>
>>> A C++ compiler needs to be optimizing. The C++ language specification 
>>> sort-of requires an > > optimizing compiler
>> Did you say that a usual C compiler (gcc, clang) can not optimize as a C++ 
>> does?
>> A tcc compiler is a compiler for a development speedup. A final stage
>> can be build by the usual compiler.
>
> No, I was just saying the obvious point that practically speaking the
> C++11 standard is expecting any compiler implementing that standard to
> optimize significantly.

I wouldn't write a true C++ compiler because the language is a mess,
but if someone else wants to, then lack of optimizations should not
precisely be considered a stopping-point.


> A C++ compiler should inline lots of functions
> (including most member functions declared inside a class) and do a lot
> of optimizations (in particular constant folding, some loop unrolling or
> if (true) optimizations, dead code elimination, etc...). I giuess that
> some template expansion cannot happen without optimizations.
>

The only one of those optimizations that I understand to be needed is
dead code elimination, and that's really just because some codebases
have started using if( 0 ) as a replacement for #if( 0 ), thus
producing linking complications. It could probably be justified for
ordinary TCC as a constants-optimization (some of which TCC does
actually have), if someone was interested in implementing it. The rest
of those optimizations may be intended, but proper function inlining
is intended with C99, yet TCC compiles C99 code okay without it.
Optimizations are only a sticking point if their absence interferes
with parsing or code generation.

Template expansion, meanwhile, probably calls for a virtual machine,
as I understand that it was one of the major stumbling-points for
CFront, and I believe their full power was only discovered after it
was abandoned. Exceptions are more of a problem, since you need
setjump()/longjmp() to play nicely: in some cases you'll need to write
your own version, and some platforms might not make this as easy as
x86 does.

At any rate, whether revolving around TCC or not, this is not
precisely a TCC project, since it's inclusion in TCC can't be
justified due to the danger of running afoul of patent licensing
rules. This is really a CFront project, and CFront already has been a
C++ compiler, so it's rather nonsensical to claim that it can't in any
way be brought up to a semi-modern standard: in fact, Comeau C/C++
compiles to C, and until recently was the ONLY major compiler to
support some C++ features.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]