forked from microsoft/llvm-mctoll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MachineFunctionRaiser.h
75 lines (64 loc) · 2.41 KB
/
MachineFunctionRaiser.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
70
71
72
73
74
75
//===-- MachineFunctionRaiser.h - Binary raiser utility llvm-mctoll -------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declaration of the MachineFunctionRaiser class used
// by llvm-mctoll. This class encapsulates the context in which an assembly
// function is raised.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_LLVM_MCTOLL_FUNCTIONRAISER_H
#define LLVM_TOOLS_LLVM_MCTOLL_FUNCTIONRAISER_H
#include "MachineInstructionRaiser.h"
#include "ModuleRaiser.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/MC/MCInstrAnalysis.h"
#include "llvm/MC/MCInstrInfo.h"
using namespace llvm;
using IndexedData32 = std::pair<uint64_t, uint32_t>;
class MachineFunctionRaiser {
public:
MachineFunctionRaiser(Module &m, MachineFunction &mf, const ModuleRaiser *mr,
uint64_t start, uint64_t end)
: MF(mf), module(m), MR(mr) {
init(start, end);
// The new MachineFunction is not in SSA form, yet
MF.getProperties().reset(MachineFunctionProperties::Property::IsSSA);
};
bool runRaiserPasses();
MachineFunction &getMachineFunction() const { return MF; }
// Getters
MCInstRaiser *getMCInstRaiser() { return mcInstRaiser; }
Module &getModule() { return module; }
MachineInstructionRaiser *getMachineInstrRaiser() {
return machineInstRaiser;
}
Function *getRaisedFunction() {
return machineInstRaiser->getRaisedFunction();
}
const ModuleRaiser *getModuleRaiser() { return MR; }
virtual ~MachineFunctionRaiser() {
delete mcInstRaiser;
}
private:
MachineFunction &MF;
Module &module;
// Data members built and used by this class
MCInstRaiser *mcInstRaiser;
MachineInstructionRaiser *machineInstRaiser;
// A vector of data blobs found in the instruction stream
// of this function. A data blob is a sequence of data bytes.
// Multiple such data blobs may be found while disassembling
// the instruction stream of a function symbol.
std::vector<IndexedData32> dataBlobVector;
const ModuleRaiser *MR;
// Functions
void init(uint64_t funcStart, uint64_t funcEnd);
};
#endif // LLVM_TOOLS_LLVM_MCTOLL_FUNCTIONRAISER_H