SConscript revision 5517
15335Shines@cs.fsu.edu# -*- mode:python -*-
27897Shestness@cs.utexas.edu
34486Sbinkertn@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
44486Sbinkertn@umich.edu# All rights reserved.
54486Sbinkertn@umich.edu#
64486Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74486Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84486Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104486Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124486Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134486Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144486Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154486Sbinkertn@umich.edu# this software without specific prior written permission.
164486Sbinkertn@umich.edu#
174486Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184486Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194486Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204486Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214486Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224486Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234486Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244486Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254486Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264486Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274486Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284486Sbinkertn@umich.edu#
297897Shestness@cs.utexas.edu# Authors: Steve Reinhardt
304486Sbinkertn@umich.edu
316654Snate@binkert.orgimport sys
326654Snate@binkert.org
336654Snate@binkert.orgImport('*')
343102SN/A
353102SN/A#################################################################
366654Snate@binkert.org#
372998SN/A# ISA "switch header" generation.
384776Sgblack@eecs.umich.edu#
394776Sgblack@eecs.umich.edu# Auto-generate arch headers that include the right ISA-specific
406654Snate@binkert.org# header based on the setting of THE_ISA preprocessor variable.
412667SN/A#
424776Sgblack@eecs.umich.edu#################################################################
434776Sgblack@eecs.umich.edu
446654Snate@binkert.org# List of headers to generate
456023Snate@binkert.orgisa_switch_hdrs = Split('''
468745Sgblack@eecs.umich.edu        arguments.hh
476654Snate@binkert.org        faults.hh
486022Sgblack@eecs.umich.edu        interrupts.hh
498745Sgblack@eecs.umich.edu        isa_traits.hh
506654Snate@binkert.org        kernel_stats.hh
516022Sgblack@eecs.umich.edu        locked_mem.hh
528745Sgblack@eecs.umich.edu        mmaped_ipr.hh
536654Snate@binkert.org        process.hh
546022Sgblack@eecs.umich.edu        predecoder.hh
558745Sgblack@eecs.umich.edu        regfile.hh
566654Snate@binkert.org        remote_gdb.hh
576116Snate@binkert.org        stacktrace.hh
588745Sgblack@eecs.umich.edu        syscallreturn.hh
596691Stjones1@inf.ed.ac.uk        tlb.hh
606691Stjones1@inf.ed.ac.uk        types.hh
618745Sgblack@eecs.umich.edu        utility.hh
624486Sbinkertn@umich.edu        vtophys.hh
635529Snate@binkert.org        ''')
641366SN/A
651310SN/A# Set up this directory to support switching headers
661310SN/Amake_switching_dir('arch', isa_switch_hdrs, env)
672901SN/A
685712Shsul@eecs.umich.edu#################################################################
695529Snate@binkert.org#
705529Snate@binkert.org# Include architecture-specific files.
715529Snate@binkert.org#
725529Snate@binkert.org#################################################################
735529Snate@binkert.org
745821Ssaidi@eecs.umich.edu#
753170SN/A# Build a SCons scanner for ISA files
765780Ssteve.reinhardt@amd.com#
775780Ssteve.reinhardt@amd.comimport SCons.Scanner
785780Ssteve.reinhardt@amd.com
795780Ssteve.reinhardt@amd.comisa_scanner = SCons.Scanner.Classic("ISAScan",
805780Ssteve.reinhardt@amd.com                                    [".isa", ".ISA"],
818784Sgblack@eecs.umich.edu                                    "SRCDIR",
828784Sgblack@eecs.umich.edu                                    r'^\s*##include\s+"([\w/.-]*)"')
838784Sgblack@eecs.umich.edu
848793Sgblack@eecs.umich.eduenv.Append(SCANNERS = isa_scanner)
851310SN/A
866654Snate@binkert.org#
876022Sgblack@eecs.umich.edu# Now create a Builder object that uses isa_parser.py to generate C++
886022Sgblack@eecs.umich.edu# output from the ISA description (*.isa) files.
898745Sgblack@eecs.umich.edu#
905647Sgblack@eecs.umich.edu
916654Snate@binkert.org# Convert to File node to fix path
926023Snate@binkert.orgisa_parser = File('isa_parser.py')
936023Snate@binkert.orgcpu_models_file = File('../cpu/cpu_models.py')
948745Sgblack@eecs.umich.edu
955647Sgblack@eecs.umich.edu# This sucks in the defintions of the CpuModel objects.
966654Snate@binkert.orgexecfile(cpu_models_file.srcnode().abspath)
976022Sgblack@eecs.umich.edu
986022Sgblack@eecs.umich.edu# Several files are generated from the ISA description.
998745Sgblack@eecs.umich.edu# We always get the basic decoder and header file.
1008745Sgblack@eecs.umich.eduisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
1016654Snate@binkert.org# We also get an execute file for each selected CPU model.
1026022Sgblack@eecs.umich.eduisa_desc_gen_files += [CpuModel.dict[cpu].filename
1036022Sgblack@eecs.umich.edu                       for cpu in env['CPU_MODELS']]
1048745Sgblack@eecs.umich.edu
1058745Sgblack@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being
1066654Snate@binkert.org# enabled via command line.
1076116Snate@binkert.orgif env['USE_CHECKER']:
1086116Snate@binkert.org    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
1098745Sgblack@eecs.umich.edu
1108745Sgblack@eecs.umich.edu# The emitter patches up the sources & targets to include the
1116691Stjones1@inf.ed.ac.uk# autogenerated files as targets and isa parser itself as a source.
1126691Stjones1@inf.ed.ac.ukdef isa_desc_emitter(target, source, env):
1136691Stjones1@inf.ed.ac.uk    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
1146691Stjones1@inf.ed.ac.uk
1158745Sgblack@eecs.umich.edu# Pieces are in place, so create the builder.
1168745Sgblack@eecs.umich.edupython = sys.executable  # use same Python binary used to run scons
1174997Sgblack@eecs.umich.edu
1184997Sgblack@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being
1196654Snate@binkert.org# enabled via command line.
1204997Sgblack@eecs.umich.eduif env['USE_CHECKER']:
1214997Sgblack@eecs.umich.edu    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
1221310SN/A                               emitter = isa_desc_emitter)
1231310SN/Aelse:
1241310SN/A    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
1251310SN/A                               emitter = isa_desc_emitter)
1261310SN/A
1271310SN/Aenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1281310SN/A