SConscript revision 4550
14120Sgblack@eecs.umich.edu# -*- mode:python -*- 24120Sgblack@eecs.umich.edu 34120Sgblack@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 44120Sgblack@eecs.umich.edu# All rights reserved. 54120Sgblack@eecs.umich.edu# 64120Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 74120Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 84120Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 94120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 104120Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 114120Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 124120Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 134120Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 144120Sgblack@eecs.umich.edu# 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################################################################# 434120Sgblack@eecs.umich.edu 444120Sgblack@eecs.umich.edu# List of headers to generate 454120Sgblack@eecs.umich.eduisa_switch_hdrs = Split(''' 464120Sgblack@eecs.umich.edu arguments.hh 474120Sgblack@eecs.umich.edu faults.hh 484120Sgblack@eecs.umich.edu interrupts.hh 494120Sgblack@eecs.umich.edu isa_traits.hh 504120Sgblack@eecs.umich.edu kernel_stats.hh 514120Sgblack@eecs.umich.edu locked_mem.hh 524120Sgblack@eecs.umich.edu mmaped_ipr.hh 534120Sgblack@eecs.umich.edu process.hh 544120Sgblack@eecs.umich.edu predecoder.hh 554120Sgblack@eecs.umich.edu regfile.hh 564120Sgblack@eecs.umich.edu remote_gdb.hh 574120Sgblack@eecs.umich.edu stacktrace.hh 584120Sgblack@eecs.umich.edu syscallreturn.hh 594120Sgblack@eecs.umich.edu tlb.hh 604120Sgblack@eecs.umich.edu types.hh 614120Sgblack@eecs.umich.edu utility.hh 624120Sgblack@eecs.umich.edu vtophys.hh 634120Sgblack@eecs.umich.edu ''') 644120Sgblack@eecs.umich.edu 654120Sgblack@eecs.umich.edu# Set up this directory to support switching headers 664120Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env) 674120Sgblack@eecs.umich.edu 684120Sgblack@eecs.umich.edu################################################################# 694120Sgblack@eecs.umich.edu# 704120Sgblack@eecs.umich.edu# Include architecture-specific files. 714120Sgblack@eecs.umich.edu# 724120Sgblack@eecs.umich.edu################################################################# 734120Sgblack@eecs.umich.edu 744120Sgblack@eecs.umich.edu# 754120Sgblack@eecs.umich.edu# Build a SCons scanner for ISA files 764120Sgblack@eecs.umich.edu# 774120Sgblack@eecs.umich.eduimport SCons.Scanner 784120Sgblack@eecs.umich.edu 794120Sgblack@eecs.umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan", 804120Sgblack@eecs.umich.edu [".isa", ".ISA"], 814120Sgblack@eecs.umich.edu "SRCDIR", 824120Sgblack@eecs.umich.edu r'^\s*##include\s+"([\w/.-]*)"') 834120Sgblack@eecs.umich.edu 844120Sgblack@eecs.umich.eduenv.Append(SCANNERS = isa_scanner) 854120Sgblack@eecs.umich.edu 864202Sbinkertn@umich.edu# 874202Sbinkertn@umich.edu# Now create a Builder object that uses isa_parser.py to generate C++ 884601Sgblack@eecs.umich.edu# output from the ISA description (*.isa) files. 894202Sbinkertn@umich.edu# 904679Sgblack@eecs.umich.edu 914679Sgblack@eecs.umich.edu# Convert to File node to fix path 924679Sgblack@eecs.umich.eduisa_parser = File('isa_parser.py') 934202Sbinkertn@umich.educpu_models_file = File('../cpu/cpu_models.py') 944202Sbinkertn@umich.edu 954249Sgblack@eecs.umich.edu# This sucks in the defintions of the CpuModel objects. 964240Sgblack@eecs.umich.eduexecfile(cpu_models_file.srcnode().abspath) 974202Sbinkertn@umich.edu 984202Sbinkertn@umich.edu# Several files are generated from the ISA description. 994120Sgblack@eecs.umich.edu# We always get the basic decoder and header file. 1004202Sbinkertn@umich.eduisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh' ] 1014202Sbinkertn@umich.edu# We also get an execute file for each selected CPU model. 1024202Sbinkertn@umich.eduisa_desc_gen_files += [CpuModel.dict[cpu].filename 1034202Sbinkertn@umich.edu for cpu in env['CPU_MODELS']] 1044202Sbinkertn@umich.edu 1054120Sgblack@eecs.umich.edu# Also include the CheckerCPU as one of the models if it is being 1064202Sbinkertn@umich.edu# enabled via command line. 1074202Sbinkertn@umich.eduif env['USE_CHECKER']: 1084202Sbinkertn@umich.edu isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 1094120Sgblack@eecs.umich.edu 1104202Sbinkertn@umich.edu# The emitter patches up the sources & targets to include the 1114202Sbinkertn@umich.edu# autogenerated files as targets and isa parser itself as a source. 1124202Sbinkertn@umich.edudef isa_desc_emitter(target, source, env): 1134202Sbinkertn@umich.edu return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 1144202Sbinkertn@umich.edu 1154202Sbinkertn@umich.edu# 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