SConscript revision 7694
16019Shines@cs.fsu.edu# -*- mode:python -*-
26019Shines@cs.fsu.edu
310037SARM gem5 Developers# Copyright (c) 2006 The Regents of The University of Michigan
47100Sgblack@eecs.umich.edu# All rights reserved.
57100Sgblack@eecs.umich.edu#
67100Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
77100Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
87100Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
97100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
107100Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
117100Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
127100Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
137100Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
147100Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
156019Shines@cs.fsu.edu# this software without specific prior written permission.
166019Shines@cs.fsu.edu#
176019Shines@cs.fsu.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186019Shines@cs.fsu.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196019Shines@cs.fsu.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206019Shines@cs.fsu.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216019Shines@cs.fsu.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226019Shines@cs.fsu.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236019Shines@cs.fsu.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246019Shines@cs.fsu.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256019Shines@cs.fsu.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266019Shines@cs.fsu.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276019Shines@cs.fsu.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286019Shines@cs.fsu.edu#
296019Shines@cs.fsu.edu# Authors: Steve Reinhardt
306019Shines@cs.fsu.edu
316019Shines@cs.fsu.eduimport sys
326019Shines@cs.fsu.edu
336019Shines@cs.fsu.eduImport('*')
346019Shines@cs.fsu.edu
356019Shines@cs.fsu.edu#################################################################
366019Shines@cs.fsu.edu#
376019Shines@cs.fsu.edu# ISA "switch header" generation.
386019Shines@cs.fsu.edu#
396019Shines@cs.fsu.edu# Auto-generate arch headers that include the right ISA-specific
406019Shines@cs.fsu.edu# header based on the setting of THE_ISA preprocessor variable.
416019Shines@cs.fsu.edu#
426757SAli.Saidi@ARM.com#################################################################
436019Shines@cs.fsu.edu
446019Shines@cs.fsu.edu# List of headers to generate
456019Shines@cs.fsu.eduisa_switch_hdrs = Split('''
466019Shines@cs.fsu.edu        faults.hh
476019Shines@cs.fsu.edu        interrupts.hh
4811320Ssteve.reinhardt@amd.com	isa.hh
496019Shines@cs.fsu.edu        isa_traits.hh
509022Sgblack@eecs.umich.edu        kernel_stats.hh
516019Shines@cs.fsu.edu        locked_mem.hh
5212640Sgiacomo.travaglini@arm.com        microcode_rom.hh
5310037SARM gem5 Developers        mmaped_ipr.hh
5410037SARM gem5 Developers        mt.hh
557170Sgblack@eecs.umich.edu        process.hh
566253Sgblack@eecs.umich.edu        predecoder.hh
5710037SARM gem5 Developers        registers.hh
587202Sgblack@eecs.umich.edu        remote_gdb.hh
5910037SARM gem5 Developers        stacktrace.hh
606253Sgblack@eecs.umich.edu        tlb.hh
6110611SAndreas.Sandberg@ARM.com        types.hh
626253Sgblack@eecs.umich.edu        utility.hh
637396Sgblack@eecs.umich.edu        vtophys.hh
6410037SARM gem5 Developers        ''')
658745Sgblack@eecs.umich.edu
667405SAli.Saidi@ARM.com# Set up this directory to support switching headers
6710461SAndreas.Sandberg@ARM.commake_switching_dir('arch', isa_switch_hdrs, env)
688782Sgblack@eecs.umich.edu
698782Sgblack@eecs.umich.edu#################################################################
708782Sgblack@eecs.umich.edu#
7110810Sbr@bsdpad.com# Include architecture-specific files.
7210810Sbr@bsdpad.com#
7310810Sbr@bsdpad.com#################################################################
747259Sgblack@eecs.umich.edu
758757Sgblack@eecs.umich.edu#
7610461SAndreas.Sandberg@ARM.com# Build a SCons scanner for ISA files
778782Sgblack@eecs.umich.edu#
788757Sgblack@eecs.umich.eduimport SCons.Scanner
7912531Sandreas.sandberg@arm.com
808777Sgblack@eecs.umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan",
818782Sgblack@eecs.umich.edu                                    [".isa", ".ISA"],
828756Sgblack@eecs.umich.edu                                    "SRCDIR",
8310037SARM gem5 Developers                                    r'^\s*##include\s+"([\w/.-]*)"')
8410037SARM gem5 Developers
856019Shines@cs.fsu.eduenv.Append(SCANNERS = isa_scanner)
8612605Sgiacomo.travaglini@arm.com
876757SAli.Saidi@ARM.com#
888757Sgblack@eecs.umich.edu# Now create a Builder object that uses isa_parser.py to generate C++
896019Shines@cs.fsu.edu# output from the ISA description (*.isa) files.
908745Sgblack@eecs.umich.edu#
919384SAndreas.Sandberg@arm.com
926397Sgblack@eecs.umich.edu# The emitter patches up the sources & targets to include the
9312531Sandreas.sandberg@arm.com# autogenerated files as targets and isa parser itself as a source.
948782Sgblack@eecs.umich.edudef isa_desc_emitter(target, source, env):
956019Shines@cs.fsu.edu    cpu_models = list(env['CPU_MODELS'])
9610461SAndreas.Sandberg@ARM.com    if env['USE_CHECKER']:
976397Sgblack@eecs.umich.edu        cpu_models.append('CheckerCPU')
988335Snate@binkert.org
9912531Sandreas.sandberg@arm.com    # Several files are generated from the ISA description.
1009023Sgblack@eecs.umich.edu    # We always get the basic decoder and header file.
1019023Sgblack@eecs.umich.edu    target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
10210461SAndreas.Sandberg@ARM.com    # We also get an execute file for each selected CPU model.
1038335Snate@binkert.org    target += [CpuModel.dict[cpu].filename for cpu in cpu_models]
1046019Shines@cs.fsu.edu
10510196SCurtis.Dunham@arm.com    return target, source + [ Value(m) for m in cpu_models ]
10612222Sgabeblack@google.com
107ARCH_DIR = Dir('.')
108
109# import ply here because SCons screws with sys.path when performing actions.
110import ply
111
112def isa_desc_action(target, source, env):
113    # Add the current directory to the system path so we can import files
114    sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ]
115    import isa_parser
116
117    models = [ s.get_contents() for s in source[1:] ]
118    cpu_models = [CpuModel.dict[cpu] for cpu in models]
119    parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models)
120    parser.parse_isa_desc(source[0].abspath)
121
122# Also include the CheckerCPU as one of the models if it is being
123# enabled via command line.
124isa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter)
125
126env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
127
128TraceFlag('IntRegs')
129TraceFlag('FloatRegs')
130TraceFlag('MiscRegs')
131CompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ])
132