mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-10-07 18:43:22 +02:00
chores: first pass of fixes spaces to tabs
This commit is contained in:
+1
-1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user