17#include <llvm/ADT/APInt.h>
18#include <llvm/Support/raw_ostream.h>
30bool AssignmentGenerator::generatePartialAssignment(
const ref<Expr> &e,
49 if (isa<ConstantExpr>(ep.
getKid(0))) {
52 }
else if (isa<ConstantExpr>(ep.
getKid(1))) {
72 if (isa<ConstantExpr>(ep.
getKid(0))) {
75 }
else if (isa<ConstantExpr>(ep.
getKid(1))) {
88 if (isa<ConstantExpr>(ep.
getKid(0))) {
91 }
else if (isa<ConstantExpr>(ep.
getKid(1))) {
100 }
else if (!
createDivRem(kid_val, val, sign)->isZero()) {
113 if (isa<ConstantExpr>(ep.
getKid(0))) {
116 }
else if (isa<ConstantExpr>(ep.
getKid(1))) {
128 if (!isa<ConstantExpr>(ep.
getKid(1))) {
136 if (!isa<ConstantExpr>(ep.
getKid(1))) {
150 if (isa<ConstantExpr>(ep.
getKid(0))) {
153 }
else if (isa<ConstantExpr>(ep.
getKid(1))) {
193 if (isa<ConstantExpr>(re.
index)) {
196 std::vector<unsigned char> c_value =
198 if (c_value.size() == 0) {
213 std::string type_str;
214 llvm::raw_string_ostream rso(type_str);
226 return SubExpr::create(re->
index, base->
index) == offset;
248 offset = AddExpr::create(offset, strideExpr);
254 offset = AddExpr::create(offset, strideExpr);
258 return cast<ReadExpr>(e.
get());
262 return SubExpr::create(r, l);
266 return AddExpr::create(r, l);
270 return MulExpr::create(r, l);
276 return SRemExpr::create(r, l);
278 return URemExpr::create(r, l);
284 return SDivExpr::create(r, l);
286 return UDivExpr::create(r, l);
290 return ShlExpr::create(r, l);
295 return LShrExpr::create(r, l);
299 return AndExpr::create(r, l);
317 std::vector<unsigned char> toReturn;
318 if (
ConstantExpr *value = dyn_cast<ConstantExpr>(val)) {
319 for (
unsigned w = 0; w < val.
get()->getWidth() / 8; ++w) {
321 unsigned char mem_val;
322 byte->toMemory(&mem_val);
323 toReturn.push_back(mem_val);
329std::vector<unsigned char>
332 const unsigned int size) {
333 std::vector<unsigned char> toReturn;
334 const llvm::APInt index_val = index.
getAPValue();
335 assert(!index_val.isSignMask() &&
"Negative index");
336 const uint64_t
id = index_val.getZExtValue() / c_val.size();
337 uint64_t arraySize = size / c_val.size();
338 for (uint64_t i = 0; i < arraySize; ++i) {
340 for (
unsigned arr_i = 0; arr_i < c_val.size(); ++arr_i) {
341 toReturn.push_back(c_val[arr_i]);
344 for (
unsigned arr_i = 0; arr_i < c_val.size(); ++arr_i) {
345 toReturn.push_back(0);
bool isSymbolicArray() const
static ref< Expr > createLShrExpr(const ref< Expr > &l, ref< Expr > &r)
static ref< Expr > createDivRem(const ref< Expr > &l, ref< Expr > &r, bool sign)
static bool isReadExprAtOffset(ref< Expr > e, const ReadExpr *base, ref< Expr > offset)
static ref< Expr > createAddExpr(const ref< Expr > &l, ref< Expr > &r)
static ref< Expr > createExtendExpr(const ref< Expr > &l, ref< Expr > &r)
static ref< Expr > createShlExpr(const ref< Expr > &l, ref< Expr > &r)
static ref< Expr > createExtractExpr(const ref< Expr > &l, ref< Expr > &r)
static ref< Expr > createDivExpr(const ref< Expr > &l, ref< Expr > &r, bool sign)
static bool helperGenerateAssignment(const ref< Expr > &e, ref< Expr > &val, Assignment *&a, Expr::Width width, bool sign)
static ref< Expr > createMulExpr(const ref< Expr > &l, ref< Expr > &r)
static std::vector< unsigned char > getIndexedValue(const std::vector< unsigned char > &c_val, ConstantExpr &index, const unsigned int size)
static ref< Expr > createAndExpr(const ref< Expr > &l, ref< Expr > &r)
static std::vector< unsigned char > getByteValue(ref< Expr > &val)
static ref< Expr > createSubExpr(const ref< Expr > &l, ref< Expr > &r)
static ReadExpr * hasOrderedReads(ref< Expr > e)
static ref< ConstantExpr > create(uint64_t v, Width w)
static ref< ConstantExpr > alloc(const llvm::APInt &v)
const llvm::APInt & getAPValue() const
Class representing symbolic expressions.
virtual Kind getKind() const =0
virtual Width getWidth() const =0
unsigned Width
The type of an expression is simply its width, in bits.
bool isZero() const
isZero - Is this a constant zero.
virtual ref< Expr > getKid(unsigned i) const =0
static void printKind(llvm::raw_ostream &os, Kind k)
Class representing a one byte read from an array.
void void void klee_warning(const char *msg,...) __attribute__((format(printf