SConscript revision 4781
110023Smatt.horsnell@ARM.com# -*- mode:python -*-
210023Smatt.horsnell@ARM.com
310023Smatt.horsnell@ARM.com# Copyright (c) 2006 The Regents of The University of Michigan
410023Smatt.horsnell@ARM.com# All rights reserved.
510023Smatt.horsnell@ARM.com#
610023Smatt.horsnell@ARM.com# Redistribution and use in source and binary forms, with or without
710023Smatt.horsnell@ARM.com# modification, are permitted provided that the following conditions are
810023Smatt.horsnell@ARM.com# met: redistributions of source code must retain the above copyright
910023Smatt.horsnell@ARM.com# notice, this list of conditions and the following disclaimer;
1010023Smatt.horsnell@ARM.com# redistributions in binary form must reproduce the above copyright
1110023Smatt.horsnell@ARM.com# notice, this list of conditions and the following disclaimer in the
1210023Smatt.horsnell@ARM.com# documentation and/or other materials provided with the distribution;
1310023Smatt.horsnell@ARM.com# neither the name of the copyright holders nor the names of its
1410023Smatt.horsnell@ARM.com# contributors may be used to endorse or promote products derived from
1510023Smatt.horsnell@ARM.com# this software without specific prior written permission.
1610023Smatt.horsnell@ARM.com#
1710023Smatt.horsnell@ARM.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1810023Smatt.horsnell@ARM.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1910023Smatt.horsnell@ARM.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2010023Smatt.horsnell@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2110023Smatt.horsnell@ARM.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2210023Smatt.horsnell@ARM.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2310023Smatt.horsnell@ARM.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2410023Smatt.horsnell@ARM.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2510023Smatt.horsnell@ARM.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2610023Smatt.horsnell@ARM.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2710023Smatt.horsnell@ARM.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2810023Smatt.horsnell@ARM.com#
2910023Smatt.horsnell@ARM.com# Authors: Steve Reinhardt
3010023Smatt.horsnell@ARM.com
3110023Smatt.horsnell@ARM.comimport sys
3210023Smatt.horsnell@ARM.com
3310023Smatt.horsnell@ARM.comImport('*')
3410023Smatt.horsnell@ARM.com
3510023Smatt.horsnell@ARM.com#################################################################
3610023Smatt.horsnell@ARM.com#
3710023Smatt.horsnell@ARM.com# ISA "switch header" generation.
3810023Smatt.horsnell@ARM.com#
3910023Smatt.horsnell@ARM.com# Auto-generate arch headers that include the right ISA-specific
4011793Sbrandon.potter@amd.com# header based on the setting of THE_ISA preprocessor variable.
4111793Sbrandon.potter@amd.com#
4210023Smatt.horsnell@ARM.com#################################################################
4311800Sbrandon.potter@amd.com
4410023Smatt.horsnell@ARM.com# List of headers to generate
4510023Smatt.horsnell@ARM.comisa_switch_hdrs = Split('''
4610023Smatt.horsnell@ARM.com        arguments.hh
4710023Smatt.horsnell@ARM.com        faults.hh
4810023Smatt.horsnell@ARM.com        interrupts.hh
4910023Smatt.horsnell@ARM.com        isa_traits.hh
5010023Smatt.horsnell@ARM.com        kernel_stats.hh
5110023Smatt.horsnell@ARM.com        locked_mem.hh
5210023Smatt.horsnell@ARM.com        mmaped_ipr.hh
5310023Smatt.horsnell@ARM.com        process.hh
5410023Smatt.horsnell@ARM.com        predecoder.hh
5510023Smatt.horsnell@ARM.com        regfile.hh
5610023Smatt.horsnell@ARM.com        remote_gdb.hh
5710023Smatt.horsnell@ARM.com        stacktrace.hh
5810023Smatt.horsnell@ARM.com        syscallreturn.hh
5910023Smatt.horsnell@ARM.com        tlb.hh
6010023Smatt.horsnell@ARM.com        types.hh
6110023Smatt.horsnell@ARM.com        utility.hh
6210023Smatt.horsnell@ARM.com        vtophys.hh
6310023Smatt.horsnell@ARM.com        ''')
6410023Smatt.horsnell@ARM.com
6510023Smatt.horsnell@ARM.com# Set up this directory to support switching headers
6610023Smatt.horsnell@ARM.commake_switching_dir('arch', isa_switch_hdrs, env)
6710365SAndreas.Sandberg@ARM.com
6810365SAndreas.Sandberg@ARM.com#################################################################
6910023Smatt.horsnell@ARM.com#
7010023Smatt.horsnell@ARM.com# Include architecture-specific files.
7110023Smatt.horsnell@ARM.com#
7210023Smatt.horsnell@ARM.com#################################################################
7310365SAndreas.Sandberg@ARM.com
7410365SAndreas.Sandberg@ARM.com#
7510365SAndreas.Sandberg@ARM.com# Build a SCons scanner for ISA files
7610365SAndreas.Sandberg@ARM.com#
7710365SAndreas.Sandberg@ARM.comimport SCons.Scanner
7810023Smatt.horsnell@ARM.com
7910023Smatt.horsnell@ARM.comisa_scanner = SCons.Scanner.Classic("ISAScan",
8010023Smatt.horsnell@ARM.com                                    [".isa", ".ISA"],
8110023Smatt.horsnell@ARM.com                                    "SRCDIR",
8210023Smatt.horsnell@ARM.com                                    r'^\s*##include\s+"([\w/.-]*)"')
8310023Smatt.horsnell@ARM.com
8410023Smatt.horsnell@ARM.comenv.Append(SCANNERS = isa_scanner)
8510023Smatt.horsnell@ARM.com
8610023Smatt.horsnell@ARM.com#
8710023Smatt.horsnell@ARM.com# Now create a Builder object that uses isa_parser.py to generate C++
8810023Smatt.horsnell@ARM.com# output from the ISA description (*.isa) files.
8910023Smatt.horsnell@ARM.com#
9010023Smatt.horsnell@ARM.com
9110023Smatt.horsnell@ARM.com# Convert to File node to fix path
9210023Smatt.horsnell@ARM.comisa_parser = File('isa_parser.py')
9310023Smatt.horsnell@ARM.comcpu_models_file = File('../cpu/cpu_models.py')
9410023Smatt.horsnell@ARM.com
9510023Smatt.horsnell@ARM.com# This sucks in the defintions of the CpuModel objects.
9610023Smatt.horsnell@ARM.comexecfile(cpu_models_file.srcnode().abspath)
9710023Smatt.horsnell@ARM.com
9810023Smatt.horsnell@ARM.com# Several files are generated from the ISA description.
9910023Smatt.horsnell@ARM.com# We always get the basic decoder and header file.
10010023Smatt.horsnell@ARM.comisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh' ]
10110023Smatt.horsnell@ARM.com# We also get an execute file for each selected CPU model.
10210023Smatt.horsnell@ARM.comisa_desc_gen_files += [CpuModel.dict[cpu].filename
10310023Smatt.horsnell@ARM.com                       for cpu in env['CPU_MODELS']]
10410023Smatt.horsnell@ARM.com
10510023Smatt.horsnell@ARM.com# Also include the CheckerCPU as one of the models if it is being
10610023Smatt.horsnell@ARM.com# enabled via command line.
10710023Smatt.horsnell@ARM.comif env['USE_CHECKER']:
10810023Smatt.horsnell@ARM.com    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
10910023Smatt.horsnell@ARM.com
11010023Smatt.horsnell@ARM.com# The emitter patches up the sources & targets to include the
11110023Smatt.horsnell@ARM.com# autogenerated files as targets and isa parser itself as a source.
11210023Smatt.horsnell@ARM.comdef isa_desc_emitter(target, source, env):
11310023Smatt.horsnell@ARM.com    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
11410023Smatt.horsnell@ARM.com
11510023Smatt.horsnell@ARM.com# Pieces are in place, so create the builder.
11610023Smatt.horsnell@ARM.compython = sys.executable  # use same Python binary used to run scons
11710023Smatt.horsnell@ARM.com
11810023Smatt.horsnell@ARM.com# Also include the CheckerCPU as one of the models if it is being
11910023Smatt.horsnell@ARM.com# enabled via command line.
12010023Smatt.horsnell@ARM.comif env['USE_CHECKER']:
12110023Smatt.horsnell@ARM.com    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
12210023Smatt.horsnell@ARM.com                               emitter = isa_desc_emitter)
12310023Smatt.horsnell@ARM.comelse:
12410023Smatt.horsnell@ARM.com    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
12510023Smatt.horsnell@ARM.com                               emitter = isa_desc_emitter)
12610023Smatt.horsnell@ARM.com
12710023Smatt.horsnell@ARM.comenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
12810023Smatt.horsnell@ARM.com