SConscript revision 5192
14120Sgblack@eecs.umich.edu# -*- mode:python -*- 24120Sgblack@eecs.umich.edu 37087Snate@binkert.org# Copyright (c) 2006 The Regents of The University of Michigan 47087Snate@binkert.org# All rights reserved. 57087Snate@binkert.org# 67087Snate@binkert.org# Redistribution and use in source and binary forms, with or without 77087Snate@binkert.org# modification, are permitted provided that the following conditions are 87087Snate@binkert.org# met: redistributions of source code must retain the above copyright 97087Snate@binkert.org# notice, this list of conditions and the following disclaimer; 107087Snate@binkert.org# redistributions in binary form must reproduce the above copyright 117087Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 127087Snate@binkert.org# documentation and/or other materials provided with the distribution; 137087Snate@binkert.org# neither the name of the copyright holders nor the names of its 147087Snate@binkert.org# contributors may be used to endorse or promote products derived from 154120Sgblack@eecs.umich.edu# this software without specific prior written permission. 164120Sgblack@eecs.umich.edu# 174120Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184120Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194120Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 204120Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 214120Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 224120Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 234120Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 244120Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 254120Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 264120Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 274120Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 284120Sgblack@eecs.umich.edu# 294120Sgblack@eecs.umich.edu# Authors: Steve Reinhardt 304120Sgblack@eecs.umich.edu 314120Sgblack@eecs.umich.eduimport sys 324120Sgblack@eecs.umich.edu 334120Sgblack@eecs.umich.eduImport('*') 344120Sgblack@eecs.umich.edu 354120Sgblack@eecs.umich.edu################################################################# 364120Sgblack@eecs.umich.edu# 374120Sgblack@eecs.umich.edu# ISA "switch header" generation. 384120Sgblack@eecs.umich.edu# 394120Sgblack@eecs.umich.edu# Auto-generate arch headers that include the right ISA-specific 404120Sgblack@eecs.umich.edu# header based on the setting of THE_ISA preprocessor variable. 414120Sgblack@eecs.umich.edu# 424120Sgblack@eecs.umich.edu################################################################# 434202Sbinkertn@umich.edu 445069Sgblack@eecs.umich.edu# List of headers to generate 454202Sbinkertn@umich.eduisa_switch_hdrs = Split(''' 465659Sgblack@eecs.umich.edu arguments.hh 474601Sgblack@eecs.umich.edu faults.hh 485124Sgblack@eecs.umich.edu interrupts.hh 497966Sgblack@eecs.umich.edu isa_traits.hh 505083Sgblack@eecs.umich.edu kernel_stats.hh 514679Sgblack@eecs.umich.edu locked_mem.hh 526515Sgblack@eecs.umich.edu mmaped_ipr.hh 535083Sgblack@eecs.umich.edu process.hh 544679Sgblack@eecs.umich.edu predecoder.hh 554679Sgblack@eecs.umich.edu regfile.hh 568745Sgblack@eecs.umich.edu remote_gdb.hh 576313Sgblack@eecs.umich.edu stacktrace.hh 586365Sgblack@eecs.umich.edu syscallreturn.hh 595124Sgblack@eecs.umich.edu tlb.hh 608752Sgblack@eecs.umich.edu types.hh 614249Sgblack@eecs.umich.edu utility.hh 624240Sgblack@eecs.umich.edu vtophys.hh 634202Sbinkertn@umich.edu ''') 644997Sgblack@eecs.umich.edu 657624Sgblack@eecs.umich.edu# Set up this directory to support switching headers 665135Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env) 678753Sgblack@eecs.umich.edu 684997Sgblack@eecs.umich.edu################################################################# 698745Sgblack@eecs.umich.edu# 706365Sgblack@eecs.umich.edu# Include architecture-specific files. 718740Sgblack@eecs.umich.edu# 726365Sgblack@eecs.umich.edu################################################################# 738740Sgblack@eecs.umich.edu 748745Sgblack@eecs.umich.edu# 758752Sgblack@eecs.umich.edu# Build a SCons scanner for ISA files 768752Sgblack@eecs.umich.edu# 778335Snate@binkert.orgimport SCons.Scanner 788335Snate@binkert.org 794120Sgblack@eecs.umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan", 804202Sbinkertn@umich.edu [".isa", ".ISA"], 815649Sgblack@eecs.umich.edu "SRCDIR", 825132Sgblack@eecs.umich.edu r'^\s*##include\s+"([\w/.-]*)"') 835132Sgblack@eecs.umich.edu 844202Sbinkertn@umich.eduenv.Append(SCANNERS = isa_scanner) 855299Sgblack@eecs.umich.edu 865132Sgblack@eecs.umich.edu# 875086Sgblack@eecs.umich.edu# Now create a Builder object that uses isa_parser.py to generate C++ 884202Sbinkertn@umich.edu# output from the ISA description (*.isa) files. 894202Sbinkertn@umich.edu# 904120Sgblack@eecs.umich.edu 914202Sbinkertn@umich.edu# Convert to File node to fix path 924202Sbinkertn@umich.eduisa_parser = File('isa_parser.py') 934202Sbinkertn@umich.educpu_models_file = File('../cpu/cpu_models.py') 944120Sgblack@eecs.umich.edu 955069Sgblack@eecs.umich.edu# This sucks in the defintions of the CpuModel objects. 965081Sgblack@eecs.umich.eduexecfile(cpu_models_file.srcnode().abspath) 975081Sgblack@eecs.umich.edu 985081Sgblack@eecs.umich.edu# Several files are generated from the ISA description. 995081Sgblack@eecs.umich.edu# We always get the basic decoder and header file. 1005081Sgblack@eecs.umich.eduisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh' ] 1015081Sgblack@eecs.umich.edu# We also get an execute file for each selected CPU model. 1025081Sgblack@eecs.umich.eduisa_desc_gen_files += [CpuModel.dict[cpu].filename 1035081Sgblack@eecs.umich.edu for cpu in env['CPU_MODELS']] 1045081Sgblack@eecs.umich.edu 1055081Sgblack@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being 1065081Sgblack@eecs.umich.edu# enabled via command line. 1075081Sgblack@eecs.umich.eduif env['USE_CHECKER']: 1085081Sgblack@eecs.umich.edu isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 1095081Sgblack@eecs.umich.edu 1105081Sgblack@eecs.umich.edu# The emitter patches up the sources & targets to include the 1115081Sgblack@eecs.umich.edu# autogenerated files as targets and isa parser itself as a source. 1125081Sgblack@eecs.umich.edudef isa_desc_emitter(target, source, env): 1135081Sgblack@eecs.umich.edu return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 1145081Sgblack@eecs.umich.edu 1155081Sgblack@eecs.umich.edu# Pieces are in place, so create the builder. 1165081Sgblack@eecs.umich.edupython = sys.executable # use same Python binary used to run scons 1175081Sgblack@eecs.umich.edu 1185081Sgblack@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being 1195081Sgblack@eecs.umich.edu# enabled via command line. 1205081Sgblack@eecs.umich.eduif env['USE_CHECKER']: 1215081Sgblack@eecs.umich.edu isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU', 1225081Sgblack@eecs.umich.edu emitter = isa_desc_emitter) 1235081Sgblack@eecs.umich.eduelse: 1245081Sgblack@eecs.umich.edu isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS', 1255081Sgblack@eecs.umich.edu emitter = isa_desc_emitter) 1265081Sgblack@eecs.umich.edu 1275081Sgblack@eecs.umich.eduenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 1285081Sgblack@eecs.umich.edu