2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
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.
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.
20 #include "kernel/yosys.h"
29 std::string pass_name
, short_help
;
30 Pass(std::string name
, std::string short_help
= "** document me **");
34 virtual void execute(std::vector
<std::string
> args
, RTLIL::Design
*design
) = 0;
39 struct pre_post_exec_state_t
{
44 pre_post_exec_state_t
pre_execute();
45 void post_execute(pre_post_exec_state_t state
);
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);
51 static void call(RTLIL::Design
*design
, std::string command
);
52 static void call(RTLIL::Design
*design
, std::vector
<std::string
> args
);
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
);
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
);
60 Pass
*next_queued_pass
;
61 virtual void run_register();
62 static void init_register();
63 static void done_register();
66 struct Frontend
: Pass
68 // for reading of here documents
69 static FILE *current_script_file
;
70 static std::string last_here_document
;
72 std::string frontend_name
;
73 Frontend(std::string name
, std::string short_help
= "** document me **");
74 virtual void run_register();
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;
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
);
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
);
88 std::string backend_name
;
89 Backend(std::string name
, std::string short_help
= "** document me **");
90 virtual void run_register();
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;
95 void extra_args(std::ostream
*&f
, std::string
&filename
, std::vector
<std::string
> args
, size_t argidx
);
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
);
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
);
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
;