On Tue, Apr 10, 2007 at 11:13:44AM -0700, Ian Lance Taylor wrote: > The obvious way to make the proposed tuples position independent would > be to use array offsets rather than pointers.
I suggest instead, if we want something like this, that we make the references be pc-relative. So something like // This would replace all ocurrences of "tree" and "gimple" within // the actual structures, to force the macros to be used. typedef struct { ptrdiff_t d; } gs_ref; static inline void * gs_ref (gs_ref *x) { return (char *)x + x->d; } #define GS_REF(TYPE,X) ((TYPE) gs_ref (&(X))) static inline void gs_ref_set (gs_ref *loc, const void *val) { loc->d = (const char *)val - (const char *)loc; } #define GS_REF_SET(LOC, VAL) gs_ref_set(&(LOC), VAL) // Ignoring other checking code for the moment. #define TREE_OPERAND(NODE, X) GS_REF(tree, (NODE)->exp.operands[X]) #define TREE_OPERAND_SET(NODE, X, VAL) \ GS_REF_SET((NODE)->exp.operands[X], VAL) When loading a .o file, this will require some fixups to the file's symbol table for external references, but otherwise everything will be self-contained. With some careful planning, one might could arrange for all of these fixups to be in the same pages of the .o file, minimizing the amount of COW space that would be used. This has an overhead of one addition insn per reference. Which ought to be much less than a memory reference via an index into an array. r~