SConscript revision 8349
12155SN/A# -*- mode:python -*- 22155SN/A 32155SN/A# Copyright (c) 2006 The Regents of The University of Michigan 42155SN/A# All rights reserved. 52155SN/A# 62155SN/A# Redistribution and use in source and binary forms, with or without 72155SN/A# modification, are permitted provided that the following conditions are 82155SN/A# met: redistributions of source code must retain the above copyright 92155SN/A# notice, this list of conditions and the following disclaimer; 102155SN/A# redistributions in binary form must reproduce the above copyright 112155SN/A# notice, this list of conditions and the following disclaimer in the 122155SN/A# documentation and/or other materials provided with the distribution; 132155SN/A# neither the name of the copyright holders nor the names of its 142155SN/A# contributors may be used to endorse or promote products derived from 152155SN/A# this software without specific prior written permission. 162155SN/A# 172155SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182155SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192155SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202155SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212155SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222155SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232155SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242155SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252155SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262155SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272155SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282665Ssaidi@eecs.umich.edu# 292665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 302155SN/A 314202Sbinkertn@umich.eduimport sys 322155SN/A 339850Sandreas.hansson@arm.comImport('*') 349850Sandreas.hansson@arm.com 359850Sandreas.hansson@arm.com################################################################# 367768SAli.Saidi@ARM.com# 377768SAli.Saidi@ARM.com# ISA "switch header" generation. 388887Sgeoffrey.blake@arm.com# 392766Sktlim@umich.edu# Auto-generate arch headers that include the right ISA-specific 404486Sbinkertn@umich.edu# header based on the setting of THE_ISA preprocessor variable. 414486Sbinkertn@umich.edu# 424776Sgblack@eecs.umich.edu################################################################# 434776Sgblack@eecs.umich.edu 448739Sgblack@eecs.umich.edu# List of headers to generate 456365Sgblack@eecs.umich.eduisa_switch_hdrs = Split(''' 4610259SAndrew.Bardsley@arm.com faults.hh 474486Sbinkertn@umich.edu interrupts.hh 484202Sbinkertn@umich.edu isa.hh 494202Sbinkertn@umich.edu isa_traits.hh 504202Sbinkertn@umich.edu kernel_stats.hh 514202Sbinkertn@umich.edu locked_mem.hh 5210319SAndreas.Sandberg@ARM.com microcode_rom.hh 534202Sbinkertn@umich.edu mmapped_ipr.hh 544776Sgblack@eecs.umich.edu mt.hh 558739Sgblack@eecs.umich.edu process.hh 566365Sgblack@eecs.umich.edu predecoder.hh 574202Sbinkertn@umich.edu registers.hh 588777Sgblack@eecs.umich.edu remote_gdb.hh 594202Sbinkertn@umich.edu stacktrace.hh 609913Ssteve.reinhardt@amd.com tlb.hh 614202Sbinkertn@umich.edu types.hh 624202Sbinkertn@umich.edu utility.hh 635217Ssaidi@eecs.umich.edu vtophys.hh 644202Sbinkertn@umich.edu ''') 6510259SAndrew.Bardsley@arm.com 662155SN/A# Set up this directory to support switching headers 678793Sgblack@eecs.umich.edumake_switching_dir('arch', isa_switch_hdrs, env) 688793Sgblack@eecs.umich.edu 698793Sgblack@eecs.umich.edu################################################################# 704776Sgblack@eecs.umich.edu# 718887Sgeoffrey.blake@arm.com# Include architecture-specific files. 7210201SAndrew.Bardsley@arm.com# 738887Sgeoffrey.blake@arm.com################################################################# 749340SAndreas.Sandberg@arm.com 758887Sgeoffrey.blake@arm.com# 765192Ssaidi@eecs.umich.edu# Build a SCons scanner for ISA files 778335Snate@binkert.org# 788335Snate@binkert.orgimport SCons.Scanner 798335Snate@binkert.org 808335Snate@binkert.orgisa_scanner = SCons.Scanner.Classic("ISAScan", 818335Snate@binkert.org [".isa", ".ISA"], 829534SAndreas.Sandberg@ARM.com "SRCDIR", 839534SAndreas.Sandberg@ARM.com r'^\s*##include\s+"([\w/.-]*)"') 849534SAndreas.Sandberg@ARM.com 858335Snate@binkert.orgenv.Append(SCANNERS = isa_scanner) 869534SAndreas.Sandberg@ARM.com 879534SAndreas.Sandberg@ARM.com# 888335Snate@binkert.org# Now create a Builder object that uses isa_parser.py to generate C++ 899534SAndreas.Sandberg@ARM.com# output from the ISA description (*.isa) files. 909534SAndreas.Sandberg@ARM.com# 919534SAndreas.Sandberg@ARM.com 929534SAndreas.Sandberg@ARM.com# The emitter patches up the sources & targets to include the 939534SAndreas.Sandberg@ARM.com# autogenerated files as targets and isa parser itself as a source. 949534SAndreas.Sandberg@ARM.comdef isa_desc_emitter(target, source, env): 959534SAndreas.Sandberg@ARM.com cpu_models = list(env['CPU_MODELS']) 969534SAndreas.Sandberg@ARM.com if env['USE_CHECKER']: 979534SAndreas.Sandberg@ARM.com cpu_models.append('CheckerCPU') 989534SAndreas.Sandberg@ARM.com 9910383Smitch.hayenga@arm.com # Several files are generated from the ISA description. 1008335Snate@binkert.org # We always get the basic decoder and header file. 1018335Snate@binkert.org target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1028471SGiacomo.Gabrielli@arm.com # We also get an execute file for each selected CPU model. 1038335Snate@binkert.org target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 1048335Snate@binkert.org 10510529Smorr@cs.wisc.edu return target, source + [ Value(m) for m in cpu_models ] 1065192Ssaidi@eecs.umich.edu 1078232Snate@binkert.orgARCH_DIR = Dir('.') 1088232Snate@binkert.org 1098232Snate@binkert.org# import ply here because SCons screws with sys.path when performing actions. 1108300Schander.sudanthi@arm.comimport ply 11110383Smitch.hayenga@arm.com 1125192Ssaidi@eecs.umich.edudef isa_desc_action_func(target, source, env): 1138300Schander.sudanthi@arm.com # Add the current directory to the system path so we can import files 1148300Schander.sudanthi@arm.com sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 1156036Sksewell@umich.edu import isa_parser 1168300Schander.sudanthi@arm.com 1178300Schander.sudanthi@arm.com models = [ s.get_contents() for s in source[1:] ] 118 cpu_models = [CpuModel.dict[cpu] for cpu in models] 119 parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 120 parser.parse_isa_desc(source[0].abspath) 121isa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1)) 122 123# Also include the CheckerCPU as one of the models if it is being 124# enabled via command line. 125isa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter) 126 127env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 128 129DebugFlag('IntRegs') 130DebugFlag('FloatRegs') 131DebugFlag('MiscRegs') 132CompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ]) 133