llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
|
7 #include <unordered_map>
10 #include "core/insts.h"
49 virtual Type
Map(Type ty,
Inst *inst,
unsigned idx) {
return ty; }
59 #define GET_INST(kind, type, name, sort) \
60 virtual Inst *Clone(type *i);
61 #include "instructions.def"
68 template<
typename It,
typename T =
typename It::value_type>
69 std::vector<T>
Map(llvm::iterator_range<It> range)
73 args.push_back(
Map(arg));
80 llvm::SmallVector<std::pair<PhiInst *, PhiInst *>, 10>
fixups_;
87 std::pair<std::unique_ptr<Prog>,
Inst *> Clone(
Prog &oldProg,
Inst *inst);
94 std::pair<std::unique_ptr<Prog>, T *> CloneT(
Prog &oldProg, T *inst)
96 auto &&[prog, newInst] = Clone(oldProg, inst);
97 return { std::move(prog),
static_cast<T *
>(newInst) };
104 std::unique_ptr<Prog> Clone(
Prog &oldProg);
void Fixup()
Fixes PHI nodes.
Definition: clone.cpp:22
virtual Atom * Map(Atom *atom)
Maps an atom to a new one.
Definition: clone.h:35
virtual Constant * Map(Constant *constant)
Maps a constant to a new one.
Definition: clone.h:37
virtual AnnotSet Annot(const Inst *inst)
Clones an annotation.
Definition: clone.cpp:86
llvm::SmallVector< std::pair< PhiInst *, PhiInst * >, 10 > fixups_
PHI instruction delayed fixups.
Definition: clone.h:80
virtual Extern * Map(Extern *ext)
Maps a block to a new one.
Definition: clone.h:33
virtual ~CloneVisitor()
Destroys the visitor.
Definition: clone.cpp:17
Definition: constant.h:21
std::vector< T > Map(llvm::iterator_range< It > range)
Map a vector of values.
Definition: clone.h:69
virtual Type Map(Type ty, Inst *inst, unsigned idx)
Maps a type to a new one.
Definition: clone.h:49
virtual Func * Map(Func *func)
Maps a block to a new one.
Definition: clone.h:31
virtual Inst * Clone(Inst *inst)
Clones an instruction.
Definition: clone.cpp:75
virtual Block * Map(Block *block)
Maps a block to a new one.
Definition: clone.h:29
virtual Ref< Inst > Map(Ref< Inst > inst)
Maps an instruction reference to a new one.
Definition: clone.h:47