-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathARMFrameBuilder.h
67 lines (55 loc) · 2.09 KB
/
ARMFrameBuilder.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
//===- ARMFrameBuilder.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 ARMFrameBuilder class for use by
// llvm-mctoll.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_LLVM_MCTOLL_ARM_ARMFRAMEBUILDER_H
#define LLVM_TOOLS_LLVM_MCTOLL_ARM_ARMFRAMEBUILDER_H
#include "ARMRaiserBase.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/IR/DataLayout.h"
namespace llvm {
namespace mctoll {
/// This class is use to build ARM abstract stack frame by analyzing ARM SP
/// register operations. Simultaneously, converts MI SP operands to
/// MO_FrameIndex type.
class ARMFrameBuilder : public ARMRaiserBase {
private:
struct StackElement {
uint64_t Size;
int64_t SPOffset;
int64_t ObjectIndex = -1; // If it is -1, means the corresponding
// StackObject has not been created.
};
MachineFrameInfo *MFI;
LLVMContext *CTX;
const DataLayout *DLT;
public:
static char ID;
ARMFrameBuilder(ARMModuleRaiser &MR, MachineFunction *MF, Function *RF);
~ARMFrameBuilder() override;
bool build();
bool runOnMachineFunction(MachineFunction &MF) override;
private:
unsigned getBitCount(unsigned Opcode);
Type *getStackType(unsigned Size);
/// Replace common regs assigned by SP to SP.
bool replaceNonSPBySP(MachineInstr &MI);
/// Analyze frame index of stack operands.
int64_t identifyStackOp(const MachineInstr &MI);
/// Find out all of frame relative operands, and update them.
void searchStackObjects(MachineFunction &MF);
/// Records of assigned common registers by sp.
SmallVector<unsigned, 16> RegAssignedBySP;
};
} // end namespace mctoll
} // end namespace llvm
#endif // LLVM_TOOLS_LLVM_MCTOLL_ARM_ARMFRAMEBUILDER_H