simplifications to previous commit
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -1927,7 +1927,7 @@ void ExtractElement::print(ostream &os) const {
StateValue ExtractElement::toSMT(State &s) const {
auto &[iv, ip] = s[*idx];
- auto vty = v->getType().getAsVectorType();
+ auto vty = static_cast<const VectorType*>(v->getType().getAsAggregateType());
expr inbounds = iv.ult(vty->numElementsConst());
auto [rv, rp] = vty->extract(s[*v], iv);
return { move(rv), ip && inbounds && rp };
@@ -1961,7 +1961,7 @@ void InsertElement::print(ostream &os) const {
StateValue InsertElement::toSMT(State &s) const {
auto &[iv, ip] = s[*idx];
- auto vty = v->getType().getAsVectorType();
+ auto vty = static_cast<const VectorType*>(v->getType().getAsAggregateType());
expr inbounds = iv.ult(vty->numElementsConst());
auto [rv, rp] = vty->update(s[*v], s[*e], iv);
return { move(rv), expr::mkIf(ip && inbounds, move(rp),
@@ -1997,7 +1997,7 @@ void ShuffleVector::print(ostream &os) const {
}
StateValue ShuffleVector::toSMT(State &s) const {
- auto vty = v1->getType().getAsVectorType();
+ auto vty = static_cast<const VectorType*>(v1->getType().getAsAggregateType());
expr sz = expr::mkUInt(vty->numElementsConst(), 32);
auto mty = mask->getType().getAsAggregateType();
vector<StateValue> vals;

MODIFY
ir/type.cpp
ir/type.cpp
@@ -215,10 +215,6 @@ const StructType* Type::getAsStructType() const {
return nullptr;
}
-const VectorType* Type::getAsVectorType() const {
- return nullptr;
-}
-
expr Type::toBV(expr e) const {
return e;
}
@@ -760,12 +756,8 @@ VectorType::VectorType(string &&name, unsigned elements, Type &elementTy)
StateValue VectorType::extract(const StateValue &val,
const expr &index) const {
auto &elementTy = *children[0];
- for (unsigned i = 1; i < elements; ++i) {
- assert(elementTy.bits() == children[i]->bits());
- }
unsigned bw_elem = elementTy.bits();
- unsigned bw_val = val.value.bits();
- assert(bw_val == val.non_poison.bits());
+ unsigned bw_val = val.bits();
expr idx = index.zextOrTrunc(bw_val) * expr::mkUInt(bw_elem, bw_val);
unsigned h = elements * bw_elem - 1;
@@ -779,10 +771,6 @@ StateValue VectorType::update(const StateValue &val,
const StateValue &n,
const expr &index) const {
auto &elementTy = *children[0];
- for (unsigned i = 1; i < elements; ++i) {
- assert(elementTy.bits() == children[i]->bits());
- }
-
unsigned bw_elem = elementTy.bits();
unsigned bw_val = bits();
@@ -828,10 +816,6 @@ void VectorType::print(ostream &os) const {
os << '<' << elements << " x " << *children[0] << '>';
}
-const VectorType* VectorType::getAsVectorType() const {
- return this;
-}
-
StructType::StructType(string &&name, vector<Type*> &&children)
: AggregateType(move(name), move(children)) {
@@ -1068,10 +1052,6 @@ const StructType* SymbolicType::getAsStructType() const {
return &*s;
}
-const VectorType* SymbolicType::getAsVectorType() const {
- return &*v;
-}
-
expr SymbolicType::toBV(expr e) const {
DISPATCH(toBV(move(e)), UNREACHABLE());
}

MODIFY
ir/type.h
ir/type.h
@@ -86,7 +86,6 @@ public:
virtual const FloatType* getAsFloatType() const;
virtual const AggregateType* getAsAggregateType() const;
virtual const StructType* getAsStructType() const;
- virtual const VectorType* getAsVectorType() const;
virtual smt::expr toBV(smt::expr e) const;
virtual IR::StateValue toBV(IR::StateValue v) const;
@@ -289,7 +288,6 @@ public:
smt::expr enforceVectorType(
const std::function<smt::expr(const Type&)> &enforceElem) const override;
void print(std::ostream &os) const override;
- const VectorType* getAsVectorType() const override;
};
@@ -346,7 +344,6 @@ public:
const FloatType* getAsFloatType() const override;
const AggregateType* getAsAggregateType() const override;
const StructType* getAsStructType() const override;
- const VectorType* getAsVectorType() const override;
smt::expr toBV(smt::expr e) const override;
IR::StateValue toBV(IR::StateValue v) const override;
smt::expr fromBV(smt::expr e) const override;

simplifications to previous commit