SConscript revision 5478
16157Snate@binkert.org# -*- mode:python -*- 26157Snate@binkert.org 36157Snate@binkert.org# Copyright (c) 2006 The Regents of The University of Michigan 46157Snate@binkert.org# All rights reserved. 56157Snate@binkert.org# 66157Snate@binkert.org# Redistribution and use in source and binary forms, with or without 76157Snate@binkert.org# modification, are permitted provided that the following conditions are 86157Snate@binkert.org# met: redistributions of source code must retain the above copyright 96157Snate@binkert.org# notice, this list of conditions and the following disclaimer; 106157Snate@binkert.org# redistributions in binary form must reproduce the above copyright 116157Snate@binkert.org# notice, this list of conditions and the following disclaimer in the 126157Snate@binkert.org# documentation and/or other materials provided with the distribution; 136157Snate@binkert.org# neither the name of the copyright holders nor the names of its 146157Snate@binkert.org# contributors may be used to endorse or promote products derived from 156157Snate@binkert.org# this software without specific prior written permission. 166157Snate@binkert.org# 176157Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186157Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196157Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206157Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216157Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226157Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236157Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246157Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256157Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266157Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276157Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286157Snate@binkert.org# 296157Snate@binkert.org# Authors: Steve Reinhardt 306157Snate@binkert.org 316157Snate@binkert.orgimport sys 328453Snate@binkert.org 336157Snate@binkert.orgImport('*') 346157Snate@binkert.org 356657Snate@binkert.org################################################################# 366157Snate@binkert.org# 378453Snate@binkert.org# ISA "switch header" generation. 388453Snate@binkert.org# 396157Snate@binkert.org# Auto-generate arch headers that include the right ISA-specific 406157Snate@binkert.org# header based on the setting of THE_ISA preprocessor variable. 418492Snilay@cs.wisc.edu# 426168Snate@binkert.org################################################################# 436168Snate@binkert.org 446157Snate@binkert.org# List of headers to generate 456157Snate@binkert.orgisa_switch_hdrs = Split(''' 466657Snate@binkert.org arguments.hh 476657Snate@binkert.org faults.hh 486657Snate@binkert.org interrupts.hh 496657Snate@binkert.org isa_traits.hh 506657Snate@binkert.org kernel_stats.hh 516657Snate@binkert.org locked_mem.hh 526657Snate@binkert.org mmaped_ipr.hh 536657Snate@binkert.org process.hh 546657Snate@binkert.org predecoder.hh 556657Snate@binkert.org regfile.hh 566157Snate@binkert.org remote_gdb.hh 576157Snate@binkert.org stacktrace.hh 586157Snate@binkert.org syscallreturn.hh 596157Snate@binkert.org tlb.hh 608453Snate@binkert.org types.hh 618453Snate@binkert.org utility.hh 628453Snate@binkert.org vtophys.hh 638453Snate@binkert.org ''') 646657Snate@binkert.org 656657Snate@binkert.org# Set up this directory to support switching headers 668454Snate@binkert.orgmake_switching_dir('arch', isa_switch_hdrs, env) 678454Snate@binkert.org 688454Snate@binkert.org################################################################# 698454Snate@binkert.org# 708453Snate@binkert.org# Include architecture-specific files. 718453Snate@binkert.org# 728453Snate@binkert.org################################################################# 738453Snate@binkert.org 746657Snate@binkert.org# 758453Snate@binkert.org# Build a SCons scanner for ISA files 766657Snate@binkert.org# 776657Snate@binkert.orgimport SCons.Scanner 786657Snate@binkert.org 798454Snate@binkert.orgisa_scanner = SCons.Scanner.Classic("ISAScan", 808454Snate@binkert.org [".isa", ".ISA"], 818454Snate@binkert.org "SRCDIR", 828454Snate@binkert.org r'^\s*##include\s+"([\w/.-]*)"') 838453Snate@binkert.org 848453Snate@binkert.orgenv.Append(SCANNERS = isa_scanner) 858453Snate@binkert.org 868453Snate@binkert.org# 876157Snate@binkert.org# Now create a Builder object that uses isa_parser.py to generate C++ 888453Snate@binkert.org# output from the ISA description (*.isa) files. 898453Snate@binkert.org# 906157Snate@binkert.org 916157Snate@binkert.org# Convert to File node to fix path 928454Snate@binkert.orgisa_parser = File('isa_parser.py') 936157Snate@binkert.orgcpu_models_file = File('../cpu/cpu_models.py') 946657Snate@binkert.org 958454Snate@binkert.org# This sucks in the defintions of the CpuModel objects. 966657Snate@binkert.orgexecfile(cpu_models_file.srcnode().abspath) 976157Snate@binkert.org 986877Ssteve.reinhardt@amd.com# Several files are generated from the ISA description. 996877Ssteve.reinhardt@amd.com# We always get the basic decoder and header file. 1006877Ssteve.reinhardt@amd.comisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1016877Ssteve.reinhardt@amd.com# We also get an execute file for each selected CPU model. 1026877Ssteve.reinhardt@amd.comisa_desc_gen_files += [CpuModel.dict[cpu].filename 1036877Ssteve.reinhardt@amd.com for cpu in env['CPU_MODELS']] 1046877Ssteve.reinhardt@amd.com 105# Also include the CheckerCPU as one of the models if it is being 106# enabled via command line. 107if env['USE_CHECKER']: 108 isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 109 110# The emitter patches up the sources & targets to include the 111# autogenerated files as targets and isa parser itself as a source. 112def isa_desc_emitter(target, source, env): 113 return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 114 115# Pieces are in place, so create the builder. 116python = sys.executable # use same Python binary used to run scons 117 118# Also include the CheckerCPU as one of the models if it is being 119# enabled via command line. 120if env['USE_CHECKER']: 121 isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU', 122 emitter = isa_desc_emitter) 123else: 124 isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS', 125 emitter = isa_desc_emitter) 126 127env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 128