SConscript revision 7756
112841Sgabeblack@google.com# -*- mode:python -*- 212841Sgabeblack@google.com 312841Sgabeblack@google.com# Copyright (c) 2006 The Regents of The University of Michigan 412841Sgabeblack@google.com# All rights reserved. 512841Sgabeblack@google.com# 612841Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 712841Sgabeblack@google.com# modification, are permitted provided that the following conditions are 812841Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 912841Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 1012841Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 1112841Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 1212841Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1312841Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1412841Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1512841Sgabeblack@google.com# this software without specific prior written permission. 1612841Sgabeblack@google.com# 1712841Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812841Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912841Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012841Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112841Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212841Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312841Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412841Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512841Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612841Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712841Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812841Sgabeblack@google.com# 2912841Sgabeblack@google.com# Authors: Steve Reinhardt 3012841Sgabeblack@google.com 3113065Sgabeblack@google.comimport sys 3213065Sgabeblack@google.com 3313065Sgabeblack@google.comImport('*') 3413065Sgabeblack@google.com 3513135Sgabeblack@google.com################################################################# 3613065Sgabeblack@google.com# 3713065Sgabeblack@google.com# ISA "switch header" generation. 3812841Sgabeblack@google.com# 3912841Sgabeblack@google.com# Auto-generate arch headers that include the right ISA-specific 4012841Sgabeblack@google.com# header based on the setting of THE_ISA preprocessor variable. 4113065Sgabeblack@google.com# 4213065Sgabeblack@google.com################################################################# 4313065Sgabeblack@google.com 4413065Sgabeblack@google.com# List of headers to generate 4513065Sgabeblack@google.comisa_switch_hdrs = Split(''' 4613065Sgabeblack@google.com faults.hh 4713065Sgabeblack@google.com interrupts.hh 4813065Sgabeblack@google.com isa.hh 4913065Sgabeblack@google.com isa_traits.hh 5013065Sgabeblack@google.com kernel_stats.hh 5113065Sgabeblack@google.com locked_mem.hh 5213065Sgabeblack@google.com microcode_rom.hh 5313065Sgabeblack@google.com mmaped_ipr.hh 5413065Sgabeblack@google.com mt.hh 5513065Sgabeblack@google.com process.hh 5613065Sgabeblack@google.com predecoder.hh 5713065Sgabeblack@google.com registers.hh 5813065Sgabeblack@google.com remote_gdb.hh 5913065Sgabeblack@google.com stacktrace.hh 6013065Sgabeblack@google.com tlb.hh 6113065Sgabeblack@google.com types.hh 6213065Sgabeblack@google.com utility.hh 6313065Sgabeblack@google.com vtophys.hh 6413135Sgabeblack@google.com ''') 6513135Sgabeblack@google.com 6613065Sgabeblack@google.com# Set up this directory to support switching headers 6713065Sgabeblack@google.commake_switching_dir('arch', isa_switch_hdrs, env) 6813065Sgabeblack@google.com 6913065Sgabeblack@google.com################################################################# 7013065Sgabeblack@google.com# 7113065Sgabeblack@google.com# Include architecture-specific files. 7213065Sgabeblack@google.com# 7313065Sgabeblack@google.com################################################################# 7413065Sgabeblack@google.com 7513065Sgabeblack@google.com# 7613065Sgabeblack@google.com# Build a SCons scanner for ISA files 7713065Sgabeblack@google.com# 7813065Sgabeblack@google.comimport SCons.Scanner 7913065Sgabeblack@google.com 8013065Sgabeblack@google.comisa_scanner = SCons.Scanner.Classic("ISAScan", 8113065Sgabeblack@google.com [".isa", ".ISA"], 8213065Sgabeblack@google.com "SRCDIR", 8313065Sgabeblack@google.com r'^\s*##include\s+"([\w/.-]*)"') 8413065Sgabeblack@google.com 8513065Sgabeblack@google.comenv.Append(SCANNERS = isa_scanner) 8612841Sgabeblack@google.com 8712841Sgabeblack@google.com# 8812841Sgabeblack@google.com# Now create a Builder object that uses isa_parser.py to generate C++ 8912841Sgabeblack@google.com# output from the ISA description (*.isa) files. 9013065Sgabeblack@google.com# 9113065Sgabeblack@google.com 9213065Sgabeblack@google.com# The emitter patches up the sources & targets to include the 9312841Sgabeblack@google.com# autogenerated files as targets and isa parser itself as a source. 9413065Sgabeblack@google.comdef isa_desc_emitter(target, source, env): 9513065Sgabeblack@google.com cpu_models = list(env['CPU_MODELS']) 9613065Sgabeblack@google.com if env['USE_CHECKER']: 9712841Sgabeblack@google.com cpu_models.append('CheckerCPU') 9812841Sgabeblack@google.com 9912841Sgabeblack@google.com # Several files are generated from the ISA description. 10013065Sgabeblack@google.com # We always get the basic decoder and header file. 10113065Sgabeblack@google.com target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 10213065Sgabeblack@google.com # We also get an execute file for each selected CPU model. 10313065Sgabeblack@google.com target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 10412841Sgabeblack@google.com 10513065Sgabeblack@google.com return target, source + [ Value(m) for m in cpu_models ] 10613065Sgabeblack@google.com 10712841Sgabeblack@google.comARCH_DIR = Dir('.') 10812841Sgabeblack@google.com 10912841Sgabeblack@google.com# import ply here because SCons screws with sys.path when performing actions. 11013065Sgabeblack@google.comimport ply 11113065Sgabeblack@google.com 11213065Sgabeblack@google.comdef isa_desc_action_func(target, source, env): 11313065Sgabeblack@google.com # Add the current directory to the system path so we can import files 11412841Sgabeblack@google.com sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 11512841Sgabeblack@google.com import isa_parser 11612841Sgabeblack@google.com 11713065Sgabeblack@google.com models = [ s.get_contents() for s in source[1:] ] 11813065Sgabeblack@google.com cpu_models = [CpuModel.dict[cpu] for cpu in models] 11913065Sgabeblack@google.com parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 12013065Sgabeblack@google.com parser.parse_isa_desc(source[0].abspath) 12112841Sgabeblack@google.comisa_desc_action = MakeAction(isa_desc_action_func, " [ISA DESC] $STRIP_SOURCE") 12212878Sgabeblack@google.com 12313065Sgabeblack@google.com# Also include the CheckerCPU as one of the models if it is being 12413065Sgabeblack@google.com# enabled via command line. 12513065Sgabeblack@google.comisa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter) 12613065Sgabeblack@google.com 12713065Sgabeblack@google.comenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 12813065Sgabeblack@google.com 12912878Sgabeblack@google.comTraceFlag('IntRegs') 13013065Sgabeblack@google.comTraceFlag('FloatRegs') 13113065Sgabeblack@google.comTraceFlag('MiscRegs') 13213065Sgabeblack@google.comCompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ]) 13313065Sgabeblack@google.com