This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA] Integrated hashtables take 2
How about:
struct cpp_identifier
{
int length;
const char* pointer;
};
struct tree_identifier
{
struct tree_common common;
struct cpp_identifier ident;
};
#define IDENTIFIER_LENGTH(NODE) \
(IDENTIFIER_NODE_CHECK (NODE)->identifier.ident.length)
#define IDENTIFIER_POINTER(NODE) \
(IDENTIFIER_NODE_CHECK (NODE)->identifier.ident.pointer)
Then we have two choices:
(a) The hashtable contains pointers to the cpp_identifier
part. For the front-end to get the tree_identifier it has
to subtract the offset of ident in tree_identifier.
There would be a cpp_alloc_identifier function, which the
front-end could define as:
struct cpp_identifier *
cpp_alloc_identifier ()
{
tree id = make_node (IDENTIFIER_NODE);
return &id->ident;
}
(b) The hashtable contains (void*) pointers to the tree_identifier
object. The front-end registers with cpplib (i.e. a global
int variable) the offset of the cpp_identifier part, or
a function that converts the (void*) pointer to tree_identifier
to one that return the cpp_identifier part. (That latter is
cleaner but slower.)
--
--Per Bothner
per@bothner.com http://www.bothner.com/per/