SConscript revision 4202
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 332139SN/AImport('*') 344202Sbinkertn@umich.edu 352152SN/A################################################################# 362152SN/A# 372139SN/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# 422152SN/A################################################################# 432152SN/A 442139SN/A# List of headers to generate 452139SN/Aisa_switch_hdrs = Split(''' 462139SN/A arguments.hh 474781Snate@binkert.org faults.hh 487799Sgblack@eecs.umich.edu interrupts.hh 494781Snate@binkert.org isa_traits.hh 504781Snate@binkert.org kernel_stats.hh 513170Sstever@eecs.umich.edu locked_mem.hh 525664Sgblack@eecs.umich.edu mmaped_ipr.hh 538105Sgblack@eecs.umich.edu process.hh 546179Sksewell@umich.edu regfile.hh 554781Snate@binkert.org remote_gdb.hh 564781Snate@binkert.org stacktrace.hh 576329Sgblack@eecs.umich.edu syscallreturn.hh 584781Snate@binkert.org tlb.hh 594781Snate@binkert.org types.hh 604781Snate@binkert.org utility.hh 614781Snate@binkert.org vtophys.hh 624781Snate@binkert.org ''') 634781Snate@binkert.org 642139SN/A# Set up this directory to support switching headers 652139SN/Amake_switching_dir('arch', isa_switch_hdrs, env) 663546Sgblack@eecs.umich.edu 674202Sbinkertn@umich.edu################################################################# 682152SN/A# 692152SN/A# Include architecture-specific files. 702152SN/A# 712152SN/A################################################################# 722152SN/A 732152SN/A# 742152SN/A# Build a SCons scanner for ISA files 752152SN/A# 762152SN/Aimport SCons.Scanner 772152SN/A 782152SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan", 792152SN/A [".isa", ".ISA"], 802504SN/A "SRCDIR", 812504SN/A r'^\s*##include\s+"([\w/.-]*)"') 822504SN/A 832504SN/Aenv.Append(SCANNERS = isa_scanner) 842152SN/A 852504SN/A# 862152SN/A# Now create a Builder object that uses isa_parser.py to generate C++ 872152SN/A# output from the ISA description (*.isa) files. 882152SN/A# 892152SN/A 902152SN/A# Convert to File node to fix path 912152SN/Aisa_parser = File('isa_parser.py') 928584Sgblack@eecs.umich.educpu_models_file = File('../cpu/cpu_models.py') 938584Sgblack@eecs.umich.edu 946993Snate@binkert.org# This sucks in the defintions of the CpuModel objects. 956993Snate@binkert.orgexecfile(cpu_models_file.srcnode().abspath) 966993Snate@binkert.org 976993Snate@binkert.org# Several files are generated from the ISA description. 988887Sgeoffrey.blake@arm.com# We always get the basic decoder and header file. 996993Snate@binkert.orgisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh' ] 1006993Snate@binkert.org# We also get an execute file for each selected CPU model. 1016993Snate@binkert.orgisa_desc_gen_files += [CpuModel.dict[cpu].filename 1026993Snate@binkert.org for cpu in env['CPU_MODELS']] 1036993Snate@binkert.org 1046993Snate@binkert.org# Also include the CheckerCPU as one of the models if it is being 1056993Snate@binkert.org# enabled via command line. 1068584Sgblack@eecs.umich.eduif env['USE_CHECKER']: 1078584Sgblack@eecs.umich.edu isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 1088584Sgblack@eecs.umich.edu 1098584Sgblack@eecs.umich.edu# The emitter patches up the sources & targets to include the 1108584Sgblack@eecs.umich.edu# autogenerated files as targets and isa parser itself as a source. 1118961Sgblack@eecs.umich.edudef isa_desc_emitter(target, source, env): 1126993Snate@binkert.org return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 1136993Snate@binkert.org 1146993Snate@binkert.org# Pieces are in place, so create the builder. 1156998Snate@binkert.orgpython = sys.executable # use same Python binary used to run scons 1166998Snate@binkert.org 1176998Snate@binkert.org# Also include the CheckerCPU as one of the models if it is being 1187756SAli.Saidi@ARM.com# enabled via command line. 1196993Snate@binkert.orgif env['USE_CHECKER']: 1206993Snate@binkert.org isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU', 1216993Snate@binkert.org emitter = isa_desc_emitter) 1226993Snate@binkert.orgelse: 1238585Sgblack@eecs.umich.edu isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS', 1248584Sgblack@eecs.umich.edu emitter = isa_desc_emitter) 1256993Snate@binkert.org 1266993Snate@binkert.orgenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 1276993Snate@binkert.org