From 24a9813ec0d0777fb34d639b647a7a29c6426140 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 29 Sep 2020 00:24:26 -0700 Subject: [PATCH] arch: Move the ISA parser into a package. This will make splitting the parser into components easier, since it will keep help keep everything together and organized. Change-Id: I737641e124b6da8b1b18a49de9110c8424d8cc4f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35277 Reviewed-by: Gabe Black Maintainer: Gabe Black Tested-by: kokoro --- src/arch/SConscript | 8 +++++--- src/arch/isa_parser/__init__.py | 26 +++++++++++++++++++++++++ src/arch/{ => isa_parser}/isa_parser.py | 0 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/arch/isa_parser/__init__.py rename src/arch/{ => isa_parser}/isa_parser.py (100%) diff --git a/src/arch/SConscript b/src/arch/SConscript index 12e605ff8..5fb543e59 100644 --- a/src/arch/SConscript +++ b/src/arch/SConscript @@ -105,15 +105,17 @@ SCons.Tool.SourceFileScanner.add_scanner('.cc.inc', SCons.Tool.CScanner) # output from the ISA description (*.isa) files. # -parser_py = File('isa_parser.py') +parser_files = Glob('isa_parser/*.py') micro_asm_py = File('micro_asm.py') # import ply here because SCons screws with sys.path when performing actions. import ply +arch_dir = Dir('.') + def run_parser(target, source, env): # Add the current directory to the system path so we can import files. - sys.path[0:0] = [ parser_py.dir.abspath ] + sys.path[0:0] = [ arch_dir.abspath ] import isa_parser parser = isa_parser.ISAParser(target[0].dir.abspath) @@ -207,7 +209,7 @@ def ISADesc(desc, decoder_splits=1, exec_splits=1): source_gen('generic_cpu_exec_%d.cc' % i) # Actually create the builder. - sources = [desc, parser_py, micro_asm_py] + sources = [desc, micro_asm_py] + parser_files IsaDescBuilder(target=gen, source=sources, env=env) return gen diff --git a/src/arch/isa_parser/__init__.py b/src/arch/isa_parser/__init__.py new file mode 100644 index 000000000..02f4999d2 --- /dev/null +++ b/src/arch/isa_parser/__init__.py @@ -0,0 +1,26 @@ +# Copyright 2020 Google, Inc. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from .isa_parser import ISAParser diff --git a/src/arch/isa_parser.py b/src/arch/isa_parser/isa_parser.py similarity index 100% rename from src/arch/isa_parser.py rename to src/arch/isa_parser/isa_parser.py -- 2.30.2