#include "BitTracker.h"
#include "HexagonBitTracker.h"
#include "HexagonInstrInfo.h"
#include "HexagonRegisterInfo.h"
#include "HexagonSubtarget.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineBasicBlock.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/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <utility>
#include <vector>
#define DEBUG_TYPE …
usingnamespacellvm;
static cl::opt<unsigned>
VRegIndexCutoff("insert-vreg-cutoff", cl::init(~0U), cl::Hidden,
cl::desc("Vreg# cutoff for insert generation."));
static cl::opt<unsigned>
VRegDistCutoff("insert-dist-cutoff", cl::init(30U), cl::Hidden,
cl::desc("Vreg distance cutoff for insert "
"generation."));
static cl::opt<unsigned>
MaxORLSize("insert-max-orl", cl::init(4096), cl::Hidden,
cl::desc("Maximum size of OrderedRegisterList"));
static cl::opt<unsigned> MaxIFMSize("insert-max-ifmap", cl::init(1024),
cl::Hidden,
cl::desc("Maximum size of IFMap"));
static cl::opt<bool> OptTiming("insert-timing", cl::Hidden,
cl::desc("Enable timing of insert generation"));
static cl::opt<bool>
OptTimingDetail("insert-timing-detail", cl::Hidden,
cl::desc("Enable detailed timing of insert "
"generation"));
static cl::opt<bool> OptSelectAll0("insert-all0", cl::init(false), cl::Hidden);
static cl::opt<bool> OptSelectHas0("insert-has0", cl::init(false), cl::Hidden);
static cl::opt<bool> OptConst("insert-const", cl::init(false), cl::Hidden);
inline static bool isDebug() { … }
namespace {
struct RegisterSet : private BitVector { … };
struct PrintRegSet { … };
raw_ostream &operator<< (raw_ostream &OS, const PrintRegSet &P) { … }
struct UnsignedMap : public DenseMap<unsigned,unsigned> { … };
struct RegisterOrdering : public UnsignedMap { … };
struct BitValueOrdering { … };
}
bool BitValueOrdering::operator() (const BitTracker::BitValue &V1,
const BitTracker::BitValue &V2) const { … }
namespace {
struct CellMapShadow { … };
struct RegisterCellLexCompare { … };
struct RegisterCellBitCompareSel { … };
}
bool RegisterCellLexCompare::operator() (unsigned VR1, unsigned VR2) const { … }
bool RegisterCellBitCompareSel::operator() (unsigned VR1, unsigned VR2) const { … }
namespace {
class OrderedRegisterList { … };
struct PrintORL { … };
raw_ostream &operator<< (raw_ostream &OS, const PrintORL &P) { … }
}
void OrderedRegisterList::insert(unsigned VR) { … }
void OrderedRegisterList::remove(unsigned VR) { … }
namespace {
struct IFRecord { … };
struct PrintIFR { … };
raw_ostream &operator<< (raw_ostream &OS, const PrintIFR &P) { … }
IFRecordWithRegSet;
}
namespace llvm {
void initializeHexagonGenInsertPass(PassRegistry&);
FunctionPass *createHexagonGenInsert();
}
namespace {
class HexagonGenInsert : public MachineFunctionPass { … };
}
char HexagonGenInsert::ID = …;
void HexagonGenInsert::dump_map() const { … }
void HexagonGenInsert::buildOrderingMF(RegisterOrdering &RO) const { … }
void HexagonGenInsert::buildOrderingBT(RegisterOrdering &RB,
RegisterOrdering &RO) const { … }
inline bool HexagonGenInsert::isIntClass(const TargetRegisterClass *RC) const { … }
bool HexagonGenInsert::isConstant(unsigned VR) const { … }
bool HexagonGenInsert::isSmallConstant(unsigned VR) const { … }
bool HexagonGenInsert::isValidInsertForm(unsigned DstR, unsigned SrcR,
unsigned InsR, uint16_t L, uint16_t S) const { … }
bool HexagonGenInsert::findSelfReference(unsigned VR) const { … }
bool HexagonGenInsert::findNonSelfReference(unsigned VR) const { … }
void HexagonGenInsert::getInstrDefs(const MachineInstr *MI,
RegisterSet &Defs) const { … }
void HexagonGenInsert::getInstrUses(const MachineInstr *MI,
RegisterSet &Uses) const { … }
unsigned HexagonGenInsert::distance(const MachineBasicBlock *FromB,
const MachineBasicBlock *ToB, const UnsignedMap &RPO,
PairMapType &M) const { … }
unsigned HexagonGenInsert::distance(MachineBasicBlock::const_iterator FromI,
MachineBasicBlock::const_iterator ToI, const UnsignedMap &RPO,
PairMapType &M) const { … }
bool HexagonGenInsert::findRecordInsertForms(unsigned VR,
OrderedRegisterList &AVs) { … }
void HexagonGenInsert::collectInBlock(MachineBasicBlock *B,
OrderedRegisterList &AVs) { … }
void HexagonGenInsert::findRemovableRegisters(unsigned VR, IFRecord IF,
RegisterSet &RMs) const { … }
void HexagonGenInsert::computeRemovableRegisters() { … }
void HexagonGenInsert::pruneEmptyLists() { … }
void HexagonGenInsert::pruneCoveredSets(unsigned VR) { … }
void HexagonGenInsert::pruneUsesTooFar(unsigned VR, const UnsignedMap &RPO,
PairMapType &M) { … }
void HexagonGenInsert::pruneRegCopies(unsigned VR) { … }
void HexagonGenInsert::pruneCandidates() { … }
namespace {
struct IFOrdering { … };
}
bool IFOrdering::operator() (const IFRecordWithRegSet &A,
const IFRecordWithRegSet &B) const { … }
void IFOrdering::stats(const RegisterSet &Rs, unsigned &Size, unsigned &Zero,
unsigned &Sum) const { … }
void HexagonGenInsert::selectCandidates() { … }
bool HexagonGenInsert::generateInserts() { … }
bool HexagonGenInsert::removeDeadCode(MachineDomTreeNode *N) { … }
bool HexagonGenInsert::runOnMachineFunction(MachineFunction &MF) { … }
FunctionPass *llvm::createHexagonGenInsert() { … }
INITIALIZE_PASS_BEGIN(HexagonGenInsert, "hexinsert",
"Hexagon generate \"insert\" instructions", false, false)
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
INITIALIZE_PASS_END(HexagonGenInsert, "hexinsert",
"Hexagon generate \"insert\" instructions", false, false)