mirror of https://github.com/YosysHQ/yosys.git
driver: add --hash-seed
This commit is contained in:
parent
898d042604
commit
3bd50682d8
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "kernel/yosys.h"
|
||||
#include "kernel/hashlib.h"
|
||||
#include "libs/sha1/sha1.h"
|
||||
#include "libs/cxxopts/include/cxxopts.hpp"
|
||||
#include <iostream>
|
||||
|
@ -276,6 +277,8 @@ int main(int argc, char **argv)
|
|||
options.add_options("developer")
|
||||
("X,trace", "enable tracing of core data structure changes. for debugging")
|
||||
("M,randomize-pointers", "will slightly randomize allocated pointer addresses. for debugging")
|
||||
("hash-seed", "mix up hashing values with <seed>, for extreme optimization and testing",
|
||||
cxxopts::value<uint64_t>(), "<seed>")
|
||||
("A,abort", "will call abort() at the end of the script. for debugging")
|
||||
("x,experimental", "do not print warnings for the experimental <feature>",
|
||||
cxxopts::value<std::vector<std::string>>(), "<feature>")
|
||||
|
@ -427,6 +430,10 @@ int main(int argc, char **argv)
|
|||
if (result.count("infile")) {
|
||||
frontend_files = result["infile"].as<std::vector<std::string>>();
|
||||
}
|
||||
if (result.count("hash-seed")) {
|
||||
int seed = result["hash-seed"].as<uint64_t>();
|
||||
Hasher::set_fudge((Hasher::hash_t)seed);
|
||||
}
|
||||
|
||||
if (log_errfile == NULL) {
|
||||
log_files.push_back(stdout);
|
||||
|
|
|
@ -81,13 +81,20 @@ class Hasher {
|
|||
// traditionally 5381 is used as starting value for the djb2 hash
|
||||
state = 5381;
|
||||
}
|
||||
static void set_fudge(uint32_t f) {
|
||||
fudge = f;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t state;
|
||||
static uint32_t fudge;
|
||||
// The XOR version of DJB2
|
||||
[[nodiscard]]
|
||||
static uint32_t mkhash(uint32_t a, uint32_t b) {
|
||||
return ((a << 5) + a) ^ b;
|
||||
uint32_t hash = ((a << 5) + a) ^ b;
|
||||
if (fudge)
|
||||
hash = fudge ^ mkhash_xorshift(hash);
|
||||
return hash;
|
||||
}
|
||||
public:
|
||||
void hash32(uint32_t i) {
|
||||
|
|
|
@ -92,6 +92,7 @@ std::set<std::string> yosys_input_files, yosys_output_files;
|
|||
bool memhasher_active = false;
|
||||
uint32_t memhasher_rng = 123456;
|
||||
std::vector<void*> memhasher_store;
|
||||
uint32_t Hasher::fudge = 0;
|
||||
|
||||
std::string yosys_share_dirname;
|
||||
std::string yosys_abc_executable;
|
||||
|
|
Loading…
Reference in New Issue