On Thu, 18 Nov 2010, Joern Rennecke wrote:

> You could do this with:
> typedef struct { int arch; void *p; } cumulative_args_t;
> or
> typedef struct { int arch; void *p; } *cumulative_args_t;
> 
> with regards to the conversion function, that could be provided in
> target-def.h
> 
> static inline CUMULATIVE_ARGS *
> get_cumulative_args (cumulative_args_t arg)
> {
>  gcc_assert (arg.arch == TARGET_NUM);
>  return (CUMULATIVE_ARGS *) arg.p;
> }
> 
> static inline cumulative_args_t
> pack_cumulative_args (CUMULATIVE_ARGS *arg)
> {
>  cumulative_arg_t ret;
>  ret.arch = TARGET_NUM;
>  ret.p = (void *) arg;
>  return ret;
> }

Yes, this seems a reasonable approach for having the types of these hooks 
not depend on the target, having as much static type safety as reasonably 
possible given that and having dynamic type safety through the runtime 
assertions when you have multiple targets each with their own 
CUMULATIVE_ARGS.  (Now I believe that we should end up not having the 
target-specific CUMULATIVE_ARGS type visible anywhere in the 
target-independent compiler, which would require something to be worked 
out about how those values are allocated and deallocated, but that's 
definitely a separate project.)

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to