From 4898cd04c6c5546728a5f81c879fc82710e477dd Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 7 Sep 2008 16:43:54 -0700 Subject: [PATCH] Remove redundant back-end selections. Target selection is done by the DLL target code generator, so there is no value having a layer of target selection ahead of it. Remove all that redundant code and simplify the target config files to reflect this. --- Makefile.in | 2 +- emit.cc | 14 -------------- main.cc | 32 ++++++++++++++++---------------- t-dll.cc | 6 ++---- t-dll.h | 2 ++ target.h | 9 --------- targets.cc | 29 ----------------------------- tgt-null/null-s.conf | 1 - tgt-null/null.conf | 1 - tgt-stub/stub-s.conf | 1 - tgt-stub/stub.conf | 1 - tgt-vhdl/vhdl.conf | 1 - tgt-vvp/vvp-s.conf.in | 1 - tgt-vvp/vvp.conf.in | 1 - 14 files changed, 21 insertions(+), 80 deletions(-) delete mode 100644 targets.cc diff --git a/Makefile.in b/Makefile.in index 6fb8b38d1..e74325e6d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -110,7 +110,7 @@ net_proc.o net_scope.o net_tran.o net_udp.o pad_to_width.o \ parse.o parse_misc.o pform.o pform_analog.o pform_disciplines.o \ pform_dump.o pform_types.o \ set_width.o symbol_search.o sync.o sys_funcs.o \ -verinum.o verireal.o target.o targets.o \ +verinum.o verireal.o target.o \ Attrib.o HName.o LineInfo.o Module.o PDelays.o PEvent.o \ PExpr.o PGate.o PGenerate.o PScope.o PSpec.o \ PTask.o PUdp.o PFunction.o PWire.o Statement.o AStatement.o StringHeap.o \ diff --git a/emit.cc b/emit.cc index 785520a12..1370cb617 100644 --- a/emit.cc +++ b/emit.cc @@ -540,17 +540,3 @@ void NetEUnary::expr_scan(struct expr_scan_t*tgt) const { tgt->expr_unary(this); } - -int emit(const Design*des, const char*type) -{ - for (unsigned idx = 0 ; target_table[idx] ; idx += 1) { - const struct target*tgt = target_table[idx]; - if (strcmp(tgt->name, type) == 0) - return des->emit(tgt->meth); - - } - - cerr << "error: Code generator type " << type - << " not found." << endl; - return -1; -} diff --git a/main.cc b/main.cc index deaae3359..6cab41113 100644 --- a/main.cc +++ b/main.cc @@ -59,6 +59,7 @@ const char NOTICE[] = # include "target.h" # include "compiler.h" # include "discipline.h" +# include "t-dll.h" #if defined(__MINGW32__) && !defined(HAVE_GETOPT_H) extern "C" int getopt(int argc, char*argv[], const char*fmt); @@ -79,8 +80,6 @@ const char VERSION[] = "$Name: $"; const char*basedir = "."; -const char*target = "null"; - /* * These are the language support control flags. These support which * language features (the generation) to support. The generation_flag @@ -293,7 +292,7 @@ static void find_module_mention(map&check_map, PGenerate*s); * -T: * Select which expression to use. * - * -t: + * -t: (obsolete) * Usually, "-t:dll" * * basedir: @@ -483,7 +482,7 @@ static void read_iconfig_file(const char*ipath) library_suff.push_back(strdup(cp)); } else if (strcmp(buf,"-t") == 0) { - target = strdup(cp); + // NO LONGER USED } else if (strcmp(buf,"-T") == 0) { if (strcmp(cp,"min") == 0) { @@ -844,20 +843,21 @@ int main(int argc, char*argv[]) } if (verbose_flag) { - cout << "CODE GENERATION -t "< 0) { - cerr << "error: Code generation had " - << emit_rc << " errors." - << endl; - return 1; - } - if (emit_rc < 0) { - cerr << "error: Code generator failure: " << emit_rc << endl; - return -1; + if (int emit_rc = des->emit(&dll_target_obj)) { + if (emit_rc > 0) { + cerr << "error: Code generation had " + << emit_rc << " errors." + << endl; + return 1; + } + if (emit_rc < 0) { + cerr << "error: Code generator failure: " << emit_rc << endl; + return -1; + } + assert(emit_rc); } if (verbose_flag) { diff --git a/t-dll.cc b/t-dll.cc index 7e4f1714f..e171babdc 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -32,6 +32,8 @@ # include # include "ivl_assert.h" +struct dll_target dll_target_obj; + #if defined(__WIN32__) inline ivl_dll_t ivl_dlopen(const char *name) @@ -144,8 +146,6 @@ static perm_string make_scope_name(const hname_t&name) return lex_strings.make(buf); } -static struct dll_target dll_target_obj; - static void drive_from_link(const Link&lnk, ivl_drive_t&drv0, ivl_drive_t&drv1) { switch (lnk.drive0()) { @@ -2578,5 +2578,3 @@ bool dll_target::signal_paths(const NetNet*net) return true; } - -extern const struct target tgt_dll = { "dll", &dll_target_obj }; diff --git a/t-dll.h b/t-dll.h index e3646417b..d13d43ce8 100644 --- a/t-dll.h +++ b/t-dll.h @@ -178,6 +178,8 @@ struct dll_target : public target_t, public expr_scan_t { static ivl_expr_t expr_from_value_(const verinum&that); }; +extern struct dll_target dll_target_obj; + /* * These are various private declarations used by the t-dll target. */ diff --git a/target.h b/target.h index bed4815e6..a266d6d15 100644 --- a/target.h +++ b/target.h @@ -151,11 +151,6 @@ struct expr_scan_t { }; -/* The emit functions take a design and emit it to the output stream - using the specified target. If the target is given by name, it is - located in the target_table and used. */ -extern int emit(const Design*des, const char*type); - /* This function takes a fully qualified Verilog name (which may have, for example, dots in it) and produces a mangled version that can be used by most any language. */ @@ -165,8 +160,4 @@ extern string mangle(const string&str); used inside a string constant for a C++ compiler. */ extern string stresc(const string&str); -/* This is the table of supported output targets. It is a null - terminated array of pointers to targets. */ -extern const struct target *target_table[]; - #endif diff --git a/targets.cc b/targets.cc deleted file mode 100644 index 8df415cf3..000000000 --- a/targets.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 1998 Stephen Williams (steve@icarus.com) - * - * This source code is free software; you can redistribute it - * and/or modify it in source code form under the terms of the GNU - * General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -# include "config.h" - -# include "target.h" - -extern const struct target tgt_dll; - -const struct target *target_table[] = { - &tgt_dll, - 0 -}; diff --git a/tgt-null/null-s.conf b/tgt-null/null-s.conf index bf62222dc..8f1cd19ea 100644 --- a/tgt-null/null-s.conf +++ b/tgt-null/null-s.conf @@ -1,5 +1,4 @@ functor:synth2 functor:synth functor:syn-rules --t:dll flag:DLL=null.tgt diff --git a/tgt-null/null.conf b/tgt-null/null.conf index 4d6369401..9d870274e 100644 --- a/tgt-null/null.conf +++ b/tgt-null/null.conf @@ -1,2 +1 @@ --t:dll flag:DLL=null.tgt diff --git a/tgt-stub/stub-s.conf b/tgt-stub/stub-s.conf index 190574ce0..193daf301 100644 --- a/tgt-stub/stub-s.conf +++ b/tgt-stub/stub-s.conf @@ -3,5 +3,4 @@ functor:synth functor:syn-rules functor:cprop functor:nodangle --t:dll flag:DLL=stub.tgt diff --git a/tgt-stub/stub.conf b/tgt-stub/stub.conf index 5c0c1c576..eb4cee787 100644 --- a/tgt-stub/stub.conf +++ b/tgt-stub/stub.conf @@ -1,4 +1,3 @@ functor:cprop functor:nodangle --t:dll flag:DLL=stub.tgt diff --git a/tgt-vhdl/vhdl.conf b/tgt-vhdl/vhdl.conf index b96c4c05e..0d382d395 100644 --- a/tgt-vhdl/vhdl.conf +++ b/tgt-vhdl/vhdl.conf @@ -1,4 +1,3 @@ functor:cprop functor:nodangle --t:dll flag:DLL=vhdl.tgt diff --git a/tgt-vvp/vvp-s.conf.in b/tgt-vvp/vvp-s.conf.in index 81c6f4a37..6d45439b8 100644 --- a/tgt-vvp/vvp-s.conf.in +++ b/tgt-vvp/vvp-s.conf.in @@ -3,5 +3,4 @@ functor:synth functor:syn-rules functor:cprop functor:nodangle --t:dll flag:DLL=vvp.tgt diff --git a/tgt-vvp/vvp.conf.in b/tgt-vvp/vvp.conf.in index 2dbe4a66b..c416038ac 100644 --- a/tgt-vvp/vvp.conf.in +++ b/tgt-vvp/vvp.conf.in @@ -1,4 +1,3 @@ functor:cprop functor:nodangle --t:dll flag:DLL=vvp.tgt