SConscript revision 8763
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 sys
322155SN/A
337768SAli.Saidi@ARM.comImport('*')
347768SAli.Saidi@ARM.com
357768SAli.Saidi@ARM.com#################################################################
362178SN/A#
372178SN/A# ISA "switch header" generation.
382178SN/A#
392178SN/A# Auto-generate arch headers that include the right ISA-specific
402178SN/A# header based on the setting of THE_ISA preprocessor variable.
412178SN/A#
422178SN/A#################################################################
432178SN/A
442178SN/A# List of headers to generate
452178SN/Aisa_switch_hdrs = Split('''
462178SN/A        faults.hh
472155SN/A        interrupts.hh
485865Sksewell@umich.edu        isa.hh
496181Sksewell@umich.edu        isa_traits.hh
506181Sksewell@umich.edu        kernel_stats.hh
515865Sksewell@umich.edu        locked_mem.hh
523918Ssaidi@eecs.umich.edu        microcode_rom.hh
535865Sksewell@umich.edu        mmapped_ipr.hh
542623SN/A        mt.hh
553918Ssaidi@eecs.umich.edu        process.hh
562155SN/A        predecoder.hh
572155SN/A        registers.hh
582292SN/A        remote_gdb.hh
596181Sksewell@umich.edu        stacktrace.hh
606181Sksewell@umich.edu        tlb.hh
613918Ssaidi@eecs.umich.edu        types.hh
622292SN/A        utility.hh
632292SN/A        vtophys.hh
642292SN/A        ''')
653918Ssaidi@eecs.umich.edu
662292SN/A# Set up this directory to support switching headers
672292SN/Amake_switching_dir('arch', isa_switch_hdrs, env)
682766Sktlim@umich.edu
692766Sktlim@umich.edu#################################################################
702766Sktlim@umich.edu#
712921Sktlim@umich.edu# Include architecture-specific files.
722921Sktlim@umich.edu#
732766Sktlim@umich.edu#################################################################
742766Sktlim@umich.edu
755529Snate@binkert.org#
762766Sktlim@umich.edu# Build a SCons scanner for ISA files
774762Snate@binkert.org#
782155SN/Aimport SCons.Scanner
792155SN/A
802155SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan",
812155SN/A                                    [".isa", ".ISA"],
822155SN/A                                    "SRCDIR",
832155SN/A                                    r'^\s*##include\s+"([\w/.-]*)"')
842766Sktlim@umich.edu
852155SN/Aenv.Append(SCANNERS = isa_scanner)
865865Sksewell@umich.edu
872155SN/A#
882155SN/A# Now create a Builder object that uses isa_parser.py to generate C++
892155SN/A# output from the ISA description (*.isa) files.
902155SN/A#
912178SN/A
922178SN/Aisa_parser = File('isa_parser.py')
937756SAli.Saidi@ARM.com
942766Sktlim@umich.edu# The emitter patches up the sources & targets to include the
952178SN/A# autogenerated files as targets and isa parser itself as a source.
962178SN/Adef isa_desc_emitter(target, source, env):
976994Snate@binkert.org    cpu_models = list(env['CPU_MODELS'])
982178SN/A    if env['USE_CHECKER']:
992766Sktlim@umich.edu        cpu_models.append('CheckerCPU')
1002766Sktlim@umich.edu
1012766Sktlim@umich.edu    # Several files are generated from the ISA description.
1022788Sktlim@umich.edu    # We always get the basic decoder and header file.
1032178SN/A    target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
1042733Sktlim@umich.edu    # We also get an execute file for each selected CPU model.
1052733Sktlim@umich.edu    target += [CpuModel.dict[cpu].filename for cpu in cpu_models]
1062817Sksewell@umich.edu
1072733Sktlim@umich.edu    # List the isa parser as a source.
1084486Sbinkertn@umich.edu    source += [ isa_parser ]
1094486Sbinkertn@umich.edu    # Add in the CPU models.
1104776Sgblack@eecs.umich.edu    source += [ Value(m) for m in cpu_models ]
1114776Sgblack@eecs.umich.edu
1128739Sgblack@eecs.umich.edu    return target, source
1136365Sgblack@eecs.umich.edu
1144486Sbinkertn@umich.eduARCH_DIR = Dir('.')
1154202Sbinkertn@umich.edu
1164202Sbinkertn@umich.edu# import ply here because SCons screws with sys.path when performing actions.
1174202Sbinkertn@umich.eduimport ply
1188541Sgblack@eecs.umich.edu
1194202Sbinkertn@umich.edudef isa_desc_action_func(target, source, env):
1204202Sbinkertn@umich.edu    # Add the current directory to the system path so we can import files
1214776Sgblack@eecs.umich.edu    sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ]
1228739Sgblack@eecs.umich.edu    import isa_parser
1236365Sgblack@eecs.umich.edu
1244202Sbinkertn@umich.edu    # Skip over the ISA description itself and the parser to the CPU models.
1254202Sbinkertn@umich.edu    models = [ s.get_contents() for s in source[2:] ]
1264202Sbinkertn@umich.edu    cpu_models = [CpuModel.dict[cpu] for cpu in models]
1274202Sbinkertn@umich.edu    parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models)
1285217Ssaidi@eecs.umich.edu    parser.parse_isa_desc(source[0].abspath)
1294202Sbinkertn@umich.eduisa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1))
1302155SN/A
1314202Sbinkertn@umich.edu# Also include the CheckerCPU as one of the models if it is being
1324202Sbinkertn@umich.edu# enabled via command line.
1332821Sktlim@umich.eduisa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter)
1344776Sgblack@eecs.umich.edu
1354776Sgblack@eecs.umich.eduenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1364776Sgblack@eecs.umich.edu
1374776Sgblack@eecs.umich.eduDebugFlag('IntRegs')
1382766Sktlim@umich.eduDebugFlag('FloatRegs')
1394202Sbinkertn@umich.eduDebugFlag('MiscRegs')
1408335Snate@binkert.orgCompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ])
1412733Sktlim@umich.edu