SConscript revision 6365
12139SN/A# -*- mode:python -*-
22139SN/A
32139SN/A# Copyright (c) 2006 The Regents of The University of Michigan
42139SN/A# All rights reserved.
52139SN/A#
62139SN/A# Redistribution and use in source and binary forms, with or without
72139SN/A# modification, are permitted provided that the following conditions are
82139SN/A# met: redistributions of source code must retain the above copyright
92139SN/A# notice, this list of conditions and the following disclaimer;
102139SN/A# redistributions in binary form must reproduce the above copyright
112139SN/A# notice, this list of conditions and the following disclaimer in the
122139SN/A# documentation and/or other materials provided with the distribution;
132139SN/A# neither the name of the copyright holders nor the names of its
142139SN/A# contributors may be used to endorse or promote products derived from
152139SN/A# this software without specific prior written permission.
162139SN/A#
172139SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182139SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192139SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202139SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212139SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222139SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232139SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242139SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252139SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262139SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272139SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
302139SN/A
312718Sstever@eecs.umich.eduimport sys
322139SN/A
332139SN/AImport('*')
342139SN/A
352139SN/A#################################################################
362152SN/A#
372152SN/A# ISA "switch header" generation.
382152SN/A#
392152SN/A# Auto-generate arch headers that include the right ISA-specific
402139SN/A# header based on the setting of THE_ISA preprocessor variable.
412139SN/A#
422139SN/A#################################################################
432139SN/A
442139SN/A# List of headers to generate
452152SN/Aisa_switch_hdrs = Split('''
462152SN/A        arguments.hh
472139SN/A        faults.hh
482139SN/A        interrupts.hh
492139SN/A	isa.hh
502984Sgblack@eecs.umich.edu        isa_traits.hh
512439SN/A        kernel_stats.hh
522139SN/A        locked_mem.hh
532439SN/A        microcode_rom.hh
542460SN/A        mmaped_ipr.hh
552439SN/A        mt.hh
562972Sgblack@eecs.umich.edu        process.hh
572171SN/A        predecoder.hh
582439SN/A        registers.hh
592439SN/A        remote_gdb.hh
602170SN/A        stacktrace.hh
612139SN/A        tlb.hh
622139SN/A        types.hh
632139SN/A        utility.hh
642139SN/A        vtophys.hh
652139SN/A        ''')
662139SN/A
672139SN/A# Set up this directory to support switching headers
682139SN/Amake_switching_dir('arch', isa_switch_hdrs, env)
692139SN/A
702139SN/A#################################################################
712139SN/A#
722139SN/A# Include architecture-specific files.
732139SN/A#
742139SN/A#################################################################
752139SN/A
762139SN/A#
772139SN/A# Build a SCons scanner for ISA files
782139SN/A#
792139SN/Aimport SCons.Scanner
802139SN/A
812139SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan",
822139SN/A                                    [".isa", ".ISA"],
832139SN/A                                    "SRCDIR",
842139SN/A                                    r'^\s*##include\s+"([\w/.-]*)"')
852178SN/A
862139SN/Aenv.Append(SCANNERS = isa_scanner)
872139SN/A
882139SN/A#
892139SN/A# Now create a Builder object that uses isa_parser.py to generate C++
902139SN/A# output from the ISA description (*.isa) files.
912139SN/A#
922139SN/A
932152SN/A# Convert to File node to fix path
942152SN/Aisa_parser = File('isa_parser.py')
952152SN/Acpu_models_file = File('../cpu/cpu_models.py')
962152SN/A
972152SN/A# This sucks in the defintions of the CpuModel objects.
982152SN/Aexecfile(cpu_models_file.srcnode().abspath)
992152SN/A
1002152SN/A# Several files are generated from the ISA description.
1012152SN/A# We always get the basic decoder and header file.
1022152SN/Aisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
1032152SN/A# We also get an execute file for each selected CPU model.
1042152SN/Aisa_desc_gen_files += [CpuModel.dict[cpu].filename
1052504SN/A                       for cpu in env['CPU_MODELS']]
1062504SN/A
1072504SN/A# Also include the CheckerCPU as one of the models if it is being
1082504SN/A# enabled via command line.
1092152SN/Aif env['USE_CHECKER']:
1102504SN/A    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
1112152SN/A
1122152SN/A# The emitter patches up the sources & targets to include the
1132152SN/A# autogenerated files as targets and isa parser itself as a source.
1142152SN/Adef isa_desc_emitter(target, source, env):
1152152SN/A    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
1162152SN/A
1172152SN/A# Pieces are in place, so create the builder.
1182152SN/Apython = sys.executable  # use same Python binary used to run scons
1192632Sstever@eecs.umich.edu
1202155SN/A# Also include the CheckerCPU as one of the models if it is being
1212155SN/A# enabled via command line.
1222155SN/Aif env['USE_CHECKER']:
1232155SN/A    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
1242155SN/A                               emitter = isa_desc_emitter)
1252155SN/Aelse:
1262155SN/A    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
1272155SN/A                               emitter = isa_desc_emitter)
1282155SN/A
1292155SN/Aenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1302152SN/A
1312766Sktlim@umich.eduTraceFlag('IntRegs')
1322766Sktlim@umich.eduTraceFlag('FloatRegs')
1332766Sktlim@umich.eduTraceFlag('MiscRegs')
1342766Sktlim@umich.eduCompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ])
1352766Sktlim@umich.edu