SConscript revision 5298
14120Sgblack@eecs.umich.edu# -*- mode:python -*-
24120Sgblack@eecs.umich.edu
34120Sgblack@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
44120Sgblack@eecs.umich.edu# All rights reserved.
54120Sgblack@eecs.umich.edu#
64120Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
74120Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
84120Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
94120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
104120Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
114120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
124120Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
134120Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
144120Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
154120Sgblack@eecs.umich.edu# this software without specific prior written permission.
164120Sgblack@eecs.umich.edu#
174120Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184120Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194120Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204120Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214120Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224120Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234120Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244120Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254120Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264120Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274120Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284120Sgblack@eecs.umich.edu#
294120Sgblack@eecs.umich.edu# Authors: Steve Reinhardt
304120Sgblack@eecs.umich.edu
315334Sgblack@eecs.umich.eduimport sys
324120Sgblack@eecs.umich.edu
334120Sgblack@eecs.umich.eduImport('*')
344120Sgblack@eecs.umich.edu
354120Sgblack@eecs.umich.edu#################################################################
364120Sgblack@eecs.umich.edu#
374120Sgblack@eecs.umich.edu# ISA "switch header" generation.
384120Sgblack@eecs.umich.edu#
394120Sgblack@eecs.umich.edu# Auto-generate arch headers that include the right ISA-specific
404120Sgblack@eecs.umich.edu# header based on the setting of THE_ISA preprocessor variable.
414120Sgblack@eecs.umich.edu#
424120Sgblack@eecs.umich.edu#################################################################
434120Sgblack@eecs.umich.edu
444120Sgblack@eecs.umich.edu# List of headers to generate
454120Sgblack@eecs.umich.eduisa_switch_hdrs = Split('''
464120Sgblack@eecs.umich.edu        arguments.hh
474120Sgblack@eecs.umich.edu        faults.hh
484120Sgblack@eecs.umich.edu        interrupts.hh
494120Sgblack@eecs.umich.edu        isa_traits.hh
504120Sgblack@eecs.umich.edu        kernel_stats.hh
514120Sgblack@eecs.umich.edu        locked_mem.hh
524120Sgblack@eecs.umich.edu        mmaped_ipr.hh
534120Sgblack@eecs.umich.edu        process.hh
544120Sgblack@eecs.umich.edu        predecoder.hh
554120Sgblack@eecs.umich.edu        regfile.hh
564120Sgblack@eecs.umich.edu        remote_gdb.hh
574120Sgblack@eecs.umich.edu        stacktrace.hh
584120Sgblack@eecs.umich.edu        syscallreturn.hh
594120Sgblack@eecs.umich.edu        tlb.hh
604120Sgblack@eecs.umich.edu        types.hh
614120Sgblack@eecs.umich.edu        utility.hh
624120Sgblack@eecs.umich.edu        vtophys.hh
634120Sgblack@eecs.umich.edu        ''')
644120Sgblack@eecs.umich.edu
654120Sgblack@eecs.umich.edu# Set up this directory to support switching headers
664120Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env)
674120Sgblack@eecs.umich.edu
684120Sgblack@eecs.umich.edu#################################################################
694120Sgblack@eecs.umich.edu#
704120Sgblack@eecs.umich.edu# Include architecture-specific files.
714120Sgblack@eecs.umich.edu#
724120Sgblack@eecs.umich.edu#################################################################
734120Sgblack@eecs.umich.edu
744120Sgblack@eecs.umich.edu#
754120Sgblack@eecs.umich.edu# Build a SCons scanner for ISA files
764120Sgblack@eecs.umich.edu#
774120Sgblack@eecs.umich.eduimport SCons.Scanner
784120Sgblack@eecs.umich.edu
794120Sgblack@eecs.umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan",
804120Sgblack@eecs.umich.edu                                    [".isa", ".ISA"],
814120Sgblack@eecs.umich.edu                                    "SRCDIR",
824120Sgblack@eecs.umich.edu                                    r'^\s*##include\s+"([\w/.-]*)"')
834120Sgblack@eecs.umich.edu
844120Sgblack@eecs.umich.eduenv.Append(SCANNERS = isa_scanner)
854120Sgblack@eecs.umich.edu
864202Sbinkertn@umich.edu#
875069Sgblack@eecs.umich.edu# Now create a Builder object that uses isa_parser.py to generate C++
884202Sbinkertn@umich.edu# output from the ISA description (*.isa) files.
895659Sgblack@eecs.umich.edu#
904601Sgblack@eecs.umich.edu
914202Sbinkertn@umich.edu# Convert to File node to fix path
925124Sgblack@eecs.umich.eduisa_parser = File('isa_parser.py')
935083Sgblack@eecs.umich.educpu_models_file = File('../cpu/cpu_models.py')
944679Sgblack@eecs.umich.edu
955083Sgblack@eecs.umich.edu# This sucks in the defintions of the CpuModel objects.
964679Sgblack@eecs.umich.eduexecfile(cpu_models_file.srcnode().abspath)
974679Sgblack@eecs.umich.edu
984202Sbinkertn@umich.edu# Several files are generated from the ISA description.
994202Sbinkertn@umich.edu# We always get the basic decoder and header file.
1005124Sgblack@eecs.umich.eduisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
1014249Sgblack@eecs.umich.edu# We also get an execute file for each selected CPU model.
1024240Sgblack@eecs.umich.eduisa_desc_gen_files += [CpuModel.dict[cpu].filename
1034202Sbinkertn@umich.edu                       for cpu in env['CPU_MODELS']]
1044202Sbinkertn@umich.edu
1054997Sgblack@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being
1065135Sgblack@eecs.umich.edu# enabled via command line.
1074997Sgblack@eecs.umich.eduif env['USE_CHECKER']:
1084997Sgblack@eecs.umich.edu    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
1095800Snate@binkert.org
1105800Snate@binkert.org# The emitter patches up the sources & targets to include the
1114120Sgblack@eecs.umich.edu# autogenerated files as targets and isa parser itself as a source.
1124202Sbinkertn@umich.edudef isa_desc_emitter(target, source, env):
1135800Snate@binkert.org    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
1145649Sgblack@eecs.umich.edu
1155647Sgblack@eecs.umich.edu# Pieces are in place, so create the builder.
1165132Sgblack@eecs.umich.edupython = sys.executable  # use same Python binary used to run scons
1175132Sgblack@eecs.umich.edu
1184202Sbinkertn@umich.edu# Also include the CheckerCPU as one of the models if it is being
1195647Sgblack@eecs.umich.edu# enabled via command line.
1205299Sgblack@eecs.umich.eduif env['USE_CHECKER']:
1215245Sgblack@eecs.umich.edu    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
1225132Sgblack@eecs.umich.edu                               emitter = isa_desc_emitter)
1235086Sgblack@eecs.umich.eduelse:
1245086Sgblack@eecs.umich.edu    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
1254202Sbinkertn@umich.edu                               emitter = isa_desc_emitter)
1264202Sbinkertn@umich.edu
1274120Sgblack@eecs.umich.eduenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1284202Sbinkertn@umich.edu