DifferenceEngine.h [plain text]
#ifndef _LLVM_DIFFERENCE_ENGINE_H_
#define _LLVM_DIFFERENCE_ENGINE_H_
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "DiffLog.h"
#include "DiffConsumer.h"
#include <utility>
namespace llvm {
class Function;
class GlobalValue;
class Instruction;
class LLVMContext;
class Module;
class Twine;
class Value;
class DifferenceEngine {
public:
struct Context {
Context(DifferenceEngine &Engine, Value *L, Value *R) : Engine(Engine) {
Engine.consumer.enterContext(L, R);
}
~Context() {
Engine.consumer.exitContext();
}
private:
DifferenceEngine &Engine;
};
struct Oracle {
virtual bool operator()(Value *L, Value *R) = 0;
protected:
virtual ~Oracle() {}
};
DifferenceEngine(LLVMContext &context, Consumer &consumer)
: context(context), consumer(consumer), globalValueOracle(0) {}
void diff(Module *L, Module *R);
void diff(Function *L, Function *R);
void log(StringRef text) {
consumer.log(text);
}
LogBuilder logf(StringRef text) {
return LogBuilder(consumer, text);
}
Consumer& getConsumer() const { return consumer; }
void setGlobalValueOracle(Oracle *oracle) {
globalValueOracle = oracle;
}
bool equivalentAsOperands(GlobalValue *L, GlobalValue *R);
private:
LLVMContext &context;
Consumer &consumer;
Oracle *globalValueOracle;
};
}
#endif