SConscript revision 5933
112027Sjungma@eit.uni-kl.de# -*- mode:python -*-
212027Sjungma@eit.uni-kl.de
312027Sjungma@eit.uni-kl.de# Copyright (c) 2006 The Regents of The University of Michigan
412027Sjungma@eit.uni-kl.de# All rights reserved.
512027Sjungma@eit.uni-kl.de#
612027Sjungma@eit.uni-kl.de# Redistribution and use in source and binary forms, with or without
712027Sjungma@eit.uni-kl.de# modification, are permitted provided that the following conditions are
812027Sjungma@eit.uni-kl.de# met: redistributions of source code must retain the above copyright
912027Sjungma@eit.uni-kl.de# notice, this list of conditions and the following disclaimer;
1012027Sjungma@eit.uni-kl.de# redistributions in binary form must reproduce the above copyright
1112027Sjungma@eit.uni-kl.de# notice, this list of conditions and the following disclaimer in the
1212027Sjungma@eit.uni-kl.de# documentation and/or other materials provided with the distribution;
1312027Sjungma@eit.uni-kl.de# neither the name of the copyright holders nor the names of its
1412027Sjungma@eit.uni-kl.de# contributors may be used to endorse or promote products derived from
1512027Sjungma@eit.uni-kl.de# this software without specific prior written permission.
1612027Sjungma@eit.uni-kl.de#
1712027Sjungma@eit.uni-kl.de# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1812027Sjungma@eit.uni-kl.de# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1912027Sjungma@eit.uni-kl.de# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2012027Sjungma@eit.uni-kl.de# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2112027Sjungma@eit.uni-kl.de# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2212027Sjungma@eit.uni-kl.de# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2312027Sjungma@eit.uni-kl.de# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2412027Sjungma@eit.uni-kl.de# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2512027Sjungma@eit.uni-kl.de# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2612027Sjungma@eit.uni-kl.de# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2712027Sjungma@eit.uni-kl.de# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2812027Sjungma@eit.uni-kl.de#
2912027Sjungma@eit.uni-kl.de# Authors: Steve Reinhardt
3012027Sjungma@eit.uni-kl.de
3112027Sjungma@eit.uni-kl.deimport sys
3212027Sjungma@eit.uni-kl.de
3312027Sjungma@eit.uni-kl.deImport('*')
3412027Sjungma@eit.uni-kl.de
3512027Sjungma@eit.uni-kl.de#################################################################
3612027Sjungma@eit.uni-kl.de#
3712027Sjungma@eit.uni-kl.de# ISA "switch header" generation.
3812027Sjungma@eit.uni-kl.de#
3912027Sjungma@eit.uni-kl.de# Auto-generate arch headers that include the right ISA-specific
4012027Sjungma@eit.uni-kl.de# header based on the setting of THE_ISA preprocessor variable.
4112027Sjungma@eit.uni-kl.de#
4212027Sjungma@eit.uni-kl.de#################################################################
4312027Sjungma@eit.uni-kl.de
4412027Sjungma@eit.uni-kl.de# List of headers to generate
4512027Sjungma@eit.uni-kl.deisa_switch_hdrs = Split('''
4612027Sjungma@eit.uni-kl.de        arguments.hh
4712027Sjungma@eit.uni-kl.de        faults.hh
4812027Sjungma@eit.uni-kl.de        interrupts.hh
4912027Sjungma@eit.uni-kl.de        isa_traits.hh
5012027Sjungma@eit.uni-kl.de        kernel_stats.hh
5112027Sjungma@eit.uni-kl.de        locked_mem.hh
5212027Sjungma@eit.uni-kl.de        microcode_rom.hh
5312027Sjungma@eit.uni-kl.de        mmaped_ipr.hh
5412027Sjungma@eit.uni-kl.de        process.hh
5512027Sjungma@eit.uni-kl.de        predecoder.hh
5612027Sjungma@eit.uni-kl.de        regfile.hh
5712027Sjungma@eit.uni-kl.de        remote_gdb.hh
5812027Sjungma@eit.uni-kl.de        stacktrace.hh
5912027Sjungma@eit.uni-kl.de        syscallreturn.hh
6012027Sjungma@eit.uni-kl.de        tlb.hh
6112027Sjungma@eit.uni-kl.de        types.hh
6212027Sjungma@eit.uni-kl.de        utility.hh
6312027Sjungma@eit.uni-kl.de        vtophys.hh
6412027Sjungma@eit.uni-kl.de        ''')
6512027Sjungma@eit.uni-kl.de
6612027Sjungma@eit.uni-kl.de# Set up this directory to support switching headers
6712027Sjungma@eit.uni-kl.demake_switching_dir('arch', isa_switch_hdrs, env)
6812027Sjungma@eit.uni-kl.de
6912027Sjungma@eit.uni-kl.de#################################################################
7012027Sjungma@eit.uni-kl.de#
7112027Sjungma@eit.uni-kl.de# Include architecture-specific files.
7212027Sjungma@eit.uni-kl.de#
7312027Sjungma@eit.uni-kl.de#################################################################
7412027Sjungma@eit.uni-kl.de
7512027Sjungma@eit.uni-kl.de#
7612027Sjungma@eit.uni-kl.de# Build a SCons scanner for ISA files
7712027Sjungma@eit.uni-kl.de#
7812027Sjungma@eit.uni-kl.deimport SCons.Scanner
7912027Sjungma@eit.uni-kl.de
8012027Sjungma@eit.uni-kl.deisa_scanner = SCons.Scanner.Classic("ISAScan",
8112027Sjungma@eit.uni-kl.de                                    [".isa", ".ISA"],
8212027Sjungma@eit.uni-kl.de                                    "SRCDIR",
8312027Sjungma@eit.uni-kl.de                                    r'^\s*##include\s+"([\w/.-]*)"')
8412027Sjungma@eit.uni-kl.de
8512027Sjungma@eit.uni-kl.deenv.Append(SCANNERS = isa_scanner)
8612027Sjungma@eit.uni-kl.de
8712027Sjungma@eit.uni-kl.de#
8812027Sjungma@eit.uni-kl.de# Now create a Builder object that uses isa_parser.py to generate C++
8912027Sjungma@eit.uni-kl.de# output from the ISA description (*.isa) files.
9012027Sjungma@eit.uni-kl.de#
9112027Sjungma@eit.uni-kl.de
9212027Sjungma@eit.uni-kl.de# Convert to File node to fix path
9312027Sjungma@eit.uni-kl.deisa_parser = File('isa_parser.py')
9412027Sjungma@eit.uni-kl.decpu_models_file = File('../cpu/cpu_models.py')
9512027Sjungma@eit.uni-kl.de
9612027Sjungma@eit.uni-kl.de# This sucks in the defintions of the CpuModel objects.
9712027Sjungma@eit.uni-kl.deexecfile(cpu_models_file.srcnode().abspath)
9812027Sjungma@eit.uni-kl.de
9912027Sjungma@eit.uni-kl.de# Several files are generated from the ISA description.
10012027Sjungma@eit.uni-kl.de# We always get the basic decoder and header file.
10112027Sjungma@eit.uni-kl.deisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
10212027Sjungma@eit.uni-kl.de# We also get an execute file for each selected CPU model.
10312027Sjungma@eit.uni-kl.deisa_desc_gen_files += [CpuModel.dict[cpu].filename
10412027Sjungma@eit.uni-kl.de                       for cpu in env['CPU_MODELS']]
10512027Sjungma@eit.uni-kl.de
10612027Sjungma@eit.uni-kl.de# Also include the CheckerCPU as one of the models if it is being
10712027Sjungma@eit.uni-kl.de# enabled via command line.
10812027Sjungma@eit.uni-kl.deif env['USE_CHECKER']:
10912027Sjungma@eit.uni-kl.de    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
11012027Sjungma@eit.uni-kl.de
11112027Sjungma@eit.uni-kl.de# The emitter patches up the sources & targets to include the
11212027Sjungma@eit.uni-kl.de# autogenerated files as targets and isa parser itself as a source.
11312027Sjungma@eit.uni-kl.dedef isa_desc_emitter(target, source, env):
11412027Sjungma@eit.uni-kl.de    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
11512027Sjungma@eit.uni-kl.de
11612027Sjungma@eit.uni-kl.de# Pieces are in place, so create the builder.
11712027Sjungma@eit.uni-kl.depython = sys.executable  # use same Python binary used to run scons
11812027Sjungma@eit.uni-kl.de
11912027Sjungma@eit.uni-kl.de# Also include the CheckerCPU as one of the models if it is being
12012027Sjungma@eit.uni-kl.de# enabled via command line.
12112027Sjungma@eit.uni-kl.deif env['USE_CHECKER']:
12212027Sjungma@eit.uni-kl.de    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
12312027Sjungma@eit.uni-kl.de                               emitter = isa_desc_emitter)
12412027Sjungma@eit.uni-kl.deelse:
12512027Sjungma@eit.uni-kl.de    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
12612027Sjungma@eit.uni-kl.de                               emitter = isa_desc_emitter)
12712027Sjungma@eit.uni-kl.de
12812027Sjungma@eit.uni-kl.deenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
12912027Sjungma@eit.uni-kl.de