SConscript revision 3806
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.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
302155SN/A
314202Sbinkertn@umich.eduimport os.path, sys
322155SN/A
332178SN/A# Import build environment variable from SConstruct.
342178SN/AImport('env')
352178SN/A
362178SN/A# Right now there are no source files immediately in this directory
372178SN/Asources = []
382178SN/A
392178SN/A#################################################################
402178SN/A#
412178SN/A# ISA "switch header" generation.
422178SN/A#
432178SN/A# Auto-generate arch headers that include the right ISA-specific
442178SN/A# header based on the setting of THE_ISA preprocessor variable.
452155SN/A#
462178SN/A#################################################################
472155SN/A
482155SN/A# List of headers to generate
492178SN/Aisa_switch_hdrs = Split('''
502155SN/A	arguments.hh
512155SN/A	faults.hh
522623SN/A	interrupts.hh
533918Ssaidi@eecs.umich.edu	isa_traits.hh
542623SN/A	kernel_stats.hh
552623SN/A        locked_mem.hh
563918Ssaidi@eecs.umich.edu        mmaped_ipr.hh
572155SN/A	process.hh
582155SN/A	regfile.hh
592292SN/A	remote_gdb.hh
603918Ssaidi@eecs.umich.edu	stacktrace.hh
612292SN/A	syscallreturn.hh
622292SN/A	tlb.hh
632292SN/A	types.hh
643918Ssaidi@eecs.umich.edu	utility.hh
652292SN/A	vtophys.hh
662292SN/A        ''')
672766Sktlim@umich.edu
682766Sktlim@umich.edu# Set up this directory to support switching headers
692766Sktlim@umich.eduenv.make_switching_dir('arch', isa_switch_hdrs, env)
702921Sktlim@umich.edu
712921Sktlim@umich.edu#################################################################
722766Sktlim@umich.edu#
732766Sktlim@umich.edu# Include architecture-specific files.
745529Snate@binkert.org#
752766Sktlim@umich.edu#################################################################
764762Snate@binkert.org
772155SN/A#
782155SN/A# Build a SCons scanner for ISA files
792155SN/A#
802155SN/Aimport SCons.Scanner
812155SN/A
822155SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan",
832766Sktlim@umich.edu                                    [".isa", ".ISA"],
842155SN/A                                    "SRCDIR",
852623SN/A                                    r'^\s*##include\s+"([\w/.-]*)"')
862155SN/A
872155SN/Aenv.Append(SCANNERS = isa_scanner)
882155SN/A
892155SN/A#
902178SN/A# Now create a Builder object that uses isa_parser.py to generate C++
912178SN/A# output from the ISA description (*.isa) files.
922178SN/A#
932766Sktlim@umich.edu
942178SN/A# Convert to File node to fix path
952178SN/Aisa_parser = File('isa_parser.py')
962178SN/Acpu_models_file = File('../cpu/cpu_models.py')
972178SN/A
982766Sktlim@umich.edu# This sucks in the defintions of the CpuModel objects.
992766Sktlim@umich.eduexecfile(cpu_models_file.srcnode().abspath)
1002766Sktlim@umich.edu
1012788Sktlim@umich.edu# Several files are generated from the ISA description.
1022178SN/A# We always get the basic decoder and header file.
1032733Sktlim@umich.eduisa_desc_gen_files = Split('decoder.cc decoder.hh')
1042733Sktlim@umich.edu# We also get an execute file for each selected CPU model.
1052817Sksewell@umich.eduisa_desc_gen_files += [CpuModel.dict[cpu].filename
1062733Sktlim@umich.edu                       for cpu in env['CPU_MODELS']]
1074486Sbinkertn@umich.edu
1084486Sbinkertn@umich.edu# Also include the CheckerCPU as one of the models if it is being
1094776Sgblack@eecs.umich.edu# enabled via command line.
1104776Sgblack@eecs.umich.eduif env['USE_CHECKER']:
1114486Sbinkertn@umich.edu    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
1124202Sbinkertn@umich.edu
1134202Sbinkertn@umich.edu# The emitter patches up the sources & targets to include the
1144202Sbinkertn@umich.edu# autogenerated files as targets and isa parser itself as a source.
1154202Sbinkertn@umich.edudef isa_desc_emitter(target, source, env):
1164202Sbinkertn@umich.edu    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
1174776Sgblack@eecs.umich.edu
1184202Sbinkertn@umich.edu# Pieces are in place, so create the builder.
1194202Sbinkertn@umich.edupython = sys.executable  # use same Python binary used to run scons
1204202Sbinkertn@umich.edu
1214202Sbinkertn@umich.edu# Also include the CheckerCPU as one of the models if it is being
1225217Ssaidi@eecs.umich.edu# enabled via command line.
1234202Sbinkertn@umich.eduif env['USE_CHECKER']:
1242155SN/A    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
1254202Sbinkertn@umich.edu                               emitter = isa_desc_emitter)
1264486Sbinkertn@umich.eduelse:
1274486Sbinkertn@umich.edu    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
1284202Sbinkertn@umich.edu                               emitter = isa_desc_emitter)
1294202Sbinkertn@umich.edu
1302821Sktlim@umich.eduenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1314776Sgblack@eecs.umich.edu
1324776Sgblack@eecs.umich.edu#
1334776Sgblack@eecs.umich.edu# Now include other ISA-specific sources from the ISA subdirectories.
1344776Sgblack@eecs.umich.edu#
1354776Sgblack@eecs.umich.edu
1364776Sgblack@eecs.umich.eduisa = env['TARGET_ISA'] # someday this may be a list of ISAs
1374776Sgblack@eecs.umich.edu
1384776Sgblack@eecs.umich.edu# Let the target architecture define what additional sources it needs
1392766Sktlim@umich.edusources += SConscript(os.path.join(isa, 'SConscript'), exports = 'env')
1404202Sbinkertn@umich.edu
1415192Ssaidi@eecs.umich.eduReturn('sources')
1422733Sktlim@umich.edu