SConscript revision 8614
12155SN/A# -*- mode:python -*-
22155SN/A
32155SN/A# Copyright (c) 2006 The Regents of The University of Michigan
42155SN/A# All rights reserved.
52155SN/A#
62155SN/A# Redistribution and use in source and binary forms, with or without
72155SN/A# modification, are permitted provided that the following conditions are
82155SN/A# met: redistributions of source code must retain the above copyright
92155SN/A# notice, this list of conditions and the following disclaimer;
102155SN/A# redistributions in binary form must reproduce the above copyright
112155SN/A# notice, this list of conditions and the following disclaimer in the
122155SN/A# documentation and/or other materials provided with the distribution;
132155SN/A# neither the name of the copyright holders nor the names of its
142155SN/A# contributors may be used to endorse or promote products derived from
152155SN/A# this software without specific prior written permission.
162155SN/A#
172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282155SN/A#
292155SN/A# Authors: Steve Reinhardt
302155SN/A
312155SN/AImport('*')
322155SN/A
332155SN/Aif env['TARGET_ISA'] == 'no':
342155SN/A    Return()
352178SN/A
362178SN/A#################################################################
372178SN/A#
382178SN/A# Generate StaticInst execute() method signatures.
392178SN/A#
402178SN/A# There must be one signature for each CPU model compiled in.
412178SN/A# Since the set of compiled-in models is flexible, we generate a
422178SN/A# header containing the appropriate set of signatures on the fly.
432178SN/A#
442178SN/A#################################################################
452178SN/A
462178SN/A# Template for execute() signature.
472155SN/Aexec_sig_template = '''
482178SN/Avirtual Fault execute(%(type)s *xc, Trace::InstRecord *traceData) const = 0;
492155SN/Avirtual Fault eaComp(%(type)s *xc, Trace::InstRecord *traceData) const
502155SN/A{ panic("eaComp not defined!"); M5_DUMMY_RETURN };
512178SN/Avirtual Fault initiateAcc(%(type)s *xc, Trace::InstRecord *traceData) const
522155SN/A{ panic("initiateAcc not defined!"); M5_DUMMY_RETURN };
532155SN/Avirtual Fault completeAcc(Packet *pkt, %(type)s *xc,
542623SN/A                          Trace::InstRecord *traceData) const
552623SN/A{ panic("completeAcc not defined!"); M5_DUMMY_RETURN };
562623SN/A'''
572623SN/A
582623SN/Amem_ini_sig_template = '''
592155SN/Avirtual Fault eaComp(%(type)s *xc, Trace::InstRecord *traceData) const
602155SN/A{ panic("eaComp not defined!"); M5_DUMMY_RETURN };
612178SN/Avirtual Fault initiateAcc(%s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); M5_DUMMY_RETURN };
622155SN/A'''
632155SN/A
642155SN/Amem_comp_sig_template = '''
652155SN/Avirtual Fault completeAcc(uint8_t *data, %s *xc, Trace::InstRecord *traceData) const { panic("Not defined!"); return NoFault; M5_DUMMY_RETURN };
662155SN/A'''
672155SN/A
682155SN/A# Generate a temporary CPU list, including the CheckerCPU if
692155SN/A# it's enabled.  This isn't used for anything else other than StaticInst
702623SN/A# headers.
712155SN/Atemp_cpu_list = env['CPU_MODELS'][:]
722155SN/A
732155SN/Aif env['USE_CHECKER']:
742155SN/A    temp_cpu_list.append('CheckerCPU')
752178SN/A    SimObject('CheckerCPU.py')
762178SN/A
772178SN/A# Generate header.
782178SN/Adef gen_cpu_exec_signatures(target, source, env):
792178SN/A    f = open(str(target[0]), 'w')
802178SN/A    print >> f, '''
812178SN/A#ifndef __CPU_STATIC_INST_EXEC_SIGS_HH__
822178SN/A#define __CPU_STATIC_INST_EXEC_SIGS_HH__
832178SN/A'''
842178SN/A    for cpu in temp_cpu_list:
852178SN/A        xc_type = CpuModel.dict[cpu].strings['CPU_exec_context']
862178SN/A        print >> f, exec_sig_template % { 'type' : xc_type }
872178SN/A    print >> f, '''
882178SN/A#endif  // __CPU_STATIC_INST_EXEC_SIGS_HH__
892178SN/A'''
902178SN/A
912155SN/A# Generate string that gets printed when header is rebuilt
922155SN/Adef gen_sigs_string(target, source, env):
932155SN/A    return " [GENERATE] static_inst_exec_sigs.hh: " \
942623SN/A           + ', '.join(temp_cpu_list)
952623SN/A
962623SN/A# Add command to generate header to environment.
972623SN/Aenv.Command('static_inst_exec_sigs.hh', (),
982623SN/A            Action(gen_cpu_exec_signatures, gen_sigs_string,
992623SN/A                   varlist = temp_cpu_list))
1002623SN/A
1012623SN/Aenv.Depends('static_inst_exec_sigs.hh', Value(env['USE_CHECKER']))
1022623SN/Aenv.Depends('static_inst_exec_sigs.hh', Value(env['CPU_MODELS']))
1032623SN/A
1042623SN/A# List of suppported CPUs by the Checker.  Errors out if USE_CHECKER=True
1052155SN/A# and one of these are not being used.
1062155SN/ACheckerSupportedCPUList = ['O3CPU', 'OzoneCPU']
1072155SN/A
1082155SN/ASimObject('BaseCPU.py')
1092155SN/ASimObject('FuncUnit.py')
1102155SN/ASimObject('ExeTracer.py')
1112155SN/ASimObject('IntelTrace.py')
1122155SN/ASimObject('NativeTrace.py')
1132155SN/A
1142155SN/ASource('activity.cc')
1152155SN/ASource('base.cc')
1162155SN/ASource('cpuevent.cc')
1172155SN/ASource('decode.cc')
1182155SN/ASource('exetrace.cc')
1192155SN/ASource('func_unit.cc')
1202155SN/ASource('inteltrace.cc')
1212155SN/ASource('nativetrace.cc')
1222155SN/ASource('pc_event.cc')
1232155SN/ASource('quiesce_event.cc')
1242155SN/ASource('static_inst.cc')
1252155SN/ASource('simple_thread.cc')
1262155SN/ASource('thread_context.cc')
1272155SN/ASource('thread_state.cc')
1282155SN/A
1292155SN/Aif env['FULL_SYSTEM']:
1302155SN/A    SimObject('IntrControl.py')
1312155SN/A
1322155SN/A    Source('intr_control.cc')
1332155SN/A    Source('profile.cc')
1342155SN/A
1352155SN/A    if env['TARGET_ISA'] == 'sparc':
1362155SN/A        SimObject('LegionTrace.py')
1372155SN/A        Source('legiontrace.cc')
1382155SN/A
1392155SN/Aif env['USE_CHECKER']:
1402155SN/A    Source('checker/cpu.cc')
1412155SN/A    DebugFlag('Checker')
1422155SN/A    checker_supports = False
1432155SN/A    for i in CheckerSupportedCPUList:
144        if i in env['CPU_MODELS']:
145            checker_supports = True
146    if not checker_supports:
147        print "Checker only supports CPU models",
148        for i in CheckerSupportedCPUList:
149            print i,
150        print ", please set USE_CHECKER=False or use one of those CPU models"
151        Exit(1)
152
153DebugFlag('Activity')
154DebugFlag('Commit')
155DebugFlag('Context')
156DebugFlag('Decode')
157DebugFlag('DynInst')
158DebugFlag('ExecEnable')
159DebugFlag('ExecCPSeq')
160DebugFlag('ExecEffAddr')
161DebugFlag('ExecFaulting', 'Trace faulting instructions')
162DebugFlag('ExecFetchSeq')
163DebugFlag('ExecOpClass')
164DebugFlag('ExecRegDelta')
165DebugFlag('ExecResult')
166DebugFlag('ExecSpeculative')
167DebugFlag('ExecSymbol')
168DebugFlag('ExecThread')
169DebugFlag('ExecTicks')
170DebugFlag('ExecMicro')
171DebugFlag('ExecMacro')
172DebugFlag('ExecUser')
173DebugFlag('ExecKernel')
174DebugFlag('ExecAsid')
175DebugFlag('Fetch')
176DebugFlag('IntrControl')
177DebugFlag('O3PipeView')
178DebugFlag('PCEvent')
179DebugFlag('Quiesce')
180
181CompoundFlag('ExecAll', [ 'ExecEnable', 'ExecCPSeq', 'ExecEffAddr',
182    'ExecFaulting', 'ExecFetchSeq', 'ExecOpClass', 'ExecRegDelta',
183    'ExecResult', 'ExecSpeculative', 'ExecSymbol', 'ExecThread',
184    'ExecTicks', 'ExecMicro', 'ExecMacro', 'ExecUser', 'ExecKernel',
185    'ExecAsid' ])
186CompoundFlag('Exec', [ 'ExecEnable', 'ExecTicks', 'ExecOpClass', 'ExecThread',
187    'ExecEffAddr', 'ExecResult', 'ExecSymbol', 'ExecMicro', 'ExecFaulting',
188    'ExecUser', 'ExecKernel' ])
189CompoundFlag('ExecNoTicks', [ 'ExecEnable', 'ExecOpClass', 'ExecThread',
190    'ExecEffAddr', 'ExecResult', 'ExecMicro', 'ExecFaulting',
191    'ExecUser', 'ExecKernel' ])
192