On Mon, 2005-04-25 at 19:01, Kazu Hirata wrote: > Hi Andrew, > No, I would like to remove stmt_ann_t pointer from the stmt node, but > not yet. All I want to do in this project is to put > tree_statement_list_node and stmt_ann_d next to each other in memory > while doing necessary adjustments in the compiler. Nothing more than > that. >
does that buy us much? > Yes, it is nice to get rid of stmt_ann_t pointer from the stmt node, > and I want to eventually get that, but not in this project. I think > there are so many places that use "stmt" instead of "bsi". They may > either pass it to subroutines or put it in some internal data > structures, so I would like to do that separately. So if you like, > the roadmap might be something like > > 1. Put tree_statement_list_node and stmt_ann_d next to each other in > memory while doing necessary adjustments. > > 2. Provide stmt_ann_from_bsi(), a function that gives you stmt_ann > given bsi. > > 3. Let everybody use stmt_ann_from_bsi(), replace stmt_ann(), and > remove the stmt_ann_t pointer from the stmt node (if these are > possible at all). > > 4. Hand off to Zdenek for his flat statement project. > > I hope this message clarifies things. > Then why not simply shorten this to: 1) put stmt annoation directly in the tree_statement_list_node 2) replace stmt_ann_t pointer in stmt with a pointer to its BSI, or the tree_statement_list_node. This makes bsi_from_stmt O(1) immediately. 3) all stmts now have access to the stmt_ann directly in the stmt_list_node, nothing changes except get_stmt_ann() returns the address of the stmt ann within the tree_stmt_list_node. 4) For fake stmts you will have to allocate a fake tree_stmt_list_node which isnt linked with anything, and set the bsi pointer to that... then you have the annotation and access to it from the stmt. that seems like a quicker more direct approach then phasing it in slowly, with less impact to anyone, and gives you immediate benefits. I would think the patch to do this would be fairly small and non-intrusive. Andrew