SConscript revision 8615
14484Sbinkertn@umich.edu# -*- mode:python -*-
24484Sbinkertn@umich.edu
34484Sbinkertn@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
44484Sbinkertn@umich.edu# All rights reserved.
54484Sbinkertn@umich.edu#
64484Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
74484Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
84484Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
94484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
104484Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
114484Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
124484Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
134484Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
144484Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
154484Sbinkertn@umich.edu# this software without specific prior written permission.
164484Sbinkertn@umich.edu#
174484Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
184484Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
194484Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
204484Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
214484Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
224484Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
234484Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244484Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254484Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264484Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
274484Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284484Sbinkertn@umich.edu#
294484Sbinkertn@umich.edu# Authors: Steve Reinhardt
304484Sbinkertn@umich.edu
314494Ssaidi@eecs.umich.eduimport sys
324484Sbinkertn@umich.edu
336121Snate@binkert.orgImport('*')
344484Sbinkertn@umich.edu
354484Sbinkertn@umich.edu#################################################################
364484Sbinkertn@umich.edu#
374484Sbinkertn@umich.edu# ISA "switch header" generation.
384781Snate@binkert.org#
394484Sbinkertn@umich.edu# Auto-generate arch headers that include the right ISA-specific
404484Sbinkertn@umich.edu# header based on the setting of THE_ISA preprocessor variable.
414484Sbinkertn@umich.edu#
424484Sbinkertn@umich.edu#################################################################
434484Sbinkertn@umich.edu
444484Sbinkertn@umich.edu# List of headers to generate
454484Sbinkertn@umich.eduisa_switch_hdrs = Split('''
464484Sbinkertn@umich.edu        faults.hh
474484Sbinkertn@umich.edu        interrupts.hh
484484Sbinkertn@umich.edu        isa.hh
494484Sbinkertn@umich.edu        isa_traits.hh
504484Sbinkertn@umich.edu        kernel_stats.hh
514484Sbinkertn@umich.edu        locked_mem.hh
524484Sbinkertn@umich.edu        microcode_rom.hh
534484Sbinkertn@umich.edu        mmapped_ipr.hh
544484Sbinkertn@umich.edu        mt.hh
554484Sbinkertn@umich.edu        process.hh
564484Sbinkertn@umich.edu        predecoder.hh
574484Sbinkertn@umich.edu        registers.hh
584484Sbinkertn@umich.edu        remote_gdb.hh
594484Sbinkertn@umich.edu        stacktrace.hh
604484Sbinkertn@umich.edu        tlb.hh
614484Sbinkertn@umich.edu        types.hh
624484Sbinkertn@umich.edu        utility.hh
634484Sbinkertn@umich.edu        vtophys.hh
644484Sbinkertn@umich.edu        ''')
654484Sbinkertn@umich.edu
664484Sbinkertn@umich.edu# Set up this directory to support switching headers
674484Sbinkertn@umich.edumake_switching_dir('arch', isa_switch_hdrs, env)
684484Sbinkertn@umich.edu
694484Sbinkertn@umich.edu#################################################################
704484Sbinkertn@umich.edu#
714484Sbinkertn@umich.edu# Include architecture-specific files.
724484Sbinkertn@umich.edu#
734484Sbinkertn@umich.edu#################################################################
744484Sbinkertn@umich.edu
754484Sbinkertn@umich.edu#
764484Sbinkertn@umich.edu# Build a SCons scanner for ISA files
774484Sbinkertn@umich.edu#
784484Sbinkertn@umich.eduimport SCons.Scanner
794484Sbinkertn@umich.edu
804484Sbinkertn@umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan",
814484Sbinkertn@umich.edu                                    [".isa", ".ISA"],
824484Sbinkertn@umich.edu                                    "SRCDIR",
834484Sbinkertn@umich.edu                                    r'^\s*##include\s+"([\w/.-]*)"')
844484Sbinkertn@umich.edu
854484Sbinkertn@umich.eduenv.Append(SCANNERS = isa_scanner)
864484Sbinkertn@umich.edu
874484Sbinkertn@umich.edu#
884484Sbinkertn@umich.edu# Now create a Builder object that uses isa_parser.py to generate C++
894484Sbinkertn@umich.edu# output from the ISA description (*.isa) files.
906121Snate@binkert.org#
916121Snate@binkert.org
926121Snate@binkert.orgisa_parser = File('isa_parser.py')
935765Snate@binkert.org
945765Snate@binkert.org# The emitter patches up the sources & targets to include the
955765Snate@binkert.org# autogenerated files as targets and isa parser itself as a source.
965397Ssaidi@eecs.umich.edudef isa_desc_emitter(target, source, env):
975274Ssaidi@eecs.umich.edu    cpu_models = list(env['CPU_MODELS'])
984494Ssaidi@eecs.umich.edu    if env['USE_CHECKER']:
994504Ssaidi@eecs.umich.edu        cpu_models.append('CheckerCPU')
1004494Ssaidi@eecs.umich.edu
1014494Ssaidi@eecs.umich.edu    # Several files are generated from the ISA description.
1024496Ssaidi@eecs.umich.edu    # We always get the basic decoder and header file.
1034504Ssaidi@eecs.umich.edu    target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
1044504Ssaidi@eecs.umich.edu    # We also get an execute file for each selected CPU model.
1054500Sbinkertn@umich.edu    target += [CpuModel.dict[cpu].filename for cpu in cpu_models]
1064500Sbinkertn@umich.edu
1074496Ssaidi@eecs.umich.edu    # List the isa parser as a source.
1084496Ssaidi@eecs.umich.edu    source += [ isa_parser ]
1097739Sgblack@eecs.umich.edu    # Add in the CPU models.
1104487Sstever@eecs.umich.edu    source += [ Value(m) for m in cpu_models ]
1114484Sbinkertn@umich.edu
1124484Sbinkertn@umich.edu    return target, source
1134484Sbinkertn@umich.edu
1144484Sbinkertn@umich.eduARCH_DIR = Dir('.')
1154484Sbinkertn@umich.edu
1164484Sbinkertn@umich.edu# import ply here because SCons screws with sys.path when performing actions.
1175601Snate@binkert.orgimport ply
1185601Snate@binkert.org
1195601Snate@binkert.orgdef isa_desc_action_func(target, source, env):
1205601Snate@binkert.org    # Add the current directory to the system path so we can import files
1214484Sbinkertn@umich.edu    sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ]
1226121Snate@binkert.org    import isa_parser
1236121Snate@binkert.org
1246121Snate@binkert.org    # Skip over the ISA description itself and the parser to the CPU models.
1254494Ssaidi@eecs.umich.edu    models = [ s.get_contents() for s in source[2:] ]
126    cpu_models = [CpuModel.dict[cpu] for cpu in models]
127    parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models)
128    parser.parse_isa_desc(source[0].abspath)
129isa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1))
130
131# Also include the CheckerCPU as one of the models if it is being
132# enabled via command line.
133isa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter)
134
135env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
136
137DebugFlag('IntRegs')
138DebugFlag('FloatRegs')
139DebugFlag('MiscRegs')
140CompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ])
141