Skip to content

Commit

Permalink
remove is_out helper fns
Browse files Browse the repository at this point in the history
used in only a single place in world.cpp, for a folding op hoist_enters
also carries out
  • Loading branch information
Hugobros3 committed Jun 22, 2021
1 parent a6d1a1b commit b83b67c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
22 changes: 0 additions & 22 deletions src/thorin/primop.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class PrimOp : public Def {
virtual bool equal(const PrimOp* other) const;
virtual const Def* vrebuild(World&, Defs, const Type*) const { return nullptr; } // = 0;

/// Is @p def the @p i^th result of a @p T @p PrimOp?
template<int i, class T> inline static const T* is_out(const Def* def);

private:
hash_t hash() const { return hash_ == 0 ? hash_ = vhash() : hash_; }

Expand Down Expand Up @@ -628,8 +625,6 @@ class Alloc : public MemOp {
const TupleType* type() const { return MemOp::type()->as<TupleType>(); }
const PtrType* out_ptr_type() const { return type()->op(1)->as<PtrType>(); }
const Type* alloced_type() const { return out_ptr_type()->pointee(); }
static const Alloc* is_out_mem(const Def* def) { return is_out<0, Alloc>(def); }
static const Alloc* is_out_ptr(const Def* def) { return is_out<1, Alloc>(def); }

private:
const Def* vrebuild(World& to, Defs ops, const Type* type) const override;
Expand Down Expand Up @@ -660,8 +655,6 @@ class Load : public Access {
const Def* out_val() const { return out(1); }
const TupleType* type() const { return MemOp::type()->as<TupleType>(); }
const Type* out_val_type() const { return type()->op(1); }
static const Load* is_out_mem(const Def* def) { return is_out<0, Load>(def); }
static const Load* is_out_val(const Def* def) { return is_out<1, Load>(def); }

private:
const Def* vrebuild(World& to, Defs ops, const Type* type) const override;
Expand Down Expand Up @@ -696,8 +689,6 @@ class Enter : public MemOp {
const TupleType* type() const { return MemOp::type()->as<TupleType>(); }
bool has_multiple_outs() const override { return true; }
const Def* out_frame() const { return out(1); }
static const Enter* is_out_mem(const Def* def) { return is_out<0, Enter>(def); }
static const Enter* is_out_frame(const Def* def) { return is_out<1, Enter>(def); }

friend class World;
};
Expand Down Expand Up @@ -746,19 +737,6 @@ inline Assembly::Flags operator&=(Assembly::Flags& lhs, Assembly::Flags rhs) { r

//------------------------------------------------------------------------------

template<int i, class T>
const T* PrimOp::is_out(const Def* def) {
if (auto extract = def->isa<Extract>()) {
if (is_primlit(extract->index(), i)) {
if (auto res = extract->agg()->isa<T>())
return res;
}
}
return nullptr;
}

//------------------------------------------------------------------------------

template<class To>
using PrimOpMap = GIDMap<const PrimOp*, To>;
using PrimOpSet = GIDSet<const PrimOp*>;
Expand Down
2 changes: 0 additions & 2 deletions src/thorin/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,6 @@ const Def* World::store(const Def* mem, const Def* ptr, const Def* value, Debug
}

const Def* World::enter(const Def* mem, Debug dbg) {
if (auto e = Enter::is_out_mem(mem))
return e;
return cse(new Enter(mem, dbg));
}

Expand Down

0 comments on commit b83b67c

Please sign in to comment.