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

Method mkUndef

ir/pointer.cpp:137–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137expr Pointer::mkUndef(State &s) {
138 auto &m = s.getMemory();
139 bool force_local = false, force_nonlocal = false;
140 if (hasLocalBit()) {
141 force_nonlocal = m.numLocals() == 0;
142 force_local = !force_nonlocal && m.numNonlocals() == 0;
143 }
144
145 unsigned bits_phy = hasLogicalBit() * bits_ptr_address;
146 unsigned bits_log
147 = bits_for_bid + bits_for_offset - (force_local | force_nonlocal);
148 unsigned var_bits = hasLogicalBit() + max(bits_log, bits_phy);
149
150 expr var = expr::mkFreshVar("undef", expr::mkUInt(0, var_bits));
151
152 expr ptr;
153 if (bits_log >= bits_phy) {
154 ptr = var.trunc(bits_log);
155 if (force_local || force_nonlocal)
156 ptr = mkLongBid(ptr, force_local);
157 if (hasLogicalBit())
158 ptr = var.sign().concat(ptr);
159 } else {
160 ptr = var;
161 }
162
163 ptr = ptr.concat_zeros(bits_for_ptrattrs);
164
165 s.addUndefVar(std::move(var));
166 assert(ptr.bits() == totalBits());
167 return ptr;
168}
169
170unsigned Pointer::totalBits() {
171 return max(total_bits_logical(), total_bits_physical());

Callers

nothing calls this directly

Calls 9

hasLogicalBitFunction · 0.85
numLocalsMethod · 0.80
numNonlocalsMethod · 0.80
signMethod · 0.80
concat_zerosMethod · 0.80
addUndefVarMethod · 0.80
truncMethod · 0.45
concatMethod · 0.45
bitsMethod · 0.45

Tested by

no test coverage detected