SConscript revision 5780
16019Shines@cs.fsu.edu# -*- mode:python -*-
26019Shines@cs.fsu.edu
37100Sgblack@eecs.umich.edu# 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        arguments.hh
476019Shines@cs.fsu.edu        faults.hh
486019Shines@cs.fsu.edu        interrupts.hh
496019Shines@cs.fsu.edu        isa_traits.hh
506019Shines@cs.fsu.edu        kernel_stats.hh
517170Sgblack@eecs.umich.edu        locked_mem.hh
526253Sgblack@eecs.umich.edu        microcode_rom.hh
537202Sgblack@eecs.umich.edu        mmaped_ipr.hh
546253Sgblack@eecs.umich.edu        process.hh
556253Sgblack@eecs.umich.edu        predecoder.hh
567396Sgblack@eecs.umich.edu        regfile.hh
578745Sgblack@eecs.umich.edu        remote_gdb.hh
587405SAli.Saidi@ARM.com        stacktrace.hh
598782Sgblack@eecs.umich.edu        syscallreturn.hh
608782Sgblack@eecs.umich.edu        tlb.hh
618782Sgblack@eecs.umich.edu        types.hh
627259Sgblack@eecs.umich.edu        utility.hh
638757Sgblack@eecs.umich.edu        vtophys.hh
647423Sgblack@eecs.umich.edu        ''')
658782Sgblack@eecs.umich.edu
668757Sgblack@eecs.umich.edu# Set up this directory to support switching headers
678777Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env)
688782Sgblack@eecs.umich.edu
698756Sgblack@eecs.umich.edu#################################################################
706019Shines@cs.fsu.edu#
716757SAli.Saidi@ARM.com# Include architecture-specific files.
728757Sgblack@eecs.umich.edu#
736019Shines@cs.fsu.edu#################################################################
748745Sgblack@eecs.umich.edu
756397Sgblack@eecs.umich.edu#
768782Sgblack@eecs.umich.edu# Build a SCons scanner for ISA files
776019Shines@cs.fsu.edu#
786397Sgblack@eecs.umich.eduimport SCons.Scanner
798335Snate@binkert.org
808335Snate@binkert.orgisa_scanner = SCons.Scanner.Classic("ISAScan",
818335Snate@binkert.org                                    [".isa", ".ISA"],
828335Snate@binkert.org                                    "SRCDIR",
836019Shines@cs.fsu.edu                                    r'^\s*##include\s+"([\w/.-]*)"')
846019Shines@cs.fsu.edu
856019Shines@cs.fsu.eduenv.Append(SCANNERS = isa_scanner)
866019Shines@cs.fsu.edu
876019Shines@cs.fsu.edu#
886019Shines@cs.fsu.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.
906019Shines@cs.fsu.edu#
91
92# Convert to File node to fix path
93isa_parser = File('isa_parser.py')
94cpu_models_file = File('../cpu/cpu_models.py')
95
96# This sucks in the defintions of the CpuModel objects.
97execfile(cpu_models_file.srcnode().abspath)
98
99# Several files are generated from the ISA description.
100# We always get the basic decoder and header file.
101isa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
102# We also get an execute file for each selected CPU model.
103isa_desc_gen_files += [CpuModel.dict[cpu].filename
104                       for cpu in env['CPU_MODELS']]
105
106# Also include the CheckerCPU as one of the models if it is being
107# enabled via command line.
108if env['USE_CHECKER']:
109    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
110
111# The emitter patches up the sources & targets to include the
112# autogenerated files as targets and isa parser itself as a source.
113def isa_desc_emitter(target, source, env):
114    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
115
116# Pieces are in place, so create the builder.
117python = sys.executable  # use same Python binary used to run scons
118
119# Also include the CheckerCPU as one of the models if it is being
120# enabled via command line.
121if env['USE_CHECKER']:
122    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
123                               emitter = isa_desc_emitter)
124else:
125    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
126                               emitter = isa_desc_emitter)
127
128env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
129