o3: drop unused statistic wbPenalized and wbPenalizedRate
[gem5.git] / src / SConscript
index ef729cb33ca008694ce4cc097b387f263d0bcf73..eae03a98ac19cda55bc39cc3f5fee4163c4991b2 100755 (executable)
@@ -379,8 +379,20 @@ def makeTheISA(source, target, env):
 
 ''')
 
+    # create defines for the preprocessing and compile-time determination
     for i,isa in enumerate(isas):
         code('#define $0 $1', define(isa), i + 1)
+    code()
+
+    # create an enum for any run-time determination of the ISA, we
+    # reuse the same name as the namespaces
+    code('enum class Arch {')
+    for i,isa in enumerate(isas):
+        if i + 1 == len(isas):
+            code('  $0 = $1', namespace(isa), define(isa))
+        else:
+            code('  $0 = $1,', namespace(isa), define(isa))
+    code('};')
 
     code('''
 
@@ -516,6 +528,7 @@ for name,obj in sorted(sim_objects.iteritems()):
 #
 module_depends = ["m5", "m5.SimObject", "m5.params"]
 depends = [ PySource.modules[dep].snode for dep in module_depends ]
+depends.sort(key = lambda x: x.name)
 
 ########################################################################
 #
@@ -579,6 +592,18 @@ def createSimObjectParamStruct(target, source, env):
     obj.cxx_param_decl(code)
     code.write(target[0].abspath)
 
+def createSimObjectCxxConfig(is_header):
+    def body(target, source, env):
+        assert len(target) == 1 and len(source) == 1
+
+        name = str(source[0].get_contents())
+        obj = sim_objects[name]
+
+        code = code_formatter()
+        obj.cxx_config_param_file(code, is_header)
+        code.write(target[0].abspath)
+    return body
+
 def createParamSwigWrapper(target, source, env):
     assert len(target) == 1 and len(source) == 1
 
@@ -644,9 +669,64 @@ for name,simobj in sorted(sim_objects.iteritems()):
     env.Depends(hh_file, depends + extra_deps)
     env.Depends(SWIG, hh_file)
 
+# C++ parameter description files
+if GetOption('with_cxx_config'):
+    for name,simobj in sorted(sim_objects.iteritems()):
+        py_source = PySource.modules[simobj.__module__]
+        extra_deps = [ py_source.tnode ]
+
+        cxx_config_hh_file = File('cxx_config/%s.hh' % name)
+        cxx_config_cc_file = File('cxx_config/%s.cc' % name)
+        env.Command(cxx_config_hh_file, Value(name),
+                    MakeAction(createSimObjectCxxConfig(True),
+                    Transform("CXXCPRHH")))
+        env.Command(cxx_config_cc_file, Value(name),
+                    MakeAction(createSimObjectCxxConfig(False),
+                    Transform("CXXCPRCC")))
+        env.Depends(cxx_config_hh_file, depends + extra_deps +
+                    [File('params/%s.hh' % name), File('sim/cxx_config.hh')])
+        env.Depends(cxx_config_cc_file, depends + extra_deps +
+                    [cxx_config_hh_file])
+        Source(cxx_config_cc_file)
+
+    cxx_config_init_cc_file = File('cxx_config/init.cc')
+
+    def createCxxConfigInitCC(target, source, env):
+        assert len(target) == 1 and len(source) == 1
+
+        code = code_formatter()
+
+        for name,simobj in sorted(sim_objects.iteritems()):
+            if not hasattr(simobj, 'abstract') or not simobj.abstract:
+                code('#include "cxx_config/${name}.hh"')
+        code()
+        code('void cxxConfigInit()')
+        code('{')
+        code.indent()
+        for name,simobj in sorted(sim_objects.iteritems()):
+            not_abstract = not hasattr(simobj, 'abstract') or \
+                not simobj.abstract
+            if not_abstract and 'type' in simobj.__dict__:
+                code('cxx_config_directory["${name}"] = '
+                     '${name}CxxConfigParams::makeDirectoryEntry();')
+        code.dedent()
+        code('}')
+        code.write(target[0].abspath)
+
+    py_source = PySource.modules[simobj.__module__]
+    extra_deps = [ py_source.tnode ]
+    env.Command(cxx_config_init_cc_file, Value(name),
+        MakeAction(createCxxConfigInitCC, Transform("CXXCINIT")))
+    cxx_param_hh_files = ["cxx_config/%s.hh" % simobj
+        for name,simobj in sorted(sim_objects.iteritems())
+        if not hasattr(simobj, 'abstract') or not simobj.abstract]
+    Depends(cxx_config_init_cc_file, cxx_param_hh_files +
+            [File('sim/cxx_config.hh')])
+    Source(cxx_config_init_cc_file)
+
 # Generate any needed param SWIG wrapper files
 params_i_files = []
