SConscript revision 4486
16019Shines@cs.fsu.edu# -*- mode:python -*-
27091Sgblack@eecs.umich.edu
37091Sgblack@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
47091Sgblack@eecs.umich.edu# All rights reserved.
57091Sgblack@eecs.umich.edu#
67091Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
77091Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
87091Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
97091Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
107091Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
117091Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
127091Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
137091Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
146019Shines@cs.fsu.edu# contributors may be used to endorse or promote products derived from
156019Shines@cs.fsu.edu# this software without specific prior written permission.
166019Shines@cs.fsu.edu#
176019Shines@cs.fsu.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186019Shines@cs.fsu.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196019Shines@cs.fsu.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206019Shines@cs.fsu.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216019Shines@cs.fsu.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226019Shines@cs.fsu.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236019Shines@cs.fsu.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246019Shines@cs.fsu.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256019Shines@cs.fsu.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266019Shines@cs.fsu.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276019Shines@cs.fsu.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286019Shines@cs.fsu.edu#
296019Shines@cs.fsu.edu# Authors: Steve Reinhardt
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.eduimport sys
326019Shines@cs.fsu.edu
336019Shines@cs.fsu.eduImport('*')
346019Shines@cs.fsu.edu
356019Shines@cs.fsu.edu#################################################################
366019Shines@cs.fsu.edu#
376019Shines@cs.fsu.edu# ISA "switch header" generation.
386019Shines@cs.fsu.edu#
396019Shines@cs.fsu.edu# Auto-generate arch headers that include the right ISA-specific
406019Shines@cs.fsu.edu# header based on the setting of THE_ISA preprocessor variable.
416019Shines@cs.fsu.edu#
426019Shines@cs.fsu.edu#################################################################
436019Shines@cs.fsu.edu
446019Shines@cs.fsu.edu# List of headers to generate
456019Shines@cs.fsu.eduisa_switch_hdrs = Split('''
466019Shines@cs.fsu.edu	arguments.hh
476019Shines@cs.fsu.edu	faults.hh
486019Shines@cs.fsu.edu	interrupts.hh
496019Shines@cs.fsu.edu	isa_traits.hh
506019Shines@cs.fsu.edu	kernel_stats.hh
516019Shines@cs.fsu.edu        locked_mem.hh
526019Shines@cs.fsu.edu        mmaped_ipr.hh
536019Shines@cs.fsu.edu	process.hh
546312Sgblack@eecs.umich.edu	predecoder.hh
556312Sgblack@eecs.umich.edu	regfile.hh
567147Sgblack@eecs.umich.edu	remote_gdb.hh
576312Sgblack@eecs.umich.edu	stacktrace.hh
586312Sgblack@eecs.umich.edu	syscallreturn.hh
596312Sgblack@eecs.umich.edu	tlb.hh
607093Sgblack@eecs.umich.edu	types.hh
616312Sgblack@eecs.umich.edu	utility.hh
626312Sgblack@eecs.umich.edu	vtophys.hh
637148Sgblack@eecs.umich.edu        ''')
647148Sgblack@eecs.umich.edu
657148Sgblack@eecs.umich.edu# Set up this directory to support switching headers
667148Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env)
677093Sgblack@eecs.umich.edu
687093Sgblack@eecs.umich.edu#################################################################
697093Sgblack@eecs.umich.edu#
707148Sgblack@eecs.umich.edu# Include architecture-specific files.
717151Sgblack@eecs.umich.edu#
726312Sgblack@eecs.umich.edu#################################################################
736312Sgblack@eecs.umich.edu
746019Shines@cs.fsu.edu#
757119Sgblack@eecs.umich.edu# Build a SCons scanner for ISA files
767119Sgblack@eecs.umich.edu#
777119Sgblack@eecs.umich.eduimport SCons.Scanner
787148Sgblack@eecs.umich.edu
797148Sgblack@eecs.umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan",
807148Sgblack@eecs.umich.edu                                    [".isa", ".ISA"],
817148Sgblack@eecs.umich.edu                                    "SRCDIR",
827119Sgblack@eecs.umich.edu                                    r'^\s*##include\s+"([\w/.-]*)"')
837119Sgblack@eecs.umich.edu
847119Sgblack@eecs.umich.eduenv.Append(SCANNERS = isa_scanner)
857119Sgblack@eecs.umich.edu
867137Sgblack@eecs.umich.edu#
877137Sgblack@eecs.umich.edu# Now create a Builder object that uses isa_parser.py to generate C++
887137Sgblack@eecs.umich.edu# output from the ISA description (*.isa) files.
897137Sgblack@eecs.umich.edu#
907137Sgblack@eecs.umich.edu
917137Sgblack@eecs.umich.edu# Convert to File node to fix path
927160Sgblack@eecs.umich.eduisa_parser = File('isa_parser.py')
937160Sgblack@eecs.umich.educpu_models_file = File('../cpu/cpu_models.py')
947160Sgblack@eecs.umich.edu
957160Sgblack@eecs.umich.edu# This sucks in the defintions of the CpuModel objects.
967160Sgblack@eecs.umich.eduexecfile(cpu_models_file.srcnode().abspath)
977160Sgblack@eecs.umich.edu
987160Sgblack@eecs.umich.edu# Several files are generated from the ISA description.
997160Sgblack@eecs.umich.edu# We always get the basic decoder and header file.
1006019Shines@cs.fsu.eduisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh' ]
1016312Sgblack@eecs.umich.edu# We also get an execute file for each selected CPU model.
1026312Sgblack@eecs.umich.eduisa_desc_gen_files += [CpuModel.dict[cpu].filename
1036312Sgblack@eecs.umich.edu                       for cpu in env['CPU_MODELS']]
1046312Sgblack@eecs.umich.edu
1056393Ssaidi@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being
1066741Sgblack@eecs.umich.edu# enabled via command line.
1076019Shines@cs.fsu.eduif env['USE_CHECKER']:
1086299Sgblack@eecs.umich.edu    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
1096312Sgblack@eecs.umich.edu
1106312Sgblack@eecs.umich.edu# The emitter patches up the sources & targets to include the
1116299Sgblack@eecs.umich.edu# autogenerated files as targets and isa parser itself as a source.
1126721Sgblack@eecs.umich.edudef isa_desc_emitter(target, source, env):
1137091Sgblack@eecs.umich.edu    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
1146019Shines@cs.fsu.edu
1156308Sgblack@eecs.umich.edu# Pieces are in place, so create the builder.
1166312Sgblack@eecs.umich.edupython = sys.executable  # use same Python binary used to run scons
1177173Sgblack@eecs.umich.edu
1186312Sgblack@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being
1196308Sgblack@eecs.umich.edu# enabled via command line.
1206019Shines@cs.fsu.eduif env['USE_CHECKER']:
1216299Sgblack@eecs.umich.edu    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
1226299Sgblack@eecs.umich.edu                               emitter = isa_desc_emitter)
1236299Sgblack@eecs.umich.eduelse:
1246019Shines@cs.fsu.edu    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
1256019Shines@cs.fsu.edu                               emitter = isa_desc_emitter)
1266299Sgblack@eecs.umich.edu
1276019Shines@cs.fsu.eduenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1287093Sgblack@eecs.umich.edu