LLVM: lib/Target/ARM/ARMBasicBlockInfo.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
17
18#define DEBUG_TYPE "arm-bb-utils"
19
20using namespace llvm;
21
22namespace llvm {
23
24
25
26static bool
28 switch(MI->getOpcode()) {
29
30 case ARM::t2LEApcrel:
31 case ARM::t2LDRpci:
32
33 case ARM::t2B:
34 case ARM::t2Bcc:
35 case ARM::tBcc:
36
37 case ARM::t2BR_JT:
38 case ARM::tBR_JTr:
39 return true;
40 }
41 return false;
42}
43
45 LLVM_DEBUG(dbgs() << "computeBlockSize: " << MBB->getName() << "\n");
50
52 BBI.Size += TII->getInstSizeInBytes(I);
53
54
55 if (I.isInlineAsm())
56 BBI.Unalign = isThumb ? 1 : 2;
57
60 }
61
62
63 if (->empty() && MBB->back().getOpcode() == ARM::tBR_JTr) {
65 MBB->getParent()->ensureAlignment(Align(4));
66 }
67}
68
69
70
71
74
75
76
77
78 unsigned Offset = BBInfo[MBB->getNumber()].Offset;
79
80
82 assert(I != MBB->end() && "Didn't find MI in its own basic block?");
83 Offset += TII->getInstSizeInBytes(*I);
84 }
86}
87
88
89
92 unsigned MaxDisp) const {
93 unsigned PCAdj = isThumb ? 4 : 8;
95 unsigned DestOffset = BBInfo[DestBB->getNumber()].Offset;
96
99 << " max delta=" << MaxDisp << " from " << getOffsetOf(MI)
100 << " to " << DestOffset << " offset "
101 << int(DestOffset - BrOffset) << "\t" << *MI);
102
103 if (BrOffset <= DestOffset) {
104
105 if (DestOffset-BrOffset <= MaxDisp)
106 return true;
107 } else {
108 if (BrOffset-DestOffset <= MaxDisp)
109 return true;
110 }
111 return false;
112}
113
116 "Basic block is not a child of the current function.\n");
117
118 unsigned BBNum = BB->getNumber();
120 << " - name: " << BB->getName() << "\n"
121 << " - number: " << BB->getNumber() << "\n"
122 << " - function: " << MF.getName() << "\n"
123 << " - blocks: " << MF.getNumBlockIDs() << "\n");
124
125 for(unsigned i = BBNum + 1, e = MF.getNumBlockIDs(); i < e; ++i) {
126
127
128 const Align Align = MF.getBlockNumbered(i)->getAlignment();
129 const unsigned Offset = BBInfo[i - 1].postOffset(Align);
130 const unsigned KnownBits = BBInfo[i - 1].postKnownBits(Align);
131
132
133
134
135 if (i > BBNum + 2 &&
138 break;
139
140 BBInfo[i].Offset = Offset;
142 }
143}
144
145}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
bool isBBInRange(MachineInstr *MI, MachineBasicBlock *DestBB, unsigned MaxDisp) const
isBBInRange - Returns true if the distance between specific MI and specific BB can fit in MI's displa...
Definition ARMBasicBlockInfo.cpp:90
void adjustBBOffsetsAfter(MachineBasicBlock *MBB)
Definition ARMBasicBlockInfo.cpp:114
void computeBlockSize(MachineBasicBlock *MBB)
Definition ARMBasicBlockInfo.cpp:44
unsigned getOffsetOf(MachineInstr *MI) const
getOffsetOf - Return the current offset of the specified machine instruction from the start of the fu...
Definition ARMBasicBlockInfo.cpp:72
MachineInstrBundleIterator< const MachineInstr > const_iterator
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
Representation of each machine instruction.
This is an optimization pass for GlobalISel generic memory operations.
static bool mayOptimizeThumb2Instruction(const MachineInstr *MI)
Definition ARMBasicBlockInfo.cpp:27
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
This struct is a compact representation of a valid (non-zero power of two) alignment.
BasicBlockInfo - Information about the offset and size of a single basic block.
unsigned Size
Size - Size of the basic block in bytes.
Align PostAlign
PostAlign - When > 1, the block terminator contains a .align directive, so the end of the block is al...
uint8_t Unalign
Unalign - When non-zero, the block contains instructions (inline asm) of unknown size.