Merge branch 'koriakin/xc7nocarrymux' into xaig
[yosys.git] / kernel / yosys.cc
index 20d972150a978239ae96731ef5622b47929a488a..94d6d675f968ff24a2e205e24c39096a955a14ae 100644 (file)
@@ -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, ...)
@@ -649,6 +651,10 @@ void rewrite_filename(std::string &filename)
                filename = filename.substr(1, GetSize(filename)-2);
        if (filename.substr(0, 2) == "+/")
                filename = proc_share_dirname() + filename.substr(2);
+#ifndef _WIN32
+       if (filename.substr(0, 2) == "~/")
+               filename = filename.replace(0, 1, getenv("HOME"));
+#endif
 }
 
 #ifdef YOSYS_ENABLE_TCL