yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
register.h
Go to the documentation of this file.
1 /*
2  * yosys -- Yosys Open SYnthesis Suite
3  *
4  * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  */
19 
20 #include "kernel/yosys.h"
21 
22 #ifndef REGISTER_H
23 #define REGISTER_H
24 
26 
27 struct Pass
28 {
29  std::string pass_name, short_help;
30  Pass(std::string name, std::string short_help = "** document me **");
31  virtual ~Pass();
32 
33  virtual void help();
34  virtual void execute(std::vector<std::string> args, RTLIL::Design *design) = 0;
35 
37  int64_t runtime_ns;
38 
41  int64_t begin_ns;
42  };
43 
46 
47  void cmd_log_args(const std::vector<std::string> &args);
48  void cmd_error(const std::vector<std::string> &args, size_t argidx, std::string msg);
49  void extra_args(std::vector<std::string> args, size_t argidx, RTLIL::Design *design, bool select = true);
50 
51  static void call(RTLIL::Design *design, std::string command);
52  static void call(RTLIL::Design *design, std::vector<std::string> args);
53 
54  static void call_on_selection(RTLIL::Design *design, const RTLIL::Selection &selection, std::string command);
55  static void call_on_selection(RTLIL::Design *design, const RTLIL::Selection &selection, std::vector<std::string> args);
56 
57  static void call_on_module(RTLIL::Design *design, RTLIL::Module *module, std::string command);
58  static void call_on_module(RTLIL::Design *design, RTLIL::Module *module, std::vector<std::string> args);
59 
61  virtual void run_register();
62  static void init_register();
63  static void done_register();
64 };
65 
66 struct Frontend : Pass
67 {
68  // for reading of here documents
69  static FILE *current_script_file;
70  static std::string last_here_document;
71 
72  std::string frontend_name;
73  Frontend(std::string name, std::string short_help = "** document me **");
74  virtual void run_register();
75  virtual ~Frontend();
76  virtual void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL;
77  virtual void execute(std::istream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) = 0;
78 
79  static std::vector<std::string> next_args;
80  void extra_args(std::istream *&f, std::string &filename, std::vector<std::string> args, size_t argidx);
81 
82  static void frontend_call(RTLIL::Design *design, std::istream *f, std::string filename, std::string command);
83  static void frontend_call(RTLIL::Design *design, std::istream *f, std::string filename, std::vector<std::string> args);
84 };
85 
86 struct Backend : Pass
87 {
88  std::string backend_name;
89  Backend(std::string name, std::string short_help = "** document me **");
90  virtual void run_register();
91  virtual ~Backend();
92  virtual void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL;
93  virtual void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) = 0;
94 
95  void extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx);
96 
97  static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::string command);
98  static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::vector<std::string> args);
99 };
100 
101 // implemented in passes/cmds/select.cc
102 extern void handle_extra_select_args(Pass *pass, std::vector<std::string> args, size_t argidx, size_t args_size, RTLIL::Design *design);
103 
104 extern std::map<std::string, Pass*> pass_register;
105 extern std::map<std::string, Frontend*> frontend_register;
106 extern std::map<std::string, Backend*> backend_register;
107 
109 
110 #endif
void cmd_error(const std::vector< std::string > &args, size_t argidx, std::string msg)
Definition: register.cc:110
virtual void run_register()
Definition: register.cc:416
void cmd_log_args(const std::vector< std::string > &args)
Definition: register.cc:100
void handle_extra_select_args(Pass *pass, std::vector< std::string > args, size_t argidx, size_t args_size, RTLIL::Design *design)
Definition: select.cc:803
static std::string last_here_document
Definition: register.h:70
#define YS_OVERRIDE
Definition: yosys.h:108
#define YOSYS_NAMESPACE_END
Definition: yosys.h:100
static void frontend_call(RTLIL::Design *design, std::istream *f, std::string filename, std::string command)
Definition: register.cc:375
std::string frontend_name
Definition: register.h:72
int64_t runtime_ns
Definition: register.h:37
RTLIL::Module * module
Definition: abc.cc:94
std::map< std::string, Frontend * > frontend_register
Definition: register.cc:34
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)=0
static FILE * current_script_file
Definition: register.h:69
Pass * next_queued_pass
Definition: register.h:60
virtual void help()
Definition: register.cc:93
std::string pass_name
Definition: register.h:29
Definition: register.h:39
void extra_args(std::ostream *&f, std::string &filename, std::vector< std::string > args, size_t argidx)
Definition: register.cc:439
static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::string command)
Definition: register.cc:479
virtual void execute(std::vector< std::string > args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL
Definition: register.cc:429
static std::vector< std::string > next_args
Definition: register.h:79
std::map< std::string, Backend * > backend_register
Definition: register.cc:36
virtual void execute(std::vector< std::string > args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL
Definition: register.cc:285
static void done_register()
Definition: register.cc:62
virtual void run_register()
Definition: register.cc:272
Pass * parent_pass
Definition: register.h:40
std::string backend_name
Definition: register.h:88
Definition: register.h:27
Pass(std::string name, std::string short_help="** document me **")
Definition: register.cc:40
#define YS_FINAL
Definition: yosys.h:109
Backend(std::string name, std::string short_help="** document me **")
Definition: register.cc:410
#define YOSYS_NAMESPACE_BEGIN
Definition: yosys.h:99
static void call_on_module(RTLIL::Design *design, RTLIL::Module *module, std::string command)
Definition: register.cc:240
int call_counter
Definition: register.h:36
virtual ~Backend()
Definition: register.cc:425
pre_post_exec_state_t pre_execute()
Definition: register.cc:74
virtual void run_register()
Definition: register.cc:48
std::string short_help
Definition: register.h:29
virtual ~Pass()
Definition: register.cc:70
static void init_register()
Definition: register.cc:54
int64_t begin_ns
Definition: register.h:41
static void call_on_selection(RTLIL::Design *design, const RTLIL::Selection &selection, std::string command)
Definition: register.cc:216
std::map< std::string, Pass * > pass_register
Definition: register.cc:35
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
Definition: register.cc:128
static void call(RTLIL::Design *design, std::string command)
Definition: register.cc:146
void extra_args(std::istream *&f, std::string &filename, std::vector< std::string > args, size_t argidx)
Definition: register.cc:302
Frontend(std::string name, std::string short_help="** document me **")
Definition: register.cc:266
virtual ~Frontend()
Definition: register.cc:281
void post_execute(pre_post_exec_state_t state)
Definition: register.cc:84