-
Notifications
You must be signed in to change notification settings - Fork 0
/
ValidationUnit.h
69 lines (59 loc) · 1.84 KB
/
ValidationUnit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef VALIDATION_UNIT_H
#define VALIDATION_UNIT_H
#include <boost/any.hpp>
#include <memory>
#include <string>
#include <stack>
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Crellvm/Structure.h"
#include "llvm/Crellvm/Dictionary.h"
namespace crellvm {
class ValidationUnit {
public:
typedef crellvm::Dictionary Dictionary;
enum PASS { NOTHING = 0, GVN, MEM2REG, PRE, INSTCOMBINE, LICM };
CoreHint &getHint();
const std::string &getOptimizationName() const;
const std::string &getDescription() const;
void setOptimizationName(const std::string &name);
void setDescription(const std::string &str);
void setIsAborted();
void intrude(std::function<void(Dictionary &, CoreHint &)> func);
private:
ValidationUnit(const std::string &optname, llvm::Function *func, bool rename=true);
~ValidationUnit();
void begin(bool rename=true);
void commit();
void abort();
std::string _filename;
std::string _optname;
std::string *_srcfile_buffer;
llvm::Function *_func;
CoreHint _corehint;
Dictionary _data;
bool isAborted;
public:
static ValidationUnit *GetInstance();
static void StartPass(PASS pass);
static PASS GetCurrentPass();
static void EndPass();
static void Begin(const std::string &optname, llvm::Function *func, bool rename=true);
static void Begin(const std::string &optname, llvm::Instruction &I, bool rename=true);
static bool BeginIfNotExists(const std::string &optname,
llvm::Function *func);
static void End();
static void Abort();
static bool EndIfExists();
static bool Exists();
private:
static ValidationUnit *_Instance;
static int _Counter;
static PASS _CurrentPass;
};
} // crellvm
#endif