Skip to content

Commit

Permalink
add support for vector ptrmask
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Sep 29, 2023
1 parent f57e6f5 commit fc4c2b2
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions ir/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3814,16 +3814,32 @@ void PtrMask::print(ostream &os) const {
StateValue PtrMask::toSMT(State &s) const {
auto &ptrval = s[*ptr];
auto &maskval = s[*mask];
Pointer ptr(s.getMemory(), ptrval.value);
return { ptr.maskOffset(maskval.value).release(),
ptrval.non_poison && maskval.non_poison };

auto fn = [&](const StateValue &ptrval, const StateValue &mask) -> StateValue {
Pointer ptr(s.getMemory(), ptrval.value);
return { ptr.maskOffset(mask.value).release(),
ptrval.non_poison && mask.non_poison };
};

if (auto agg = getType().getAsAggregateType()) {
auto maskTy = mask->getType().getAsAggregateType();
assert(maskTy);
vector<StateValue> vals;
for (unsigned i = 0, e = agg->numElementsConst(); i != e; ++i) {
vals.emplace_back(fn(agg->extract(ptrval, i),
maskTy->extract(maskval, i)));
}
return agg->aggregateVals(vals);
}
return fn(ptrval, maskval);
}

expr PtrMask::getTypeConstraints(const Function &f) const {
return Value::getTypeConstraints() &&
ptr->getType().enforcePtrType() &&
ptr->getType().enforcePtrOrVectorType() &&
getType() == ptr->getType() &&
mask->getType().enforceIntType();
mask->getType().enforceIntOrVectorType() &&
ptr->getType().enforceVectorTypeIff(mask->getType());
}

unique_ptr<Instr> PtrMask::dup(Function &f, const string &suffix) const {
Expand Down

0 comments on commit fc4c2b2

Please sign in to comment.