X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=kernel%2Fyosys.cc;h=377572fc2984243a2ede59d2e35af34a7fa27b8d;hb=d26646051c4ae9740decd5d76eec6a3afd63844a;hp=a12355f1d509453bf54bc6b4414f019e90fcee73;hpb=4883391b6331e62226c46e797f82a31ef9ef81a3;p=yosys.git diff --git a/kernel/yosys.cc b/kernel/yosys.cc index a12355f1d..377572fc2 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -151,14 +151,16 @@ void yosys_banner() int ceil_log2(int x) { +#if defined(__GNUC__) + return x > 1 ? (8*sizeof(int)) - __builtin_clz(x-1) : 0; +#else if (x <= 0) return 0; - for (int i = 0; i < 32; i++) if (((x-1) >> i) == 0) return i; - log_abort(); +#endif } std::string stringf(const char *fmt, ...) @@ -482,6 +484,20 @@ void remove_directory(std::string dirname) #endif } +std::string escape_filename_spaces(const std::string& filename) +{ + std::string out; + out.reserve(filename.size()); + for (auto c : filename) + { + if (c == ' ') + out += "\\ "; + else + out.push_back(c); + } + return out; +} + int GetSize(RTLIL::Wire *wire) { return wire->width;