MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / hash

Method hash

ir/function.cpp:133–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131BasicBlock Function::sink_bb("#sink");
132
133unsigned Function::FnDecl::hash() const {
134 GenHash hash;
135
136 function<void(const Type&)> hash_ty = [&](const Type &ty) {
137 if (ty.isPtrType()) {
138 hash.add((uint8_t)0x42);
139 } else if (dynamic_cast<const VoidType*>(&ty)) {
140 hash.add((uint8_t)0xEF);
141 } else if (auto agg = ty.getAsAggregateType()) {
142 hash.add((uint8_t)0x11);
143 for (unsigned i = 0, e = agg->numElementsConst(); i != e; ++i) {
144 if (!agg->isPadding(i))
145 hash_ty(agg->getChild(i));
146 }
147 } else {
148 uint8_t data[2] = { uint8_t(0x33+ty.isFloatType()), (uint8_t)ty.bits() };
149 hash.add(data, sizeof(data));
150 }
151 };
152
153 for (auto &[ty, attrs] : inputs) {
154 hash_ty(*ty);
155 }
156 hash_ty(*output);
157 hash.add(is_varargs * 32);
158 return hash();
159}
160
161expr Function::getTypeConstraints() const {
162 expr t(true);

Callers 3

addFnCallMethod · 0.45
mkAxiomsMethod · 0.45
toSMTMethod · 0.45

Calls 7

isPtrTypeMethod · 0.80
getAsAggregateTypeMethod · 0.80
numElementsConstMethod · 0.80
isPaddingMethod · 0.80
isFloatTypeMethod · 0.80
addMethod · 0.45
bitsMethod · 0.45

Tested by

no test coverage detected