SConscript revision 9020
13534Sgblack@eecs.umich.edu# -*- mode:python -*- 23534Sgblack@eecs.umich.edu 33534Sgblack@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 43534Sgblack@eecs.umich.edu# All rights reserved. 53534Sgblack@eecs.umich.edu# 63534Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 73534Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 83534Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 93534Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 103534Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 113534Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 123534Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 133534Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 143534Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 153534Sgblack@eecs.umich.edu# this software without specific prior written permission. 163534Sgblack@eecs.umich.edu# 173534Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 183534Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 193534Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 203534Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 213534Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 223534Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 233534Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 243534Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 253534Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 263534Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 273534Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 283534Sgblack@eecs.umich.edu# 293534Sgblack@eecs.umich.edu# Authors: Steve Reinhardt 303534Sgblack@eecs.umich.edu 313534Sgblack@eecs.umich.eduimport sys 324202Sbinkertn@umich.eduimport os 333534Sgblack@eecs.umich.edu 344202Sbinkertn@umich.eduImport('*') 354486Sbinkertn@umich.edu 365794Ssaidi@eecs.umich.edu################################################################# 374486Sbinkertn@umich.edu# 384486Sbinkertn@umich.edu# ISA "switch header" generation. 394486Sbinkertn@umich.edu# 404486Sbinkertn@umich.edu# Auto-generate arch headers that include the right ISA-specific 414486Sbinkertn@umich.edu# header based on the setting of THE_ISA preprocessor variable. 424486Sbinkertn@umich.edu# 434486Sbinkertn@umich.edu################################################################# 445478Snate@binkert.org 454486Sbinkertn@umich.edu# List of headers to generate 464486Sbinkertn@umich.eduisa_switch_hdrs = Split(''' 474202Sbinkertn@umich.edu decoder.hh 485794Ssaidi@eecs.umich.edu interrupts.hh 494202Sbinkertn@umich.edu isa.hh 504202Sbinkertn@umich.edu isa_traits.hh 515485Snate@binkert.org kernel_stats.hh 524202Sbinkertn@umich.edu locked_mem.hh 534202Sbinkertn@umich.edu microcode_rom.hh 544202Sbinkertn@umich.edu mmapped_ipr.hh 554202Sbinkertn@umich.edu mt.hh 564762Snate@binkert.org process.hh 574218Ssaidi@eecs.umich.edu predecoder.hh 584202Sbinkertn@umich.edu registers.hh 594202Sbinkertn@umich.edu remote_gdb.hh 605443Sgblack@eecs.umich.edu stacktrace.hh 614202Sbinkertn@umich.edu tlb.hh 624202Sbinkertn@umich.edu types.hh 635392Sgblack@eecs.umich.edu utility.hh 644202Sbinkertn@umich.edu vtophys.hh 654202Sbinkertn@umich.edu ''') 664202Sbinkertn@umich.edu 674202Sbinkertn@umich.edu# Set up this directory to support switching headers 684202Sbinkertn@umich.edumake_switching_dir('arch', isa_switch_hdrs, env) 694202Sbinkertn@umich.edu 704762Snate@binkert.org################################################################# 715478Snate@binkert.org# 724202Sbinkertn@umich.edu# Include architecture-specific files. 734202Sbinkertn@umich.edu# 745192Ssaidi@eecs.umich.edu################################################################# 755192Ssaidi@eecs.umich.edu 765192Ssaidi@eecs.umich.edu# 775192Ssaidi@eecs.umich.edu# Build a SCons scanner for ISA files 785794Ssaidi@eecs.umich.edu# 795192Ssaidi@eecs.umich.eduimport SCons.Scanner 805192Ssaidi@eecs.umich.edu 815192Ssaidi@eecs.umich.eduisa_scanner = SCons.Scanner.Classic("ISAScan", 825192Ssaidi@eecs.umich.edu [".isa", ".ISA"], 835192Ssaidi@eecs.umich.edu "SRCDIR", 845192Ssaidi@eecs.umich.edu r'^\s*##include\s+"([\w/.-]*)"') 855192Ssaidi@eecs.umich.edu 865192Ssaidi@eecs.umich.eduenv.Append(SCANNERS = isa_scanner) 875192Ssaidi@eecs.umich.edu 885192Ssaidi@eecs.umich.edu# 895192Ssaidi@eecs.umich.edu# Now create a Builder object that uses isa_parser.py to generate C++ 905443Sgblack@eecs.umich.edu# output from the ISA description (*.isa) files. 915192Ssaidi@eecs.umich.edu# 925392Sgblack@eecs.umich.edu 935192Ssaidi@eecs.umich.eduisa_parser = File('isa_parser.py') 945192Ssaidi@eecs.umich.edu 955192Ssaidi@eecs.umich.edu# The emitter patches up the sources & targets to include the 965192Ssaidi@eecs.umich.edu# autogenerated files as targets and isa parser itself as a source. 975478Snate@binkert.orgdef isa_desc_emitter(target, source, env): 985478Snate@binkert.org cpu_models = list(env['CPU_MODELS']) 995192Ssaidi@eecs.umich.edu cpu_models.append('CheckerCPU') 1005192Ssaidi@eecs.umich.edu 1015192Ssaidi@eecs.umich.edu # Several files are generated from the ISA description. 1025192Ssaidi@eecs.umich.edu # We always get the basic decoder and header file. 1035192Ssaidi@eecs.umich.edu target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1045763Ssaidi@eecs.umich.edu # We also get an execute file for each selected CPU model. 1055192Ssaidi@eecs.umich.edu target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 1065192Ssaidi@eecs.umich.edu 1075192Ssaidi@eecs.umich.edu # List the isa parser as a source. 1085192Ssaidi@eecs.umich.edu source += [ isa_parser ] 109 # Add in the CPU models. 110 source += [ Value(m) for m in cpu_models ] 111 112 return [os.path.join("generated", t) for t in target], source 113 114ARCH_DIR = Dir('.') 115 116# import ply here because SCons screws with sys.path when performing actions. 117import ply 118 119def isa_desc_action_func(target, source, env): 120 # Add the current directory to the system path so we can import files 121 sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 122 import isa_parser 123 124 # Skip over the ISA description itself and the parser to the CPU models. 125 models = [ s.get_contents() for s in source[2:] ] 126 cpu_models = [CpuModel.dict[cpu] for cpu in models] 127 parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 128 parser.parse_isa_desc(source[0].abspath) 129isa_desc_action = MakeAction(isa_desc_action_func, Transform("ISA DESC", 1)) 130 131# Also include the CheckerCPU as one of the models if it is being 132# enabled via command line. 133isa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter) 134 135env.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 136 137DebugFlag('IntRegs') 138DebugFlag('FloatRegs') 139DebugFlag('MiscRegs') 140CompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ]) 141