-for name,param in params_to_swig.iteritems():
+for name,param in sorted(params_to_swig.iteritems()):
     i_file = File('python/m5/internal/%s.i' % (param.swig_module_name()))
     params_i_files.append(i_file)
     env.Command(i_file, Value(name),
@@ -681,10 +761,9 @@ for name,enum in sorted(all_enums.iteritems()):
     SwigSource('m5.internal', i_file)
 
 # Generate SimObject SWIG wrapper files
-for name,simobj in sim_objects.iteritems():
+for name,simobj in sorted(sim_objects.iteritems()):
     py_source = PySource.modules[simobj.__module__]
     extra_deps = [ py_source.tnode ]
-
     i_file = File('python/m5/internal/param_%s.i' % name)
     env.Command(i_file, Value(name),
                 MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG")))
@@ -773,9 +852,9 @@ namespace Debug {
             last = len(compound) - 1
             for i,flag in enumerate(compound):
                 if i != last:
-                    comp_code('$flag,')
+                    comp_code('&$flag,')
                 else:
-                    comp_code('$flag);')
+                    comp_code('&$flag);')
             comp_code.dedent()
 
     code.append(comp_code)
@@ -837,6 +916,11 @@ env.Command('debug/flags.cc', Value(debug_flags),
 env.Depends(SWIG, 'debug/flags.cc')
 Source('debug/flags.cc')
 
+# version tags
+env.Command('sim/tags.cc', None,
+            MakeAction('util/cpt_upgrader.py --get-cc-file > $TARGET',
+                       Transform("VER TAGS")))
+
 # Embed python files.  All .py files that have been indicated by a
 # PySource() call in a SConscript need to be embedded into the M5
 # library.  To do that, we compile the file to byte code, marshal the
@@ -936,7 +1020,8 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
 
     # Add additional warnings here that should not be applied to
     # the SWIG generated code
-    new_env.Append(CXXFLAGS='-Wmissing-declarations')
+    new_env.Append(CXXFLAGS=['-Wmissing-declarations',
+                             '-Wdelete-non-virtual-dtor'])
 
     if env['GCC']:
         # Depending on the SWIG version, we also need to supress
@@ -944,15 +1029,8 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
         # initializers.
         swig_env.Append(CCFLAGS=['-Wno-uninitialized',
                                  '-Wno-missing-field-initializers',
-                                 '-Wno-unused-but-set-variable'])
-
-        # If gcc supports it, also warn for deletion of derived
-        # classes with non-virtual desctructors. For gcc >= 4.7 we
-        # also have to disable warnings about the SWIG code having
-        # potentially uninitialized variables.
-        if compareVersions(env['GCC_VERSION'], '4.7') >= 0:
-            new_env.Append(CXXFLAGS='-Wdelete-non-virtual-dtor')
-            swig_env.Append(CCFLAGS='-Wno-maybe-uninitialized')
+                                 '-Wno-unused-but-set-variable',
+                                 '-Wno-maybe-uninitialized'])
 
         # Only gcc >= 4.9 supports UBSan, so check both the version
         # and the command-line option before adding the compiler and
@@ -963,10 +1041,6 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
             new_env.Append(LINKFLAGS='-fsanitize=undefined')
 
     if env['CLANG']:
-        # Always enable the warning for deletion of derived classes
-        # with non-virtual destructors
-        new_env.Append(CXXFLAGS=['-Wdelete-non-virtual-dtor'])
-
         swig_env.Append(CCFLAGS=[
                 # Some versions of SWIG can return uninitialized values
                 '-Wno-sometimes-uninitialized',
@@ -982,7 +1056,12 @@ def makeEnv(env, label, objsfx, strip = False, **kwargs):
             new_env.Append(LINKFLAGS='-fsanitize=undefined')
 
     werror_env = new_env.Clone()
-    werror_env.Append(CCFLAGS='-Werror')
+    # Treat warnings as errors but white list some warnings that we
+    # want to allow (e.g., deprecation warnings).
+    werror_env.Append(CCFLAGS=['-Werror',
+                               '-Wno-error=deprecated-declarations',
+                               '-Wno-error=deprecated',
+                               ])
 
     def make_obj(source, static, extra_deps = None):
         '''This function adds the specified source to the correct