SConscript revision 4500
12929Sktlim@umich.edu# -*- mode:python -*-
22929Sktlim@umich.edu
32932Sktlim@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
42929Sktlim@umich.edu# All rights reserved.
52929Sktlim@umich.edu#
62929Sktlim@umich.edu# Redistribution and use in source and binary forms, with or without
72929Sktlim@umich.edu# modification, are permitted provided that the following conditions are
82929Sktlim@umich.edu# met: redistributions of source code must retain the above copyright
92929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer;
102929Sktlim@umich.edu# redistributions in binary form must reproduce the above copyright
112929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer in the
122929Sktlim@umich.edu# documentation and/or other materials provided with the distribution;
132929Sktlim@umich.edu# neither the name of the copyright holders nor the names of its
142929Sktlim@umich.edu# contributors may be used to endorse or promote products derived from
152929Sktlim@umich.edu# this software without specific prior written permission.
162929Sktlim@umich.edu#
172929Sktlim@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182929Sktlim@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192929Sktlim@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202929Sktlim@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212929Sktlim@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222929Sktlim@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232929Sktlim@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242929Sktlim@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252929Sktlim@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262929Sktlim@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272929Sktlim@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282932Sktlim@umich.edu#
292932Sktlim@umich.edu# Authors: Steve Reinhardt
302932Sktlim@umich.edu
312929Sktlim@umich.eduimport sys
326007Ssteve.reinhardt@amd.com
337735SAli.Saidi@ARM.comImport('*')
342929Sktlim@umich.edu
352929Sktlim@umich.edu#################################################################
362929Sktlim@umich.edu#
372929Sktlim@umich.edu# ISA "switch header" generation.
382929Sktlim@umich.edu#
392929Sktlim@umich.edu# Auto-generate arch headers that include the right ISA-specific
402929Sktlim@umich.edu# header based on the setting of THE_ISA preprocessor variable.
412929Sktlim@umich.edu#
422929Sktlim@umich.edu#################################################################
432929Sktlim@umich.edu
442929Sktlim@umich.edu# List of headers to generate
452929Sktlim@umich.eduisa_switch_hdrs = Split('''
462929Sktlim@umich.edu	arguments.hh
476007Ssteve.reinhardt@amd.com	faults.hh
486007Ssteve.reinhardt@amd.com	interrupts.hh
496007Ssteve.reinhardt@amd.com	isa_traits.hh
506007Ssteve.reinhardt@amd.com	kernel_stats.hh
516007Ssteve.reinhardt@amd.com        locked_mem.hh
526007Ssteve.reinhardt@amd.com        mmaped_ipr.hh
536007Ssteve.reinhardt@amd.com	process.hh
546007Ssteve.reinhardt@amd.com	predecoder.hh
556007Ssteve.reinhardt@amd.com	regfile.hh
566007Ssteve.reinhardt@amd.com	remote_gdb.hh
576007Ssteve.reinhardt@amd.com	stacktrace.hh
586007Ssteve.reinhardt@amd.com	syscallreturn.hh
596007Ssteve.reinhardt@amd.com	tlb.hh
606007Ssteve.reinhardt@amd.com	types.hh
616007Ssteve.reinhardt@amd.com	utility.hh
626007Ssteve.reinhardt@amd.com	vtophys.hh
636007Ssteve.reinhardt@amd.com        ''')
646007Ssteve.reinhardt@amd.com
656007Ssteve.reinhardt@amd.com# Set up this directory to support switching headers
666007Ssteve.reinhardt@amd.commake_switching_dir('arch', isa_switch_hdrs, env)
676007Ssteve.reinhardt@amd.com
686007Ssteve.reinhardt@amd.com#################################################################
696007Ssteve.reinhardt@amd.com#
706007Ssteve.reinhardt@amd.com# Include architecture-specific files.
716007Ssteve.reinhardt@amd.com#
726007Ssteve.reinhardt@amd.com#################################################################
736007Ssteve.reinhardt@amd.com
746007Ssteve.reinhardt@amd.com#
756007Ssteve.reinhardt@amd.com# Build a SCons scanner for ISA files
762929Sktlim@umich.edu#
772929Sktlim@umich.eduimport SCons.Scanner
782929Sktlim@umich.edu
796007Ssteve.reinhardt@amd.comisa_scanner = SCons.Scanner.Classic("ISAScan",
806007Ssteve.reinhardt@amd.com                                    [".isa", ".ISA"],
816007Ssteve.reinhardt@amd.com                                    "SRCDIR",
826007Ssteve.reinhardt@amd.com                                    r'^\s*##include\s+"([\w/.-]*)"')
836007Ssteve.reinhardt@amd.com
846007Ssteve.reinhardt@amd.comenv.Append(SCANNERS = isa_scanner)
852929Sktlim@umich.edu
862929Sktlim@umich.edu#
872929Sktlim@umich.edu# Now create a Builder object that uses isa_parser.py to generate C++
882929Sktlim@umich.edu# output from the ISA description (*.isa) files.
892929Sktlim@umich.edu#
906011Ssteve.reinhardt@amd.com
916007Ssteve.reinhardt@amd.com# Convert to File node to fix path
926007Ssteve.reinhardt@amd.comisa_parser = File('isa_parser.py')
936007Ssteve.reinhardt@amd.comcpu_models_file = File('../cpu/cpu_models.py')
946007Ssteve.reinhardt@amd.com
956007Ssteve.reinhardt@amd.com# This sucks in the defintions of the CpuModel objects.
966007Ssteve.reinhardt@amd.comexecfile(cpu_models_file.srcnode().abspath)
976007Ssteve.reinhardt@amd.com
986007Ssteve.reinhardt@amd.com# Several files are generated from the ISA description.
996007Ssteve.reinhardt@amd.com# We always get the basic decoder and header file.
1006007Ssteve.reinhardt@amd.comisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh' ]
1016007Ssteve.reinhardt@amd.com# We also get an execute file for each selected CPU model.
1026007Ssteve.reinhardt@amd.comisa_desc_gen_files += [CpuModel.dict[cpu].filename
1036007Ssteve.reinhardt@amd.com                       for cpu in env['CPU_MODELS']]
1046007Ssteve.reinhardt@amd.com
1057735SAli.Saidi@ARM.com# Also include the CheckerCPU as one of the models if it is being
1066011Ssteve.reinhardt@amd.com# enabled via command line.
1076007Ssteve.reinhardt@amd.comif env['USE_CHECKER']:
1086007Ssteve.reinhardt@amd.com    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
1096007Ssteve.reinhardt@amd.com
1106007Ssteve.reinhardt@amd.com# The emitter patches up the sources & targets to include the
1117735SAli.Saidi@ARM.com# autogenerated files as targets and isa parser itself as a source.
1127735SAli.Saidi@ARM.comdef isa_desc_emitter(target, source, env):
1137735SAli.Saidi@ARM.com    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
1147735SAli.Saidi@ARM.com
1157735SAli.Saidi@ARM.com# Pieces are in place, so create the builder.
1167735SAli.Saidi@ARM.compython = sys.executable  # use same Python binary used to run scons
1177735SAli.Saidi@ARM.com
1187735SAli.Saidi@ARM.com# Also include the CheckerCPU as one of the models if it is being
1197735SAli.Saidi@ARM.com# enabled via command line.
1207735SAli.Saidi@ARM.comif env['USE_CHECKER']:
1217735SAli.Saidi@ARM.com    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
1227735SAli.Saidi@ARM.com                               emitter = isa_desc_emitter)
1237735SAli.Saidi@ARM.comelse:
1247735SAli.Saidi@ARM.com    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
1256007Ssteve.reinhardt@amd.com                               emitter = isa_desc_emitter)
1267685Ssteve.reinhardt@amd.com
1276007Ssteve.reinhardt@amd.comenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1286011Ssteve.reinhardt@amd.com