SConscript revision 5398
112837Sgabeblack@google.com# -*- mode:python -*- 212837Sgabeblack@google.com 312837Sgabeblack@google.com# Copyright (c) 2006 The Regents of The University of Michigan 412837Sgabeblack@google.com# All rights reserved. 512837Sgabeblack@google.com# 612837Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 712837Sgabeblack@google.com# modification, are permitted provided that the following conditions are 812837Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 912837Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 1012837Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 1112837Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 1212837Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1312837Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1412837Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1512837Sgabeblack@google.com# this software without specific prior written permission. 1612837Sgabeblack@google.com# 1712837Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812837Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912837Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012837Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112837Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212837Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312837Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412837Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512837Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612837Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712837Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812837Sgabeblack@google.com# 2912837Sgabeblack@google.com# Authors: Steve Reinhardt 3012837Sgabeblack@google.com 3112837Sgabeblack@google.comImport('*') 3212837Sgabeblack@google.com 3313273Sgabeblack@google.com################################################################# 3412957Sgabeblack@google.com# 3512957Sgabeblack@google.com# Generate StaticInst execute() method signatures. 3613053Sgabeblack@google.com# 3712842Sgabeblack@google.com# There must be one signature for each CPU model compiled in. 3812837Sgabeblack@google.com# Since the set of compiled-in models is flexible, we generate a 3912837Sgabeblack@google.com# header containing the appropriate set of signatures on the fly. 4012957Sgabeblack@google.com# 4112957Sgabeblack@google.com################################################################# 4212957Sgabeblack@google.com 4313207Sgabeblack@google.com# CPU model-specific data is contained in cpu_models.py 4412957Sgabeblack@google.com# Convert to SCons File node to get path handling 4512957Sgabeblack@google.commodels_db = File('cpu_models.py') 4612957Sgabeblack@google.com# slurp in contents of file 4712837Sgabeblack@google.comexecfile(models_db.srcnode().abspath) 4812837Sgabeblack@google.com 4912837Sgabeblack@google.com# Template for execute() signature. 5012837Sgabeblack@google.comexec_sig_template = ''' 5113245Sgabeblack@google.comvirtual Fault execute(%s *xc, Trace::InstRecord *traceData) const = 0; 5213245Sgabeblack@google.comvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const 5313245Sgabeblack@google.com{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN }; 5413245Sgabeblack@google.comvirtual Fault completeAcc(Packet *pkt, %s *xc, 5513245Sgabeblack@google.com Trace::InstRecord *traceData) const 5613245Sgabeblack@google.com{ panic("completeAcc not defined!"); M5_DUMMY_RETURN }; 5713245Sgabeblack@google.com''' 5813245Sgabeblack@google.com 5913245Sgabeblack@google.commem_ini_sig_template = ''' 6013245Sgabeblack@google.comvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN }; 6113245Sgabeblack@google.com''' 6213245Sgabeblack@google.com 6313245Sgabeblack@google.commem_comp_sig_template = ''' 6413245Sgabeblack@google.comvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN }; 6513245Sgabeblack@google.com''' 6613245Sgabeblack@google.com 6712837Sgabeblack@google.com# Generate a temporary CPU list, including the CheckerCPU if 6812837Sgabeblack@google.com# it's enabled. This isn't used for anything else other than StaticInst 6912837Sgabeblack@google.com# headers. 7012837Sgabeblack@google.comtemp_cpu_list = env['CPU_MODELS'][:] 7112837Sgabeblack@google.com 7212837Sgabeblack@google.comif env['USE_CHECKER']: 7312837Sgabeblack@google.com temp_cpu_list.append('CheckerCPU') 7412837Sgabeblack@google.com 7512837Sgabeblack@google.com# Generate header. 7612837Sgabeblack@google.comdef gen_cpu_exec_signatures(target, source, env): 7712837Sgabeblack@google.com f = open(str(target[0]), 'w') 7812957Sgabeblack@google.com print >> f, ''' 7913207Sgabeblack@google.com#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__ 8012842Sgabeblack@google.com#define __CPU_STATIC_INST_EXEC_SIGS_HH__ 8112842Sgabeblack@google.com''' 8212938Sgabeblack@google.com for cpu in temp_cpu_list: 8312957Sgabeblack@google.com xc_type = CpuModel.dict[cpu].strings['CPU_exec_context'] 8412957Sgabeblack@google.com print >> f, exec_sig_template % (xc_type, xc_type, xc_type) 8512957Sgabeblack@google.com print >> f, ''' 8613202Sgabeblack@google.com#endif // __CPU_STATIC_INST_EXEC_SIGS_HH__ 8713202Sgabeblack@google.com''' 8812938Sgabeblack@google.com 8912938Sgabeblack@google.com# Generate string that gets printed when header is rebuilt 9012938Sgabeblack@google.comdef gen_sigs_string(target, source, env): 9112938Sgabeblack@google.com return "Generating static_inst_exec_sigs.hh: " \ 9212944Sgabeblack@google.com + ', '.join(temp_cpu_list) 9313091Sgabeblack@google.com 9413091Sgabeblack@google.com# Add command to generate header to environment. 9512944Sgabeblack@google.comenv.Command('static_inst_exec_sigs.hh', models_db, 9612944Sgabeblack@google.com Action(gen_cpu_exec_signatures, gen_sigs_string, 9712944Sgabeblack@google.com varlist = temp_cpu_list)) 9812957Sgabeblack@google.com 9913059Sgabeblack@google.comenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER'])) 10013059Sgabeblack@google.comenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS'])) 10113059Sgabeblack@google.com 10213059Sgabeblack@google.com# List of suppported CPUs by the Checker. Errors out if USE_CHECKER=True 10313059Sgabeblack@google.com# and one of these are not being used. 10413290Sgabeblack@google.comCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU'] 10513290Sgabeblack@google.com 10612957Sgabeblack@google.comSimObject('BaseCPU.py') 10713207Sgabeblack@google.comSimObject('FuncUnit.py') 10813053Sgabeblack@google.comSimObject('ExeTracer.py') 10913053Sgabeblack@google.comSimObject('IntelTrace.py') 11013053Sgabeblack@google.com 11113053Sgabeblack@google.comSource('activity.cc') 11212957Sgabeblack@google.comSource('base.cc') 11313207Sgabeblack@google.comSource('cpuevent.cc') 11413273Sgabeblack@google.comSource('exetrace.cc') 11512837Sgabeblack@google.comSource('func_unit.cc') 11612837Sgabeblack@google.comSource('inteltrace.cc') 11712837Sgabeblack@google.comSource('pc_event.cc') 11812837Sgabeblack@google.comSource('quiesce_event.cc') 11912837Sgabeblack@google.comSource('static_inst.cc') 12012837Sgabeblack@google.comSource('simple_thread.cc') 12113053Sgabeblack@google.comSource('thread_context.cc') 12213053Sgabeblack@google.comSource('thread_state.cc') 12312837Sgabeblack@google.com 12413053Sgabeblack@google.comif env['FULL_SYSTEM']: 12513053Sgabeblack@google.com SimObject('IntrControl.py') 12612837Sgabeblack@google.com 12713090Sgabeblack@google.com Source('intr_control.cc') 12813090Sgabeblack@google.com Source('profile.cc') 12913090Sgabeblack@google.com 13013290Sgabeblack@google.com if env['TARGET_ISA'] == 'sparc': 13113290Sgabeblack@google.com SimObject('LegionTrace.py') 13213290Sgabeblack@google.com Source('legiontrace.cc') 13313290Sgabeblack@google.com 13413090Sgabeblack@google.comif env['TARGET_ISA'] == 'x86': 13513090Sgabeblack@google.com SimObject('NativeTrace.py') 13613090Sgabeblack@google.com Source('nativetrace.cc') 13713090Sgabeblack@google.com 13813090Sgabeblack@google.comif env['USE_CHECKER']: 13913290Sgabeblack@google.com Source('checker/cpu.cc') 14013290Sgabeblack@google.com TraceFlag('Checker') 14113290Sgabeblack@google.com checker_supports = False 14213290Sgabeblack@google.com for i in CheckerSupportedCPUList: 14313090Sgabeblack@google.com if i in env['CPU_MODELS']: 14413090Sgabeblack@google.com checker_supports = True 14512837Sgabeblack@google.com if not checker_supports: 14613090Sgabeblack@google.com print "Checker only supports CPU models", 14713090Sgabeblack@google.com for i in CheckerSupportedCPUList: 14813090Sgabeblack@google.com print i, 14913290Sgabeblack@google.com print ", please set USE_CHECKER=False or use one of those CPU models" 15013290Sgabeblack@google.com Exit(1) 15113290Sgabeblack@google.comelse: 15213290Sgabeblack@google.com Dir('checker') 15313090Sgabeblack@google.com 15413090Sgabeblack@google.comTraceFlag('Activity') 15513090Sgabeblack@google.comTraceFlag('Commit') 15613090Sgabeblack@google.comTraceFlag('Context') 15713090Sgabeblack@google.comTraceFlag('Decode') 15813290Sgabeblack@google.comTraceFlag('DynInst') 15913290Sgabeblack@google.comTraceFlag('ExecEnable') 16013290Sgabeblack@google.comTraceFlag('ExecCPSeq') 16113290Sgabeblack@google.comTraceFlag('ExecEffAddr') 16213090Sgabeblack@google.comTraceFlag('ExecFetchSeq') 16313090Sgabeblack@google.comTraceFlag('ExecOpClass') 16412837Sgabeblack@google.comTraceFlag('ExecRegDelta') 16513090Sgabeblack@google.comTraceFlag('ExecResult') 16613090Sgabeblack@google.comTraceFlag('ExecSpeculative') 16713090Sgabeblack@google.comTraceFlag('ExecSymbol') 16813290Sgabeblack@google.comTraceFlag('ExecThread') 16913290Sgabeblack@google.comTraceFlag('ExecTicks') 17013090Sgabeblack@google.comTraceFlag('Fetch') 17113090Sgabeblack@google.comTraceFlag('IntrControl') 17213090Sgabeblack@google.comTraceFlag('PCEvent') 17313090Sgabeblack@google.comTraceFlag('Quiesce') 17413090Sgabeblack@google.com 17513290Sgabeblack@google.comCompoundFlag('Exec', [ 'ExecEnable', 'ExecTicks', 'ExecOpClass', 'ExecThread', 17613290Sgabeblack@google.com 'ExecEffAddr', 'ExecResult', 'ExecSymbol' ]) 17713090Sgabeblack@google.com