diff --git a/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.cc b/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.cc index 34801c2d1..837fee33e 100644 --- a/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.cc +++ b/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.cc @@ -81,8 +81,8 @@ struct cxxrtl_object *cxxrtl_get_parts(cxxrtl_handle handle, const char *name, s } void cxxrtl_enum(cxxrtl_handle handle, void *data, - void (*callback)(void *data, const char *name, - cxxrtl_object *object, size_t parts)) { + void (*callback)(void *data, const char *name, + cxxrtl_object *object, size_t parts)) { for (auto &it : handle->objects.table) callback(data, it.first.c_str(), static_cast(&it.second[0]), it.second.size()); } diff --git a/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.h b/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.h index 62ca38943..7deef2711 100644 --- a/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.h +++ b/backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.h @@ -305,8 +305,8 @@ static inline struct cxxrtl_object *cxxrtl_get(cxxrtl_handle handle, const char // hierarchical name of the object (see `cxxrtl_get` for details), and the object parts. // The provided `name` and `object` values are valid until the design is destroyed. void cxxrtl_enum(cxxrtl_handle handle, void *data, - void (*callback)(void *data, const char *name, - struct cxxrtl_object *object, size_t parts)); + void (*callback)(void *data, const char *name, + struct cxxrtl_object *object, size_t parts)); // Opaque reference to an outline. // diff --git a/backends/firrtl/firrtl.cc b/backends/firrtl/firrtl.cc index db5036552..a6f891f55 100644 --- a/backends/firrtl/firrtl.cc +++ b/backends/firrtl/firrtl.cc @@ -648,8 +648,8 @@ struct FirrtlWorker continue; } if (cell->type.in(ID($add), ID($sub), ID($mul), ID($div), ID($mod), ID($xor), ID($_XOR_), ID($xnor), ID($and), ID($_AND_), ID($or), ID($_OR_), ID($eq), ID($eqx), - ID($gt), ID($ge), ID($lt), ID($le), ID($ne), ID($nex), ID($shr), ID($sshr), ID($sshl), ID($shl), - ID($logic_and), ID($logic_or), ID($pow))) + ID($gt), ID($ge), ID($lt), ID($le), ID($ne), ID($nex), ID($shr), ID($sshr), ID($sshl), ID($shl), + ID($logic_and), ID($logic_or), ID($pow))) { string a_expr = make_expr(cell->getPort(ID::A)); string b_expr = make_expr(cell->getPort(ID::B)); diff --git a/backends/functional/cxx.cc b/backends/functional/cxx.cc index d67bc9143..d2f4af748 100644 --- a/backends/functional/cxx.cc +++ b/backends/functional/cxx.cc @@ -242,13 +242,13 @@ struct FunctionalCxxBackend : public Backend { FunctionalCxxBackend() : Backend("functional_cxx", "convert design to C++ using the functional backend") {} - void help() override + void help() override { // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| log("\n"); log("TODO: add help message\n"); log("\n"); - } + } void printCxx(std::ostream &stream, std::string, Module *module) { @@ -262,13 +262,13 @@ struct FunctionalCxxBackend : public Backend void execute(std::ostream *&f, std::string filename, std::vector args, RTLIL::Design *design) override { - log_header(design, "Executing Functional C++ backend.\n"); + log_header(design, "Executing Functional C++ backend.\n"); size_t argidx = 1; extra_args(f, filename, args, argidx, design); for (auto module : design->selected_modules()) { - log("Dumping module `%s'.\n", module->name); + log("Dumping module `%s'.\n", module->name); printCxx(*f, filename, module); } } diff --git a/backends/functional/smtlib_rosette.cc b/backends/functional/smtlib_rosette.cc index 1adceddd5..18027e509 100644 --- a/backends/functional/smtlib_rosette.cc +++ b/backends/functional/smtlib_rosette.cc @@ -323,8 +323,8 @@ struct SmtrModule { struct FunctionalSmtrBackend : public Backend { FunctionalSmtrBackend() : Backend("functional_rosette", "Generate Rosette compatible Racket from Functional IR") {} - void help() override { - // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| + void help() override { + // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| log("\n"); log(" write_functional_rosette [options] [filename]\n"); log("\n"); diff --git a/backends/functional/test_generic.cc b/backends/functional/test_generic.cc index d6a1ce4af..4c85f4d6e 100644 --- a/backends/functional/test_generic.cc +++ b/backends/functional/test_generic.cc @@ -120,17 +120,17 @@ struct FunctionalTestGeneric : public Pass internal(); } - void help() override + void help() override { // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| log("\n"); log("TODO: add help message\n"); log("\n"); - } + } void execute(std::vector args, RTLIL::Design *design) override { - log_header(design, "Executing Test Generic.\n"); + log_header(design, "Executing Test Generic.\n"); size_t argidx = 1; extra_args(args, argidx, design); @@ -143,7 +143,7 @@ struct FunctionalTestGeneric : public Pass */ for (auto module : design->selected_modules()) { - log("Dumping module `%s'.\n", module->name); + log("Dumping module `%s'.\n", module->name); auto fir = Functional::IR::from_module(module); for(auto node : fir) std::cout << node.name().unescape() << " = " << node.to_string([](auto n) { return n.name().unescape(); }) << "\n"; diff --git a/backends/verilog/verilog_backend.cc b/backends/verilog/verilog_backend.cc index f23742913..ceb874881 100644 --- a/backends/verilog/verilog_backend.cc +++ b/backends/verilog/verilog_backend.cc @@ -2765,7 +2765,7 @@ struct VerilogBackend : public Backend { Pass::call(design, "clean_zerowidth"); log_pop(); - design->sort_modules(); + design->sort_modules(); *f << stringf("/* Generated by %s */\n", yosys_maybe_version()); diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index 7e7c7e615..982f55802 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -1331,9 +1331,9 @@ static RTLIL::Module *process_module(RTLIL::Design *design, AstNode *ast, bool d RTLIL::Module * AST_INTERNAL::process_and_replace_module(RTLIL::Design *design, - RTLIL::Module *old_module, - AST::AstNode *new_ast, - std::unique_ptr original_ast) + RTLIL::Module *old_module, + AST::AstNode *new_ast, + std::unique_ptr original_ast) { // The old module will be deleted. Rename and mark for deletion, using // a static counter to make sure we get a unique name. diff --git a/frontends/ast/ast_binding.cc b/frontends/ast/ast_binding.cc index c20d1df4d..5b722557c 100644 --- a/frontends/ast/ast_binding.cc +++ b/frontends/ast/ast_binding.cc @@ -25,8 +25,8 @@ YOSYS_NAMESPACE_BEGIN using namespace AST_INTERNAL; AST::Binding::Binding(RTLIL::IdString target_type, - RTLIL::IdString target_name, - const AstNode &cell) + RTLIL::IdString target_name, + const AstNode &cell) : RTLIL::Binding(target_type, target_name), ast_node(cell.clone()) { diff --git a/frontends/ast/dpicall.cc b/frontends/ast/dpicall.cc index 3b1d13b09..a764a5aee 100644 --- a/frontends/ast/dpicall.cc +++ b/frontends/ast/dpicall.cc @@ -103,26 +103,26 @@ std::unique_ptr AST::dpi_call(AstSrcLocType loc, const std::string } } - if (rtype == "integer") { - types[args.size()] = &ffi_type_slong; - values[args.size()] = &value_store[args.size()].i32; - } else if (rtype == "shortreal") { - types[args.size()] = &ffi_type_float; - values[args.size()] = &value_store[args.size()].f32; - } else if (rtype == "real") { - types[args.size()] = &ffi_type_double; - values[args.size()] = &value_store[args.size()].f64; - } else if (rtype == "chandle") { - types[args.size()] = &ffi_type_pointer; - values[args.size()] = &value_store[args.size()].ptr; - } else { - log_error("invalid rtype '%s'.\n", rtype); - } + if (rtype == "integer") { + types[args.size()] = &ffi_type_slong; + values[args.size()] = &value_store[args.size()].i32; + } else if (rtype == "shortreal") { + types[args.size()] = &ffi_type_float; + values[args.size()] = &value_store[args.size()].f32; + } else if (rtype == "real") { + types[args.size()] = &ffi_type_double; + values[args.size()] = &value_store[args.size()].f64; + } else if (rtype == "chandle") { + types[args.size()] = &ffi_type_pointer; + values[args.size()] = &value_store[args.size()].ptr; + } else { + log_error("invalid rtype '%s'.\n", rtype); + } - if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args.size(), types[args.size()], types.data())) != FFI_OK) - log_error("ffi_prep_cif failed: status %d.\n", status); + if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args.size(), types[args.size()], types.data())) != FFI_OK) + log_error("ffi_prep_cif failed: status %d.\n", status); - ffi_call(&cif, resolve_fn(fname.c_str()), values[args.size()], values.data()); + ffi_call(&cif, resolve_fn(fname.c_str()), values[args.size()], values.data()); if (rtype == "real") { newNode = std::make_unique(loc, AST_REALVALUE); diff --git a/frontends/rpc/rpc_frontend.cc b/frontends/rpc/rpc_frontend.cc index bc5ef013d..675d445b3 100644 --- a/frontends/rpc/rpc_frontend.cc +++ b/frontends/rpc/rpc_frontend.cc @@ -39,12 +39,12 @@ YOSYS_NAMESPACE_BEGIN #if defined(_WIN32) static std::wstring str2wstr(const std::string &in) { - if(in == "") return L""; - std::wstring out; - out.resize(MultiByteToWideChar(/*CodePage=*/CP_UTF8, /*dwFlags=*/0, /*lpMultiByteStr=*/&in[0], /*cbMultiByte=*/(int)in.length(), /*lpWideCharStr=*/NULL, /*cchWideChar=*/0)); - int written = MultiByteToWideChar(/*CodePage=*/CP_UTF8, /*dwFlags=*/0, /*lpMultiByteStr=*/&in[0], /*cbMultiByte=*/(int)in.length(), /*lpWideCharStr=*/&out[0], /*cchWideChar=*/(int)out.length()); - log_assert(written == (int)out.length()); - return out; + if(in == "") return L""; + std::wstring out; + out.resize(MultiByteToWideChar(/*CodePage=*/CP_UTF8, /*dwFlags=*/0, /*lpMultiByteStr=*/&in[0], /*cbMultiByte=*/(int)in.length(), /*lpWideCharStr=*/NULL, /*cchWideChar=*/0)); + int written = MultiByteToWideChar(/*CodePage=*/CP_UTF8, /*dwFlags=*/0, /*lpMultiByteStr=*/&in[0], /*cbMultiByte=*/(int)in.length(), /*lpWideCharStr=*/&out[0], /*cchWideChar=*/(int)out.length()); + log_assert(written == (int)out.length()); + return out; } static std::string wstr2str(const std::wstring &in) { diff --git a/frontends/verilog/preproc.cc b/frontends/verilog/preproc.cc index 7675bab62..19f365aa7 100644 --- a/frontends/verilog/preproc.cc +++ b/frontends/verilog/preproc.cc @@ -644,8 +644,8 @@ read_define_args() // "`define". static void read_define(const std::string &filename, - define_map_t &defines_map, - define_map_t &global_defines_cache) + define_map_t &defines_map, + define_map_t &global_defines_cache) { std::string name, value; arg_map_t args; @@ -747,12 +747,12 @@ read_define(const std::string &filename, std::string frontend_verilog_preproc(std::istream &f, - std::string filename, - const define_map_t &pre_defines, - define_map_t &global_defines_cache, - const std::list &include_dirs, - ParseState &parse_state, - ParseMode &parse_mode) + std::string filename, + const define_map_t &pre_defines, + define_map_t &global_defines_cache, + const std::list &include_dirs, + ParseState &parse_state, + ParseMode &parse_mode) { define_map_t defines; defines.merge(pre_defines); diff --git a/frontends/verilog/preproc.h b/frontends/verilog/preproc.h index 8333f7661..52515f1c7 100644 --- a/frontends/verilog/preproc.h +++ b/frontends/verilog/preproc.h @@ -73,12 +73,12 @@ struct define_map_t; std::string frontend_verilog_preproc(std::istream &f, - std::string filename, - const define_map_t &pre_defines, - define_map_t &global_defines_cache, - const std::list &include_dirs, - VERILOG_FRONTEND::ParseState &parse_state, - VERILOG_FRONTEND::ParseMode &parse_mode); + std::string filename, + const define_map_t &pre_defines, + define_map_t &global_defines_cache, + const std::list &include_dirs, + VERILOG_FRONTEND::ParseState &parse_state, + VERILOG_FRONTEND::ParseMode &parse_mode); YOSYS_NAMESPACE_END diff --git a/frontends/verilog/verilog_frontend.cc b/frontends/verilog/verilog_frontend.cc index 2c35b42d5..b17c2e611 100644 --- a/frontends/verilog/verilog_frontend.cc +++ b/frontends/verilog/verilog_frontend.cc @@ -48,10 +48,10 @@ static std::list> verilog_defaults_stack; static void error_on_dpi_function(AST::AstNode *node) { - if (node->type == AST::AST_DPI_FUNCTION) - err_at_loc(node->location, "Found DPI function %s.\n", node->str); - for (auto& child : node->children) - error_on_dpi_function(child.get()); + if (node->type == AST::AST_DPI_FUNCTION) + err_at_loc(node->location, "Found DPI function %s.\n", node->str); + for (auto& child : node->children) + error_on_dpi_function(child.get()); } static void add_package_types(dict &user_types, std::vector> &package_list) diff --git a/kernel/binding.cc b/kernel/binding.cc index 621f7007b..d10d63037 100644 --- a/kernel/binding.cc +++ b/kernel/binding.cc @@ -22,7 +22,7 @@ YOSYS_NAMESPACE_BEGIN RTLIL::Binding::Binding(RTLIL::IdString target_type, - RTLIL::IdString target_name) + RTLIL::IdString target_name) : target_type(target_type), target_name(target_name) {} diff --git a/kernel/driver.cc b/kernel/driver.cc index c67630f10..82a1a5e8e 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -209,7 +209,7 @@ int main(int argc, char **argv) ("q,quiet", "quiet operation. Only write warnings and error messages to console. " \ "Use this option twice to also quiet warning messages") ("v,verbose", "print log headers up to to the console. " \ - "Implies -q for everything except the 'End of script.' message.", + "Implies -q for everything except the 'End of script.' message.", cxxopts::value(), "") ("t,timestamp", "annotate all log messages with a time stamp") ("d,detailed-timing", "print more detailed timing stats at exit") diff --git a/kernel/functional.cc b/kernel/functional.cc index d04677332..767c90b70 100644 --- a/kernel/functional.cc +++ b/kernel/functional.cc @@ -725,31 +725,31 @@ public: IR IR::from_module(Module *module) { IR ir; - auto factory = ir.factory(); - FunctionalIRConstruction ctor(module, factory); - ctor.process_queue(); - ir.topological_sort(); - ir.forward_buf(); - return ir; + auto factory = ir.factory(); + FunctionalIRConstruction ctor(module, factory); + ctor.process_queue(); + ir.topological_sort(); + ir.forward_buf(); + return ir; } void IR::topological_sort() { - Graph::SccAdaptor compute_graph_scc(_graph); - bool scc = false; - std::vector perm; - TopoSortedSccs toposort(compute_graph_scc, [&](int *begin, int *end) { - perm.insert(perm.end(), begin, end); - if (end > begin + 1) - { - log_warning("Combinational loop:\n"); - for (int *i = begin; i != end; ++i) { + Graph::SccAdaptor compute_graph_scc(_graph); + bool scc = false; + std::vector perm; + TopoSortedSccs toposort(compute_graph_scc, [&](int *begin, int *end) { + perm.insert(perm.end(), begin, end); + if (end > begin + 1) + { + log_warning("Combinational loop:\n"); + for (int *i = begin; i != end; ++i) { Node node(_graph[*i]); - log("- %s = %s\n", node.name().unescape(), node.to_string()); + log("- %s = %s\n", node.name().unescape(), node.to_string()); } - log("\n"); - scc = true; - } - }); + log("\n"); + scc = true; + } + }); for(const auto &[name, state]: _states) if(state.has_next_value()) toposort.process(state.next_value().id()); @@ -757,8 +757,8 @@ void IR::topological_sort() { if(output.has_value()) toposort.process(output.value().id()); // any nodes untouched by this point are dead code and will be removed by permute - _graph.permute(perm); - if(scc) log_error("The design contains combinational loops. This is not supported by the functional backend. " + _graph.permute(perm); + if(scc) log_error("The design contains combinational loops. This is not supported by the functional backend. " "Try `scc -select; simplemap; select -clear` to avoid this error.\n"); } @@ -770,16 +770,16 @@ static IdString merge_name(IdString a, IdString b) { } void IR::forward_buf() { - std::vector perm, alias; - perm.clear(); + std::vector perm, alias; + perm.clear(); - for (int i = 0; i < _graph.size(); ++i) - { - auto node = _graph[i]; - if (node.function().fn() == Fn::buf && node.arg(0).index() < i) - { - int target_index = alias[node.arg(0).index()]; - auto target_node = _graph[perm[target_index]]; + for (int i = 0; i < _graph.size(); ++i) + { + auto node = _graph[i]; + if (node.function().fn() == Fn::buf && node.arg(0).index() < i) + { + int target_index = alias[node.arg(0).index()]; + auto target_node = _graph[perm[target_index]]; if(node.has_sparse_attr()) { if(target_node.has_sparse_attr()) { IdString id = merge_name(node.sparse_attr(), target_node.sparse_attr()); @@ -789,15 +789,15 @@ void IR::forward_buf() { target_node.sparse_attr() = id; } } - alias.push_back(target_index); - } - else - { - alias.push_back(GetSize(perm)); - perm.push_back(i); - } - } - _graph.permute(perm, alias); + alias.push_back(target_index); + } + else + { + alias.push_back(GetSize(perm)); + perm.push_back(i); + } + } + _graph.permute(perm, alias); } // Quoting routine to make error messages nicer diff --git a/kernel/gzip.cc b/kernel/gzip.cc index 433c35902..2417bc435 100644 --- a/kernel/gzip.cc +++ b/kernel/gzip.cc @@ -18,30 +18,30 @@ YOSYS_NAMESPACE_BEGIN #ifdef YOSYS_ENABLE_ZLIB gzip_ostream::obuf::obuf() { - setp(buffer, buffer + buffer_size - 1); + setp(buffer, buffer + buffer_size - 1); } bool gzip_ostream::obuf::open(const std::string &filename) { - gzf = Zlib::gzopen(filename.c_str(), "wb"); - return gzf != nullptr; + gzf = Zlib::gzopen(filename.c_str(), "wb"); + return gzf != nullptr; } int gzip_ostream::obuf::sync() { - int num = pptr() - pbase(); - if (num > 0) { - if (Zlib::gzwrite(gzf, reinterpret_cast(pbase()), num) != num) { - return -1; - } - pbump(-num); - } - return 0; + int num = pptr() - pbase(); + if (num > 0) { + if (Zlib::gzwrite(gzf, reinterpret_cast(pbase()), num) != num) { + return -1; + } + pbump(-num); + } + return 0; } gzip_ostream::obuf::~obuf() { - if (gzf) { - sync(); - Zlib::gzclose(gzf); - } + if (gzf) { + sync(); + Zlib::gzclose(gzf); + } } bool gzip_istream::ibuf::open(const std::string& filename) { diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 3e48905fa..bf4606590 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -244,14 +244,14 @@ template struct hash_ops> { }; template struct hash_ops> { - static inline bool cmp(const std::array &a, const std::array &b) { - return a == b; - } - [[nodiscard]] static inline Hasher hash_into(const std::array &a, Hasher h) { - for (const auto& k : a) - h = hash_ops::hash_into(k, h); - return h; - } + static inline bool cmp(const std::array &a, const std::array &b) { + return a == b; + } + [[nodiscard]] static inline Hasher hash_into(const std::array &a, Hasher h) { + for (const auto& k : a) + h = hash_ops::hash_into(k, h); + return h; + } HASH_TOP_LOOP_FST (const std::array &a) HASH_TOP_LOOP_SND }; diff --git a/kernel/io.cc b/kernel/io.cc index be3c244db..a039f17e4 100644 --- a/kernel/io.cc +++ b/kernel/io.cc @@ -554,8 +554,8 @@ void format_emit_unsigned_long_long(std::string &result, std::string_view spec, return; } if (spec_parameter_size(spec) <= 4) { - // On some platforms (Wasm) we must ensure that the arg is properly aligned - // after the dynamic `int` parameters. + // On some platforms (Wasm) we must ensure that the arg is properly aligned + // after the dynamic `int` parameters. format_emit_stringf(result, spec, dynamic_ints, num_dynamic_ints, (unsigned int)arg); } else { format_emit_stringf(result, spec, dynamic_ints, num_dynamic_ints, arg); diff --git a/kernel/io.h b/kernel/io.h index 1212a8f39..afdd7b74b 100644 --- a/kernel/io.h +++ b/kernel/io.h @@ -225,7 +225,7 @@ struct ptr_has_name_member : decltype(ptr_has_name_member_imp(0)){}; // dynamic width/precision args for the next format conversion specifier. template constexpr void check_format(std::string_view fmt, int fmt_start, bool *has_escapes, FoundFormatSpec* specs, - DynamicIntCount int_args_consumed) + DynamicIntCount int_args_consumed) { FoundFormatSpec found = find_next_format_spec(fmt, fmt_start, has_escapes); if (found.num_dynamic_ints > int_args_consumed) { diff --git a/kernel/log_compat.cc b/kernel/log_compat.cc index e512fc086..e7e95c16c 100644 --- a/kernel/log_compat.cc +++ b/kernel/log_compat.cc @@ -33,63 +33,63 @@ YOSYS_NAMESPACE_BEGIN void log_cmd_error(const char *format, ...) { - va_list ap; + va_list ap; va_start(ap, format); std::string formatted = vstringf(format, ap); va_end(ap); - log_formatted_cmd_error(formatted); + log_formatted_cmd_error(formatted); } void log_warning(const char *format, ...) { - va_list ap; + va_list ap; va_start(ap, format); std::string formatted = vstringf(format, ap); va_end(ap); - log_formatted_warning("Warning: ", formatted); + log_formatted_warning("Warning: ", formatted); } void log_warning_noprefix(const char *format, ...) { - va_list ap; + va_list ap; va_start(ap, format); std::string formatted = vstringf(format, ap); va_end(ap); - log_formatted_warning("", formatted); + log_formatted_warning("", formatted); } void log_error(const char *format, ...) { - va_list ap; + va_list ap; va_start(ap, format); std::string formatted = vstringf(format, ap); va_end(ap); - log_formatted_error(formatted); + log_formatted_error(formatted); } static inline void log_formatted(std::string const &str) { - // We use this inline wrapper as the following becomes ambiguous as soon as - // the `log` function below is declared. - return log("%s", str); + // We use this inline wrapper as the following becomes ambiguous as soon as + // the `log` function below is declared. + return log("%s", str); } void log(const char *format, ...) { - va_list ap; + va_list ap; va_start(ap, format); std::string formatted = vstringf(format, ap); va_end(ap); - log_formatted(formatted); + log_formatted(formatted); } void log_compat(const char *format, ...) { - va_list ap; - va_start(ap, format); - std::string formatted = vstringf(format, ap); - va_end(ap); - log_formatted(formatted); + va_list ap; + va_start(ap, format); + std::string formatted = vstringf(format, ap); + va_end(ap); + log_formatted(formatted); } YOSYS_NAMESPACE_END diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 79466ac3b..7d77d56e8 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -302,11 +302,11 @@ struct RTLIL::IdString std::optional next() { if (suffix_number < 0) return std::nullopt; - int i = sizeof(buf); + int i = sizeof(buf); do { --i; - buf[i] = (suffix_number % 10) + '0'; - suffix_number /= 10; + buf[i] = (suffix_number % 10) + '0'; + suffix_number /= 10; } while (suffix_number > 0); suffix_number = -1; return std::string_view(buf + i, sizeof(buf) - i); @@ -746,7 +746,7 @@ template <> struct IDMacroHelper<-1> { static const YOSYS_NAMESPACE_PREFIX RTLIL::IdString id = \ YOSYS_NAMESPACE_PREFIX RTLIL::OwningIdString::immortal(q); \ return id; \ - }) + }) namespace RTLIL { extern dict constpad; @@ -1109,8 +1109,8 @@ public: bits_internal()[i] = state; } void resize(int size, RTLIL::State fill) { - log_assert(size >= 0 && size < RTLIL::WIDTH_LIMIT); - bits_internal().resize(size, fill); + log_assert(size >= 0 && size < RTLIL::WIDTH_LIMIT); + bits_internal().resize(size, fill); } class const_iterator { diff --git a/kernel/sexpr.h b/kernel/sexpr.h index 41073ea23..690c0d7de 100644 --- a/kernel/sexpr.h +++ b/kernel/sexpr.h @@ -29,92 +29,92 @@ public: std::variant, std::string> _v; public: SExpr(std::string a) : _v(std::move(a)) {} - SExpr(const char *a) : _v(a) {} - // FIXME: should maybe be defined for all integral types + SExpr(const char *a) : _v(a) {} + // FIXME: should maybe be defined for all integral types SExpr(int n) : _v(std::to_string(n)) {} SExpr(std::vector const &l) : _v(l) {} SExpr(std::vector &&l) : _v(std::move(l)) {} - // It would be nicer to have an std::initializer_list constructor, - // but that causes confusing issues with overload resolution sometimes. - template static SExpr list(Args&&... args) { + // It would be nicer to have an std::initializer_list constructor, + // but that causes confusing issues with overload resolution sometimes. + template static SExpr list(Args&&... args) { return SExpr(std::vector{std::forward(args)...}); - } - bool is_atom() const { return std::holds_alternative(_v); } - std::string const &atom() const { return std::get(_v); } - bool is_list() const { return std::holds_alternative>(_v); } - std::vector const &list() const { return std::get>(_v); } + } + bool is_atom() const { return std::holds_alternative(_v); } + std::string const &atom() const { return std::get(_v); } + bool is_list() const { return std::holds_alternative>(_v); } + std::vector const &list() const { return std::get>(_v); } std::string to_string() const; }; std::ostream &operator<<(std::ostream &os, SExpr const &sexpr); namespace SExprUtil { - // A little hack so that `using SExprUtil::list` lets you import a shortcut to `SExpr::list` - template SExpr list(Args&&... args) { + // A little hack so that `using SExprUtil::list` lets you import a shortcut to `SExpr::list` + template SExpr list(Args&&... args) { return SExpr(std::vector{std::forward(args)...}); - } + } } // SExprWriter is a pretty printer for s-expr. It does not try very hard to get a good layout. class SExprWriter { - std::ostream &os; - int _max_line_width; - int _indent = 0; - int _pos = 0; - // If _pending_nl is set, print a newline before the next character. - // This lets us "undo" the last newline so we can put - // closing parentheses or a hanging comment on the same line. - bool _pending_nl = false; - // Unclosed parentheses (boolean stored is indent_rest) + std::ostream &os; + int _max_line_width; + int _indent = 0; + int _pos = 0; + // If _pending_nl is set, print a newline before the next character. + // This lets us "undo" the last newline so we can put + // closing parentheses or a hanging comment on the same line. + bool _pending_nl = false; + // Unclosed parentheses (boolean stored is indent_rest) vector _unclosed; - // Used only for push() and pop() (stores _unclosed.size()) + // Used only for push() and pop() (stores _unclosed.size()) vector _unclosed_stack; void nl_if_pending(); - void puts(std::string_view s); - int check_fit(SExpr const &sexpr, int space); - void print(SExpr const &sexpr, bool close = true, bool indent_rest = true); + void puts(std::string_view s); + int check_fit(SExpr const &sexpr, int space); + void print(SExpr const &sexpr, bool close = true, bool indent_rest = true); public: - SExprWriter(std::ostream &os, int max_line_width = 80) - : os(os) - , _max_line_width(max_line_width) - {} - // Print an s-expr. - SExprWriter &operator <<(SExpr const &sexpr) { - print(sexpr); - _pending_nl = true; - return *this; - } - // Print an s-expr (which must be a list), but leave room for extra elements - // which may be printed using either << or further calls to open. - // If indent_rest = false, the remaining elements are not intended - // (for avoiding unreasonable indentation on deeply nested structures). - void open(SExpr const &sexpr, bool indent_rest = true) { - log_assert(sexpr.is_list()); - print(sexpr, false, indent_rest); - } - // Close the s-expr opened with the last call to open - // (if an argument is given, close that many s-exprs). - void close(size_t n = 1); - // push() remembers how many s-exprs are currently open + SExprWriter(std::ostream &os, int max_line_width = 80) + : os(os) + , _max_line_width(max_line_width) + {} + // Print an s-expr. + SExprWriter &operator <<(SExpr const &sexpr) { + print(sexpr); + _pending_nl = true; + return *this; + } + // Print an s-expr (which must be a list), but leave room for extra elements + // which may be printed using either << or further calls to open. + // If indent_rest = false, the remaining elements are not intended + // (for avoiding unreasonable indentation on deeply nested structures). + void open(SExpr const &sexpr, bool indent_rest = true) { + log_assert(sexpr.is_list()); + print(sexpr, false, indent_rest); + } + // Close the s-expr opened with the last call to open + // (if an argument is given, close that many s-exprs). + void close(size_t n = 1); + // push() remembers how many s-exprs are currently open void push() { _unclosed_stack.push_back(_unclosed.size()); } - // pop() closes all s-expr opened since the corresponding call to push() + // pop() closes all s-expr opened since the corresponding call to push() void pop() { auto t = _unclosed_stack.back(); log_assert(_unclosed.size() >= t); close(_unclosed.size() - t); _unclosed_stack.pop_back(); } - // Print a comment. - // If hanging = true, append it to the end of the last printed s-expr. + // Print a comment. + // If hanging = true, append it to the end of the last printed s-expr. void comment(std::string const &str, bool hanging = false); - // Flush any unprinted characters to the std::ostream, but does not close unclosed parentheses. - void flush() { - nl_if_pending(); - } - // Destructor closes any unclosed parentheses and flushes. - ~SExprWriter(); + // Flush any unprinted characters to the std::ostream, but does not close unclosed parentheses. + void flush() { + nl_if_pending(); + } + // Destructor closes any unclosed parentheses and flushes. + ~SExprWriter(); }; YOSYS_NAMESPACE_END diff --git a/kernel/utils.h b/kernel/utils.h index e71fb4911..3dc90fd4a 100644 --- a/kernel/utils.h +++ b/kernel/utils.h @@ -273,7 +273,7 @@ struct arrow_proxy { inline int ceil_log2(int x) { #if defined(__GNUC__) - return x > 1 ? (8*sizeof(int)) - __builtin_clz(x-1) : 0; + return x > 1 ? (8*sizeof(int)) - __builtin_clz(x-1) : 0; #else if (x <= 0) return 0; diff --git a/kernel/yosys_common.h b/kernel/yosys_common.h index 9e19814bd..07f2d6204 100644 --- a/kernel/yosys_common.h +++ b/kernel/yosys_common.h @@ -56,8 +56,8 @@ #ifndef _YOSYS_ # error It looks like you are trying to build Yosys without the config defines set. \ - When building Yosys with a custom make system, make sure you set all the \ - defines the Yosys Makefile would set for your build configuration. + When building Yosys with a custom make system, make sure you set all the \ + defines the Yosys Makefile would set for your build configuration. #endif #include "kernel/yosys_config.h" diff --git a/passes/cmds/icell_liberty.cc b/passes/cmds/icell_liberty.cc index e0a73d08f..c0af0a5d9 100644 --- a/passes/cmds/icell_liberty.cc +++ b/passes/cmds/icell_liberty.cc @@ -93,7 +93,7 @@ struct LibertyStubber { log_assert(clock_pin_name.size()); i.item("related_pin", clock_pin_name); i.indent--; - f << "\t\t\t}\n"; + f << "\t\t\t}\n"; } f << "\t\t}\n"; } diff --git a/passes/cmds/internal_stats.cc b/passes/cmds/internal_stats.cc index 65e74cc04..8a18ad324 100644 --- a/passes/cmds/internal_stats.cc +++ b/passes/cmds/internal_stats.cc @@ -37,31 +37,31 @@ PRIVATE_NAMESPACE_BEGIN std::optional current_mem_bytes() { #if defined(__APPLE__) - task_basic_info_64_data_t basicInfo; - mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT; - kern_return_t error = task_info(mach_task_self(), TASK_BASIC_INFO_64, (task_info_t)&basicInfo, &count); - if (error != KERN_SUCCESS) { - return {}; // Error getting task information - } - return basicInfo.resident_size; // Return RSS in KB + task_basic_info_64_data_t basicInfo; + mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT; + kern_return_t error = task_info(mach_task_self(), TASK_BASIC_INFO_64, (task_info_t)&basicInfo, &count); + if (error != KERN_SUCCESS) { + return {}; // Error getting task information + } + return basicInfo.resident_size; // Return RSS in KB #elif defined(__linux__) // Not all linux distributions have to have this file - std::ifstream statusFile("/proc/self/status"); - std::string line; - while (std::getline(statusFile, line)) { - if (line.find("VmRSS:") == 0) { - std::istringstream iss(line); - std::string token; + std::ifstream statusFile("/proc/self/status"); + std::string line; + while (std::getline(statusFile, line)) { + if (line.find("VmRSS:") == 0) { + std::istringstream iss(line); + std::string token; // Skip prefix - iss >> token; - uint64_t rss; - iss >> rss; - return rss * 1024; - } - } + iss >> token; + uint64_t rss; + iss >> rss; + return rss * 1024; + } + } // Error reading /proc/self/status - return {}; + return {}; #else return {}; diff --git a/passes/cmds/sort.cc b/passes/cmds/sort.cc index ab058880e..f57ee587d 100644 --- a/passes/cmds/sort.cc +++ b/passes/cmds/sort.cc @@ -17,9 +17,9 @@ struct SortPass : Pass { void execute(std::vector args, RTLIL::Design *d) override { log_header(d, "Executing SORT pass.\n"); - if (args.size() != 1) - log_cmd_error("This pass takes no arguments.\n"); - d->sort(); + if (args.size() != 1) + log_cmd_error("This pass takes no arguments.\n"); + d->sort(); } } SortPass; diff --git a/passes/hierarchy/flatten.cc b/passes/hierarchy/flatten.cc index 29e7205ee..dd623a7c7 100644 --- a/passes/hierarchy/flatten.cc +++ b/passes/hierarchy/flatten.cc @@ -31,15 +31,15 @@ PRIVATE_NAMESPACE_BEGIN template [[nodiscard]] std::string concat_views(const Args&... views) { - static_assert((std::is_convertible_v && ...), - "All arguments must be convertible to std::string_view."); - const std::size_t total_size = (std::string_view(views).size() + ... + 0); + static_assert((std::is_convertible_v && ...), + "All arguments must be convertible to std::string_view."); + const std::size_t total_size = (std::string_view(views).size() + ... + 0); - std::string result; - result.reserve(total_size); + std::string result; + result.reserve(total_size); - (result.append(views), ...); - return result; + (result.append(views), ...); + return result; } IdString concat_name(RTLIL::Cell *cell, IdString const &object_name, const std::string &separator = ".") @@ -427,7 +427,7 @@ struct FlattenPass : public Pass { for (auto cell : module->selected_cells()) { RTLIL::Module *tpl = design->module(cell->type); if (tpl != nullptr) { - if (!topo_modules.has_node(tpl)) + if (!topo_modules.has_node(tpl)) worklist.insert(tpl); topo_modules.edge(tpl, module); } diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index 74edbabf4..88d3b89d6 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -368,10 +368,10 @@ struct IFExpander // something. or null otherwise (the module should be blackbox or we couldn't // find it and check is not set). RTLIL::Module *get_module(RTLIL::Design &design, - RTLIL::Cell &cell, - RTLIL::Module &parent, - bool check, - const std::vector &libdirs) + RTLIL::Cell &cell, + RTLIL::Module &parent, + bool check, + const std::vector &libdirs) { std::string cell_type = cell.type.str(); RTLIL::Module *abs_mod = design.module("$abstract" + cell_type); diff --git a/passes/sat/mutate.cc b/passes/sat/mutate.cc index 63a8de277..11a680ab0 100644 --- a/passes/sat/mutate.cc +++ b/passes/sat/mutate.cc @@ -379,16 +379,16 @@ void database_reduce(std::vector &database, const mutate_opts_t &opts, } #define X(__wght, __queue) \ - k -= __wght; \ - if (k < 0) { \ - mutate_t *m = __queue.pick(rng, coverdb, opts); \ - if (m != nullptr) { \ - m->used = true; \ - coverdb.update(*m); \ - new_database.push_back(*m); \ - }; \ - continue; \ - } + k -= __wght; \ + if (k < 0) { \ + mutate_t *m = __queue.pick(rng, coverdb, opts); \ + if (m != nullptr) { \ + m->used = true; \ + coverdb.update(*m); \ + new_database.push_back(*m); \ + }; \ + continue; \ + } X(opts.weight_pq_w, primary_queue_wire) X(opts.weight_pq_b, primary_queue_bit) diff --git a/passes/techmap/clockgate.cc b/passes/techmap/clockgate.cc index 650719cd5..b26e331e0 100644 --- a/passes/techmap/clockgate.cc +++ b/passes/techmap/clockgate.cc @@ -412,7 +412,7 @@ struct ClockgatePass : public Pass { } log("Converted %d FFs.\n", gated_flop_count); - } + } } ClockgatePass; diff --git a/passes/techmap/dfflibmap.cc b/passes/techmap/dfflibmap.cc index 9320c6acc..8f5d449de 100644 --- a/passes/techmap/dfflibmap.cc +++ b/passes/techmap/dfflibmap.cc @@ -244,7 +244,7 @@ static bool parse_pin(const LibertyAst *cell, const LibertyAst *attr, std::strin /* If we end up here, the pin specified in the attribute does not exist, which is an error, or, the attribute contains an expression which we do not yet support. - For now, we'll simply produce a warning to let the user know something is up. + For now, we'll simply produce a warning to let the user know something is up. */ if (pin_name.find_first_of("^*|&") == std::string::npos) { log_debug("Malformed liberty file - cannot find pin '%s' in cell '%s' - skipping.\n", pin_name, cell->args[0]); diff --git a/tests/unit/kernel/bitpatternTest.cc b/tests/unit/kernel/bitpatternTest.cc index a641b85a3..b54646fec 100644 --- a/tests/unit/kernel/bitpatternTest.cc +++ b/tests/unit/kernel/bitpatternTest.cc @@ -7,36 +7,36 @@ YOSYS_NAMESPACE_BEGIN TEST(BitpatternTest, has) { - SigSpec _aaa = {RTLIL::Sa, RTLIL::Sa, RTLIL::Sa}; - SigSpec _01a = {RTLIL::S0, RTLIL::S1, RTLIL::Sa}; - SigSpec _011 = {RTLIL::S0, RTLIL::S1, RTLIL::S1}; - SigSpec _111 = {RTLIL::S1, RTLIL::S1, RTLIL::S1}; - SigSpec _01x = {RTLIL::S0, RTLIL::S1, RTLIL::Sx}; - SigSpec _01z = {RTLIL::S0, RTLIL::S1, RTLIL::Sz}; + SigSpec _aaa = {RTLIL::Sa, RTLIL::Sa, RTLIL::Sa}; + SigSpec _01a = {RTLIL::S0, RTLIL::S1, RTLIL::Sa}; + SigSpec _011 = {RTLIL::S0, RTLIL::S1, RTLIL::S1}; + SigSpec _111 = {RTLIL::S1, RTLIL::S1, RTLIL::S1}; + SigSpec _01x = {RTLIL::S0, RTLIL::S1, RTLIL::Sx}; + SigSpec _01z = {RTLIL::S0, RTLIL::S1, RTLIL::Sz}; - EXPECT_TRUE(BitPatternPool(_aaa).has_any(_01a)); - EXPECT_TRUE(BitPatternPool(_01a).has_any(_01a)); - // 011 overlaps with 01a - EXPECT_TRUE(BitPatternPool(_011).has_any(_01a)); - // overlap is symmetric - EXPECT_TRUE(BitPatternPool(_01a).has_any(_011)); - EXPECT_FALSE(BitPatternPool(_111).has_any(_01a)); - // overlaps nothing - EXPECT_FALSE(BitPatternPool(_011).has_any(_01x)); - EXPECT_FALSE(BitPatternPool(_011).has_any(_01z)); - EXPECT_FALSE(BitPatternPool(_aaa).has_any(_01x)); + EXPECT_TRUE(BitPatternPool(_aaa).has_any(_01a)); + EXPECT_TRUE(BitPatternPool(_01a).has_any(_01a)); + // 011 overlaps with 01a + EXPECT_TRUE(BitPatternPool(_011).has_any(_01a)); + // overlap is symmetric + EXPECT_TRUE(BitPatternPool(_01a).has_any(_011)); + EXPECT_FALSE(BitPatternPool(_111).has_any(_01a)); + // overlaps nothing + EXPECT_FALSE(BitPatternPool(_011).has_any(_01x)); + EXPECT_FALSE(BitPatternPool(_011).has_any(_01z)); + EXPECT_FALSE(BitPatternPool(_aaa).has_any(_01x)); EXPECT_TRUE(BitPatternPool(_aaa).has_all(_01a)); EXPECT_TRUE(BitPatternPool(_01a).has_all(_01a)); - // 011 is covered by 01a - EXPECT_TRUE(BitPatternPool(_01a).has_all(_011)); - // 01a is not covered by 011 - EXPECT_FALSE(BitPatternPool(_011).has_all(_01a)); - EXPECT_FALSE(BitPatternPool(_111).has_all(_01a)); - // trivially covered by any pool - EXPECT_TRUE(BitPatternPool(_011).has_all(_01x)); - EXPECT_TRUE(BitPatternPool(_011).has_all(_01z)); - EXPECT_TRUE(BitPatternPool(_111).has_all(_01x)); + // 011 is covered by 01a + EXPECT_TRUE(BitPatternPool(_01a).has_all(_011)); + // 01a is not covered by 011 + EXPECT_FALSE(BitPatternPool(_011).has_all(_01a)); + EXPECT_FALSE(BitPatternPool(_111).has_all(_01a)); + // trivially covered by any pool + EXPECT_TRUE(BitPatternPool(_011).has_all(_01x)); + EXPECT_TRUE(BitPatternPool(_011).has_all(_01z)); + EXPECT_TRUE(BitPatternPool(_111).has_all(_01x)); } YOSYS_NAMESPACE_END diff --git a/tests/unit/kernel/ioTest.cc b/tests/unit/kernel/ioTest.cc index 6186c34cb..c1c0f639f 100644 --- a/tests/unit/kernel/ioTest.cc +++ b/tests/unit/kernel/ioTest.cc @@ -15,8 +15,8 @@ TEST(KernelStringfTest, integerTruncation) TEST(KernelStringfTest, charFormat) { - EXPECT_EQ(stringf("%c", 256), std::string_view("\0", 1)); - EXPECT_EQ(stringf("%c", -1), "\377"); + EXPECT_EQ(stringf("%c", 256), std::string_view("\0", 1)); + EXPECT_EQ(stringf("%c", -1), "\377"); } TEST(KernelStringfTest, floatFormat) @@ -26,29 +26,29 @@ TEST(KernelStringfTest, floatFormat) TEST(KernelStringfTest, intToFloat) { - EXPECT_EQ(stringf("%g", 1), "1"); + EXPECT_EQ(stringf("%g", 1), "1"); } TEST(KernelStringfTest, floatToInt) { - EXPECT_EQ(stringf("%d", 1.0), "1"); - EXPECT_EQ(stringf("%d", -1.6), "-1"); + EXPECT_EQ(stringf("%d", 1.0), "1"); + EXPECT_EQ(stringf("%d", -1.6), "-1"); } TEST(KernelStringfTest, stringParam) { - EXPECT_EQ(stringf("%s", std::string("hello")), "hello"); + EXPECT_EQ(stringf("%s", std::string("hello")), "hello"); } TEST(KernelStringfTest, stringViewParam) { - EXPECT_EQ(stringf("%s", std::string_view("hello")), "hello"); + EXPECT_EQ(stringf("%s", std::string_view("hello")), "hello"); } TEST(KernelStringfTest, idStringParam) { - RTLIL::IdString id("$hello"); - EXPECT_EQ(stringf("%s", id), "$hello"); + RTLIL::IdString id("$hello"); + EXPECT_EQ(stringf("%s", id), "$hello"); } TEST(KernelStringfTest, escapePercent) @@ -63,27 +63,27 @@ TEST(KernelStringfTest, trailingPercent) TEST(KernelStringfTest, dynamicWidth) { - EXPECT_EQ(stringf("%*s", 8, "hello"), " hello"); + EXPECT_EQ(stringf("%*s", 8, "hello"), " hello"); } TEST(KernelStringfTest, dynamicPrecision) { - EXPECT_EQ(stringf("%.*f", 4, 1.0), "1.0000"); + EXPECT_EQ(stringf("%.*f", 4, 1.0), "1.0000"); } TEST(KernelStringfTest, dynamicWidthAndPrecision) { - EXPECT_EQ(stringf("%*.*f", 8, 4, 1.0), " 1.0000"); + EXPECT_EQ(stringf("%*.*f", 8, 4, 1.0), " 1.0000"); } TEST(KernelStringfTest, dynamicPrecisionInt) { - EXPECT_EQ(stringf("%.*d", 4, 7), "0007"); + EXPECT_EQ(stringf("%.*d", 4, 7), "0007"); } TEST(KernelStringfTest, dynamicWidthAndPrecisionInt) { - EXPECT_EQ(stringf("%*.*d", 8, 4, 7), " 0007"); + EXPECT_EQ(stringf("%*.*d", 8, 4, 7), " 0007"); } YOSYS_NAMESPACE_END