On Jun 26, 2010, at 12:24 PM, Richard Sandiford wrote: > GCC has a fair number of global variables that cache target-dependent > data. This makes it difficult to switch between subtargets on the fly, > such as when switching between a MIPS16 and a non-MIPS16 function. > > Our current approach is to call target_reinit each time we make such > a switch. This function goes off and redoes a fair chunk of the target > initialisation process, and although it works (or least worked) pretty well, > it is very slow. >
> * doc/tm.texi (SWITCHABLE_TARGET): Document. > * Makefile.in (target_globals_def): New variable. > (target_globals_h): Likewise. > (TARGET_GLOBALS_H): Likewise. > (OBJS-common): Add target-globals.o. > (gtype-desc.o): Depend on $(TARGET_GLOBALS_H). > (target-globals.o): New rule. > ($(target_globals_h)): Likewise. > (s-target-globals): Likewise. > (GTFILES): Add $(target_globals_h). > (build/gentarget-globals.o): New rule. > * defaults.h (SWITCHABLE_TARGET): Define. > * gengtype.c (open_base_files): Add target-globals.h to the > include list. > * target-globals.def: New file. > * gentarget-globals.c: Likewise. > * target-globals.c: Likewise. First, thanks for the work. I have a switchable port, I seem to be seeing: ../../gcc/gcc/target-globals.c: In function ‘target_globals* save_target_globals()’: ../../gcc/gcc/target-globals.c:69:33: error: ‘ggc_alloc_target_globals’ was not declared in this scope make: *** [target-globals.o] Error 1 after the switch to C++. I was wondering if your switchable target port compiles post the switch to C++? Before the switch, I saw a C warning for using ggc_alloc_target_globals undeclared. With: diff --git a/gcc/target-globals.c b/gcc/target-globals.c index e679f21..4e33359 100644 --- a/gcc/target-globals.c +++ b/gcc/target-globals.c @@ -65,6 +65,7 @@ struct target_globals * save_target_globals (void) { struct target_globals *g; + extern struct target_globals *ggc_alloc_target_globals (void); g = ggc_alloc_target_globals (); g->flag_state = XCNEW (struct target_flag_state); my port again compiles. Certainly I hate block scoped external function declarations, it is wrong... could you decide where it goes and drop in that line someplace? Thanks.