Fabrice Bellard wrote: > You should add a runtime selection system : see the ARM and PowerPC > targets (I would prefer a parameter to cpu_init(). It was not done that > way on PowerPC for legacy reasons). Each machine should be able to > select the processor it needs (and allow the user to change it if > needed, but it is not the main point). There is no good reason to make > the selection at compile time because the translator can efficiently > handle any CPU differences at runtime. Find in the attachment a first proposal for runtime instruction set configuration for MIPS target. Please comment, correct etc. Some notes: - As first step, only three options for R4K, NEC (partly, see below) and FPU are used. The different MIPS ISA levels aren't used at the moment and are there for future use. Fabrice mentioned that he likes to split the different MIPS intstruction set configurations clearly. - As I understand it, MIPS III is an extension of MIPS II, MIPS IV is an extension of MIPS III etc. Therefore I used definitions for ISAx which include the smaller ones as well. - With the #ifdef MIPS_USES_xxx #define mips_uses_xxx() (env->features & MIPS_FEATURE_xxx) #else #define mips_uses_xxx() 0 #endif logic it should be possible to enable or disable a feature at compile time by setting the corresponding macro *or* at runtime by adding machines with different features to cpu_mips_set_model(). - If mips_uses_xxx() is set to 0 at compile time, I think gcc should optimize away the if(mips_uses_xxx()) parts in translate.c. Therefore I think we can remove some #if defined (MIPS_USES_xxx). - An cpu_mips_set_model() is introduced similiar to the ARM one. Because in mips-defs.h there was a hardcoded CPU, some reorganization for runtime selection was necessary. - Later, it should be possible to move more options to runtime configuration, like endianess and the #if defined (MIPS_CONFIGx) in cpu_mips_init(). For the moment, to keep patch small I concentrated only on instruction set. I don't want to mix to much instruction set configuration and machine runtime selection for the moment. - cpu_mips_init() moved from translate.c to helper.c and was extended there by set_feature() and cpu_mips_set_model() (same file location like used by ARM). Setting of FPU options moved from cpu_mips_init() to model configuration cpu_mips_set_model(). - My patch for NEC instruction set extension (the main reason for the whole stuff ;) ) will be send and updated if you like the configuration in this patch and something like this is applied. For the moment, there's only a stub in decode_opc() which should generate an exception. Best regards Dirk