On Tue, Apr 17, 2012 at 2:52 AM, Oleg Endo <oleg.e...@t-online.de> wrote:
> On Mon, 2012-04-16 at 04:11 +0800, Chiheng Xu wrote:
>> On Sat, Apr 14, 2012 at 11:47 AM, Chiheng Xu <chiheng...@gmail.com> wrote:
>> >
>> > And I want to say that tree/gimple/rtl are compiler's data(or state),
>> > not compiler's text(or logic), the most important thing about them is
>> > how to access their fields.
>> >
>>
>> Given the above assumption, now I doubt the necessity of accessor
>> macros or C++ getter/setter method.
>
> According to my experience, it doesn't take more time/effort to write
> "tree->code ()" instead of "tree->code" and such getter functions allow
> for easier refactoring etc.  If you omit the getters/setters you can't
> express things such as immutable objects (well you still could with
> const ivars but...), and you'll always have to have the ivar...
>
Sorry,  I don't know what is the benefit of const ivars.
But if you use "tree->code" instead of "tree->code()", the compiler
know very well whether you intend to read or write a piece of memory.
The const-ness is clear. I doubt how the compiler optimizer can
further optimize it.

>>
>> Is "tree->code" more direct and efficient than "TREE_CODE(tree)" or
>> "tree->get_code()" ?
>
> What do you mean by efficient?  All of them will (most likely) end up as
> the same machine code.

By saying "efficient", I probably mean compile time is reduced( macro
expansion + optimizing, or inlining + optimizing, are avoided).
I also probably mean reduced .h file size( the definitions of accessor
macros and C++ getter/setter inline methods, are avoided).

-- 
Chiheng Xu

Reply via email to