SConscript revision 6657
12139SN/A# -*- mode:python -*-
22139SN/A
32139SN/A# Copyright (c) 2006 The Regents of The University of Michigan
42139SN/A# All rights reserved.
52139SN/A#
62139SN/A# Redistribution and use in source and binary forms, with or without
72139SN/A# modification, are permitted provided that the following conditions are
82139SN/A# met: redistributions of source code must retain the above copyright
92139SN/A# notice, this list of conditions and the following disclaimer;
102139SN/A# redistributions in binary form must reproduce the above copyright
112139SN/A# notice, this list of conditions and the following disclaimer in the
122139SN/A# documentation and/or other materials provided with the distribution;
132139SN/A# neither the name of the copyright holders nor the names of its
142139SN/A# contributors may be used to endorse or promote products derived from
152139SN/A# this software without specific prior written permission.
162139SN/A#
172139SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182139SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192139SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202139SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212139SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222139SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232139SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242139SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252139SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262139SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272139SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
302139SN/A
314202Sbinkertn@umich.eduImport('*')
322139SN/A
334202Sbinkertn@umich.edu#################################################################
342152SN/A#
352152SN/A# Generate StaticInst execute() method signatures.
362139SN/A#
372139SN/A# There must be one signature for each CPU model compiled in.
382139SN/A# Since the set of compiled-in models is flexible, we generate a
392139SN/A# header containing the appropriate set of signatures on the fly.
402139SN/A#
412152SN/A#################################################################
422152SN/A
432139SN/A# CPU model-specific data is contained in cpu_models.py
442139SN/A# Convert to SCons File node to get path handling
452139SN/Amodels_db = File('cpu_models.py')
464781Snate@binkert.org# slurp in contents of file
474781Snate@binkert.orgexecfile(models_db.srcnode().abspath)
484781Snate@binkert.org
496313Sgblack@eecs.umich.edu# Template for execute() signature.
504781Snate@binkert.orgexec_sig_template = '''
514781Snate@binkert.orgvirtual Fault execute(%(type)s *xc, Trace::InstRecord *traceData) const = 0;
523170Sstever@eecs.umich.eduvirtual Fault eaComp(%(type)s *xc, Trace::InstRecord *traceData) const
535664Sgblack@eecs.umich.edu{ panic("eaComp not defined!"); M5_DUMMY_RETURN };
543806Ssaidi@eecs.umich.eduvirtual Fault initiateAcc(%(type)s *xc, Trace::InstRecord *traceData) const
556179Sksewell@umich.edu{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN };
564781Snate@binkert.orgvirtual Fault completeAcc(Packet *pkt, %(type)s *xc,
574781Snate@binkert.org                          Trace::InstRecord *traceData) const
586329Sgblack@eecs.umich.edu{ panic("completeAcc not defined!"); M5_DUMMY_RETURN };
594781Snate@binkert.org'''
604781Snate@binkert.org
614781Snate@binkert.orgmem_ini_sig_template = '''
624781Snate@binkert.orgvirtual Fault eaComp(%(type)s *xc, Trace::InstRecord *traceData) const
634781Snate@binkert.org{ panic("eaComp not defined!"); M5_DUMMY_RETURN };
644781Snate@binkert.orgvirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN };
652139SN/A'''
662139SN/A
673546Sgblack@eecs.umich.edumem_comp_sig_template = '''
684202Sbinkertn@umich.eduvirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN };
692152SN/A'''
702152SN/A
712152SN/A# Generate a temporary CPU list, including the CheckerCPU if
722152SN/A# it's enabled.  This isn't used for anything else other than StaticInst
732152SN/A# headers.
742152SN/Atemp_cpu_list = env['CPU_MODELS'][:]
752152SN/A
762152SN/Aif env['USE_CHECKER']:
772152SN/A    temp_cpu_list.append('CheckerCPU')
782152SN/A    SimObject('CheckerCPU.py')
792152SN/A
802152SN/A# Generate header.
812504SN/Adef gen_cpu_exec_signatures(target, source, env):
822504SN/A    f = open(str(target[0]), 'w')
832504SN/A    print >> f, '''
842504SN/A#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
852152SN/A#define __CPU_STATIC_INST_EXEC_SIGS_HH__
862504SN/A'''
872152SN/A    for cpu in temp_cpu_list:
882152SN/A        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
892152SN/A        print >> f, exec_sig_template % { 'type' : xc_type }
902152SN/A    print >> f, '''
912152SN/A#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
922152SN/A'''
932152SN/A
942152SN/A# Generate string that gets printed when header is rebuilt
952632Sstever@eecs.umich.edudef gen_sigs_string(target, source, env):
962155SN/A    return "Generating static_inst_exec_sigs.hh: " \
972155SN/A           + ', '.join(temp_cpu_list)
982155SN/A
992155SN/A# Add command to generate header to environment.
1002155SN/Aenv.Command('static_inst_exec_sigs.hh', models_db,
1012155SN/A            Action(gen_cpu_exec_signatures, gen_sigs_string,
1025228Sgblack@eecs.umich.edu                   varlist = temp_cpu_list))
1032155SN/A
1042155SN/Aenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1052155SN/Aenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1062152SN/A
1072766Sktlim@umich.edu# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1082766Sktlim@umich.edu# and one of these are not being used.
1092766Sktlim@umich.eduCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
1102766Sktlim@umich.edu
1112766Sktlim@umich.eduSimObject('BaseCPU.py')
1122152SN/ASimObject('FuncUnit.py')
1132152SN/ASimObject('ExeTracer.py')
1142152SN/ASimObject('IntelTrace.py')
1152155SN/ASimObject('NativeTrace.py')
1162152SN/A
1172152SN/ASource('activity.cc')
1182718Sstever@eecs.umich.eduSource('base.cc')
1192921Sktlim@umich.eduSource('cpuevent.cc')
1202921Sktlim@umich.eduSource('exetrace.cc')
1212921Sktlim@umich.eduSource('func_unit.cc')
1222921Sktlim@umich.eduSource('inteltrace.cc')
1232921Sktlim@umich.eduSource('nativetrace.cc')
1242921Sktlim@umich.eduSource('pc_event.cc')
1252921Sktlim@umich.eduSource('quiesce_event.cc')
1262921Sktlim@umich.eduSource('static_inst.cc')
1272921Sktlim@umich.eduSource('simple_thread.cc')
1282152SN/ASource('thread_context.cc')
1292152SN/ASource('thread_state.cc')
1305944Sgblack@eecs.umich.edu
1315944Sgblack@eecs.umich.eduif env['FULL_SYSTEM']:
1325944Sgblack@eecs.umich.edu    SimObject('IntrControl.py')
1335944Sgblack@eecs.umich.edu
1345944Sgblack@eecs.umich.edu    Source('intr_control.cc')
135    Source('profile.cc')
136
137    if env['TARGET_ISA'] == 'sparc':
138        SimObject('LegionTrace.py')
139        Source('legiontrace.cc')
140
141if env['USE_CHECKER']:
142    Source('checker/cpu.cc')
143    TraceFlag('Checker')
144    checker_supports = False
145    for i in CheckerSupportedCPUList:
146        if i in env['CPU_MODELS']:
147            checker_supports = True
148    if not checker_supports:
149        print "Checker only supports CPU models",
150        for i in CheckerSupportedCPUList:
151            print i,
152        print ", please set USE_CHECKER=False or use one of those CPU models"
153        Exit(1)
154
155TraceFlag('Activity')
156TraceFlag('Commit')
157TraceFlag('Context')
158TraceFlag('Decode')
159TraceFlag('DynInst')
160TraceFlag('ExecEnable')
161TraceFlag('ExecCPSeq')
162TraceFlag('ExecEffAddr')
163TraceFlag('ExecFetchSeq')
164TraceFlag('ExecOpClass')
165TraceFlag('ExecRegDelta')
166TraceFlag('ExecResult')
167TraceFlag('ExecSpeculative')
168TraceFlag('ExecSymbol')
169TraceFlag('ExecThread')
170TraceFlag('ExecTicks')
171TraceFlag('ExecMicro')
172TraceFlag('ExecMacro')
173TraceFlag('Fetch')
174TraceFlag('IntrControl')
175TraceFlag('PCEvent')
176TraceFlag('Quiesce')
177
178CompoundFlag('Exec', [ 'ExecEnable', 'ExecTicks', 'ExecOpClass', 'ExecThread',
179    'ExecEffAddr', 'ExecResult', 'ExecSymbol', 'ExecMicro' ])
180CompoundFlag('ExecNoTicks', [ 'ExecEnable', 'ExecOpClass', 'ExecThread',
181    'ExecEffAddr', 'ExecResult', 'ExecMicro' ])
182