SConscript revision 8777
12139SN/A# -*- mode:python -*- 22139SN/A 32139SN/A# Copyright (c) 2006 The Regents of The University of Michigan 42139SN/A# All rights reserved. 52139SN/A# 62139SN/A# Redistribution and use in source and binary forms, with or without 72139SN/A# modification, are permitted provided that the following conditions are 82139SN/A# met: redistributions of source code must retain the above copyright 92139SN/A# notice, this list of conditions and the following disclaimer; 102139SN/A# redistributions in binary form must reproduce the above copyright 112139SN/A# notice, this list of conditions and the following disclaimer in the 122139SN/A# documentation and/or other materials provided with the distribution; 132139SN/A# neither the name of the copyright holders nor the names of its 142139SN/A# contributors may be used to endorse or promote products derived from 152139SN/A# this software without specific prior written permission. 162139SN/A# 172139SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182139SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192139SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202139SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212139SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222139SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232139SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242139SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252139SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262139SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272139SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 302139SN/A 314202Sbinkertn@umich.eduimport sys 328961Sgblack@eecs.umich.edu 3310196SCurtis.Dunham@arm.comImport('*') 342139SN/A 354202Sbinkertn@umich.edu################################################################# 362152SN/A# 372152SN/A# ISA "switch header" generation. 382139SN/A# 392139SN/A# Auto-generate arch headers that include the right ISA-specific 402139SN/A# header based on the setting of THE_ISA preprocessor variable. 412139SN/A# 422139SN/A################################################################# 432152SN/A 442152SN/A# List of headers to generate 452139SN/Aisa_switch_hdrs = Split(''' 462139SN/A faults.hh 472139SN/A interrupts.hh 489020Sgblack@eecs.umich.edu isa.hh 494781Snate@binkert.org isa_traits.hh 507799Sgblack@eecs.umich.edu kernel_stats.hh 514781Snate@binkert.org locked_mem.hh 524781Snate@binkert.org microcode_rom.hh 533170Sstever@eecs.umich.edu mmapped_ipr.hh 545664Sgblack@eecs.umich.edu mt.hh 558105Sgblack@eecs.umich.edu process.hh 566179Sksewell@umich.edu predecoder.hh 574781Snate@binkert.org registers.hh 5810553Salexandru.dutu@amd.com remote_gdb.hh 596329Sgblack@eecs.umich.edu stacktrace.hh 604781Snate@binkert.org tlb.hh 614781Snate@binkert.org types.hh 624781Snate@binkert.org utility.hh 634781Snate@binkert.org vtophys.hh 644781Snate@binkert.org ''') 654781Snate@binkert.org 662139SN/A# Set up this directory to support switching headers 672139SN/Amake_switching_dir('arch', isa_switch_hdrs, env) 683546Sgblack@eecs.umich.edu 694202Sbinkertn@umich.edu################################################################# 702152SN/A# 712152SN/A# Include architecture-specific files. 722152SN/A# 732152SN/A################################################################# 742152SN/A 752152SN/A# 762152SN/A# Build a SCons scanner for ISA files 772152SN/A# 782152SN/Aimport SCons.Scanner 792152SN/A 802152SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan", 812152SN/A [".isa", ".ISA"], 822504SN/A "SRCDIR", 832504SN/A r'^\s*##include\s+"([\w/.-]*)"') 842504SN/A 852504SN/Aenv.Append(SCANNERS = isa_scanner) 862152SN/A 872504SN/A# 882152SN/A# Now create a Builder object that uses isa_parser.py to generate C++ 892152SN/A# output from the ISA description (*.isa) files. 902152SN/A# 912152SN/A 922152SN/Aisa_parser = File('isa_parser.py') 932152SN/A 948584Sgblack@eecs.umich.edu# The emitter patches up the sources & targets to include the 958584Sgblack@eecs.umich.edu# autogenerated files as targets and isa parser itself as a source. 966993Snate@binkert.orgdef isa_desc_emitter(target, source, env): 976993Snate@binkert.org cpu_models = list(env['CPU_MODELS']) 986993Snate@binkert.org if env['USE_CHECKER']: 998584Sgblack@eecs.umich.edu cpu_models.append('CheckerCPU') 10010319SAndreas.Sandberg@ARM.com 10110319SAndreas.Sandberg@ARM.com # Several files are generated from the ISA description. 10210319SAndreas.Sandberg@ARM.com # We always get the basic decoder and header file. 10310319SAndreas.Sandberg@ARM.com target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1048584Sgblack@eecs.umich.edu # We also get an execute file for each selected CPU model. 10510196SCurtis.Dunham@arm.com target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 10610196SCurtis.Dunham@arm.com 10710196SCurtis.Dunham@arm.com # List the isa parser as a source. 10810196SCurtis.Dunham@arm.com source += [ isa_parser ] 10910196SCurtis.Dunham@arm.com # Add in the CPU models. 11010196SCurtis.Dunham@arm.com source += [ Value(m) for m in cpu_models ] 11110196SCurtis.Dunham@arm.com 11210196SCurtis.Dunham@arm.com return target, source 11310196SCurtis.Dunham@arm.com 11410196SCurtis.Dunham@arm.comARCH_DIR = Dir('.') 11510196SCurtis.Dunham@arm.com 11610196SCurtis.Dunham@arm.com# import ply here because SCons screws with sys.path when performing actions. 11710196SCurtis.Dunham@arm.comimport ply 11810196SCurtis.Dunham@arm.com 11910196SCurtis.Dunham@arm.comdef isa_desc_action_func(target, source, env): 12010196SCurtis.Dunham@arm.com # Add the current directory to the system path so we can import files 12110196SCurtis.Dunham@arm.com sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 12210196SCurtis.Dunham@arm.com import isa_parser 12310196SCurtis.Dunham@arm.com 12410196SCurtis.Dunham@arm.com # Skip over the ISA description itself and the parser to the CPU models. 12510196SCurtis.Dunham@arm.com models = [ s.get_contents() for s in source[2:] ] 1266993Snate@binkert.org cpu_models = [CpuModel.dict[cpu] for cpu in models] 1276993Snate@binkert.org parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 1286993Snate@binkert.org parser.parse_isa_desc(source[0].abspath) 1296998Snate@binkert.orgisa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1)) 1306998Snate@binkert.org 1316998Snate@binkert.org# Also include the CheckerCPU as one of the models if it is being 1327756SAli.Saidi@ARM.com# enabled via command line. 1336993Snate@binkert.orgisa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter) 1346993Snate@binkert.org 1356993Snate@binkert.orgenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 1366993Snate@binkert.org 1378585Sgblack@eecs.umich.eduDebugFlag('IntRegs') 1388584Sgblack@eecs.umich.eduDebugFlag('FloatRegs') 13910319SAndreas.Sandberg@ARM.comDebugFlag('MiscRegs') 1406993Snate@binkert.orgCompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ]) 1417816Ssteve.reinhardt@amd.com