SConscript revision 5742
12SN/A# -*- mode:python -*- 29235Sandreas.hansson@arm.com 39235Sandreas.hansson@arm.com# Copyright (c) 2006 The Regents of The University of Michigan 49235Sandreas.hansson@arm.com# All rights reserved. 59235Sandreas.hansson@arm.com# 69235Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without 79235Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are 89235Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright 99235Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer; 109235Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright 119235Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the 129235Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution; 139235Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its 141762SN/A# contributors may be used to endorse or promote products derived from 152SN/A# this software without specific prior written permission. 162SN/A# 172SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 182SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 192SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 202SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 212SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 222SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 272SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282SN/A# 292SN/A# Authors: Steve Reinhardt 302SN/A 312SN/Aimport sys 322SN/A 332SN/AImport('*') 342SN/A 352SN/A################################################################# 362SN/A# 372SN/A# ISA "switch header" generation. 382SN/A# 392665SN/A# Auto-generate arch headers that include the right ISA-specific 402665SN/A# header based on the setting of THE_ISA preprocessor variable. 412665SN/A# 429235Sandreas.hansson@arm.com################################################################# 432SN/A 442SN/A# List of headers to generate 459235Sandreas.hansson@arm.comisa_switch_hdrs = Split(''' 469235Sandreas.hansson@arm.com arguments.hh 472SN/A faults.hh 489412Sandreas.hansson@arm.com interrupts.hh 499412Sandreas.hansson@arm.com isa_traits.hh 509411Sandreas.hansson@arm.com kernel_stats.hh 519405Sandreas.hansson@arm.com locked_mem.hh 529411Sandreas.hansson@arm.com microcode_rom.hh 539235Sandreas.hansson@arm.com mmaped_ipr.hh 549235Sandreas.hansson@arm.com process.hh 559235Sandreas.hansson@arm.com predecoder.hh 562SN/A regfile.hh 572SN/A remote_gdb.hh 589405Sandreas.hansson@arm.com stacktrace.hh 599405Sandreas.hansson@arm.com syscallreturn.hh 609411Sandreas.hansson@arm.com tlb.hh 619405Sandreas.hansson@arm.com types.hh 629405Sandreas.hansson@arm.com utility.hh 639405Sandreas.hansson@arm.com vtophys.hh 649411Sandreas.hansson@arm.com ''') 659411Sandreas.hansson@arm.com 669411Sandreas.hansson@arm.com# Set up this directory to support switching headers 679411Sandreas.hansson@arm.commake_switching_dir('arch', isa_switch_hdrs, env) 689411Sandreas.hansson@arm.com 699411Sandreas.hansson@arm.com################################################################# 709411Sandreas.hansson@arm.com# 719411Sandreas.hansson@arm.com# Include architecture-specific files. 729411Sandreas.hansson@arm.com# 739411Sandreas.hansson@arm.com################################################################# 749235Sandreas.hansson@arm.com 752SN/A# 769235Sandreas.hansson@arm.com# Build a SCons scanner for ISA files 779411Sandreas.hansson@arm.com# 789411Sandreas.hansson@arm.comimport SCons.Scanner 799411Sandreas.hansson@arm.com 809411Sandreas.hansson@arm.comisa_scanner = SCons.Scanner.Classic("ISAScan", 819411Sandreas.hansson@arm.com [".isa", ".ISA"], 829411Sandreas.hansson@arm.com "SRCDIR", 839411Sandreas.hansson@arm.com r'^\s*##include\s+"([\w/.-]*)"') 849235Sandreas.hansson@arm.com 859235Sandreas.hansson@arm.comenv.Append(SCANNERS = isa_scanner) 869235Sandreas.hansson@arm.com 879411Sandreas.hansson@arm.com# 889411Sandreas.hansson@arm.com# Now create a Builder object that uses isa_parser.py to generate C++ 899235Sandreas.hansson@arm.com# output from the ISA description (*.isa) files. 909235Sandreas.hansson@arm.com# 919405Sandreas.hansson@arm.com 929412Sandreas.hansson@arm.com# Convert to File node to fix path 939412Sandreas.hansson@arm.comisa_parser = File('isa_parser.py') 949412Sandreas.hansson@arm.comcpu_models_file = File('../cpu/cpu_models.py') 959412Sandreas.hansson@arm.com 969412Sandreas.hansson@arm.com# This sucks in the defintions of the CpuModel objects. 979412Sandreas.hansson@arm.comexecfile(cpu_models_file.srcnode().abspath) 989412Sandreas.hansson@arm.com 999412Sandreas.hansson@arm.com# Several files are generated from the ISA description. 1009412Sandreas.hansson@arm.com# We always get the basic decoder and header file. 1019412Sandreas.hansson@arm.comisa_desc_gen_files = [ 'decoder.cc', 'decoder.hh', 'max_inst_regs.hh' ] 1029412Sandreas.hansson@arm.com# We also get an execute file for each selected CPU model. 1039412Sandreas.hansson@arm.comisa_desc_gen_files += [CpuModel.dict[cpu].filename 1049412Sandreas.hansson@arm.com for cpu in env['CPU_MODELS']] 1059412Sandreas.hansson@arm.com 1069412Sandreas.hansson@arm.com# Also include the CheckerCPU as one of the models if it is being 1079412Sandreas.hansson@arm.com# enabled via command line. 1089412Sandreas.hansson@arm.comif env['USE_CHECKER']: 1099412Sandreas.hansson@arm.com isa_desc_gen_files += [CpuModel.dict['CheckerCPU'].filename] 1109412Sandreas.hansson@arm.com 1119412Sandreas.hansson@arm.com# The emitter patches up the sources & targets to include the 1129412Sandreas.hansson@arm.com# autogenerated files as targets and isa parser itself as a source. 1139412Sandreas.hansson@arm.comdef isa_desc_emitter(target, source, env): 1149412Sandreas.hansson@arm.com return (isa_desc_gen_files, [isa_parser, cpu_models_file] + source) 1159412Sandreas.hansson@arm.com 1169412Sandreas.hansson@arm.com# Pieces are in place, so create the builder. 1179412Sandreas.hansson@arm.compython = sys.executable # use same Python binary used to run scons 1189412Sandreas.hansson@arm.com 1199412Sandreas.hansson@arm.com# Also include the CheckerCPU as one of the models if it is being 1209412Sandreas.hansson@arm.com# enabled via command line. 1219412Sandreas.hansson@arm.comif env['USE_CHECKER']: 1229412Sandreas.hansson@arm.com isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS CheckerCPU', 1239412Sandreas.hansson@arm.com emitter = isa_desc_emitter) 1249412Sandreas.hansson@arm.comelse: 1259412Sandreas.hansson@arm.com isa_desc_builder = Builder(action=python + ' $SOURCES $TARGET.dir $CPU_MODELS', 1269412Sandreas.hansson@arm.com emitter = isa_desc_emitter) 1279412Sandreas.hansson@arm.com 1289412Sandreas.hansson@arm.comenv.Append(BUILDERS = { 'ISADesc' : isa_desc_builder }) 1299412Sandreas.hansson@arm.com