-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMachineFunctionRaiser.h
executable file
·80 lines (61 loc) · 2.55 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
76
77
78
79
80
//===-- MachineFunctionRaiser.h ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// 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), M(M), machineInstRaiser(nullptr), MR(MR) {
mcInstRaiser = new MCInstRaiser(Start, End);
// The new MachineFunction is not in SSA form, yet
MF.getProperties().reset(MachineFunctionProperties::Property::IsSSA);
};
virtual ~MachineFunctionRaiser() { delete mcInstRaiser; }
bool runRaiserPasses();
MachineFunction &getMachineFunction() const { return MF; }
// Getters
MCInstRaiser *getMCInstRaiser() { return mcInstRaiser; }
Module &getModule() { return M; }
MachineInstructionRaiser *getMachineInstrRaiser();
void setMachineInstrRaiser(MachineInstructionRaiser *MIR) {
machineInstRaiser = MIR;
}
Function *getRaisedFunction();
void setRaisedFunction(Function *);
const ModuleRaiser *getModuleRaiser() { return MR; }
// Cleanup orphaned empty basic blocks from raised function
void cleanupRaisedFunction();
private:
MachineFunction &MF;
Module &M;
// 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;
};
#endif // LLVM_TOOLS_LLVM_MCTOLL_FUNCTIONRAISER_H