SConscript revision 2522
1955SN/A# -*- mode:python -*- 2955SN/A 31762SN/A# Copyright (c) 2006 The Regents of The University of Michigan 4955SN/A# All rights reserved. 5955SN/A# 6955SN/A# Redistribution and use in source and binary forms, with or without 7955SN/A# modification, are permitted provided that the following conditions are 8955SN/A# met: redistributions of source code must retain the above copyright 9955SN/A# notice, this list of conditions and the following disclaimer; 10955SN/A# redistributions in binary form must reproduce the above copyright 11955SN/A# notice, this list of conditions and the following disclaimer in the 12955SN/A# documentation and/or other materials provided with the distribution; 13955SN/A# neither the name of the copyright holders nor the names of its 14955SN/A# contributors may be used to endorse or promote products derived from 15955SN/A# this software without specific prior written permission. 16955SN/A# 17955SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18955SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19955SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20955SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21955SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22955SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23955SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24955SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25955SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26955SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27955SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu 294762Snate@binkert.orgimport os 30955SN/Aimport os.path 314762Snate@binkert.org 32955SN/A# Import build environment variable from SConstruct. 33955SN/AImport('env') 344202Sbinkertn@umich.edu 354382Sbinkertn@umich.edu################################################################# 364202Sbinkertn@umich.edu# 374762Snate@binkert.org# Generate StaticInst execute() method signatures. 384762Snate@binkert.org# 394762Snate@binkert.org# There must be one signature for each CPU model compiled in. 40955SN/A# Since the set of compiled-in models is flexible, we generate a 414381Sbinkertn@umich.edu# header containing the appropriate set of signatures on the fly. 424381Sbinkertn@umich.edu# 43955SN/A################################################################# 44955SN/A 45955SN/A# CPU model-specific data is contained in cpu_models.py 464202Sbinkertn@umich.edu# Convert to SCons File node to get path handling 47955SN/Amodels_db = File('cpu_models.py') 484382Sbinkertn@umich.edu# slurp in contents of file 494382Sbinkertn@umich.eduexecfile(models_db.srcnode().abspath) 504382Sbinkertn@umich.edu 514762Snate@binkert.org# Template for execute() signature. 524762Snate@binkert.orgexec_sig_template = ''' 534762Snate@binkert.orgvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0; 544762Snate@binkert.org''' 554762Snate@binkert.org 564762Snate@binkert.org# Generate header. 574762Snate@binkert.orgdef gen_cpu_exec_signatures(target, source, env): 584762Snate@binkert.org f = open(str(target[0]), 'w') 594762Snate@binkert.org print >> f, ''' 604762Snate@binkert.org#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__ 614762Snate@binkert.org#define __CPU_STATIC_INST_EXEC_SIGS_HH__ 624762Snate@binkert.org''' 634762Snate@binkert.org for cpu in env['CPU_MODELS']: 644762Snate@binkert.org xc_type = CpuModel.dict[cpu].strings['CPU_exec_context'] 654762Snate@binkert.org print >> f, exec_sig_template % xc_type 664762Snate@binkert.org print >> f, ''' 674762Snate@binkert.org#endif // __CPU_STATIC_INST_EXEC_SIGS_HH__ 684762Snate@binkert.org''' 694762Snate@binkert.org 704762Snate@binkert.org# Generate string that gets printed when header is rebuilt 714762Snate@binkert.orgdef gen_sigs_string(target, source, env): 724762Snate@binkert.org return "Generating static_inst_exec_sigs.hh: " \ 734762Snate@binkert.org + ', '.join(env['CPU_MODELS']) 744762Snate@binkert.org 754762Snate@binkert.org# Add command to generate header to environment. 764762Snate@binkert.orgenv.Command('static_inst_exec_sigs.hh', models_db, 774762Snate@binkert.org Action(gen_cpu_exec_signatures, gen_sigs_string, 784762Snate@binkert.org varlist = ['CPU_MODELS'])) 794762Snate@binkert.org 804762Snate@binkert.org################################################################# 814762Snate@binkert.org# 824762Snate@binkert.org# Include CPU-model-specific files based on set of models 834762Snate@binkert.org# specified in CPU_MODELS build option. 844382Sbinkertn@umich.edu# 854762Snate@binkert.org################################################################# 864382Sbinkertn@umich.edu 874762Snate@binkert.orgsources = [] 884381Sbinkertn@umich.edu 894762Snate@binkert.orgif 'SimpleCPU' in env['CPU_MODELS']: 904762Snate@binkert.org sources += Split('simple/cpu.cc') 914762Snate@binkert.org 924762Snate@binkert.orgif 'FastCPU' in env['CPU_MODELS']: 934762Snate@binkert.org sources += Split('fast/cpu.cc') 944762Snate@binkert.org 954762Snate@binkert.orgif 'AlphaFullCPU' in env['CPU_MODELS']: 964762Snate@binkert.org sources += Split(''' 974762Snate@binkert.org o3/2bit_local_pred.cc 984762Snate@binkert.org o3/alpha_dyn_inst.cc 994762Snate@binkert.org o3/alpha_cpu.cc 1004762Snate@binkert.org o3/alpha_cpu_builder.cc 1014762Snate@binkert.org o3/bpred_unit.cc 1024762Snate@binkert.org o3/btb.cc 1034762Snate@binkert.org o3/commit.cc 1044762Snate@binkert.org o3/decode.cc 1054762Snate@binkert.org o3/fetch.cc 1064762Snate@binkert.org o3/free_list.cc 1074762Snate@binkert.org o3/cpu.cc 1084762Snate@binkert.org o3/iew.cc 1094762Snate@binkert.org o3/inst_queue.cc 1104762Snate@binkert.org o3/ldstq.cc 1114762Snate@binkert.org o3/mem_dep_unit.cc 1124762Snate@binkert.org o3/ras.cc 1134762Snate@binkert.org o3/rename.cc 1144762Snate@binkert.org o3/rename_map.cc 1154762Snate@binkert.org o3/rob.cc 1164762Snate@binkert.org o3/sat_counter.cc 1174762Snate@binkert.org o3/store_set.cc 1184762Snate@binkert.org o3/tournament_pred.cc 1194762Snate@binkert.org ''') 1204762Snate@binkert.org 1214762Snate@binkert.org# FullCPU sources are included from m5/SConscript since they're not 1224762Snate@binkert.org# below this point in the file hierarchy. 1234762Snate@binkert.org 1244762Snate@binkert.org# Convert file names to SCons File objects. This takes care of the 1254762Snate@binkert.org# path relative to the top of the directory tree. 1264762Snate@binkert.orgsources = [File(s) for s in sources] 1274762Snate@binkert.org 1284762Snate@binkert.orgReturn('sources') 129955SN/A 1304382Sbinkertn@umich.edu