SConscript revision 7259
16019Shines@cs.fsu.edu# -*- mode:python -*- 26019Shines@cs.fsu.edu 310037SARM gem5 Developers# 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 arguments.hh 476019Shines@cs.fsu.edu faults.hh 4811320Ssteve.reinhardt@amd.com interrupts.hh 496019Shines@cs.fsu.edu isa.hh 509022Sgblack@eecs.umich.edu isa_traits.hh 516019Shines@cs.fsu.edu kernel_stats.hh 5212640Sgiacomo.travaglini@arm.com locked_mem.hh 5310037SARM gem5 Developers microcode_rom.hh 5410037SARM gem5 Developers mmaped_ipr.hh 557170Sgblack@eecs.umich.edu mt.hh 566253Sgblack@eecs.umich.edu process.hh 5710037SARM gem5 Developers predecoder.hh 587202Sgblack@eecs.umich.edu registers.hh 5910037SARM gem5 Developers remote_gdb.hh 606253Sgblack@eecs.umich.edu stacktrace.hh 6110611SAndreas.Sandberg@ARM.com tlb.hh 626253Sgblack@eecs.umich.edu types.hh 637396Sgblack@eecs.umich.edu utility.hh 6410037SARM gem5 Developers vtophys.hh 658745Sgblack@eecs.umich.edu ''') 667405SAli.Saidi@ARM.com 6710461SAndreas.Sandberg@ARM.com# Set up this directory to support switching headers 688782Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env) 698782Sgblack@eecs.umich.edu 708782Sgblack@eecs.umich.edu################################################################# 7110810Sbr@bsdpad.com# 7210810Sbr@bsdpad.com# Include architecture-specific files. 7310810Sbr@bsdpad.com# 747259Sgblack@eecs.umich.edu################################################################# 758757Sgblack@eecs.umich.edu 7610461SAndreas.Sandberg@ARM.com# 778782Sgblack@eecs.umich.edu# Build a SCons scanner for ISA files 788757Sgblack@eecs.umich.edu# 7912531Sandreas.sandberg@arm.comimport SCons.Scanner 808777Sgblack@eecs.umich.edu 818782Sgblack@eecs.umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan", 828756Sgblack@eecs.umich.edu [".isa", ".ISA"], 8310037SARM gem5 Developers "SRCDIR", 8410037SARM gem5 Developers r'^\s*##include\s+"([\w/.-]*)"') 856019Shines@cs.fsu.edu 8612605Sgiacomo.travaglini@arm.comenv.Append(SCANNERS = isa_scanner) 876757SAli.Saidi@ARM.com 888757Sgblack@eecs.umich.edu# 896019Shines@cs.fsu.edu# Now create a Builder object that uses isa_parser.py to generate C++ 908745Sgblack@eecs.umich.edu# output from the ISA description (*.isa) files. 919384SAndreas.Sandberg@arm.com# 926397Sgblack@eecs.umich.edu 9312531Sandreas.sandberg@arm.com# The emitter patches up the sources & targets to include the 948782Sgblack@eecs.umich.edu# autogenerated files as targets and isa parser itself as a source. 956019Shines@cs.fsu.edudef isa_desc_emitter(target, source, env): 9610461SAndreas.Sandberg@ARM.com cpu_models = list(env['CPU_MODELS']) 976397Sgblack@eecs.umich.edu if env['USE_CHECKER']: 988335Snate@binkert.org cpu_models.append('CheckerCPU') 9912531Sandreas.sandberg@arm.com 1009023Sgblack@eecs.umich.edu # Several files are generated from the ISA description. 1019023Sgblack@eecs.umich.edu # We always get the basic decoder and header file. 10210461SAndreas.Sandberg@ARM.com target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1038335Snate@binkert.org # We also get an execute file for each selected CPU model. 1046019Shines@cs.fsu.edu target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 10510196SCurtis.Dunham@arm.com 10612222Sgabeblack@google.com return target, source + [ Value(m) for m in cpu_models ] 107 108ARCH_DIR = Dir('.') 109 110# import ply here because SCons screws with sys.path when performing actions. 111import ply 112 113def isa_desc_action(target, source, env): 114 # Add the current directory to the system path so we can import files 115 sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 116 import isa_parser 117 118 models = [ s.get_contents() for s in source[1:] ] 119 cpu_models = [CpuModel.dict[cpu] for cpu in models] 120 parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 121 parser.parse_isa_desc(source[0].abspath) 122 123# Also include the CheckerCPU as one of the models if it is being 124# enabled via command line. 125isa_desc_builder = Builder(action=isa_desc_action, 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