chores: first pass of fixes spaces to tabs

This commit is contained in:
Miodrag Milanovic
2026-08-21 14:43:33 +02:00
parent a55d987b3a
commit b1fda43bcd
36 changed files with 304 additions and 304 deletions
@@ -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<cxxrtl_object*>(&it.second[0]), it.second.size());
}
@@ -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.
//
+2 -2
View File
@@ -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));
+4 -4
View File
@@ -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<std::string> 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);
}
}
+2 -2
View File
@@ -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");
+4 -4
View File
@@ -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<std::string> 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";
+1 -1
View File
@@ -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());
+3 -3
View File
@@ -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<AstNode> original_ast)
RTLIL::Module *old_module,
AST::AstNode *new_ast,
std::unique_ptr<AstNode> 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.
+2 -2
View File
@@ -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())
{
+18 -18
View File
@@ -103,26 +103,26 @@ std::unique_ptr<AST::AstNode> 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<AstNode>(loc, AST_REALVALUE);
+6 -6
View File
@@ -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) {
+8 -8
View File
@@ -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<std::string> &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<std::string> &include_dirs,
ParseState &parse_state,
ParseMode &parse_mode)
{
define_map_t defines;
defines.merge(pre_defines);
+6 -6
View File
@@ -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<std::string> &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<std::string> &include_dirs,
VERILOG_FRONTEND::ParseState &parse_state,
VERILOG_FRONTEND::ParseMode &parse_mode);
YOSYS_NAMESPACE_END
+4 -4
View File
@@ -48,10 +48,10 @@ static std::list<std::vector<std::string>> 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<std::string, AST::AstNode *> &user_types, std::vector<std::unique_ptr<AST::AstNode>> &package_list)
+1 -1
View File
@@ -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)
{}
+1 -1
View File
@@ -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 <level> 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<int>(), "<level>")
("t,timestamp", "annotate all log messages with a time stamp")
("d,detailed-timing", "print more detailed timing stats at exit")
+40 -40
View File
@@ -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<int> 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<int> 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<int> perm, alias;
perm.clear();
std::vector<int> 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
+15 -15
View File
@@ -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<const void*>(pbase()), num) != num) {
return -1;
}
pbump(-num);
}
return 0;
int num = pptr() - pbase();
if (num > 0) {
if (Zlib::gzwrite(gzf, reinterpret_cast<const void*>(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) {
+8 -8
View File
@@ -244,14 +244,14 @@ template<typename T> struct hash_ops<std::vector<T>> {
};
template<typename T, size_t N> struct hash_ops<std::array<T, N>> {
static inline bool cmp(const std::array<T, N> &a, const std::array<T, N> &b) {
return a == b;
}
[[nodiscard]] static inline Hasher hash_into(const std::array<T, N> &a, Hasher h) {
for (const auto& k : a)
h = hash_ops<T>::hash_into(k, h);
return h;
}
static inline bool cmp(const std::array<T, N> &a, const std::array<T, N> &b) {
return a == b;
}
[[nodiscard]] static inline Hasher hash_into(const std::array<T, N> &a, Hasher h) {
for (const auto& k : a)
h = hash_ops<T>::hash_into(k, h);
return h;
}
HASH_TOP_LOOP_FST (const std::array<T, N> &a) HASH_TOP_LOOP_SND
};
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -225,7 +225,7 @@ struct ptr_has_name_member : decltype(ptr_has_name_member_imp<T>(0)){};
// dynamic width/precision args for the next format conversion specifier.
template <typename Arg, typename... Args>
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) {
+18 -18
View File
@@ -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
+6 -6
View File
@@ -302,11 +302,11 @@ struct RTLIL::IdString
std::optional<std::string_view> 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<std::string, std::string> 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 {
+57 -57
View File
@@ -29,92 +29,92 @@ public:
std::variant<std::vector<SExpr>, 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<SExpr> const &l) : _v(l) {}
SExpr(std::vector<SExpr> &&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<typename... Args> 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<typename... Args> static SExpr list(Args&&... args) {
return SExpr(std::vector<SExpr>{std::forward<Args>(args)...});
}
bool is_atom() const { return std::holds_alternative<std::string>(_v); }
std::string const &atom() const { return std::get<std::string>(_v); }
bool is_list() const { return std::holds_alternative<std::vector<SExpr>>(_v); }
std::vector<SExpr> const &list() const { return std::get<std::vector<SExpr>>(_v); }
}
bool is_atom() const { return std::holds_alternative<std::string>(_v); }
std::string const &atom() const { return std::get<std::string>(_v); }
bool is_list() const { return std::holds_alternative<std::vector<SExpr>>(_v); }
std::vector<SExpr> const &list() const { return std::get<std::vector<SExpr>>(_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<typename... Args> SExpr list(Args&&... args) {
// A little hack so that `using SExprUtil::list` lets you import a shortcut to `SExpr::list`
template<typename... Args> SExpr list(Args&&... args) {
return SExpr(std::vector<SExpr>{std::forward<Args>(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<bool> _unclosed;
// Used only for push() and pop() (stores _unclosed.size())
// Used only for push() and pop() (stores _unclosed.size())
vector<size_t> _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
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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"
+1 -1
View File
@@ -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";
}
+20 -20
View File
@@ -37,31 +37,31 @@ PRIVATE_NAMESPACE_BEGIN
std::optional<uint64_t> 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 {};
+3 -3
View File
@@ -17,9 +17,9 @@ struct SortPass : Pass {
void execute(std::vector<std::string> 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;
+8 -8
View File
@@ -31,15 +31,15 @@ PRIVATE_NAMESPACE_BEGIN
template <typename... Args>
[[nodiscard]] std::string concat_views(const Args&... views) {
static_assert((std::is_convertible_v<Args, std::string_view> && ...),
"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<Args, std::string_view> && ...),
"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);
}
+4 -4
View File
@@ -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<std::string> &libdirs)
RTLIL::Cell &cell,
RTLIL::Module &parent,
bool check,
const std::vector<std::string> &libdirs)
{
std::string cell_type = cell.type.str();
RTLIL::Module *abs_mod = design.module("$abstract" + cell_type);
+10 -10
View File
@@ -379,16 +379,16 @@ void database_reduce(std::vector<mutate_t> &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)
+1 -1
View File
@@ -412,7 +412,7 @@ struct ClockgatePass : public Pass {
}
log("Converted %d FFs.\n", gated_flop_count);
}
}
} ClockgatePass;
+1 -1
View File
@@ -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]);
+26 -26
View File
@@ -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
+14 -14
View File
@@ -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