SConscript revision 6365:a3037fa327a0
12SN/A# -*- mode:python -*-
21762SN/A
32SN/A# Copyright (c) 2006 The Regents of The University of Michigan
42SN/A# All rights reserved.
52SN/A#
62SN/A# Redistribution and use in source and binary forms, with or without
72SN/A# modification, are permitted provided that the following conditions are
82SN/A# met: redistributions of source code must retain the above copyright
92SN/A# notice, this list of conditions and the following disclaimer;
102SN/A# redistributions in binary form must reproduce the above copyright
112SN/A# notice, this list of conditions and the following disclaimer in the
122SN/A# documentation and/or other materials provided with the distribution;
132SN/A# neither the name of the copyright holders nor the names of its
142SN/A# contributors may be used to endorse or promote products derived from
152SN/A# this software without specific prior written permission.
162SN/A#
172SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272665Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284123Sbinkertn@umich.edu#
292SN/A# Authors: Steve Reinhardt
302SN/A
314123Sbinkertn@umich.eduImport('*')
324128Sbinkertn@umich.edu
332655Sstever@eecs.umich.edu#################################################################
344123Sbinkertn@umich.edu#
354123Sbinkertn@umich.edu# Generate StaticInst execute() method signatures.
362SN/A#
374123Sbinkertn@umich.edu# There must be one signature for each CPU model compiled in.
38146SN/A# Since the set of compiled-in models is flexible, we generate a
393356Sbinkertn@umich.edu# header containing the appropriate set of signatures on the fly.
403868Sbinkertn@umich.edu#
41146SN/A#################################################################
42146SN/A
431696SN/A# CPU model-specific data is contained in cpu_models.py
442SN/A# Convert to SCons File node to get path handling
452SN/Amodels_db = File('cpu_models.py')
462SN/A# slurp in contents of file
472SN/Aexecfile(models_db.srcnode().abspath)
482SN/A
492SN/A# Template for execute() signature.
502SN/Aexec_sig_template = '''
512SN/Avirtual Fault execute(%(type)s *xc, Trace::InstRecord *traceData) const = 0;
524123Sbinkertn@umich.eduvirtual Fault eaComp(%(type)s *xc, Trace::InstRecord *traceData) const
532SN/A{ panic("eaComp not defined!"); M5_DUMMY_RETURN };
542SN/Avirtual Fault initiateAcc(%(type)s *xc, Trace::InstRecord *traceData) const
55329SN/A{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN };
56329SN/Avirtual Fault completeAcc(Packet *pkt, %(type)s *xc,
57329SN/A                          Trace::InstRecord *traceData) const
58329SN/A{ panic("completeAcc not defined!"); M5_DUMMY_RETURN };
594123Sbinkertn@umich.edu'''
604123Sbinkertn@umich.edu
61329SN/Amem_ini_sig_template = '''
62329SN/Avirtual Fault eaComp(%(type)s *xc, Trace::InstRecord *traceData) const
632SN/A{ panic("eaComp not defined!"); M5_DUMMY_RETURN };
642SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN };
652SN/A'''
662SN/A
672SN/Amem_comp_sig_template = '''
682SN/Avirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN };
692SN/A'''
702SN/A
71764SN/A# Generate a temporary CPU list, including the CheckerCPU if
72764SN/A# it's enabled.  This isn't used for anything else other than StaticInst
73764SN/A# headers.
74764SN/Atemp_cpu_list = env['CPU_MODELS'][:]
754123Sbinkertn@umich.edu
76764SN/Aif env['USE_CHECKER']:
77764SN/A    temp_cpu_list.append('CheckerCPU')
782SN/A    SimObject('CheckerCPU.py')
792SN/A
802SN/A# Generate header.
812SN/Adef gen_cpu_exec_signatures(target, source, env):
822SN/A    f = open(str(target[0]), 'w')
83329SN/A    print >> f, '''
84329SN/A#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
85329SN/A#define __CPU_STATIC_INST_EXEC_SIGS_HH__
86764SN/A'''
872SN/A    for cpu in temp_cpu_list:
882655Sstever@eecs.umich.edu        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
892667Sstever@eecs.umich.edu        print >> f, exec_sig_template % { 'type' : xc_type }
902667Sstever@eecs.umich.edu    print >> f, '''
912889Sbinkertn@umich.edu#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
922889Sbinkertn@umich.edu'''
932889Sbinkertn@umich.edu
942889Sbinkertn@umich.edu# Generate string that gets printed when header is rebuilt
952667Sstever@eecs.umich.edudef gen_sigs_string(target, source, env):
962667Sstever@eecs.umich.edu    return "Generating static_inst_exec_sigs.hh: " \
972667Sstever@eecs.umich.edu           + ', '.join(temp_cpu_list)
982889Sbinkertn@umich.edu
992889Sbinkertn@umich.edu# Add command to generate header to environment.
1002667Sstever@eecs.umich.eduenv.Command('static_inst_exec_sigs.hh', models_db,
1012667Sstever@eecs.umich.edu            Action(gen_cpu_exec_signatures, gen_sigs_string,
1022889Sbinkertn@umich.edu                   varlist = temp_cpu_list))
1032667Sstever@eecs.umich.edu
1042667Sstever@eecs.umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1053356Sbinkertn@umich.eduenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1063356Sbinkertn@umich.edu
1073356Sbinkertn@umich.edu# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1083356Sbinkertn@umich.edu# and one of these are not being used.
1093356Sbinkertn@umich.eduCheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
1102667Sstever@eecs.umich.edu
1112655Sstever@eecs.umich.eduSimObject('BaseCPU.py')
1122655Sstever@eecs.umich.eduSimObject('FuncUnit.py')
1131311SN/ASimObject('ExeTracer.py')
1143645Sbinkertn@umich.eduSimObject('IntelTrace.py')
1153868Sbinkertn@umich.eduSimObject('NativeTrace.py')
1161703SN/A
1173102Sstever@eecs.umich.eduSource('activity.cc')
1183102Sstever@eecs.umich.eduSource('base.cc')
1192667Sstever@eecs.umich.eduSource('cpuevent.cc')
1202667Sstever@eecs.umich.eduSource('exetrace.cc')
1212655Sstever@eecs.umich.eduSource('func_unit.cc')
1222667Sstever@eecs.umich.eduSource('inteltrace.cc')
123Source('nativetrace.cc')
124Source('pc_event.cc')
125Source('quiesce_event.cc')
126Source('static_inst.cc')
127Source('simple_thread.cc')
128Source('thread_context.cc')
129Source('thread_state.cc')
130
131if env['FULL_SYSTEM']:
132    SimObject('IntrControl.py')
133
134    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