SConscript revision 7752
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        faults.hh
472139SN/A        interrupts.hh
482139SN/A	isa.hh
492139SN/A        isa_traits.hh
502984Sgblack@eecs.umich.edu        kernel_stats.hh
512439SN/A        locked_mem.hh
523520Sgblack@eecs.umich.edu        microcode_rom.hh
532139SN/A        mmaped_ipr.hh
543565Sgblack@eecs.umich.edu        mt.hh
553170Sstever@eecs.umich.edu        process.hh
563806Ssaidi@eecs.umich.edu        predecoder.hh
572439SN/A        registers.hh
582460SN/A        remote_gdb.hh
593536Sgblack@eecs.umich.edu        stacktrace.hh
602439SN/A        tlb.hh
612972Sgblack@eecs.umich.edu        types.hh
622171SN/A        utility.hh
632439SN/A        vtophys.hh
642439SN/A        ''')
652170SN/A
662139SN/A# Set up this directory to support switching headers
672139SN/Amake_switching_dir('arch', isa_switch_hdrs, env)
683546Sgblack@eecs.umich.edu
693546Sgblack@eecs.umich.edu#################################################################
702152SN/A#
712152SN/A# Include architecture-specific files.
722152SN/A#
732152SN/A#################################################################
742152SN/A
752152SN/A#
762152SN/A# Build a SCons scanner for ISA files
772152SN/A#
782152SN/Aimport SCons.Scanner
792152SN/A
802152SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan",
812152SN/A                                    [".isa", ".ISA"],
822504SN/A                                    "SRCDIR",
832504SN/A                                    r'^\s*##include\s+"([\w/.-]*)"')
842504SN/A
852504SN/Aenv.Append(SCANNERS = isa_scanner)
862152SN/A
872504SN/A#
882152SN/A# Now create a Builder object that uses isa_parser.py to generate C++
892152SN/A# output from the ISA description (*.isa) files.
902152SN/A#
912152SN/A
922152SN/A# The emitter patches up the sources & targets to include the
932152SN/A# autogenerated files as targets and isa parser itself as a source.
942152SN/Adef isa_desc_emitter(target, source, env):
952152SN/A    cpu_models = list(env['CPU_MODELS'])
962632Sstever@eecs.umich.edu    if env['USE_CHECKER']:
972155SN/A        cpu_models.append('CheckerCPU')
982155SN/A
992155SN/A    # Several files are generated from the ISA description.
1002155SN/A    # We always get the basic decoder and header file.
1012155SN/A    target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
1022155SN/A    # We also get an execute file for each selected CPU model.
1032155SN/A    target += [CpuModel.dict[cpu].filename for cpu in cpu_models]
1042155SN/A
1052155SN/A    return target, source + [ Value(m) for m in cpu_models ]
1062155SN/A
1072152SN/AARCH_DIR = Dir('.')
1082766Sktlim@umich.edu
1092766Sktlim@umich.edu# import ply here because SCons screws with sys.path when performing actions.
1102766Sktlim@umich.eduimport ply
1112766Sktlim@umich.edu
1122766Sktlim@umich.edudef isa_desc_action(target, source, env):
1132152SN/A    # Add the current directory to the system path so we can import files
1142152SN/A    sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ]
1152152SN/A    import isa_parser
1162155SN/A
1172152SN/A    models = [ s.get_contents() for s in source[1:] ]
1182152SN/A    cpu_models = [CpuModel.dict[cpu] for cpu in models]
1192718Sstever@eecs.umich.edu    parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models)
1202921Sktlim@umich.edu    parser.parse_isa_desc(source[0].abspath)
1212921Sktlim@umich.edu
1222921Sktlim@umich.edu# Also include the CheckerCPU as one of the models if it is being
1232921Sktlim@umich.edu# enabled via command line.
1242921Sktlim@umich.eduisa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter)
1252921Sktlim@umich.edu
1262921Sktlim@umich.eduenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
1272921Sktlim@umich.edu
1282921Sktlim@umich.eduTraceFlag('IntRegs')
1292152SN/ATraceFlag('FloatRegs')
1302152SN/ATraceFlag('MiscRegs')
1312152SN/ACompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ])
1322152SN/A