#include "HexagonVLIWPacketizer.h"
#include "Hexagon.h"
#include "HexagonInstrInfo.h"
#include "HexagonRegisterInfo.h"
#include "HexagonSubtarget.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/ScheduleDAG.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/InitializePasses.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstdint>
#include <iterator>
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<bool>
DisablePacketizer("disable-packetizer", cl::Hidden,
cl::desc("Disable Hexagon packetizer pass"));
static cl::opt<bool> Slot1Store("slot1-store-slot0-load", cl::Hidden,
cl::init(true),
cl::desc("Allow slot1 store and slot0 load"));
static cl::opt<bool> PacketizeVolatiles(
"hexagon-packetize-volatiles", cl::Hidden, cl::init(true),
cl::desc("Allow non-solo packetization of volatile memory references"));
static cl::opt<bool>
EnableGenAllInsnClass("enable-gen-insn", cl::Hidden,
cl::desc("Generate all instruction with TC"));
static cl::opt<bool>
DisableVecDblNVStores("disable-vecdbl-nv-stores", cl::Hidden,
cl::desc("Disable vector double new-value-stores"));
extern cl::opt<bool> ScheduleInlineAsm;
namespace llvm {
FunctionPass *createHexagonPacketizer(bool Minimal);
void initializeHexagonPacketizerPass(PassRegistry&);
}
namespace {
class HexagonPacketizer : public MachineFunctionPass { … };
}
char HexagonPacketizer::ID = …;
INITIALIZE_PASS_BEGIN(HexagonPacketizer, "hexagon-packetizer",
"Hexagon Packetizer", false, false)
INITIALIZE_PASS_DEPENDENCY(MachineDominatorTreeWrapperPass)
INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(MachineLoopInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
INITIALIZE_PASS_END(HexagonPacketizer, "hexagon-packetizer",
"Hexagon Packetizer", false, false)
HexagonPacketizerList::HexagonPacketizerList(MachineFunction &MF,
MachineLoopInfo &MLI, AAResults *AA,
const MachineBranchProbabilityInfo *MBPI, bool Minimal)
: … { … }
static bool hasWriteToReadDep(const MachineInstr &FirstI,
const MachineInstr &SecondI,
const TargetRegisterInfo *TRI) { … }
static MachineBasicBlock::iterator moveInstrOut(MachineInstr &MI,
MachineBasicBlock::iterator BundleIt, bool Before) { … }
bool HexagonPacketizer::runOnMachineFunction(MachineFunction &MF) { … }
void HexagonPacketizerList::reserveResourcesForConstExt() { … }
bool HexagonPacketizerList::canReserveResourcesForConstExt() { … }
bool HexagonPacketizerList::tryAllocateResourcesForConstExt(bool Reserve) { … }
bool HexagonPacketizerList::isCallDependent(const MachineInstr &MI,
SDep::Kind DepType, unsigned DepReg) { … }
static bool isRegDependence(const SDep::Kind DepType) { … }
static bool isDirectJump(const MachineInstr &MI) { … }
static bool isSchedBarrier(const MachineInstr &MI) { … }
static bool isControlFlow(const MachineInstr &MI) { … }
static bool doesModifyCalleeSavedReg(const MachineInstr &MI,
const TargetRegisterInfo *TRI) { … }
bool HexagonPacketizerList::isNewifiable(const MachineInstr &MI,
const TargetRegisterClass *NewRC) { … }
bool HexagonPacketizerList::promoteToDotCur(MachineInstr &MI,
SDep::Kind DepType, MachineBasicBlock::iterator &MII,
const TargetRegisterClass* RC) { … }
void HexagonPacketizerList::cleanUpDotCur() { … }
bool HexagonPacketizerList::canPromoteToDotCur(const MachineInstr &MI,
const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII,
const TargetRegisterClass *RC) { … }
bool HexagonPacketizerList::promoteToDotNew(MachineInstr &MI,
SDep::Kind DepType, MachineBasicBlock::iterator &MII,
const TargetRegisterClass* RC) { … }
bool HexagonPacketizerList::demoteToDotOld(MachineInstr &MI) { … }
bool HexagonPacketizerList::useCallersSP(MachineInstr &MI) { … }
void HexagonPacketizerList::useCalleesSP(MachineInstr &MI) { … }
bool HexagonPacketizerList::updateOffset(SUnit *SUI, SUnit *SUJ) { … }
void HexagonPacketizerList::undoChangedOffset(MachineInstr &MI) { … }
enum PredicateKind { … };
static PredicateKind getPredicateSense(const MachineInstr &MI,
const HexagonInstrInfo *HII) { … }
static const MachineOperand &getPostIncrementOperand(const MachineInstr &MI,
const HexagonInstrInfo *HII) { … }
static const MachineOperand& getStoreValueOperand(const MachineInstr &MI) { … }
static bool isLoadAbsSet(const MachineInstr &MI) { … }
static const MachineOperand &getAbsSetOperand(const MachineInstr &MI) { … }
bool HexagonPacketizerList::canPromoteToNewValueStore(const MachineInstr &MI,
const MachineInstr &PacketMI, unsigned DepReg) { … }
bool HexagonPacketizerList::canPromoteToNewValue(const MachineInstr &MI,
const SUnit *PacketSU, unsigned DepReg,
MachineBasicBlock::iterator &MII) { … }
static bool isImplicitDependency(const MachineInstr &I, bool CheckDef,
unsigned DepReg) { … }
bool HexagonPacketizerList::canPromoteToDotNew(const MachineInstr &MI,
const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII,
const TargetRegisterClass* RC) { … }
bool HexagonPacketizerList::restrictingDepExistInPacket(MachineInstr &MI,
unsigned DepReg) { … }
static unsigned getPredicatedRegister(MachineInstr &MI,
const HexagonInstrInfo *QII) { … }
bool HexagonPacketizerList::arePredicatesComplements(MachineInstr &MI1,
MachineInstr &MI2) { … }
void HexagonPacketizerList::initPacketizerState() { … }
bool HexagonPacketizerList::ignorePseudoInstruction(const MachineInstr &MI,
const MachineBasicBlock *) { … }
bool HexagonPacketizerList::isSoloInstruction(const MachineInstr &MI) { … }
static bool cannotCoexistAsymm(const MachineInstr &MI, const MachineInstr &MJ,
const HexagonInstrInfo &HII) { … }
bool HexagonPacketizerList::cannotCoexist(const MachineInstr &MI,
const MachineInstr &MJ) { … }
void HexagonPacketizerList::unpacketizeSoloInstrs(MachineFunction &MF) { … }
static bool isSystemInstr(const MachineInstr &MI) { … }
bool HexagonPacketizerList::hasDeadDependence(const MachineInstr &I,
const MachineInstr &J) { … }
bool HexagonPacketizerList::hasControlDependence(const MachineInstr &I,
const MachineInstr &J) { … }
bool HexagonPacketizerList::hasRegMaskDependence(const MachineInstr &I,
const MachineInstr &J) { … }
bool HexagonPacketizerList::hasDualStoreDependence(const MachineInstr &I,
const MachineInstr &J) { … }
bool HexagonPacketizerList::isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) { … }
bool HexagonPacketizerList::isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) { … }
bool HexagonPacketizerList::foundLSInPacket() { … }
MachineBasicBlock::iterator
HexagonPacketizerList::addToPacket(MachineInstr &MI) { … }
void HexagonPacketizerList::endPacket(MachineBasicBlock *MBB,
MachineBasicBlock::iterator EndMI) { … }
bool HexagonPacketizerList::shouldAddToPacket(const MachineInstr &MI) { … }
unsigned int HexagonPacketizerList::calcStall(const MachineInstr &I) { … }
bool HexagonPacketizerList::producesStall(const MachineInstr &I) { … }
FunctionPass *llvm::createHexagonPacketizer(bool Minimal) { … }