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

40

41using namespace llvm;

42

43#define DEBUG_TYPE "ppc-ctrloops-verify"

44

45namespace {

46

48 public:

49 static char ID;

50

53 }

54

58 }

59

61

62 private:

64 };

65

66 char PPCCTRLoopsVerify::ID = 0;

67}

68

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

74

76 return new PPCCTRLoopsVerify();

77}

78

81 if (MO.isReg()) {

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

83 return true;

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

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

86 return true;

87 }

88 }

89

90 return false;

91}

92

98 bool CheckPreds;

99

102 goto queue_preds;

103 } else

104 --I;

105

106check_block:

109 goto queue_preds;

110

111 CheckPreds = true;

113 unsigned Opc = I->getOpcode();

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

115 CheckPreds = false;

116 break;

117 }

118

121 << ") instruction " << *I

122 << " clobbers CTR, invalidating "

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

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

126 return false;

127 }

128

129 if (I == IE)

130 break;

131 }

132

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

134 return true;

135

136 if (CheckPreds) {

137queue_preds:

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

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

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

143 return false;

144 }

145

147 }

148

149 do {

153 goto check_block;

154 }

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

156

157 return true;

158}

159

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

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

162

163

164

166 if (!MDT->isReachableFromEntry(&MBB))

167 continue;

168

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

171 unsigned Opc = MII->getOpcode();

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

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

176 }

177 }

178

179 return false;

180}

181#endif

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

ppc ctr loops PowerPC CTR Loops Verify

static bool clobbersCTR(const MachineInstr &MI)

#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 SmallSet class.

This file defines the SmallVector class.

Represent the analysis usage information of a pass.

AnalysisUsage & addRequired()

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

iterator getFirstTerminator()

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

iterator getLastNonDebugInstr(bool SkipPseudoOp=true)

Returns an iterator to the last non-debug instruction in the basic block, or end().

const MachineFunction * getParent() const

Return the MachineFunction containing this basic block.

std::string getFullName() const

Return a formatted string to identify this block and its parent function.

iterator_range< pred_iterator > predecessors()

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.

virtual bool runOnMachineFunction(MachineFunction &MF)=0

runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

static PassRegistry * getPassRegistry()

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

SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...

size_type count(const T &V) const

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

std::pair< const_iterator, bool > insert(const T &V)

insert - Insert an element into the set if it isn't already there.

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 &)

raw_ostream & dbgs()

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

FunctionPass * createPPCCTRLoopsVerify()

Printable printMBBReference(const MachineBasicBlock &MBB)

Prints a machine basic block reference.