SConscript revision 9651
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 312139SN/Aimport sys 322139SN/Aimport os 332139SN/A 342139SN/AImport('*') 352139SN/A 362152SN/A################################################################# 372152SN/A# 382152SN/A# ISA "switch header" generation. 392152SN/A# 402139SN/A# Auto-generate arch headers that include the right ISA-specific 412139SN/A# header based on the setting of THE_ISA preprocessor variable. 422139SN/A# 432139SN/A################################################################# 442139SN/A 452152SN/A# List of headers to generate 462152SN/Aisa_switch_hdrs = Split(''' 472139SN/A decoder.hh 482139SN/A interrupts.hh 492139SN/A isa.hh 502439SN/A isa_traits.hh 512439SN/A kernel_stats.hh 522439SN/A locked_mem.hh 532139SN/A microcode_rom.hh 542439SN/A mmapped_ipr.hh 552460SN/A mt.hh 562439SN/A process.hh 572171SN/A registers.hh 582439SN/A remote_gdb.hh 592439SN/A stacktrace.hh 602170SN/A tlb.hh 612139SN/A types.hh 622139SN/A utility.hh 632139SN/A vtophys.hh 642139SN/A ''') 652139SN/A 662139SN/A# Set up this directory to support switching headers 672139SN/Amake_switching_dir('arch', isa_switch_hdrs, env) 682139SN/A 692139SN/A################################################################# 702139SN/A# 712139SN/A# Include architecture-specific files. 722139SN/A# 732139SN/A################################################################# 742139SN/A 752139SN/A# 762139SN/A# Build a SCons scanner for ISA files 772139SN/A# 782139SN/Aimport SCons.Scanner 792139SN/A 802139SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan", 812139SN/A [".isa", ".ISA"], 822139SN/A "SRCDIR", 832139SN/A r'^\s*##include\s+"([\w/.-]*)"') 842139SN/A 852178SN/Aenv.Append(SCANNERS = isa_scanner) 862139SN/A 872139SN/A# 882139SN/A# Now create a Builder object that uses isa_parser.py to generate C++ 892139SN/A# output from the ISA description (*.isa) files. 902139SN/A# 912139SN/A 922139SN/Aisa_parser = File('isa_parser.py') 932152SN/A 942152SN/A# The emitter patches up the sources & targets to include the 952152SN/A# autogenerated files as targets and isa parser itself as a source. 962152SN/Adef isa_desc_emitter(target, source, env): 972152SN/A cpu_models = list(env['CPU_MODELS']) 982152SN/A cpu_models.append('CheckerCPU') 992152SN/A 1002152SN/A # Several files are generated from the ISA description. 1012152SN/A # We always get the basic decoder and header file. 1022152SN/A target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1032152SN/A # We also get an execute file for each selected CPU model. 1042152SN/A target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 1052504SN/A 1062504SN/A # List the isa parser as a source. 1072504SN/A source += [ isa_parser ] 1082504SN/A # Add in the CPU models. 1092152SN/A source += [ Value(m) for m in cpu_models ] 1102504SN/A 1112152SN/A return [os.path.join("generated", t) for t in target], source 1122152SN/A 1132152SN/AARCH_DIR = Dir('.') 1142152SN/A 1152152SN/A# import ply here because SCons screws with sys.path when performing actions. 1162152SN/Aimport ply 1172152SN/A 1182152SN/Adef isa_desc_action_func(target, source, env): 1192632Sstever@eecs.umich.edu # Add the current directory to the system path so we can import files 1202155SN/A sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 1212155SN/A import isa_parser 1222155SN/A 1232155SN/A # Skip over the ISA description itself and the parser to the CPU models. 1242155SN/A models = [ s.get_contents() for s in source[2:] ] 1252155SN/A cpu_models = [CpuModel.dict[cpu] for cpu in models] 1262155SN/A parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 1272155SN/A parser.parse_isa_desc(source[0].abspath) 1282155SN/Aisa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1)) 1292155SN/A 1302152SN/A# Also include the CheckerCPU as one of the models if it is being 1312152SN/A# enabled via command line. 1322152SN/Aisa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter) 1332152SN/A 1342155SN/Aenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 1352152SN/A 1362152SN/ADebugFlag('IntRegs') 1372637Sstever@eecs.umich.eduDebugFlag('FloatRegs') 1382152SN/ADebugFlag('MiscRegs') 1392152SN/ACompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ]) 1402152SN/A