SConscript revision 7816
16145SN/A# -*- mode:python -*-
28688SN/A
36145SN/A# Copyright (c) 2006 The Regents of The University of Michigan
46145SN/A# All rights reserved.
56145SN/A#
66145SN/A# Redistribution and use in source and binary forms, with or without
76145SN/A# modification, are permitted provided that the following conditions are
86145SN/A# met: redistributions of source code must retain the above copyright
96145SN/A# notice, this list of conditions and the following disclaimer;
106145SN/A# redistributions in binary form must reproduce the above copyright
116145SN/A# notice, this list of conditions and the following disclaimer in the
126145SN/A# documentation and/or other materials provided with the distribution;
136145SN/A# neither the name of the copyright holders nor the names of its
146145SN/A# contributors may be used to endorse or promote products derived from
156145SN/A# this software without specific prior written permission.
166145SN/A#
176145SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
186145SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
196145SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
206145SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216145SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
226145SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
236145SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
246145SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
256145SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
266145SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
276145SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
286145SN/A#
296145SN/A# Authors: Steve Reinhardt
307039SN/A
317039SN/Aimport sys
327039SN/A
336145SN/AImport('*')
346145SN/A
357039SN/A#################################################################
367039SN/A#
376145SN/A# ISA "switch header" generation.
387039SN/A#
399350SN/A# Auto-generate arch headers that include the right ISA-specific
4011108Sdavid.hashe@amd.com# header based on the setting of THE_ISA preprocessor variable.
4110301SN/A#
4210301SN/A#################################################################
4310301SN/A
447039SN/A# List of headers to generate
459206SN/Aisa_switch_hdrs = Split('''
466145SN/A        faults.hh
477039SN/A        interrupts.hh
4810920SN/A        isa.hh
496285SN/A        isa_traits.hh
509206SN/A        kernel_stats.hh
517039SN/A        locked_mem.hh
527039SN/A        microcode_rom.hh
538688SN/A        mmaped_ipr.hh
548688SN/A        mt.hh
558688SN/A        process.hh
568688SN/A        predecoder.hh
578688SN/A        registers.hh
5810919SN/A        remote_gdb.hh
598688SN/A        stacktrace.hh
608688SN/A        tlb.hh
618688SN/A        types.hh
628688SN/A        utility.hh
6310919SN/A        vtophys.hh
648688SN/A        ''')
658688SN/A
668688SN/A# Set up this directory to support switching headers
678688SN/Amake_switching_dir('arch', isa_switch_hdrs, env)
686876SN/A
696876SN/A#################################################################
707039SN/A#
716145SN/A# Include architecture-specific files.
727039SN/A#
737039SN/A#################################################################
749504SN/A
759504SN/A#
769504SN/A# Build a SCons scanner for ISA files
7710837SN/A#
7810837SN/Aimport SCons.Scanner
796285SN/A
8010525SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan",
8110918SN/A                                    [".isa", ".ISA"],
8211294Sandreas.hansson@arm.com                                    "SRCDIR",
8310525SN/A                                    r'^\s*##include\s+"([\w/.-]*)"')
847039SN/A
857039SN/Aenv.Append(SCANNERS = isa_scanner)
867039SN/A
877039SN/A#
8810012SN/A# Now create a Builder object that uses isa_parser.py to generate C++
8910012SN/A# output from the ISA description (*.isa) files.
907039SN/A#
916285SN/A
9211523Sdavid.guillen@arm.com# The emitter patches up the sources & targets to include the
9311523Sdavid.guillen@arm.com# autogenerated files as targets and isa parser itself as a source.
9411523Sdavid.guillen@arm.comdef isa_desc_emitter(target, source, env):
9511523Sdavid.guillen@arm.com    cpu_models = list(env['CPU_MODELS'])
9610012SN/A    if env['USE_CHECKER']:
9711169Sandreas.hansson@arm.com        cpu_models.append('CheckerCPU')
986285SN/A
9911169Sandreas.hansson@arm.com    # Several files are generated from the ISA description.
10011168Sandreas.hansson@arm.com    # We always get the basic decoder and header file.
10111168Sandreas.hansson@arm.com    target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
10211168Sandreas.hansson@arm.com    # We also get an execute file for each selected CPU model.
1038688SN/A    target += [CpuModel.dict[cpu].filename for cpu in cpu_models]
10411169Sandreas.hansson@arm.com
1059270SN/A    return target, source + [ Value(m) for m in cpu_models ]
1069270SN/A
1077562SN/AARCH_DIR = Dir('.')
1088436SN/A
1098436SN/A# import ply here because SCons screws with sys.path when performing actions.
1108436SN/Aimport ply
1118937SN/A
1128937SN/Adef isa_desc_action_func(target, source, env):
1138937SN/A    # Add the current directory to the system path so we can import files
1148937SN/A    sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ]
1158937SN/A    import isa_parser
1168937SN/A
1178937SN/A    models = [ s.get_contents() for s in source[1:] ]
1187039SN/A    cpu_models = [CpuModel.dict[cpu] for cpu in models]
1197039SN/A    parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models)
1207039SN/A    parser.parse_isa_desc(source[0].abspath)
1217039SN/Aisa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1))
1226285SN/A
12310991SN/A# Also include the CheckerCPU as one of the models if it is being
12411061SN/A# enabled via command line.
12511061SN/Aisa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter)
12610991SN/A
12711060SN/Aenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
12811060SN/A
12911061SN/ATraceFlag('IntRegs')
13011060SN/ATraceFlag('FloatRegs')
13111061SN/ATraceFlag('MiscRegs')
1327039SN/ACompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ])
1337039SN/A