LLVM: lib/Target/PowerPC/PPCCTRLoopsVerify.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18#ifndef NDEBUG

39

40using namespace llvm;

41

42#define DEBUG_TYPE "ppc-ctrloops-verify"

43

44namespace {

45

47 public:

48 static char ID;

49

52 }

53

54 void getAnalysisUsage(AnalysisUsage &AU) const override {

57 }

58

60

61 private:

63 };

64

65 char PPCCTRLoopsVerify::ID = 0;

66}

67

69 "PowerPC CTR Loops Verify", false, false)

73

75 return new PPCCTRLoopsVerify();

76}

77

80 if (MO.isReg()) {

81 if (MO.isDef() && (MO.getReg() == PPC::CTR || MO.getReg() == PPC::CTR8))

82 return true;

83 } else if (MO.isRegMask()) {

84 if (MO.clobbersPhysReg(PPC::CTR) || MO.clobbersPhysReg(PPC::CTR8))

85 return true;

86 }

87 }

88

89 return false;

90}

91

97 bool CheckPreds;

98

99 if (I == MBB->begin()) {

101 goto queue_preds;

102 } else

103 --I;

104

105check_block:

107 if (I == MBB->end())

108 goto queue_preds;

109

110 CheckPreds = true;

112 unsigned Opc = I->getOpcode();

113 if (Opc == PPC::MTCTRloop || Opc == PPC::MTCTR8loop) {

114 CheckPreds = false;

115 break;

116 }

117

120 << ") instruction " << *I

121 << " clobbers CTR, invalidating "

123 << BI->getParent()->getFullName() << ") instruction "

124 << *BI << "\n");

125 return false;

126 }

127

128 if (I == IE)

129 break;

130 }

131

132 if (!CheckPreds && Preds.empty())

133 return true;

134

135 if (CheckPreds) {

136queue_preds:

138 LLVM_DEBUG(dbgs() << "Unable to find a MTCTR instruction for "

140 << BI->getParent()->getFullName() << ") instruction "

141 << *BI << "\n");

142 return false;

143 }

144

146 }

147

148 do {

151 I = MBB->getLastNonDebugInstr();

152 goto check_block;

153 }

154 } while (!Preds.empty());

155

156 return true;

157}

158

159bool PPCCTRLoopsVerify::runOnMachineFunction(MachineFunction &MF) {

160 MDT = &getAnalysis().getDomTree();

161

162

163

164 for (MachineBasicBlock &MBB : MF) {

166 continue;

167

169 MIIE = MBB.end(); MII != MIIE; ++MII) {

170 unsigned Opc = MII->getOpcode();

171 if (Opc == PPC::BDNZ8 || Opc == PPC::BDNZ ||

172 Opc == PPC::BDZ8 || Opc == PPC::BDZ)

175 }

176 }

177

178 return false;

179}

180#endif

static bool verifyCTRBranch(MachineBasicBlock *MBB, MachineBasicBlock::iterator I)

Definition PPCCTRLoopsVerify.cpp:92

static bool clobbersCTR(const MachineInstr &MI)

Definition PPCCTRLoopsVerify.cpp:78

#define INITIALIZE_PASS_DEPENDENCY(depName)

#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)

#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)

This file defines the SmallVector class.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

bool isReachableFromEntry(const NodeT *A) const

isReachableFromEntry - Return true if A is dominated by the entry block of the function containing it...

FunctionPass class - This class is used to implement most global optimizations.

LLVM_ABI iterator getFirstTerminator()

Returns an iterator to the first terminator instruction of this basic block.

MachineInstrBundleIterator< MachineInstr > iterator

Analysis pass which computes a MachineDominatorTree.

DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...

MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...

void getAnalysisUsage(AnalysisUsage &AU) const override

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

BasicBlockListType::iterator iterator

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

static LLVM_ABI PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

size_type count(ConstPtrType Ptr) const

count - Return 1 if the specified pointer is in the set, 0 otherwise.

std::pair< iterator, bool > insert(PtrType Ptr)

Inserts Ptr if and only if there is no element in the container equal to Ptr.

SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

This is an optimization pass for GlobalISel generic memory operations.

void append_range(Container &C, Range &&R)

Wrapper function to append range R to container C.

void initializePPCCTRLoopsVerifyPass(PassRegistry &)

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

FunctionPass * createPPCCTRLoopsVerify()

Definition PPCCTRLoopsVerify.cpp:74

LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)

Prints a machine basic block reference.