SConscript revision 8745
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 faults.hh 476019Shines@cs.fsu.edu interrupts.hh 486019Shines@cs.fsu.edu isa.hh 496019Shines@cs.fsu.edu isa_traits.hh 509022Sgblack@eecs.umich.edu kernel_stats.hh 516019Shines@cs.fsu.edu locked_mem.hh 5210037SARM gem5 Developers microcode_rom.hh 5310037SARM gem5 Developers mmapped_ipr.hh 547170Sgblack@eecs.umich.edu mt.hh 556253Sgblack@eecs.umich.edu process.hh 5610037SARM gem5 Developers predecoder.hh 577202Sgblack@eecs.umich.edu registers.hh 5810037SARM gem5 Developers remote_gdb.hh 596253Sgblack@eecs.umich.edu stacktrace.hh 606253Sgblack@eecs.umich.edu tlb.hh 617396Sgblack@eecs.umich.edu types.hh 6210037SARM gem5 Developers utility.hh 638745Sgblack@eecs.umich.edu vtophys.hh 647405SAli.Saidi@ARM.com ''') 658782Sgblack@eecs.umich.edu 668782Sgblack@eecs.umich.edu# Set up this directory to support switching headers 678782Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env) 687259Sgblack@eecs.umich.edu 698757Sgblack@eecs.umich.edu################################################################# 708782Sgblack@eecs.umich.edu# 718757Sgblack@eecs.umich.edu# Include architecture-specific files. 728777Sgblack@eecs.umich.edu# 738782Sgblack@eecs.umich.edu################################################################# 748756Sgblack@eecs.umich.edu 7510037SARM gem5 Developers# 7610037SARM gem5 Developers# Build a SCons scanner for ISA files 776019Shines@cs.fsu.edu# 786757SAli.Saidi@ARM.comimport SCons.Scanner 798757Sgblack@eecs.umich.edu 806019Shines@cs.fsu.eduisa_scanner = SCons.Scanner.Classic("ISAScan", 818745Sgblack@eecs.umich.edu [".isa", ".ISA"], 829384SAndreas.Sandberg@arm.com "SRCDIR", 836397Sgblack@eecs.umich.edu r'^\s*##include\s+"([\w/.-]*)"') 848782Sgblack@eecs.umich.edu 856019Shines@cs.fsu.eduenv.Append(SCANNERS = isa_scanner) 866397Sgblack@eecs.umich.edu 878335Snate@binkert.org# 889023Sgblack@eecs.umich.edu# Now create a Builder object that uses isa_parser.py to generate C++ 899023Sgblack@eecs.umich.edu# output from the ISA description (*.isa) files. 908335Snate@binkert.org# 916019Shines@cs.fsu.edu 9210196SCurtis.Dunham@arm.comisa_parser = File('isa_parser.py') 9310196SCurtis.Dunham@arm.com 94# The emitter patches up the sources & targets to include the 95# autogenerated files as targets and isa parser itself as a source. 96def isa_desc_emitter(target, source, env): 97 cpu_models = list(env['CPU_MODELS']) 98 if env['USE_CHECKER']: 99 cpu_models.append('CheckerCPU') 100 101 # Several files are generated from the ISA description. 102 # We always get the basic decoder and header file. 103 target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 104 # We also get an execute file for each selected CPU model. 105 target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 106 107 # List the isa parser as a source. 108 source += [ isa_parser ] 109 # Add in the CPU models. 110 source += [ Value(m) for m in cpu_models ] 111 112 return target, source 113 114ARCH_DIR = Dir('.') 115 116# import ply here because SCons screws with sys.path when performing actions. 117import ply 118 119def isa_desc_action_func(target, source, env): 120 # Add the current directory to the system path so we can import files 121 sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 122 import isa_parser 123 124 # Skip over the ISA description itself and the parser to the CPU models. 125 models = [ s.get_contents() for s in source[2:] ] 126 cpu_models = [CpuModel.dict[cpu] for cpu in models] 127 parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 128 parser.parse_isa_desc(source[0].abspath) 129isa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1)) 130 131# Also include the CheckerCPU as one of the models if it is being 132# enabled via command line. 133isa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter) 134 135env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 136 137DebugFlag('IntRegs') 138DebugFlag('FloatRegs') 139DebugFlag('MiscRegs') 140CompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ]) 141