SConscript revision 7585
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        faults.hh
476019Shines@cs.fsu.edu        interrupts.hh
486019Shines@cs.fsu.edu	isa.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        mt.hh
556253Sgblack@eecs.umich.edu        process.hh
567396Sgblack@eecs.umich.edu        predecoder.hh
577405SAli.Saidi@ARM.com        registers.hh
587259Sgblack@eecs.umich.edu        remote_gdb.hh
597423Sgblack@eecs.umich.edu        stacktrace.hh
606397Sgblack@eecs.umich.edu        tlb.hh
616019Shines@cs.fsu.edu        types.hh
626757SAli.Saidi@ARM.com        utility.hh
637752SWilliam.Wang@arm.com        vtophys.hh
646019Shines@cs.fsu.edu        ''')
656397Sgblack@eecs.umich.edu
666019Shines@cs.fsu.edu# Set up this directory to support switching headers
676397Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env)
688335Snate@binkert.org
698335Snate@binkert.org#################################################################
708335Snate@binkert.org#
718335Snate@binkert.org# Include architecture-specific files.
726019Shines@cs.fsu.edu#
736757SAli.Saidi@ARM.com#################################################################
746757SAli.Saidi@ARM.com
756757SAli.Saidi@ARM.com#
767694SAli.Saidi@ARM.com# Build a SCons scanner for ISA files
777585SAli.Saidi@arm.com#
787404SAli.Saidi@ARM.comimport SCons.Scanner
796757SAli.Saidi@ARM.com
806757SAli.Saidi@ARM.comisa_scanner = SCons.Scanner.Classic("ISAScan",
816757SAli.Saidi@ARM.com                                    [".isa", ".ISA"],
826019Shines@cs.fsu.edu                                    "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#
916019Shines@cs.fsu.edu
926019Shines@cs.fsu.edu# The emitter patches up the sources & targets to include the
936019Shines@cs.fsu.edu# autogenerated files as targets and isa parser itself as a source.
94def isa_desc_emitter(target, source, env):
95    cpu_models = list(env['CPU_MODELS'])
96    if env['USE_CHECKER']:
97        cpu_models.append('CheckerCPU')
98
99    # Several files are generated from the ISA description.
100    # We always get the basic decoder and header file.
101    target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
102    # We also get an execute file for each selected CPU model.
103    target += [CpuModel.dict[cpu].filename for cpu in cpu_models]
104
105    return target, source + [ Value(m) for m in cpu_models ]
106
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