ISA-Specific Compilation

From gem5
Jump to: navigation, search

We need three things:

  1. the ability to say "include isa_traits.hh" or "include endian.hh" in some syntax and get the right file
  2. the ability to call an ISA-specific function and get the right implementation, e.g. htog(foo) or decode(inst)
  3. the ability to say "if (ISA == Alpha)" in some syntax to insert isa-specific code in mostly non-isa-specific files (obviously we want to minimize this, but it will be difficult to avoid completely)

Here's my proposed solution:

  • ISA-specific functions will be in namespaces (e.g. AlphaISA, SparcISA).
  • For all files that have compile-time ISA dependencies, the symbol "TheISA" will be defined by the preprocessor to one of the actual ISA namespaces. Thus the caller can:
    • use e.g. TheISA::htog() to refer to a particular function,
    • say "using namespace TheISA" to get at all the ISA-specific functions, and/or
    • use e.g. "#if THE_ISA == ALPHA_ISA" to insert specific ISA-dependent code. (Again, the use of this feature should be minimized, but may be necessary.)
  • ISA-specific declarations of standard ISA functions (i.e. where the interface is ISA-independent but the implementation is ISA-dependent) will be in header files with standard names, e.g. isa_traits.hh. These headers will be located in arch/alpha, arch/sparc, arch/mips, etc.
  • For each of these standard header files, there will be an autogenerated "switch" file in arch that will be included by other header and source files that need these declarations. For example, arch/isa_traits.hh would look like:
#define ALPHA_ISA 21064
#define SPARC_ISA 42
#include "arch/alpha/isa_traits.hh"
#define TheISA AlphaISA
#include "arch/sparc/isa_traits.hh"
#define TheISA SparcISA
#error "THE_ISA not set"
  • Each file with compile-time ISA dependencies will get compiled to an ISA-specific object file by using "-DTHE_ISA=ALPHA_ISA" on the compiler command line. For example, cpu/simple/ would generate both arch/alpha/cpu/simple/ and arch/sparc/cpu/simple/ (Other paths may be better... we'll have to see what works best with scons.)

Note: we should add "-Wundef" to our standard command line to avoid disasters.

Selectively compiling operating system files

Currently, when compiling m5, all operating system files are compiled in. In some cases this doesn't make sense, like compiling Tru64 support code for SPARC. This is also causing some compilation errors. We seem to need a way to specify which operating systems we want to compile similarly to how we can specify what processor models to use. --Gblack 16:55, 20 March 2006 (EST)