SConscript revision 6143
12155SN/A# -*- mode:python -*-
22155SN/A
32155SN/A# Copyright (c) 2006 The Regents of The University of Michigan
42155SN/A# All rights reserved.
52155SN/A#
62155SN/A# Redistribution and use in source and binary forms, with or without
72155SN/A# modification, are permitted provided that the following conditions are
82155SN/A# met: redistributions of source code must retain the above copyright
92155SN/A# notice, this list of conditions and the following disclaimer;
102155SN/A# redistributions in binary form must reproduce the above copyright
112155SN/A# notice, this list of conditions and the following disclaimer in the
122155SN/A# documentation and/or other materials provided with the distribution;
132155SN/A# neither the name of the copyright holders nor the names of its
142155SN/A# contributors may be used to endorse or promote products derived from
152155SN/A# this software without specific prior written permission.
162155SN/A#
172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu#
292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
302155SN/A
314202Sbinkertn@umich.eduimport sys
322155SN/A
339850Sandreas.hansson@arm.comImport('*')
349850Sandreas.hansson@arm.com
359850Sandreas.hansson@arm.com#################################################################
367768SAli.Saidi@ARM.com#
377768SAli.Saidi@ARM.com# ISA "switch header" generation.
3810695SAli.Saidi@ARM.com#
3910695SAli.Saidi@ARM.com# Auto-generate arch headers that include the right ISA-specific
4010695SAli.Saidi@ARM.com# header based on the setting of THE_ISA preprocessor variable.
4110695SAli.Saidi@ARM.com#
4210695SAli.Saidi@ARM.com#################################################################
438887Sgeoffrey.blake@arm.com
442766Sktlim@umich.edu# List of headers to generate
454486Sbinkertn@umich.eduisa_switch_hdrs = Split('''
4610663SAli.Saidi@ARM.com        arguments.hh
474486Sbinkertn@umich.edu        faults.hh
488739Sgblack@eecs.umich.edu        interrupts.hh
4910259SAndrew.Bardsley@arm.com        isa_traits.hh
504486Sbinkertn@umich.edu        kernel_stats.hh
514202Sbinkertn@umich.edu        locked_mem.hh
524202Sbinkertn@umich.edu        microcode_rom.hh
534202Sbinkertn@umich.edu        mmaped_ipr.hh
544202Sbinkertn@umich.edu        process.hh
5510319SAndreas.Sandberg@ARM.com        predecoder.hh
564202Sbinkertn@umich.edu        regfile.hh
574776Sgblack@eecs.umich.edu        remote_gdb.hh
588739Sgblack@eecs.umich.edu        stacktrace.hh
596365Sgblack@eecs.umich.edu        tlb.hh
604202Sbinkertn@umich.edu        types.hh
618777Sgblack@eecs.umich.edu        utility.hh
624202Sbinkertn@umich.edu        vtophys.hh
639913Ssteve.reinhardt@amd.com        ''')
644202Sbinkertn@umich.edu
654202Sbinkertn@umich.edu# Set up this directory to support switching headers
665217Ssaidi@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env)
674202Sbinkertn@umich.edu
6810259SAndrew.Bardsley@arm.com#################################################################
692155SN/A#
708887Sgeoffrey.blake@arm.com# Include architecture-specific files.
7110201SAndrew.Bardsley@arm.com#
728887Sgeoffrey.blake@arm.com#################################################################
739340SAndreas.Sandberg@arm.com
748887Sgeoffrey.blake@arm.com#
755192Ssaidi@eecs.umich.edu# Build a SCons scanner for ISA files
768335Snate@binkert.org#
778335Snate@binkert.orgimport SCons.Scanner
788335Snate@binkert.org
798335Snate@binkert.orgisa_scanner = SCons.Scanner.Classic("ISAScan",
808335Snate@binkert.org                                    [".isa", ".ISA"],
819534SAndreas.Sandberg@ARM.com                                    "SRCDIR",
829534SAndreas.Sandberg@ARM.com                                    r'^\s*##include\s+"([\w/.-]*)"')
839534SAndreas.Sandberg@ARM.com
848335Snate@binkert.orgenv.Append(SCANNERS = isa_scanner)
859534SAndreas.Sandberg@ARM.com
869534SAndreas.Sandberg@ARM.com#
878335Snate@binkert.org# Now create a Builder object that uses isa_parser.py to generate C++
889534SAndreas.Sandberg@ARM.com# output from the ISA description (*.isa) files.
899534SAndreas.Sandberg@ARM.com#
909534SAndreas.Sandberg@ARM.com
919534SAndreas.Sandberg@ARM.com# Convert to File node to fix path
929534SAndreas.Sandberg@ARM.comisa_parser = File('isa_parser.py')
939534SAndreas.Sandberg@ARM.comcpu_models_file = File('../cpu/cpu_models.py')
949534SAndreas.Sandberg@ARM.com
959534SAndreas.Sandberg@ARM.com# This sucks in the defintions of the CpuModel objects.
969534SAndreas.Sandberg@ARM.comexecfile(cpu_models_file.srcnode().abspath)
9710383Smitch.hayenga@arm.com
988335Snate@binkert.org# Several files are generated from the ISA description.
998335Snate@binkert.org# We always get the basic decoder and header file.
1008471SGiacomo.Gabrielli@arm.comisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ]
1018335Snate@binkert.org# We also get an execute file for each selected CPU model.
1028335Snate@binkert.orgisa_desc_gen_files += [CpuModel.dict[cpu].filename
10310529Smorr@cs.wisc.edu                       for cpu in env['CPU_MODELS']]
1045192Ssaidi@eecs.umich.edu
1058232Snate@binkert.org# Also include the CheckerCPU as one of the models if it is being
1068232Snate@binkert.org# enabled via command line.
10710664SAli.Saidi@ARM.comif env['USE_CHECKER']:
1088300Schander.sudanthi@arm.com    isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename]
10910383Smitch.hayenga@arm.com
1105192Ssaidi@eecs.umich.edu# The emitter patches up the sources & targets to include the
11111162Ssteve.reinhardt@amd.com# autogenerated files as targets and isa parser itself as a source.
11211162Ssteve.reinhardt@amd.comdef isa_desc_emitter(target, source, env):
11311162Ssteve.reinhardt@amd.com    return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source)
11411162Ssteve.reinhardt@amd.com
1158300Schander.sudanthi@arm.com# Pieces are in place, so create the builder.
116python = sys.executable  # use same Python binary used to run scons
117
118# Also include the CheckerCPU as one of the models if it is being
119# enabled via command line.
120if env['USE_CHECKER']:
121    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU',
122                               emitter = isa_desc_emitter)
123else:
124    isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS',
125                               emitter = isa_desc_emitter)
126
127env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder })
128
129TraceFlag('IntRegs')
130TraceFlag('FloatRegs')
131TraceFlag('MiscRegs')
132CompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ])
133