This is the mail archive of the gcc@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: Help with BLOCK vs BIND_EXPR trees


On Tue, Jun 16, 2009 at 3:19 PM, Jerry Quinn<jlquinn@optonline.net> wrote:
> On Tue, 2009-06-16 at 14:43 +0200, Richard Guenther wrote:
>> BIND_EXPRs are containers for local variables in the GENERIC
>> function body (they persist until GIMPLE is lowered). ?BLOCKs
>> represent the scope tree of the function (which also refers to
>> local variables). ?The BLOCK tree is kept live throughout the
>> compilation and is used to generate proper debug information
>> for example.
>
> So let me see if I understand with an example from C. ?If we have the
> following C function:
>
> void foo() {
> ?int a;
> ?{ int b; }
> ?{ int c; }
> }
>
>
> then starting with FUNCTION_DECL, we should have pseudocode for the
> GENERIC something like the following?
>
>
> tree foo = FUNCTION_DECL
>
> tree int_a = VAR_DECL
> tree int_b = VAR_DECL
> tree int_c = VAR_DECL
>
> tree scope_b = BIND_EXPR
> BIND_EXPR_VARS(scope_b) = int_b
> BIND_EXPR_BODY(scope_b) = int_b
>
> tree scope_c = BIND_EXPR
> BIND_EXPR_VARS(scope_c) = int_b
> BIND_EXPR_BODY(scope_c) = int_b
>
> tree foo_body = STATEMENT_LIST
> // I know this is actually a tree-iterator
> foo_body = { int_a, scope_b, scope_c }
>
> tree scope_foo = BIND_EXPR
> BIND_EXPR_VARS(scope_foo) = int_a
> BIND_EXPR_BODY(scope_foo) = foo_body
>
> DECL_SAVED_FUNCTION(foo) = scope_foo
>
> tree block_foo = BLOCK
> tree block_b = BLOCK
> tree block_c = BLOCK
>
> BLOCK_VARS(block_b) = int_b
> BLOCK_SUPERCONTEXT(block_b) = block_foo
> BLOCK_CHAIN(block_b) = block_c
>
> BLOCK_VARS(block_c) = int_c
> BLOCK_SUPERCONTEXT(block_c) = block_foo
> BLOCK_CHAIN(block_c) = null
>
> BLOCK_VARS(block_foo) = int_a
> BLOCK_SUPERCONTEXT(block_foo) = foo
> BLOCK_CHAIN(block_foo) = null
> BLOCK_SUBBLOCKS(block_foo) = block_b, block_c
>
>
> DECL_INITIAL(foo) = block_foo
>
>

Yes, that is about right.

Richard.

>
> Thanks for taking the time to clarify things for me,
> Jerry
>
>
>
>
>
>
>
>
>


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