#include "Hexagon.h"
#include "HexagonInstrInfo.h"
#include "HexagonSubtarget.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/Pass.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <iterator>
#define DEBUG_TYPE …
usingnamespacellvm;
namespace llvm {
FunctionPass *createHexagonEarlyIfConversion();
void initializeHexagonEarlyIfConversionPass(PassRegistry& Registry);
}
static cl::opt<bool> EnableHexagonBP("enable-hexagon-br-prob", cl::Hidden,
cl::init(true), cl::desc("Enable branch probability info"));
static cl::opt<unsigned> SizeLimit("eif-limit", cl::init(6), cl::Hidden,
cl::desc("Size limit in Hexagon early if-conversion"));
static cl::opt<bool> SkipExitBranches("eif-no-loop-exit", cl::init(false),
cl::Hidden, cl::desc("Do not convert branches that may exit the loop"));
namespace {
struct PrintMB { … };
raw_ostream &operator<< (raw_ostream &OS, const PrintMB &P) { … }
struct FlowPattern { … };
struct PrintFP { … };
raw_ostream &operator<<(raw_ostream &OS,
const PrintFP &P) LLVM_ATTRIBUTE_UNUSED;
raw_ostream &operator<<(raw_ostream &OS, const PrintFP &P) { … }
class HexagonEarlyIfConversion : public MachineFunctionPass { … };
}
char HexagonEarlyIfConversion::ID = …;
INITIALIZE_PASS(…)
bool HexagonEarlyIfConversion::isPreheader(const MachineBasicBlock *B) const { … }
bool HexagonEarlyIfConversion::matchFlowPattern(MachineBasicBlock *B,
MachineLoop *L, FlowPattern &FP) { … }
bool HexagonEarlyIfConversion::hasEHLabel(const MachineBasicBlock *B) const { … }
bool HexagonEarlyIfConversion::hasUncondBranch(const MachineBasicBlock *B)
const { … }
bool HexagonEarlyIfConversion::isValidCandidate(const MachineBasicBlock *B)
const { … }
bool HexagonEarlyIfConversion::usesUndefVReg(const MachineInstr *MI) const { … }
bool HexagonEarlyIfConversion::isValid(const FlowPattern &FP) const { … }
unsigned HexagonEarlyIfConversion::computePhiCost(const MachineBasicBlock *B,
const FlowPattern &FP) const { … }
unsigned HexagonEarlyIfConversion::countPredicateDefs(
const MachineBasicBlock *B) const { … }
bool HexagonEarlyIfConversion::isProfitable(const FlowPattern &FP) const { … }
bool HexagonEarlyIfConversion::visitBlock(MachineBasicBlock *B,
MachineLoop *L) { … }
bool HexagonEarlyIfConversion::visitLoop(MachineLoop *L) { … }
bool HexagonEarlyIfConversion::isPredicableStore(const MachineInstr *MI)
const { … }
bool HexagonEarlyIfConversion::isSafeToSpeculate(const MachineInstr *MI)
const { … }
bool HexagonEarlyIfConversion::isPredicate(unsigned R) const { … }
unsigned HexagonEarlyIfConversion::getCondStoreOpcode(unsigned Opc,
bool IfTrue) const { … }
void HexagonEarlyIfConversion::predicateInstr(MachineBasicBlock *ToB,
MachineBasicBlock::iterator At, MachineInstr *MI,
unsigned PredR, bool IfTrue) { … }
void HexagonEarlyIfConversion::predicateBlockNB(MachineBasicBlock *ToB,
MachineBasicBlock::iterator At, MachineBasicBlock *FromB,
unsigned PredR, bool IfTrue) { … }
unsigned HexagonEarlyIfConversion::buildMux(MachineBasicBlock *B,
MachineBasicBlock::iterator At, const TargetRegisterClass *DRC,
unsigned PredR, unsigned TR, unsigned TSR, unsigned FR, unsigned FSR) { … }
void HexagonEarlyIfConversion::updatePhiNodes(MachineBasicBlock *WhereB,
const FlowPattern &FP) { … }
void HexagonEarlyIfConversion::convert(const FlowPattern &FP) { … }
void HexagonEarlyIfConversion::removeBlock(MachineBasicBlock *B) { … }
void HexagonEarlyIfConversion::eliminatePhis(MachineBasicBlock *B) { … }
void HexagonEarlyIfConversion::mergeBlocks(MachineBasicBlock *PredB,
MachineBasicBlock *SuccB) { … }
void HexagonEarlyIfConversion::simplifyFlowGraph(const FlowPattern &FP) { … }
bool HexagonEarlyIfConversion::runOnMachineFunction(MachineFunction &MF) { … }
FunctionPass *llvm::createHexagonEarlyIfConversion() { … }