#include "PPC.h"
#include "PPCInstrInfo.h"
#include "PPCSubtarget.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Register.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumCTRLoops, "Number of CTR loops generated");
STATISTIC(NumNormalLoops, "Number of normal compare + branch loops generated");
namespace {
class PPCCTRLoops : public MachineFunctionPass { … };
}
char PPCCTRLoops::ID = …;
INITIALIZE_PASS_BEGIN(PPCCTRLoops, DEBUG_TYPE, "PowerPC CTR loops generation",
false, false)
INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
INITIALIZE_PASS_END(PPCCTRLoops, DEBUG_TYPE, "PowerPC CTR loops generation",
false, false)
FunctionPass *llvm::createPPCCTRLoopsPass() { … }
bool PPCCTRLoops::runOnMachineFunction(MachineFunction &MF) { … }
bool PPCCTRLoops::isCTRClobber(MachineInstr *MI, bool CheckReads) const { … }
bool PPCCTRLoops::processLoop(MachineLoop *ML) { … }
void PPCCTRLoops::expandNormalLoops(MachineLoop *ML, MachineInstr *Start,
MachineInstr *Dec) { … }
void PPCCTRLoops::expandCTRLoops(MachineLoop *ML, MachineInstr *Start,
MachineInstr *Dec) { … }