From f0b4259e98773bee04cd0af5dda7bcfba5032589 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 26 Feb 2010 18:14:48 -0800 Subject: cpu_models: get rid of cpu_models.py and move the stuff into SCons --- SConstruct | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'SConstruct') diff --git a/SConstruct b/SConstruct index 6ca3d6a14..55cf71876 100644 --- a/SConstruct +++ b/SConstruct @@ -612,10 +612,34 @@ main = conf.Finish() all_isa_list = [ ] Export('all_isa_list') -# Define the universe of supported CPU models -all_cpu_list = [ ] -default_cpus = [ ] -Export('all_cpu_list', 'default_cpus') +class CpuModel(object): + '''The CpuModel class encapsulates everything the ISA parser needs to + know about a particular CPU model.''' + + # Dict of available CPU model objects. Accessible as CpuModel.dict. + dict = {} + list = [] + defaults = [] + + # Constructor. Automatically adds models to CpuModel.dict. + def __init__(self, name, filename, includes, strings, default=False): + self.name = name # name of model + self.filename = filename # filename for output exec code + self.includes = includes # include files needed in exec file + # The 'strings' dict holds all the per-CPU symbols we can + # substitute into templates etc. + self.strings = strings + + # This cpu is enabled by default + self.default = default + + # Add self to dict + if name in CpuModel.dict: + raise AttributeError, "CpuModel '%s' already registered" % name + CpuModel.dict[name] = self + CpuModel.list.append(name) + +Export('CpuModel') # Sticky variables get saved in the variables file so they persist from # one invocation to the next (unless overridden, in which case the new @@ -640,13 +664,13 @@ for bdir in [ base_dir ] + extras_dir_list: SConscript(joinpath(root, 'SConsopts')) all_isa_list.sort() -all_cpu_list.sort() -default_cpus.sort() sticky_vars.AddVariables( EnumVariable('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), BoolVariable('FULL_SYSTEM', 'Full-system support', False), - ListVariable('CPU_MODELS', 'CPU models', default_cpus, all_cpu_list), + ListVariable('CPU_MODELS', 'CPU models', + sorted(n for n,m in CpuModel.dict.iteritems() if m.default), + sorted(CpuModel.list)), BoolVariable('NO_FAST_ALLOC', 'Disable fast object allocator', False), BoolVariable('FAST_ALLOC_DEBUG', 'Enable fast object allocator debugging', False), -- cgit v1.2.3