add a few utility functions that we had to write to support the ARM lifter
MODIFY
ir/function.cpp
ir/function.cpp
@@ -50,7 +50,7 @@ void BasicBlock::addInstrAt(unique_ptr<Instr> &&i, const Instr *other,
}
}
-void BasicBlock::delInstr(Instr *i) {
+void BasicBlock::delInstr(const Instr *i) {
for (auto I = m_instrs.begin(), E = m_instrs.end(); I != E; ++I) {
if (I->get() == i) {
m_instrs.erase(I);
@@ -125,6 +125,11 @@ expr Function::getTypeConstraints() const {
return t;
}
+void Function::rauw(const Value &what, Value &with) {
+ for (auto bb : getBBs())
+ bb->rauw(what, with);
+}
+
void Function::fixupTypes(const Model &m) {
for (auto bb : getBBs()) {
bb->fixupTypes(m);
@@ -223,6 +228,10 @@ void Function::addInput(unique_ptr<Value> &&i) {
inputs.emplace_back(std::move(i));
}
+void Function::replaceInput(std::unique_ptr<Value> &&c, unsigned idx) {
+ inputs[idx] = std::move(c);
+}
+
bool Function::hasReturn() const {
for (auto &i : instrs()) {
if (dynamic_cast<const Return *>(&i))

MODIFY
ir/function.h
ir/function.h
@@ -37,7 +37,7 @@ public:
void addInstr(std::unique_ptr<Instr> &&i, bool push_front = false);
void addInstrAt(std::unique_ptr<Instr> &&i, const Instr *other, bool before);
- void delInstr(Instr *i);
+ void delInstr(const Instr *i);
util::const_strip_unique_ptr<decltype(m_instrs)> instrs() const {
return m_instrs;
@@ -100,6 +100,7 @@ public:
smt::expr getTypeConstraints() const;
void fixupTypes(const smt::Model &m);
+ void rauw(const Value &what, Value &with);
const BasicBlock& getFirstBB() const { return *BB_order[0]; }
BasicBlock& getFirstBB() { return *BB_order[0]; }
@@ -132,6 +133,8 @@ public:
void addAggregate(std::unique_ptr<AggregateValue> &&a);
void addInput(std::unique_ptr<Value> &&c);
+ void replaceInput(std::unique_ptr<Value> &&c, unsigned idx);
+ Value &getInput(int idx) { return *inputs[idx]; }
util::const_strip_unique_ptr<decltype(inputs)> getInputs() const {
return inputs;
}

add a few utility functions that we had to write to support the ARM lifter (#869)