SConscript revision 7674
12968SN/A# -*- mode:python -*- 22968SN/A 32968SN/A# Copyright (c) 2006 The Regents of The University of Michigan 42968SN/A# All rights reserved. 52968SN/A# 63176SN/A# Redistribution and use in source and binary forms, with or without 72968SN/A# modification, are permitted provided that the following conditions are 82968SN/A# met: redistributions of source code must retain the above copyright 92968SN/A# notice, this list of conditions and the following disclaimer; 102968SN/A# redistributions in binary form must reproduce the above copyright 112968SN/A# notice, this list of conditions and the following disclaimer in the 122968SN/A# documentation and/or other materials provided with the distribution; 132968SN/A# neither the name of the copyright holders nor the names of its 142968SN/A# contributors may be used to endorse or promote products derived from 152968SN/A# this software without specific prior written permission. 162968SN/A# 172968SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182968SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 193171SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2011570SCurtis.Dunham@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 219885Sstever@gmail.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 223176SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232968SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242968SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252968SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262968SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272968SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 283171SN/A# 293171SN/A# Authors: Steve Reinhardt 3011680SCurtis.Dunham@arm.com 312968SN/Aimport sys 322968SN/A 332968SN/AImport('*') 343171SN/A 352968SN/A################################################################# 362968SN/A# 372968SN/A# ISA "switch header" generation. 382968SN/A# 393176SN/A# Auto-generate arch headers that include the right ISA-specific 403171SN/A# header based on the setting of THE_ISA preprocessor variable. 412968SN/A# 424966SN/A################################################################# 432968SN/A 442968SN/A# List of headers to generate 452968SN/Aisa_switch_hdrs = Split(''' 462968SN/A faults.hh 472968SN/A interrupts.hh 482968SN/A isa.hh 492968SN/A isa_traits.hh 502968SN/A kernel_stats.hh 512968SN/A locked_mem.hh 522968SN/A microcode_rom.hh 532968SN/A mmaped_ipr.hh 542968SN/A mt.hh 553171SN/A process.hh 562968SN/A predecoder.hh 573171SN/A registers.hh 583171SN/A remote_gdb.hh 593171SN/A stacktrace.hh 603171SN/A tlb.hh 612968SN/A types.hh 622968SN/A utility.hh 632968SN/A vtophys.hh 645778SN/A ''') 652968SN/A 662968SN/A# Set up this directory to support switching headers 673171SN/Amake_switching_dir('arch', isa_switch_hdrs, env) 683171SN/A 693171SN/A################################################################# 703171SN/A# 712968SN/A# Include architecture-specific files. 722968SN/A# 732968SN/A################################################################# 742968SN/A 752968SN/A# 765778SN/A# Build a SCons scanner for ISA files 772968SN/A# 782968SN/Aimport SCons.Scanner 792968SN/A 802968SN/Aisa_scanner = SCons.Scanner.Classic("ISAScan", 812968SN/A [".isa", ".ISA"], 822968SN/A "SRCDIR", 834966SN/A r'^\s*##include\s+"([\w/.-]*)"') 843171SN/A 852968SN/Aenv.Append(SCANNERS = isa_scanner) 862968SN/A 872968SN/A# 883171SN/A# Now create a Builder object that uses isa_parser.py to generate C++ 892968SN/A# output from the ISA description (*.isa) files. 902968SN/A# 912968SN/A 923171SN/A# The emitter patches up the sources & targets to include the 933171SN/A# autogenerated files as targets and isa parser itself as a source. 943171SN/Adef isa_desc_emitter(target, source, env): 953171SN/A cpu_models = list(env['CPU_MODELS']) 963171SN/A if env['USE_CHECKER']: 973171SN/A cpu_models.append('CheckerCPU') 982968SN/A 992968SN/A # Several files are generated from the ISA description. 1003171SN/A # We always get the basic decoder and header file. 1012968SN/A target = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1022968SN/A # We also get an execute file for each selected CPU model. 1032968SN/A target += [CpuModel.dict[cpu].filename for cpu in cpu_models] 1042968SN/A 1052968SN/A return target, source + [ Value(m) for m in cpu_models ] 1062968SN/A 1072968SN/AARCH_DIR = Dir('.') 1082968SN/A 1093171SN/A# import ply here because SCons screws with sys.path when performing actions. 1104966SN/Aimport ply 1114966SN/A 1124966SN/Adef isa_desc_action(target, source, env): 1134966SN/A # Add the current directory to the system path so we can import files 11411680SCurtis.Dunham@arm.com sys.path[0:0] = [ ARCH_DIR.srcnode().abspath ] 11511680SCurtis.Dunham@arm.com import isa_parser 11611680SCurtis.Dunham@arm.com 11711680SCurtis.Dunham@arm.com models = [ s.get_contents() for s in source[1:] ] 11811680SCurtis.Dunham@arm.com cpu_models = [CpuModel.dict[cpu] for cpu in models] 11911680SCurtis.Dunham@arm.com parser = isa_parser.ISAParser(target[0].dir.abspath, cpu_models) 12011680SCurtis.Dunham@arm.com parser.parse_isa_desc(source[0].abspath) 12111680SCurtis.Dunham@arm.com 12211680SCurtis.Dunham@arm.com# Also include the CheckerCPU as one of the models if it is being 12311680SCurtis.Dunham@arm.com# enabled via command line. 12411680SCurtis.Dunham@arm.comisa_desc_builder = Builder(action=isa_desc_action, emitter=isa_desc_emitter) 12511680SCurtis.Dunham@arm.com 12611680SCurtis.Dunham@arm.comenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 12711680SCurtis.Dunham@arm.com 12811680SCurtis.Dunham@arm.comTraceFlag('IntRegs') 12911680SCurtis.Dunham@arm.comTraceFlag('FloatRegs') 13011680SCurtis.Dunham@arm.comTraceFlag('MiscRegs') 13111680SCurtis.Dunham@arm.comCompoundFlag('Registers', [ 'IntRegs', 'FloatRegs', 'MiscRegs' ]) 13211680SCurtis.Dunham@arm.com