8#include "llvm/Support/raw_ostream.h"
9#include "llvm/Support/Debug.h"
10#include "llvm/ADT/StringRef.h"
11#include "llvm/Support/FileSystem.h"
28 HDLMain(CompilerInstance &ci, std::string topModule =
"!none",
29 const std::string &hdl_file_out =
"default_hdl.txt")
31 HDLMain(ASTUnit *from_ast, std::string topModule =
"!none",
32 const std::string &hdl_file_out =
"default_hdl.txt")
39 llvm::raw_fd_ostream &SCout);
89 class HDLAXN :
public ASTFrontendAction {
92 HDLAXN(
const std::string &top,
const std::string &hdl_file_out)
101 clang::CompilerInstance &Compiler, llvm::StringRef inFile) {
113 const std::string &hdl_file_out)
116 std::unique_ptr<clang::FrontendAction>
create()
override {
117 return std::unique_ptr<FrontendAction>(
138 llvm::cl::OptionCategory HDLcategory(
"HDL options");
139 llvm::cl::opt<std::string> topModule(
142 "Specify top-level module declaration for synthesis entry point"),
143 llvm::cl::cat(HDLcategory));
145 llvm::cl::opt<bool> debug_mode(
146 "debug", llvm::cl::desc(
"Enable debug output from systemc-clang"),
147 llvm::cl::cat(HDLcategory));
149 llvm::cl::opt<std::string> debug_only(
151 llvm::cl::desc(
"Enable debug only for the specified DEBUG_TYPE"),
152 llvm::cl::cat(HDLcategory));
154 llvm::cl::opt<std::string> hdl_file_out(
155 "hdl-file-out", llvm::cl::desc(
"HDL output file location"),
156 llvm::cl::cat(HDLcategory));
160 llvm::Expected<clang::tooling::CommonOptionsParser> options_parser{
161 clang::tooling::CommonOptionsParser::create(argc, argv, HDLcategory)};
163 llvm::dbgs() <<
"Options parser\n";
164 if (
auto err = options_parser.takeError() ) {
165 llvm::logAllUnhandledErrors(std::move(err), llvm::errs(),
"[PluginAction Error]");
171 ClangTool Tool(options_parser->getCompilations(),
172 options_parser->getSourcePathList());
176 if (debug_mode || (debug_only !=
"") ) {
177 LLVM_DEBUG(llvm::dbgs() <<
"Debug mode enabled\n";);
178 llvm::DebugFlag =
true;
181 if (debug_only !=
"") {
183 setCurrentDebugType(debug_only.c_str());
185 llvm::setCurrentDebugType(debug_only.c_str());
189 if (hdl_file_out !=
"") {
190 LLVM_DEBUG(llvm::dbgs()
191 <<
"HDL output file specified: " << hdl_file_out <<
"\n";);
194 std::unique_ptr<FrontendActionFactory> FrontendFactory;
198 FrontendFactory = std::unique_ptr<tooling::FrontendActionFactory>(
200 Tool.run(FrontendFactory.get());
std::vector< std::tuple< std::string, PortDecl * > > portMapType
std::map< std::string, SignalDecl * > signalMapType
std::map< std::string, ProcessDecl * > processMapType
This is the main consumer class that beings the parsing of SystemC.
clang::ASTContext & getContext() const
virtual std::unique_ptr< ASTConsumer > CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef inFile)
HDLAXN(const std::string &top)
std::string hdl_file_out_
HDLAXN(const std::string &top, const std::string &hdl_file_out)
std::string top_module_declaration_
std::string hdl_file_out_
HDLFrontendActionFactory(const std::string &top, const std::string &hdl_file_out)
HDLFrontendActionFactory(const std::string &top)
std::unique_ptr< clang::FrontendAction > create() override
void SCport2hcode(ModuleInstance::portMapType pmap, hNode::hdlopsEnum h_op, hNodep &h_info, hdecl_name_map_t &mod_vname_map)
clang::DiagnosticsEngine & main_diag_engine
void SCportbindings2hcode(ModuleInstance *mod, hNodep &h_pb)
hmodinst_name_map_t mod_name_map
void SCmodule2hcode(ModuleInstance *mod, hNodep &h_module, llvm::raw_fd_ostream &SCout)
void MakeResetMap(resetvar_map_t &threadresetmap, hNodep h_allsenslists)
HDLMain(CompilerInstance &ci, std::string topModule="!none", const std::string &hdl_file_out="default_hdl.txt")
Provide hdl_file_out as argument.
void SCsig2hcode(ModuleInstance::signalMapType pmap, hNode::hdlopsEnum h_op, hNodep &h_info, hdecl_name_map_t &mod_vname_map)
void SCproc2hcode(ModuleInstance::processMapType pm, hNodep &h_top, hNodep &h_port, hdecl_name_map_t &mod_vname_map, overridden_method_map_t &overridden_method_map, resetvar_map_t &threadresetmap)
void GenerateInstanceNames(ModuleInstance *smod, std::vector< std::string > &instnames)
resetvar_map_t threadresetmap
std::unordered_set< string > module_vars
bool isValidMethod(CXXMethodDecl *method)
HDLMain(ASTUnit *from_ast, std::string topModule="!none", const std::string &hdl_file_out="default_hdl.txt")
hfunc_name_map_t allmethodecls
std::string hdl_file_out_
Command line options.
HDLPluginAction(int argc, const char **argv)
Clang forward declarations.
std::unordered_map< string, hNodep > resetvar_map_t
std::unordered_map< const CXXMethodDecl *, const CXXMethodDecl * > overridden_method_map_t